|
LORENE
|
Basic array class. More...
#include <tbl.h>
Public Member Functions | |
| Tbl (int size0) | |
| 1D constructor More... | |
| Tbl (int size1, int size0) | |
| 2D constructor More... | |
| Tbl (int size2, int size1, int size0) | |
| 3D constructor More... | |
| Tbl (int size3, int size2, int size1, int size0) | |
| 4D constructor More... | |
| Tbl (Itbl sizes) | |
| N-dimensional constructor. More... | |
| Tbl (const Grille3d &grid) | |
| Constructor from a 3D grid. More... | |
| Tbl (const Dim_tbl &dim) | |
Constructor from a Dim_tbl. More... | |
| Tbl (FILE *) | |
Constructor from a file (see sauve(FILE* )) More... | |
| Tbl (const Tbl &a) | |
| Copy constructor. More... | |
| Tbl (const Matrice &mat) | |
| Constructor from a matrix. More... | |
| ~Tbl () | |
| Destructor. More... | |
| void | operator= (const Tbl &) |
Assignment to another Tbl. More... | |
| void | operator= (double) |
Assignment to a double. More... | |
| void | operator= (int) |
Assignment to a int. More... | |
| void | set_etat_nondef () |
Sets the logical state to ETATNONDEF (undefined). More... | |
| void | set_etat_zero () |
Sets the logical state to ETATZERO (zero). More... | |
| void | set_etat_qcq () |
Sets the logical state to ETATQCQ (ordinary state). More... | |
| void | annule_hard () |
Sets the Tbl to zero in a hard way. More... | |
| double & | set (int i) |
Read/write of a particular element (index i) (1D case) More... | |
| void | affecte (int i, double val) |
Affectation of a particular element (index i) (1D case) More... | |
| double | operator() (int i) const |
Read-only of a particular element (index i) (1D case) More... | |
| double & | set (int j, int i) |
Read/write of a particular element (index (j,i)) (2D case) More... | |
| double | operator() (int j, int i) const |
Read-only of a particular element (index (j,i)) (2D case) More... | |
| double & | set (int k, int j, int i) |
Read/write of a particular element (index (k,j,i)) (3D case) More... | |
| double | operator() (int k, int j, int i) const |
Read-only of a particular element (index (k,j,i)) (3D case) More... | |
| double & | set (const Itbl place) |
| Read/write of a particular element (multi-dimensional case) More... | |
| double | operator() (const Itbl place) const |
Read-only of a particular element (index (k,j,i)) (multi-dimensional case) More... | |
| int | get_etat () const |
| Gives the logical state. More... | |
| int | get_taille () const |
Gives the total size (ie dim.taille) More... | |
| int | get_ndim () const |
Gives the number of dimensions (ie dim.ndim) More... | |
| int | get_dim (int i) const |
Gives the i-th dimension (ie dim.dim[i]) More... | |
| void | sauve (FILE *) const |
| Save in a file. More... | |
| void | affiche_seuil (ostream &ostr, int precision=4, double threshold=1.e-7) const |
| Prints only the values greater than a given threshold. More... | |
| void | operator+= (const Tbl &) |
Addition of a Tbl to this. More... | |
| void | operator+= (double) |
Addition of a double to this. More... | |
| void | operator-= (const Tbl &) |
Subtraction of a Tbl to this. More... | |
| void | operator-= (double) |
Subtraction of a double to this. More... | |
| void | operator*= (const Tbl &) |
Multiplication of this by a Tbl. More... | |
| void | operator*= (double) |
Multiplication of this by a double. More... | |
| void | operator/= (const Tbl &) |
Division of this by a Tbl. More... | |
| void | operator/= (double) |
Division of this by a double. More... | |
Public Attributes | |
| Dim_tbl | dim |
| Number of dimensions, size,... More... | |
| double * | t |
The array of double. More... | |
Private Member Functions | |
| void | del_t () |
Logical destructor: dellocates the memory occupied by the array t and sets the logical state to ETATNONDEF. More... | |
Private Attributes | |
| int | etat |
logical state (ETATNONDEF, ETATQCQ or ETATZERO). More... | |
Friends | |
| class | Matrice |
| ostream & | operator<< (ostream &, const Tbl &) |
| Display. More... | |
Basic array class.
This class is essentially an double array class. The elements of the array are stored continuously using the C convention. A Tbl is initialy created with a logical state ETATNONDEF (i.e. undefined), except by the copy constructor and the constructor from a file. The general logical state of an initialized Tbl is ETATQCQ; it is the only state for which the memory allocation is performed for the double} array t. The value zero is treated as a special logical state (ETATZERO), without any memory allocation. Arithmetic operations are provided with the usual meaning (see below). ()
|
explicit |
| Lorene::Tbl::Tbl | ( | int | size1, |
| int | size0 | ||
| ) |
2D constructor
| size1 | [input] Defines the range [0, size1-1] of the outermost index in the storage of the array t. Will be assigned to dim.dim[1]. |
| size0 | [input] Defines the range [0, size0-1] of the innermost index in the storage of the array t. Will be assigned to dim.dim[0]. |
| Lorene::Tbl::Tbl | ( | int | size2, |
| int | size1, | ||
| int | size0 | ||
| ) |
3D constructor
| size2 | [input] Defines the range [0, size2-1] of the outermost index in the storage of the array t. Will be assigned to dim.dim[2]. |
| size1 | [input] Defines the range [0, size1-1] of the intermediate index in the storage of the array t. Will be assigned to dim.dim[1]. |
| size0 | [input] Defines the range [0, size0-1] of the innermost index in the storage of the array t. Will be assigned to dim.dim[0]. |
| Lorene::Tbl::Tbl | ( | int | size3, |
| int | size2, | ||
| int | size1, | ||
| int | size0 | ||
| ) |
4D constructor
| size3 | [input] Defines the range [0, size3-1] of the outermost index in the storage of the array t. Will be assigned to dim.dim[3]. |
| size2 | [input] Defines the range [0, size2-1] of the outermost index in the storage of the array t. Will be assigned to dim.dim[2]. |
| size1 | [input] Defines the range [0, size1-1] of the intermediate index in the storage of the array t. Will be assigned to dim.dim[1]. |
| size0 | [input] Defines the range [0, size0-1] of the innermost index in the storage of the array t. Will be assigned to dim.dim[0]. |
| Lorene::Tbl::Tbl | ( | Itbl | sizes | ) |
|
explicit |
|
explicit |
|
explicit |
Constructor from a file (see sauve(FILE* ))
Definition at line 198 of file tbl.C.
References etat, and Lorene::fread_be().
| Lorene::Tbl::Tbl | ( | const Tbl & | a | ) |
|
explicit |
Constructor from a matrix.
If the matrix has only one row or one column, the Tbl is 1D, otherwise it is 2D.
Definition at line 213 of file tbl.C.
References Lorene::Dim_tbl::dim, dim, etat, and Lorene::Dim_tbl::ndim.
|
inline |
| void Lorene::Tbl::affiche_seuil | ( | ostream & | ostr, |
| int | precision = 4, |
||
| double | threshold = 1.e-7 |
||
| ) | const |
Prints only the values greater than a given threshold.
| ostr | [input] Output stream used for the printing |
| precision | [input] Number of printed digits (default: 4) |
| threshold | [input] Value above which an array element is printed (default: 1.e-7) |
Definition at line 471 of file tbl.C.
References etat, get_dim(), get_ndim(), and get_taille().
| void Lorene::Tbl::annule_hard | ( | ) |
Sets the Tbl to zero in a hard way.
1/ Sets the logical state to ETATQCQ, i.e. to an ordinary state. 2/ Allocates the memory of the double array t, and fills it with zeros. NB: this function must be used for debugging purposes only. For other operations, the function set_etat_zero() must be perferred.
Definition at line 375 of file tbl.C.
References etat, get_taille(), and t.
|
private |
|
inline |
Gives the i-th dimension (ie dim.dim[i])
Definition at line 423 of file tbl.h.
References Lorene::Dim_tbl::dim, dim, and Lorene::Dim_tbl::ndim.
|
inline |
|
inline |
Gives the number of dimensions (ie dim.ndim)
Definition at line 420 of file tbl.h.
References dim, and Lorene::Dim_tbl::ndim.
|
inline |
Gives the total size (ie dim.taille)
Definition at line 417 of file tbl.h.
References dim, and Lorene::Dim_tbl::taille.
|
inline |
|
inline |
|
inline |
|
inline |
| void Lorene::Tbl::operator*= | ( | const Tbl & | ti | ) |
Multiplication of this by a Tbl.
Definition at line 631 of file tbl_arithm.C.
| void Lorene::Tbl::operator*= | ( | double | x | ) |
| void Lorene::Tbl::operator+= | ( | const Tbl & | ti | ) |
| void Lorene::Tbl::operator+= | ( | double | x | ) |
| void Lorene::Tbl::operator-= | ( | const Tbl & | ti | ) |
Subtraction of a Tbl to this.
Definition at line 559 of file tbl_arithm.C.
| void Lorene::Tbl::operator-= | ( | double | x | ) |
| void Lorene::Tbl::operator/= | ( | const Tbl & | ti | ) |
| void Lorene::Tbl::operator/= | ( | double | x | ) |
| void Lorene::Tbl::operator= | ( | const Tbl & | tx | ) |
| void Lorene::Tbl::operator= | ( | double | a | ) |
Assignment to a double.
Definition at line 293 of file tbl.C.
References get_taille(), set_etat_qcq(), set_etat_zero(), and t.
| void Lorene::Tbl::operator= | ( | int | m | ) |
Assignment to a int.
Definition at line 308 of file tbl.C.
References get_taille(), set_etat_qcq(), set_etat_zero(), and t.
| void Lorene::Tbl::sauve | ( | FILE * | fd | ) | const |
Save in a file.
Definition at line 329 of file tbl.C.
References dim, etat, Lorene::fwrite_be(), and Lorene::Dim_tbl::sauve().
|
inline |
|
inline |
|
inline |
|
inline |
Read/write of a particular element (multi-dimensional case)
Definition at line 377 of file tbl.h.
References Lorene::Dim_tbl::dim, dim, Lorene::Dim_tbl::ndim, and t.
| void Lorene::Tbl::set_etat_nondef | ( | ) |
| void Lorene::Tbl::set_etat_qcq | ( | ) |
| void Lorene::Tbl::set_etat_zero | ( | ) |
|
friend |
|
private |