LORENE
Lorene::Matrice Class Reference

Matrix handling. More...

#include <matrice.h>

Public Member Functions

 Matrice (int size1, int size2)
 Standard constructor. More...
 
 Matrice (const Matrice &)
 Constructor by copy. More...
 
 Matrice (const Tbl &tab)
 Constructor from a Tbl. More...
 
 ~Matrice ()
 Destructor. More...
 
int get_etat () const
 Returns the logical state. More...
 
void set_etat_qcq ()
 Sets the logical state to ETATQCQ (ordinary state). More...
 
void set_etat_zero ()
 Sets the logical state to ETATZERO (zero). More...
 
void set_etat_nondef ()
 Sets the logical state to ETATNONDEF (undefined state). More...
 
void annule_hard ()
 Sets the logical state to ETATQCQ (undefined state). More...
 
int get_dim (int i) const
 Returns the dimension of the matrix. More...
 
Tbl get_array () const
 Returns the array of matrix elements. More...
 
void operator= (double x)
 Sets all the element of *std to x. More...
 
void operator= (const Matrice &)
 Assignement to another Matrice. More...
 
void operator= (const Tbl &)
 Assignement to a Tbl. More...
 
double & set (int j, int i)
 Read/write of a particuliar element. More...
 
double operator() (int j, int i) const
 Read-only of a particuliar element. More...
 
void set_band (int up, int low) const
 Calculate the band storage of *std. More...
 
void set_lu () const
 Calculate the LU-representation, assuming the band-storage has been done. More...
 
Tbl inverse (const Tbl &sec_membre) const
 Solves the linear system represented by the matrix. More...
 
Tbl val_propre () const
 Returns the eigenvalues of the matrix, calculated using LAPACK. More...
 
Matrice vect_propre () const
 Returns the eigenvectors of the matrix, calculated using LAPACK. More...
 
double determinant () const
 Computes the determinant of the matrix, using LAPACK and the standard decomposition. More...
 
Matrice transpose () const
 Computes the transpose matrix. More...
 
void operator+= (const Matrice &)
 Addition of a Matrice to this. More...
 
void operator+= (double)
 Addition of a double to this. More...
 
void operator-= (const Matrice &)
 Subtraction of a Matrice to this. More...
 
void operator-= (double)
 Subtraction of a double to this. More...
 
void operator*= (double)
 Multiplication of this by a double. More...
 
void operator/= (double)
 Division of this by a double. More...
 

Private Member Functions

void del_t ()
 Logical destructor : dellocates the memory of the various used representations. More...
 
void del_deriv ()
 Deletes the (mutable) derived members: band, lu, permute. More...
 

Private Attributes

int etat
 logical state (ETATZERO, ETATQCQ or ETATNONDEF) More...
 
Tblstd
 Pointer on the array of the standard representation. More...
 
int ku
 Number of upper-diagonals in the band representation. More...
 
int kl
 Number of lower-diagonals in the band representation. More...
 
Tblband
 Pointer on the array of the band representation of a square matrix. More...
 
Tbllu
 Pointer on the first array of the LU-representation. More...
 
Itblpermute
 Pointer on the second array of the LU-representation. More...
 

Friends

ostream & operator<< (ostream &, const Matrice &)
 Display. More...
 
Matrice operator+ (const Matrice &, const Matrice &)
 Matrice + Matrice More...
 
Matrice operator- (const Matrice &, const Matrice &)
 Matrice - Matrice More...
 
Matrice operator* (const Matrice &, double)
 Matrice * double More...
 
Matrice operator* (double, const Matrice &)
 double * Matrice More...
 
Matrice operator* (const Matrice &, const Matrice &)
 Matrix product. More...
 
Matrice operator/ (const Matrice &, double)
 Matrice / double More...
 

Detailed Description

Matrix handling.

The matrix can be stored in the usual way in std, in a band-way by band and on a LU-decomposition by the two arrays lu and permute. All the storage conventions are those af LAPACK which is used to make the LU-decomposition, the inversion and to compute the eigenvalues of the matrix. All those representations are redondant, that means that doing the LU-decomposition, for example, does NOT destroy previously calculated type of storage.

()

Definition at line 152 of file matrice.h.

Constructor & Destructor Documentation

◆ Matrice() [1/3]

Lorene::Matrice::Matrice ( int  size1,
int  size2 
)

Standard constructor.

All the representations are set to ETATNONDEF.

Parameters
size1[input] number of lines.
size2[input] number of columns.

Definition at line 206 of file matrice.C.

References etat.

◆ Matrice() [2/3]

Lorene::Matrice::Matrice ( const Matrice source)

Constructor by copy.

