KADATH
|
Template class for arrays. More...
#include <array.hpp>
Public Types | |
using | reference = T & |
Sylvain's stuff. More... | |
using | const_reference = T const & |
Sylvain's stuff. More... | |
using | pointer = T * |
Sylvain's stuff More... | |
using | const_pointer = T const * |
Sylvain's stuff More... | |
Public Member Functions | |
Array (const Dim_array &res) | |
Constructor from a Dim_array . More... | |
Array (int i) | |
Constructor for a 1d-array. More... | |
Array (int i, int j) | |
Constructor for a 2d-array. More... | |
Array (int i, int j, int k) | |
Constructor for a 3d-array. More... | |
Array (FILE *fd, Array_ordering order=last_index) | |
Constructor from a file. More... | |
void | swap (Array< T > &so) |
Swaps contents between the two arrays (beware when using it with arrays of allocated pointers). More... | |
void | delete_data () |
Logical destructor (kills the data) More... | |
void | resize (Dim_array const &new_dim) |
Resize the array by reallocating its ressource. More... | |
void | resize (int new_size) |
Resize overload for the one-dimension array case. More... | |
void | save (FILE *fd, Array_ordering order=last_index) const |
Save in a file. More... | |
Array & | operator= (T xx) |
Assigns the same value to all the elements. More... | |
reference | set (const Index &pos) |
Read/write of an element. More... | |
reference | set (const Array_iterator &pos) |
Read/write of an element. More... | |
reference | set (int i) |
Read/write of an element for a 1d-array. More... | |
reference | set (int i, int j) |
Read/write of an element for a 2d-array. More... | |
reference | set (int i, int j, int k) |
Read/write of an element for a 3d-array. More... | |
T | operator() (const Index &pos) const |
Read only of an element. More... | |
T | operator() (Array_iterator const &pos) const |
Read only of an element. More... | |
T | operator() (int i) const |
Read only of an element for a 1d-array. More... | |
T | operator() (int i, int j) const |
Read only of an element for a 2d-array. More... | |
T | operator() (int i, int j, int k) const |
Read only of an element for a 3d-array. More... | |
const_pointer | get_data () const |
Direct accessor to the data, read only version. More... | |
pointer | set_data () |
Direct accessor to the data, read/write version. More... | |
int | get_ndim () const |
Returns the number of dimensions. More... | |
int | get_nbr () const |
Returns the total number of elements. More... | |
int | get_size (int i) const |
Returns the size of a given dimension. More... | |
const Dim_array & | get_dimensions () const |
Returns the Dim_array of the Array . More... | |
bool | is_increasing () const |
Checks if a 1D array is increasing. More... | |
Array< T > & | operator+= (const Array< T > &so) |
Operator +. More... | |
Array< T > & | operator-= (const Array< T > &so) |
Operator -=. More... | |
Array< T > & | operator*= (const Array< T > &so) |
Operator *=. More... | |
Array< T > & | operator/= (const Array< T > &so) |
Operator /=. More... | |
Array< T > & | operator+= (const T xx) |
Operator +=. More... | |
Array< T > & | operator-= (const T xx) |
Operator -=. More... | |
Array< T > & | operator*= (const T xx) |
Operator *=. More... | |
Array< T > & | operator/= (const T xx) |
Operator /=. More... | |
int | to_last_dim_major_index (int i_first_dim_major) const |
Index formulae to change major dimension indexation from first dimension to the last. More... | |
int | to_first_dim_major_index (int i_last_dim_major) const |
Index formulae to change major dimension indexation from last dimension to first. More... | |
Public Attributes | |
Dim_array | dimensions |
Dimensions of the Array . More... | |
int | nbr |
Total number of elements. More... | |
Memory_mapped_array< T > | data |
Elements of the Array . More... | |
Friends | |
class | Matrice |
ostream & | operator<< (ostream &, const Array< T > &) |
Output operator. More... | |
Array< T > | sin (const Array< T > &) |
sine operator More... | |
Array< T > | cos (const Array< T > &) |
cosine operator More... | |
Array< T > | sinh (const Array< T > &) |
Hyperbolic sine operator. More... | |
Array< T > | cosh (const Array< T > &) |
Hyperbolic sine operator. More... | |
Array< T > | operator+ (const Array< T > &) |
Unitary operator +. More... | |
Array< T > | operator- (const Array< T > &) |
Unitary operator -. More... | |
Array< T > | operator+ (const Array< T > &, const Array< T > &) |
Operator + (two arrays) More... | |
Array< T > | operator+ (const Array< T > &, T) |
Operator + (one array and one value) More... | |
Array< T > | operator+ (T, const Array< T > &) |
Operator + (one value and one array) More... | |
Array< T > | operator- (const Array< T > &, const Array< T > &) |
Operator - (two arrays) More... | |
Array< T > | operator- (const Array< T > &, T) |
Operator - (one array and one value) More... | |
Array< T > | operator- (T, const Array< T > &) |
Operator - (one value and one array) More... | |
Array< T > | operator* (const Array< T > &, const Array< T > &) |
Operator * (two arrays) More... | |
Array< T > | operator* (const Array< T > &, T) |
Operator * (one array and one value) More... | |
Array< T > | operator* (T, const Array< T > &) |
Operator * (one value and one array) More... | |
Array< T > | operator/ (const Array< T > &, const Array< T > &) |
Operator / (two arrays) More... | |
Array< T > | operator/ (const Array< T > &, T) |
Operator / (one array and one value) More... | |
Array< T > | operator/ (T, const Array< T > &) |
Operator / (one value and one array) More... | |
Array< T > | pow (const Array< T > &, int) |
Operator power (integer version) More... | |
Array< T > | pow (const Array< T > &, double) |
Operator power (double version) More... | |
Array< T > | sqrt (const Array< T > &) |
Operator square root. More... | |
Array< T > | exp (const Array< T > &) |
Operator exponential. More... | |
Array< T > | log (const Array< T > &) |
Operator logarithm. More... | |
Array< T > | atanh (const Array< T > &) |
Operator hyperbolic argtan. More... | |
Array< T > | fabs (const Array< T > &) |
Operator absolute value. More... | |
T | scal (const Array< T > &, const Array< T > &) |
Scalar product of two arrays. More... | |
T | diffmax (const Array< T > &, const Array< T > &) |
Maximal difference between two arrays. More... | |
T | max (const Array< T > &) |
Maximal value. More... | |
T | min (const Array< T > &) |
Minimal value. More... | |
T | sum (const Array< T > &) |
Summation of all the elements. More... | |
Array< T > | atan (const Array< T > &) |
Operator arctan. More... | |
Template class for arrays.
It is designed mainly to handle multi-dimensional arrays of int
and double
.
using Kadath::Array< T >::const_pointer = T const * |
using Kadath::Array< T >::const_reference = T const & |
using Kadath::Array< T >::pointer = T* |
using Kadath::Array< T >::reference = T& |
|
inlineexplicit |
Constructor from a Dim_array
.
The elements are not initialized.
Definition at line 107 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Dim_array::get_ndim(), and Kadath::Array< T >::nbr.
|
inlineexplicit |
Constructor for a 1d-array.
i | [input] : size of the only dimension. The elements are not initialized. |
Definition at line 116 of file array.hpp.
References Kadath::Array< T >::dimensions, and Kadath::Dim_array::set().
|
inlineexplicit |
Constructor for a 2d-array.
i | [input] : size of the first dimension. |
j | [input] : size of the second dimension. The elements are not initialized. |
Definition at line 125 of file array.hpp.
References Kadath::Array< T >::dimensions, and Kadath::Dim_array::set().
|
inlineexplicit |
Constructor for a 3d-array.
i | [input] : size of the first dimension. |
j | [input] : size of the second dimension. |
k | [input] : size of the third dimension. The elements are not initialized. |
Definition at line 137 of file array.hpp.
References Kadath::Array< T >::dimensions, and Kadath::Dim_array::set().
|
explicit |
Constructor from a file.
The file should have been generated by the save function.
fd | the file. |
order | specifies the type of index ordering used to write the array about to be read. |
Definition at line 490 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::nbr, and Kadath::Array< T >::to_last_dim_major_index().
|
inline |
Logical destructor (kills the data)
Definition at line 154 of file array.hpp.
References Kadath::Array< T >::data.
|
inline |
Direct accessor to the data, read only version.
Definition at line 313 of file array.hpp.
References Kadath::Array< T >::data.
|
inline |
Returns the Dim_array
of the Array
.
Definition at line 335 of file array.hpp.
References Kadath::Array< T >::dimensions.
|
inline |
Returns the total number of elements.
Definition at line 327 of file array.hpp.
References Kadath::Array< T >::nbr.
|
inline |
Returns the number of dimensions.
Definition at line 323 of file array.hpp.
References Kadath::Array< T >::dimensions, and Kadath::Dim_array::get_ndim().
|
inline |
Returns the size of a given dimension.
Definition at line 331 of file array.hpp.
References Kadath::Array< T >::dimensions.
bool Kadath::Array< T >::is_increasing |
|
inline |
Read only of an element.
pos | [input] : position of the element. |
Definition at line 274 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array_iterator::position.
|
inline |
Read only of an element.
pos | [input] : position of the element. |
Definition at line 250 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::dimensions, Kadath::Dim_array::get_ndim(), and Kadath::Index::sizes.
|
inline |
Read only of an element for a 1d-array.
i | [input] : position of the element. |
Definition at line 279 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::dimensions, and Kadath::Dim_array::get_ndim().
|
inline |
Read only of an element for a 2d-array.
i | [input] : first index of the element. |
j | [input] : second index of the element. |
Definition at line 289 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::dimensions, and Kadath::Dim_array::get_ndim().
|
inline |
Read only of an element for a 3d-array.
i | [input] : first index of the element. |
j | [input] : second index of the element. |
k | [input] : third index of the element. |
Definition at line 302 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::dimensions, and Kadath::Dim_array::get_ndim().
|
inline |
Operator *=.
Definition at line 349 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array< T >::nbr.
|
inline |
Operator *=.
Definition at line 359 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array< T >::nbr.
|
inline |
Operator +.
Definition at line 343 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array< T >::nbr.
|
inline |
Operator +=.
Definition at line 355 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array< T >::nbr.
|
inline |
Operator -=.
Definition at line 346 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array< T >::nbr.
|
inline |
Operator -=.
Definition at line 357 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array< T >::nbr.
|
inline |
Operator /=.
Definition at line 352 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array< T >::nbr.
|
inline |
Operator /=.
Definition at line 361 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array< T >::nbr.
|
inline |
Assigns the same value to all the elements.
xx | [input] : value to be assigned. |
Definition at line 181 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array< T >::nbr.
|
inline |
Resize the array by reallocating its ressource.
All values are invalidated.
new_dim | new Dim_array object enumerating dimensions. |
Definition at line 160 of file array.hpp.
References Kadath::Array< T >::operator=().
|
inline |
Resize overload for the one-dimension array case.
new_size | new size of the array. |
Definition at line 165 of file array.hpp.
References Kadath::Array< T >::operator=().
void Kadath::Array< T >::save | ( | FILE * | fd, |
Array_ordering | order = last_index |
||
) | const |
Save in a file.
The file can then been used by the constructor from a file.
fd | the file. |
order | allows to save the array in column major order (faster and need less memory, use the first_index value - not compatible with files made using previous versions of Kadath) or row major order (use the default last_index value). The most expensive case is used as default for the sake of backward compatibility. |
|
inline |
Read/write of an element.
pos | [input] : position of the element. |
Definition at line 210 of file array.hpp.
References Kadath::Array< T >::data, and Kadath::Array_iterator::position.
|
inline |
Read/write of an element.
pos | [input] : position of the element. |
Definition at line 186 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::dimensions, Kadath::Dim_array::get_ndim(), and Kadath::Index::sizes.
|
inline |
Read/write of an element for a 1d-array.
i | [input] : position of the element. |
Definition at line 215 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::dimensions, and Kadath::Dim_array::get_ndim().
|
inline |
Read/write of an element for a 2d-array.
i | [input] : first index of the element. |
j | [input] : second index of the element. |
Definition at line 225 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::dimensions, and Kadath::Dim_array::get_ndim().
|
inline |
Read/write of an element for a 3d-array.
i | [input] : first index of the element. |
j | [input] : second index of the element. |
k | [input] : third index of the element. |
Definition at line 238 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::dimensions, and Kadath::Dim_array::get_ndim().
|
inline |
Direct accessor to the data, read/write version.
Definition at line 318 of file array.hpp.
References Kadath::Array< T >::data.
|
inline |
Swaps contents between the two arrays (beware when using it with arrays of allocated pointers).
Definition at line 152 of file array.hpp.
References Kadath::Array< T >::data, Kadath::Array< T >::dimensions, Kadath::Array< T >::nbr, and Kadath::Dim_array::swap().
int Kadath::Array< T >::to_first_dim_major_index | ( | int | i_last_dim_major | ) | const |
int Kadath::Array< T >::to_last_dim_major_index | ( | int | i_first_dim_major | ) | const |
Operator arctan.
Definition at line 250 of file array_math.hpp.
Operator hyperbolic argtan.
Definition at line 193 of file array_math.hpp.
cosine operator
Definition at line 32 of file array_math.hpp.
Hyperbolic sine operator.
Definition at line 46 of file array_math.hpp.
Maximal difference between two arrays.
Definition at line 215 of file array_math.hpp.
Operator exponential.
Definition at line 179 of file array_math.hpp.
Operator absolute value.
Definition at line 200 of file array_math.hpp.
Operator logarithm.
Definition at line 186 of file array_math.hpp.
|
friend |
Maximal value.
Definition at line 227 of file array_math.hpp.
|
friend |
Minimal value.
Definition at line 235 of file array_math.hpp.
Operator * (two arrays)
Definition at line 113 of file array_math.hpp.
Operator * (one array and one value)
Definition at line 122 of file array_math.hpp.
Operator * (one value and one array)
Definition at line 129 of file array_math.hpp.
Unitary operator +.
Definition at line 53 of file array_math.hpp.
Operator + (two arrays)
Definition at line 64 of file array_math.hpp.
Operator + (one array and one value)
Definition at line 73 of file array_math.hpp.
Operator + (one value and one array)
Definition at line 80 of file array_math.hpp.
Unitary operator -.
Definition at line 56 of file array_math.hpp.
Operator - (two arrays)
Definition at line 89 of file array_math.hpp.
Operator - (one array and one value)
Definition at line 98 of file array_math.hpp.
Operator - (one value and one array)
Definition at line 106 of file array_math.hpp.
Operator / (two arrays)
Definition at line 136 of file array_math.hpp.
Operator / (one array and one value)
Definition at line 144 of file array_math.hpp.
Operator / (one value and one array)
Definition at line 151 of file array_math.hpp.
|
friend |
Operator power (double version)
Definition at line 165 of file array_math.hpp.
Operator power (integer version)
Definition at line 158 of file array_math.hpp.
Scalar product of two arrays.
Definition at line 207 of file array_math.hpp.
sine operator
Definition at line 25 of file array_math.hpp.
Hyperbolic sine operator.
Definition at line 39 of file array_math.hpp.
Operator square root.
Definition at line 172 of file array_math.hpp.
|
friend |
Summation of all the elements.
Definition at line 243 of file array_math.hpp.
Memory_mapped_array<T> Kadath::Array< T >::data |
Dim_array Kadath::Array< T >::dimensions |
int Kadath::Array< T >::nbr |