LORENE
Lorene::Tbl Class Reference

Basic array class. More...

#include <tbl.h>

Public Member Functions

 Tbl (int size0)
 1D constructor
 
 Tbl (int size1, int size0)
 2D constructor
 
 Tbl (int size2, int size1, int size0)
 3D constructor
 
 Tbl (Itbl sizes)
 N-dimensional constructor.
 
 Tbl (const Grille3d &grid)
 Constructor from a 3D grid.
 
 Tbl (const Dim_tbl &dim)
 Constructor from a Dim_tbl.
 
 Tbl (FILE *)
 Constructor from a file (see sauve(FILE* ))
 
 Tbl (const Tbl &a)
 Copy constructor.
 
 Tbl (const Matrice &mat)
 Constructor from a matrix.
 
 ~Tbl ()
 Destructor.
 
void operator= (const Tbl &)
 Assignment to another Tbl.
 
void operator= (double)
 Assignment to a double.
 
void operator= (int)
 Assignment to a int.
 
void set_etat_nondef ()
 Sets the logical state to ETATNONDEF (undefined).
 
void set_etat_zero ()
 Sets the logical state to ETATZERO (zero).
 
void set_etat_qcq ()
 Sets the logical state to ETATQCQ (ordinary state).
 
void annule_hard ()
 Sets the Tbl to zero in a hard way.
 
doubleset (int i)
 Read/write of a particular element (index i) (1D case)
 
void affecte (int i, double val)
 Affectation of a particular element (index i) (1D case)
 
double operator() (int i) const
 Read-only of a particular element (index i) (1D case)
 
doubleset (int j, int i)
 Read/write of a particular element (index (j,i)) (2D case)
 
double operator() (int j, int i) const
 Read-only of a particular element (index (j,i)) (2D case)
 
doubleset (int k, int j, int i)
 Read/write of a particular element (index (k,j,i)) (3D case)
 
double operator() (int k, int j, int i) const
 Read-only of a particular element (index (k,j,i)) (3D case)
 
doubleset (const Itbl place)
 Read/write of a particular element (multi-dimensional case)
 
double operator() (const Itbl place) const
 Read-only of a particular element (index (k,j,i)) (multi-dimensional case)
 
int get_etat () const
 Gives the logical state.
 
int get_taille () const
 Gives the total size (ie dim.taille)
 
int get_ndim () const
 Gives the number of dimensions (ie dim.ndim)
 
int get_dim (int i) const
 Gives the i-th dimension (ie dim.dim[i])
 
void sauve (FILE *) const
 Save in a file.
 
void affiche_seuil (ostream &ostr, int precision=4, double threshold=1.e-7) const
 Prints only the values greater than a given threshold.
 
void operator+= (const Tbl &)
 Addition of a Tbl to this.
 
void operator+= (double)
 Addition of a double to this.
 
void operator-= (const Tbl &)
 Subtraction of a Tbl to this.
 
void operator-= (double)
 Subtraction of a double to this.
 
void operator*= (const Tbl &)
 Multiplication of this by a Tbl.
 
void operator*= (double)
 Multiplication of this by a double.
 
void operator/= (const Tbl &)
 Division of this by a Tbl.
 
void operator/= (double)
 Division of this by a double.
 

Public Attributes

Dim_tbl dim
 Number of dimensions, size,...
 
doublet
 The array of double.
 

Private Member Functions

void del_t ()
 Logical destructor: dellocates the memory occupied by the array t and sets the logical state to ETATNONDEF.
 

Private Attributes

int etat
 logical state (ETATNONDEF, ETATQCQ or ETATZERO).
 

Friends

class Matrice
 
ostreamoperator<< (ostream &, const Tbl &)
 Display

 

Detailed Description

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). ()

Definition at line 161 of file tbl.h.

Constructor & Destructor Documentation

◆ Tbl() [1/9]

Lorene::Tbl::Tbl ( int  size0)
explicit

1D constructor

Parameters
size0[input] Number of elements of the array t. Will be assigned to dim.dim[0].

Definition at line 144 of file tbl.C.

◆ Tbl() [2/9]

Lorene::Tbl::Tbl ( int  size1,
int  size0 
)

2D constructor

Parameters
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].

Definition at line 147 of file tbl.C.

◆ Tbl() [3/9]

Lorene::Tbl::Tbl ( int  size2,
int  size1,
int  size0 
)

3D constructor

Parameters
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].

Definition at line 150 of file tbl.C.

◆ Tbl() [4/9]

Lorene::Tbl::Tbl ( Itbl  sizes)

N-dimensional constructor.

Parameters
sizes[input] the sizes of each dimensions

Definition at line 158 of file tbl.C.

References dim.