Definition at line 217 of file matrice.C.

References band, etat, kl, ku, lu, permute, and std.

◆ Matrice() [3/3]

Lorene::Matrice::Matrice ( const Tbl tab)

Constructor from a Tbl.

Parameters
tab[input] 2-dimension or 1-dimension array

If tab is a 1-dimension Tbl, a single-column matrix is created, otherwise *std is simply constructed by a Tbl copy of tab.

Definition at line 231 of file matrice.C.

References etat, Lorene::Tbl::get_etat(), Lorene::Tbl::get_ndim(), Lorene::Tbl::get_taille(), kl, and ku.

◆ ~Matrice()

Lorene::Matrice::~Matrice ( )

Destructor.

Definition at line 258 of file matrice.C.

References del_t().

Member Function Documentation

◆ annule_hard()

void Lorene::Matrice::annule_hard ( )

Sets the logical state to ETATQCQ (undefined state).

And sets all the components to zero

Definition at line 196 of file matrice.C.

References del_deriv(), and etat.

◆ del_deriv()

void Lorene::Matrice::del_deriv ( )
private

Deletes the (mutable) derived members: band, lu, permute.

Definition at line 167 of file matrice.C.

References band, lu, and permute.

◆ del_t()

void Lorene::Matrice::del_t ( )
private

Logical destructor : dellocates the memory of the various used representations.

Definition at line 159 of file matrice.C.

References del_deriv(), and std.

◆ determinant()

double Lorene::Matrice::determinant ( ) const

Computes the determinant of the matrix, using LAPACK and the standard decomposition.

Definition at line 563 of file matrice.C.

References get_dim(), and val_propre().

◆ get_array()

Tbl Lorene::Matrice::get_array ( ) const
inline

Returns the array of matrix elements.

Definition at line 251 of file matrice.h.

References std.

◆ get_dim()

int Lorene::Matrice::get_dim ( int  i) const

Returns the dimension of the matrix.

Parameters
i[input] if i =0 returns the number of lines and if i =2 returns the number of columns.

Definition at line 263 of file matrice.C.

◆ get_etat()

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

Returns the logical state.

Definition at line 213 of file matrice.h.

References etat.

◆ inverse()

Tbl Lorene::Matrice::inverse ( const Tbl sec_membre) const

Solves the linear system represented by the matrix.

The calculus assumes the the LU-decomposition has been done and is conducted using LAPACK.

Parameters
sec_membre[input] the right-hand side of the system.

Definition at line 427 of file matrice.C.

References Lorene::Tbl::get_etat(), and lu.

◆ operator()()

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

Read-only of a particuliar element.

Parameters
j[input] line coordinate.
i[input] column coordinate.

Definition at line 290 of file matrice.h.

References etat.

◆ operator*=()

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

Multiplication of this by a double.

Definition at line 625 of file matrice.C.

◆ operator+=() [1/2]

void Lorene::Matrice::operator+= ( const Matrice a)

Addition of a Matrice to this.

Definition at line 605 of file matrice.C.

References std.

◆ operator+=() [2/2]

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

Addition of a double to this.

Definition at line 615 of file matrice.C.

◆ operator-=() [1/2]

void Lorene::Matrice::operator-= ( const Matrice a)

Subtraction of a Matrice to this.

Definition at line 610 of file matrice.C.

References std.

◆ operator-=() [2/2]

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

Subtraction of a double to this.

Definition at line 620 of file matrice.C.

◆ operator/=()

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

Division of this by a double.

Definition at line 630 of file matrice.C.

◆ operator=() [1/3]

void Lorene::Matrice::operator= ( double  x)

Sets all the element of *std to x.

The other representations are set to ETATNONDEF.

Definition at line 268 of file matrice.C.

References set_etat_qcq(), and set_etat_zero().

◆ operator=() [2/3]

void Lorene::Matrice::operator= ( const Matrice source)

Assignement to another Matrice.

Definition at line 276 of file matrice.C.

References etat, Lorene::Tbl::get_dim(), and std.

◆ operator=() [3/3]

void Lorene::Matrice::operator= ( const Tbl source)

Assignement to a Tbl.

Definition at line 309 of file matrice.C.

References Lorene::Tbl::etat, and Lorene::Tbl::get_dim().

◆ set()

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

Read/write of a particuliar element.

This is done in *std and all the other representations are no longer valid.

Parameters
j[input] line coordinate.
i[input] column coordinate.

Definition at line 277 of file matrice.h.

References etat.

◆ set_band()

void Lorene::Matrice::set_band ( int  up,
int  low 
) const

Calculate the band storage of *std.

Please note that this function does NOT check if *std represents a real band-matrix.

