LORENE
Lorene::Itbl Class Reference

Basic integer array class. More...

#include <itbl.h>

Public Member Functions

 Itbl (int size0)
 1D constructor. More...
 
 Itbl (int size1, int size0)
 2D constructor. More...
 
 Itbl (int size2, int size1, int size0)
 3D constructor This constructor sets the Itbl in the logical state ETATQCQ , so that it is ready for initialization via the method set(int, int, int ) . More...
 
 Itbl (const Dim_tbl &)
 Constructor from a Dim_tbl . More...
 
 Itbl (FILE *)
 Constructor from a file (see sauve(FILE* ) ) More...
 
 Itbl (const Itbl &)
 Copy constructor. More...
 
 ~Itbl ()
 Destructor. More...
 
void operator= (const Itbl &)
 Assignment to another Itbl. 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 Itbl to zero in a hard way. More...
 
int & set (int i)
 Read/write of a particular element (index i ) (1D case) More...
 
int operator() (int i) const
 Read-only of a particular element (index i ) (1D case) More...
 
int & set (int j, int i)
 Read/write of a particular element (index (j,i) ) (2D case) More...
 
int operator() (int j, int i) const
 Read-only of a particular element (index (j,i) ) (2D case) More...
 
int & set (int k, int j, int i)
 Read/write of a particular element (index (k,j,i) ) (3D case) More...
 