◆ Tbl() [5/9]

Lorene::Tbl::Tbl ( const Grille3d grid)
explicit

Constructor from a 3D grid.

Definition at line 153 of file tbl.C.

◆ Tbl() [6/9]

Lorene::Tbl::Tbl ( const Dim_tbl dim)
explicit

Constructor from a Dim_tbl.

Definition at line 172 of file tbl.C.

◆ Tbl() [7/9]

Lorene::Tbl::Tbl ( FILE fd)
explicit

Constructor from a file (see sauve(FILE* ))

Definition at line 195 of file tbl.C.

References etat, Lorene::fread_be(), get_taille(), and t.

◆ Tbl() [8/9]

Lorene::Tbl::Tbl ( const Tbl a)

Copy constructor.

Definition at line 175 of file tbl.C.

References dim, t, and Lorene::Dim_tbl::taille.

◆ Tbl() [9/9]

Lorene::Tbl::Tbl ( const Matrice mat)
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 210 of file tbl.C.

References Lorene::Dim_tbl::dim, dim, etat, Lorene::Matrice::get_array(), get_taille(), Lorene::Dim_tbl::ndim, and t.

◆ ~Tbl()

Lorene::Tbl::~Tbl ( )

Destructor.

Definition at line 250 of file tbl.C.

References t.

Member Function Documentation

◆ affecte()

void Lorene::Tbl::affecte ( int  i,
double  val 
)
inline

Affectation of a particular element (index i) (1D case)

Definition at line 290 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, etat, Lorene::Dim_tbl::ndim, and t.

◆ affiche_seuil()

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.

Parameters
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 468 of file tbl.C.

References etat, get_dim(), get_ndim(), and get_taille().

◆ annule_hard()

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 372 of file tbl.C.

References etat, get_taille(), and t.

◆ del_t()

void Lorene::Tbl::del_t ( )
private

Logical destructor: dellocates the memory occupied by the array t and sets the logical state to ETATNONDEF.

Definition at line 340 of file tbl.C.

References etat, and t.

◆ get_dim()

int Lorene::Tbl::get_dim ( int  i) const
inline

Gives the i-th dimension (ie dim.dim[i])

Definition at line 403 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, and Lorene::Dim_tbl::ndim.

◆ get_etat()

int Lorene::Tbl::get_etat ( ) const
inline

Gives the logical state.

Definition at line 394 of file tbl.h.

References etat.

◆ get_ndim()

int Lorene::Tbl::get_ndim ( ) const
inline

Gives the number of dimensions (ie dim.ndim)

Definition at line 400 of file tbl.h.

References dim, and Lorene::Dim_tbl::ndim.

◆ get_taille()

int Lorene::Tbl::get_taille ( ) const
inline

Gives the total size (ie dim.taille)

Definition at line 397 of file tbl.h.

References dim, and Lorene::Dim_tbl::taille.

◆ operator()() [1/4]

double Lorene::Tbl::operator() ( const Itbl  place) const
inline

Read-only of a particular element (index (k,j,i)) (multi-dimensional case)

Definition at line 371 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, etat, Lorene::Itbl::get_dim(), Lorene::Dim_tbl::ndim, and t.

◆ operator()() [2/4]

double Lorene::Tbl::operator() ( int  i) const
inline

Read-only of a particular element (index i) (1D case)

Definition at line 298 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, etat, Lorene::Dim_tbl::ndim, and t.

◆ operator()() [3/4]

double Lorene::Tbl::operator() ( int  j,
int  i 
) const
inline

Read-only of a particular element (index (j,i)) (2D case)

Definition at line 320 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, etat, Lorene::Dim_tbl::ndim, and t.

◆ operator()() [4/4]

double Lorene::Tbl::operator() ( int  k,
int  j,
int  i 
) const
inline

Read-only of a particular element (index (k,j,i)) (3D case)

Definition at line 343 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, etat, Lorene::Dim_tbl::ndim, and t.

◆ operator*=() [1/2]

void Lorene::Tbl::operator*= ( const Tbl ti)

Multiplication of this by a Tbl.

Definition at line 628 of file tbl_arithm.C.

References dim, etat, get_taille(), set_etat_zero(), and t.

◆ operator*=() [2/2]

void Lorene::Tbl::operator*= ( double  x)

Multiplication of this by a double.

Definition at line 654 of file tbl_arithm.C.

References etat, get_taille(), set_etat_zero(), and t.

◆ operator+=() [1/2]

void Lorene::Tbl::operator+= ( const Tbl ti)

Addition of a Tbl to this.

Definition at line 484 of file tbl_arithm.C.

References dim, etat, get_taille(), set_etat_qcq(), and t.

◆ operator+=() [2/2]