Parameters
up[input] number of upper-diagonals.
low[input] number of lower-diagonals.

Definition at line 367 of file matrice.C.

References Lorene::Tbl::annule_hard(), band, kl, ku, and Lorene::Tbl::set().

◆ set_etat_nondef()

void Lorene::Matrice::set_etat_nondef ( )

Sets the logical state to ETATNONDEF (undefined state).

The state of of all the representations is now ETATNONDEF.

Definition at line 190 of file matrice.C.

References del_deriv(), and etat.

◆ set_etat_qcq()

void Lorene::Matrice::set_etat_qcq ( )

Sets the logical state to ETATQCQ (ordinary state).

The state of *std is now ETATQCQ and the one of all the other representations is ETATNONDEF.

Definition at line 178 of file matrice.C.

References del_deriv(), and etat.

◆ set_etat_zero()

void Lorene::Matrice::set_etat_zero ( )

Sets the logical state to ETATZERO (zero).

The state of *std is now ETATZERO and the one of all the other representations is ETATNONDEF.

Definition at line 184 of file matrice.C.

References del_deriv(), and etat.

◆ set_lu()

void Lorene::Matrice::set_lu ( ) const

Calculate the LU-representation, assuming the band-storage has been done.

The calculus is done using LAPACK.

Definition at line 395 of file matrice.C.

References band, Lorene::Tbl::get_etat(), lu, permute, and Lorene::Itbl::set_etat_qcq().

◆ transpose()

Matrice Lorene::Matrice::transpose ( ) const

Computes the transpose matrix.

Definition at line 581 of file matrice.C.

References etat.

◆ val_propre()

Tbl Lorene::Matrice::val_propre ( ) const

Returns the eigenvalues of the matrix, calculated using LAPACK.

Returns
contains the real and the imaginary parts of the eigenvalues. The real parts are in Tbl (0, *) and the imaginary parts in Tbl (1, *).

Definition at line 460 of file matrice.C.

References etat.

◆ vect_propre()

Matrice Lorene::Matrice::vect_propre ( ) const

Returns the eigenvectors of the matrix, calculated using LAPACK.

Definition at line 510 of file matrice.C.

References etat.

Friends And Related Function Documentation

◆ operator* [1/3]

Matrice operator* ( const Matrice a,
double  x 
)
friend

Matrice * double

Definition at line 649 of file matrice.C.

◆ operator* [2/3]

Matrice operator* ( double  x,
const Matrice a 
)
friend

double * Matrice

Definition at line 655 of file matrice.C.

◆ operator* [3/3]

Matrice operator* ( const Matrice aa,
const Matrice bb 
)
friend

Matrix product.

Definition at line 661 of file matrice.C.

◆ operator+

Matrice operator+ ( const Matrice a,
const Matrice b 
)
friend

Matrice + Matrice

Definition at line 637 of file matrice.C.

◆ operator-

Matrice operator- ( const Matrice a,
const Matrice b 
)
friend

Matrice - Matrice

Definition at line 643 of file matrice.C.

◆ operator/

Matrice operator/ ( const Matrice a,
double  x 
)
friend

Matrice / double

Definition at line 696 of file matrice.C.

◆ operator<<

ostream& operator<< ( ostream &  flux,
const Matrice source 
)
friend

Display.

Definition at line 333 of file matrice.C.

Member Data Documentation

◆ band

Tbl* Lorene::Matrice::band
mutableprivate

Pointer on the array of the band representation of a square matrix.

To be precise, $ A(i, j)$ is stored in band $[ku+1+i-j, j]$ for $\mathrm {max}(1, j-ku) \leq i \leq \mathrm{min} (n, j+kl)$, n being the size of the matrix.

Definition at line 170 of file matrice.h.

◆ etat

int Lorene::Matrice::etat
private

logical state (ETATZERO, ETATQCQ or ETATNONDEF)

Definition at line 156 of file matrice.h.

◆ kl

int Lorene::Matrice::kl
mutableprivate

Number of lower-diagonals in the band representation.

Definition at line 162 of file matrice.h.

◆ ku

int Lorene::Matrice::ku
mutableprivate

Number of upper-diagonals in the band representation.

Definition at line 161 of file matrice.h.

◆ lu

Tbl* Lorene::Matrice::lu
mutableprivate

Pointer on the first array of the LU-representation.

Definition at line 173 of file matrice.h.

◆ permute

Itbl* Lorene::Matrice::permute
mutableprivate

Pointer on the second array of the LU-representation.

Definition at line 174 of file matrice.h.

◆ std

Tbl* Lorene::Matrice::std
private

Pointer on the array of the standard representation.

Definition at line 158 of file matrice.h.


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