int operator() (int k, int j, int i) const
 Read-only of a particular element (index (k,j,i) ) (3D 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 {tt dim.dim[i] ) More...
 
void sauve (FILE *) const
 Save in a file. More...
 
void operator+= (const Itbl &)
 Addition of a Itbl to this. More...
 
void operator+= (int)
 Addition of a int to this. More...
 
void operator-= (const Itbl &)
 Subtraction of a Itbl to this. More...
 
void operator-= (int)
 Subtraction of a int to this. More...
 
void operator*= (const Itbl &)
 Multiplication of this by a Itbl. More...
 
void operator*= (int)
 Multiplication of this by a int. More...
 

Public Attributes

Dim_tbl dim
 Number of dimensions, size,... More...
 
int * t
 The array of int 's. 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

ostream & operator<< (ostream &, const Itbl &)
 Display. More...
 

Detailed Description

Basic integer array class.

This class is essentially an int array class. The elements of the array are stored continuously using the C convention.

The general logical state of an initialized Itbl is ETATQCQ ; it is the only state for which the memory allocation is performed for the int array t . The value zero is treated as a special logical state (ETATZERO ), without any memory allocation.

Contrary to a Tbl , an Itbl is initialy created in a logical state ETATQCQ (i.e. ordinary state, with memory allocated for the array t ).

Arithmetic operations are provided with the usual meaning (see below).

A 1D Itbl can be of dimension 0 (size 0). Its logical state is then ETATZERO (by convention).

()

Definition at line 122 of file itbl.h.

Constructor & Destructor Documentation

◆ Itbl() [1/6]

Lorene::Itbl::Itbl ( int  size0)
explicit

1D constructor.

This constructor sets the Itbl in the logical state ETATQCQ , so that it is ready for initialization via the method set(int ) .

Parameters
size0[input] Number of elements of the array t . Will be assigned to dim.dim[0] . The size 0 is allowed (the corresponding logical state will be then ETATZERO).

Definition at line 100 of file itbl.C.

◆ Itbl() [2/6]

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

2D constructor.

This constructor sets the Itbl in the logical state ETATQCQ , so that it is ready for initialization via the method set(int, int ) .

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 113 of file itbl.C.

◆ Itbl() [3/6]

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

3D constructor This constructor sets the Itbl in the logical state ETATQCQ , so that it is ready for initialization via the method set(int, int, int ) .

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 119 of file itbl.C.

◆ Itbl() [4/6]

Lorene::Itbl::Itbl ( const Dim_tbl dt)
explicit

Constructor from a Dim_tbl .

This constructor sets the Itbl in the logical state ETATQCQ , so that it is ready for initialization via the method set .

Definition at line 125 of file itbl.C.

◆ Itbl() [5/6]

Lorene::Itbl::Itbl ( FILE *  fd)
explicit

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

Definition at line 152 of file itbl.C.

References etat, and Lorene::fread_be().

◆ Itbl() [6/6]

Lorene::Itbl::Itbl ( const Itbl tc)

Copy constructor.

Definition at line 136 of file itbl.C.

References etat.

◆ ~Itbl()

Lorene::Itbl::~Itbl ( )

Destructor.

Definition at line 170 of file itbl.C.

References t.

Member Function Documentation

◆ annule_hard()

void Lorene::Itbl::annule_hard ( )

Sets the Itbl 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 int 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 275 of file itbl.C.

References etat, get_taille(), and t.

◆ del_t()

void Lorene::Itbl::del_t ( )
private

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

Definition at line 243 of file itbl.C.

References etat, and t.

◆ get_dim()

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

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

Definition at line 326 of file itbl.h.

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

◆ get_etat()

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

Gives the logical state.

Definition at line 317 of file itbl.h.

References etat.

◆ get_ndim()

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

Gives the number of dimensions (ie dim.ndim )

Definition at line 323 of file itbl.h.

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

◆ get_taille()

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

Gives the total size (ie dim.taille )

Definition at line 320 of file itbl.h.

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

◆ operator()() [1/3]

int Lorene::Itbl::operator() ( int  i) const
inline

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

Definition at line 256 of file itbl.h.

References etat.

◆ operator()() [2/3]

int Lorene::Itbl::operator() ( int  j,
int  i 
) const
inline

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

Definition at line 278 of file itbl.h.

References etat.

◆ operator()() [3/3]

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

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

Definition at line 301 of file itbl.h.

References etat.

◆ operator*=() [1/2]

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

Multiplication of this by a Itbl.

Definition at line 465 of file itbl_arithm.C.

References dim, and etat.

◆ operator*=() [2/2]

void Lorene::Itbl::operator*= ( int  x)

Multiplication of this by a int.

Definition at line 490 of file itbl_arithm.C.

References etat.

◆ operator+=() [1/2]

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

Addition of a Itbl to this.

Definition at line 321 of file itbl_arithm.C.

References dim, and etat.

◆ operator+=() [2/2]

void Lorene::Itbl::operator+= ( int  x)

Addition of a int to this.

Definition at line 358 of file itbl_arithm.C.

References etat.

◆ operator-=() [1/2]

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

Subtraction of a Itbl to this.

Definition at line 393 of file itbl_arithm.C.

References dim, and etat.

◆ operator-=() [2/2]

void Lorene::Itbl::operator-= ( int  x)

Subtraction of a int to this.

Definition at line 430 of file itbl_arithm.C.

References etat.

◆ operator=() [1/2]

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

Assignment to another Itbl.

Definition at line 179 of file itbl.C.

References dim, and get_etat().

◆ operator=() [2/2]

void Lorene::Itbl::operator= ( int  a)

Assignment to a int.

Definition at line 206 of file itbl.C.

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

◆ sauve()

void Lorene::Itbl::sauve ( FILE *  fd) const

Save in a file.

Definition at line 229 of file itbl.C.

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

◆ set() [1/3]

int& Lorene::Itbl::set ( int  i)
inline

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

Definition at line 247 of file itbl.h.

References etat.

◆ set() [2/3]

int& Lorene::Itbl::set ( int  j,
int  i 
)
inline

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

Definition at line 269 of file itbl.h.

References etat.

◆ set() [3/3]

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

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

Definition at line 291 of file itbl.h.

References etat.

◆ set_etat_nondef()

void Lorene::Itbl::set_etat_nondef ( )

Sets the logical state to ETATNONDEF (undefined).

Deallocates the memory occupied by the int array t .

Definition at line 257 of file itbl.C.

References etat.

◆ set_etat_qcq()

void Lorene::Itbl::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 int array t .

Definition at line 264 of file itbl.C.

References etat.

◆ set_etat_zero()

void Lorene::Itbl::set_etat_zero ( )

Sets the logical state to ETATZERO (zero).

Deallocates the memory occupied by the int array t .

Definition at line 250 of file itbl.C.

References etat.

Friends And Related Function Documentation

◆ operator<<

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

Display.

Definition at line 294 of file itbl.C.

Member Data Documentation

◆ dim

Dim_tbl Lorene::Itbl::dim

Number of dimensions, size,...

Definition at line 131 of file itbl.h.

◆ etat

int Lorene::Itbl::etat
private

logical state (ETATNONDEF , ETATQCQ or ETATZERO ).

Definition at line 128 of file itbl.h.

◆ t

int* Lorene::Itbl::t

The array of int 's.

Definition at line 132 of file itbl.h.


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