void Lorene::Tbl::operator+= ( double  x)

Addition of a double to this.

Definition at line 521 of file tbl_arithm.C.

References etat, get_taille(), set_etat_qcq(), and t.

◆ operator-=() [1/2]

void Lorene::Tbl::operator-= ( const Tbl ti)

Subtraction of a Tbl to this.

Definition at line 556 of file tbl_arithm.C.

References dim, etat, get_taille(), set_etat_qcq(), and t.

◆ operator-=() [2/2]

void Lorene::Tbl::operator-= ( double  x)

Subtraction of a double to this.

Definition at line 593 of file tbl_arithm.C.

References etat, get_taille(), set_etat_qcq(), and t.

◆ operator/=() [1/2]

void Lorene::Tbl::operator/= ( const Tbl ti)

Division of this by a Tbl.

Definition at line 678 of file tbl_arithm.C.

References dim, etat, get_taille(), and t.

◆ operator/=() [2/2]

void Lorene::Tbl::operator/= ( double  x)

Division of this by a double.

Definition at line 705 of file tbl_arithm.C.

References etat, get_taille(), and t.

◆ operator=() [1/3]

void Lorene::Tbl::operator= ( const Tbl tx)

Assignment to another Tbl.

Definition at line 259 of file tbl.C.

References dim, get_taille(), set_etat_qcq(), set_etat_zero(), and t.

◆ operator=() [2/3]

void Lorene::Tbl::operator= ( double  a)

Assignment to a double.

Definition at line 290 of file tbl.C.

References get_taille(), set_etat_qcq(), set_etat_zero(), and t.

◆ operator=() [3/3]

void Lorene::Tbl::operator= ( int  m)

Assignment to a int.

Definition at line 305 of file tbl.C.

References get_taille(), set_etat_qcq(), set_etat_zero(), and t.

◆ sauve()

void Lorene::Tbl::sauve ( FILE fd) const

Save in a file.

Definition at line 326 of file tbl.C.

References dim, etat, Lorene::fwrite_be(), get_taille(), Lorene::Dim_tbl::sauve(), and t.

◆ set() [1/4]

double & Lorene::Tbl::set ( const Itbl  place)
inline

Read/write of a particular element (multi-dimensional case)

Definition at line 357 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, Lorene::Itbl::get_dim(), Lorene::Dim_tbl::ndim, and t.

◆ set() [2/4]

double & Lorene::Tbl::set ( int  i)
inline

Read/write of a particular element (index i) (1D case)

Definition at line 281 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, etat, Lorene::Dim_tbl::ndim, and t.

◆ set() [3/4]

double & Lorene::Tbl::set ( int  j,
int  i 
)
inline

Read/write of a particular element (index (j,i)) (2D case)

Definition at line 311 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, etat, Lorene::Dim_tbl::ndim, and t.

◆ set() [4/4]

double & Lorene::Tbl::set ( int  k,
int  j,
int  i 
)
inline

Read/write of a particular element (index (k,j,i)) (3D case)

Definition at line 333 of file tbl.h.

References Lorene::Dim_tbl::dim, dim, etat, Lorene::Dim_tbl::ndim, and t.

◆ set_etat_nondef()

void Lorene::Tbl::set_etat_nondef ( )

Sets the logical state to ETATNONDEF (undefined).

Deallocates the memory occupied by the double array t.

Definition at line 354 of file tbl.C.

References del_t(), and etat.

◆ set_etat_qcq()

void Lorene::Tbl::set_etat_qcq ( )

Sets the logical state to ETATQCQ (ordinary state).

If the state (member etat) is already ETATQCQ, this function does nothing. Otherwise, it performs the memory allocation for the double array t.

Definition at line 361 of file tbl.C.

References etat, get_taille(), and t.

◆ set_etat_zero()

void Lorene::Tbl::set_etat_zero ( )

Sets the logical state to ETATZERO (zero).

Deallocates the memory occupied by the double array t.

Definition at line 347 of file tbl.C.

References del_t(), and etat.

Friends And Related Symbol Documentation

◆ Matrice

Definition at line 163 of file tbl.h.

◆ operator<<

ostream & operator<< ( ostream o,
const Tbl t 
)
friend

Display

Definition at line 391 of file tbl.C.

Member Data Documentation

◆ dim

Dim_tbl Lorene::Tbl::dim

Number of dimensions, size,...

Definition at line 172 of file tbl.h.

◆ etat

int Lorene::Tbl::etat
private

logical state (ETATNONDEF, ETATQCQ or ETATZERO).

Definition at line 169 of file tbl.h.

◆ t

double* Lorene::Tbl::t

The array of double.

Definition at line 173 of file tbl.h.


The documentation for this class was generated from the following files: