KADATH
Kadath::Matrice Class Reference

Matrix handling. More...

#include <matrice.hpp>

Inheritance diagram for Kadath::Matrice:

Public Member Functions

 Matrice (int size1, int size2)
 Standard constructor. More...
 
 Matrice (const Matrice &)
 Constructor by copy. More...
 
 Matrice (const Array< double > &tab)
 Constructor from a Tbl. More...
 
 ~Matrice ()
 Destructor. More...
 
void annule ()
 Sets all the coeficients of the *std to 0. More...
 
int get_dim (int i) const
 Returns the dimension of the matrix. More...
 
Array< double > * get_lu ()
 Returns a pointer on the lu decomposition. More...
 
Array< int > * get_permute ()
 Returns a pointer on the permutation array. More...
 
const Array< double > & get_array () const
 Returns the array of matrix elements. More...
 
Array< double > & get_array ()
 Returns the array of matrix elements non const version. 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 Array< double > &)
 Assignement to an array. More...
 
double & set (int i, int j)
 Read/write of a particuliar element. More...
 
void copy_inside (int i, int j, const Matrice &so)
 Copies the elements of so inside the matrice, starting at the position $ (i,j) $. More...
 
double operator() (int i, int j) 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...
 
Array< double > solve (const Array< double > &sec_membre) const
 Solves the linear system represented by the matrix. More...
 
Array< double > 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...
 
Matrice transpose () const
 Computes the transpose matrix. More...
 
void operator+= (const Matrice &)
 Operator +=. More...
 
void operator+= (double)
 Operator +=. More...
 
void operator-= (const Matrice &)
 Operator -=. More...
 
void operator-= (double)
 Operator -=. More...
 
void operator*= (double)
 Operator *=. More...
 
void operator/= (double)
 Operator /=. More...
 

Private Member Functions

void del_deriv ()
 Logical destructor : dellocates the memory of the various used representations. More...
 

Private Attributes

Dim_array sizes
 Dim_array of dimension 2 containing the size of the matrix. More...
 
Array< double > * std
 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...
 
Array< double > * band
 Pointer on the array of the band representation of a square matrix. More...
 
Array< double > * lu
 Pointer on the first array of the LU-representation. More...
 
Array< int > * permute
 Pointer on the second array of the LU-representation. More...
 

Friends

ostream & operator<< (ostream &, const Matrice &)
 Impression. More...
 
Matrice operator+ (const Matrice &, const Matrice &)
 Operator + (binary version) More...
 
Matrice operator- (const Matrice &, const Matrice &)
 Operator - (binary version) More...
 
Matrice operator- (const Matrice &)
 Operator - (unitary version) More...
 
Matrice operator* (const Matrice &, double)
 Operator*. More...
 
Matrice operator* (double, const Matrice &)
 Operator*. More...
 
Matrice operator* (const Matrice &, const Matrice &)
 Operator*. More...
 
Matrice operator/ (const Matrice &, double)
 Operator/. 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 38 of file matrice.hpp.

Constructor & Destructor Documentation

◆ Matrice() [1/3]

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

Standard constructor.

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

Definition at line 45 of file matrice.cpp.

References band, kl, ku, lu, permute, Kadath::Dim_array::set(), sizes, and std.

◆ Matrice() [2/3]

Kadath::Matrice::Matrice ( const Matrice source)

Constructor by copy.

Definition at line 57 of file matrice.cpp.

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

◆ Matrice() [3/3]

Kadath::Matrice::Matrice ( const Array< double > &  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 71 of file matrice.cpp.

References band, Kadath::Dim_array::get_ndim(), kl, ku, lu, permute, sizes, and std.

◆ ~Matrice()

Kadath::Matrice::~Matrice ( )

Destructor.

Definition at line 82 of file matrice.cpp.

References del_deriv(), and std.

Member Function Documentation

◆ annule()

void Kadath::Matrice::annule ( )

Sets all the coeficients of the *std to 0.

The other representations are destroyed.

Definition at line 37 of file matrice.cpp.

References del_deriv(), Kadath::Index::inc(), Kadath::Array< T >::set(), sizes, and std.

◆ copy_inside()

void Kadath::Matrice::copy_inside ( int  i,
int  j,
const Matrice so 
)

Copies the elements of so inside the matrice, starting at the position $ (i,j) $.

Definition at line 130 of file matrice.cpp.

References del_deriv(), Kadath::Index::inc(), Kadath::Array< T >::set(), Kadath::Index::set(), sizes, and std.

◆ del_deriv()

void Kadath::Matrice::del_deriv ( )
private

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

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

Definition at line 27 of file matrice.cpp.

References band, lu, and permute.

◆ get_array() [1/2]

Array<double>& Kadath::Matrice::get_array ( )
inline

Returns the array of matrix elements non const version.

Definition at line 116 of file matrice.hpp.

References std.

◆ get_array() [2/2]

const Array<double>& Kadath::Matrice::get_array ( ) const
inline

Returns the array of matrix elements.

Definition at line 114 of file matrice.hpp.

References std.

◆ get_dim()

int Kadath::Matrice::get_dim ( int  i) const
inline

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 108 of file matrice.hpp.

References sizes.

◆ get_lu()

Array<double>* Kadath::Matrice::get_lu ( )
inline

Returns a pointer on the lu decomposition.

Definition at line 110 of file matrice.hpp.

References lu.

◆ get_permute()

Array<int>* Kadath::Matrice::get_permute ( )
inline

Returns a pointer on the permutation array.

Definition at line 112 of file matrice.hpp.

References permute.

◆ operator()()

double Kadath::Matrice::operator() ( int  i,
int  j 
) const

Read-only of a particuliar element.

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

Definition at line 144 of file matrice.cpp.

References Kadath::Index::set(), sizes, and std.

◆ operator*=()

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

Operator *=.

Definition at line 400 of file matrice.cpp.

References std.

◆ operator+=() [1/2]

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

Operator +=.

Definition at line 380 of file matrice.cpp.

References std.

◆ operator+=() [2/2]

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

Operator +=.

Definition at line 390 of file matrice.cpp.

References std.

◆ operator-=() [1/2]

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

Operator -=.

Definition at line 385 of file matrice.cpp.

References std.

◆ operator-=() [2/2]

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

Operator -=.

Definition at line 395 of file matrice.cpp.

References std.

◆ operator/=()

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

Operator /=.

Definition at line 405 of file matrice.cpp.

References std.

◆ operator=() [1/3]

void Kadath::Matrice::operator= ( const Array< double > &  source)

Assignement to an array.

Definition at line 111 of file matrice.cpp.

References del_deriv(), Kadath::Array< T >::get_dimensions(), kl, ku, sizes, and std.

◆ operator=() [2/3]

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

Assignement to another Matrice.

Definition at line 94 of file matrice.cpp.

References band, del_deriv(), kl, ku, lu, permute, sizes, and std.

◆ operator=() [3/3]

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

Sets all the element of *std to x.

The other representations are destroyed.

Definition at line 88 of file matrice.cpp.

References del_deriv(), and std.

◆ set()

double & Kadath::Matrice::set ( int  i,
int  j 
)

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 122 of file matrice.cpp.

References del_deriv(), Kadath::Array< T >::set(), Kadath::Index::set(), sizes, and std.

◆ set_band()

void Kadath::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 165 of file matrice.cpp.

References band, kl, ku, Kadath::Array< T >::set(), and sizes.

◆ set_lu()

void Kadath::Matrice::set_lu ( ) const

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

The calculus is done using LAPACK.

Definition at line 192 of file matrice.cpp.

References band, kl, ku, lu, permute, Kadath::Array< T >::set_data(), sizes, and std.

◆ solve()

Array< double > Kadath::Matrice::solve ( const Array< double > &  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 221 of file matrice.cpp.

References band, Kadath::Array< T >::get_size(), kl, ku, lu, permute, Kadath::Array< T >::set_data(), and sizes.

◆ transpose()

Matrice Kadath::Matrice::transpose ( ) const

Computes the transpose matrix.

Definition at line 362 of file matrice.cpp.

References Kadath::Array< T >::get_dimensions(), Kadath::Index::set(), set(), sizes, and std.

◆ val_propre()

Array< double > Kadath::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 Array<double> (0, *) and the imaginary parts in Array<double> (1, *).

Definition at line 253 of file matrice.cpp.

References Kadath::Index::inc(), Kadath::Array< T >::set(), Kadath::Dim_array::set(), and sizes.

◆ vect_propre()

Matrice Kadath::Matrice::vect_propre ( ) const

Returns the eigenvectors of the matrix, calculated using LAPACK.

Definition at line 308 of file matrice.cpp.

References Kadath::Index::inc(), set(), sizes, and std.

Friends And Related Function Documentation

◆ operator* [1/3]

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

Operator*.

Definition at line 442 of file matrice.cpp.

◆ operator* [2/3]

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

Operator*.

Definition at line 430 of file matrice.cpp.

◆ operator* [3/3]

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

Operator*.

Definition at line 436 of file matrice.cpp.

◆ operator+

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

Operator + (binary version)

Definition at line 411 of file matrice.cpp.

◆ operator- [1/2]

Matrice operator- ( const Matrice a)
friend

Operator - (unitary version)

Definition at line 423 of file matrice.cpp.

◆ operator- [2/2]

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

Operator - (binary version)

Definition at line 417 of file matrice.cpp.

◆ operator/

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

Operator/.

Definition at line 463 of file matrice.cpp.

◆ operator<<

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

Impression.

Definition at line 152 of file matrice.cpp.

Member Data Documentation

◆ band

Array<double>* Kadath::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 58 of file matrice.hpp.

◆ kl

int Kadath::Matrice::kl
mutableprivate

Number of lower-diagonals in the band representation.

Definition at line 50 of file matrice.hpp.

◆ ku

int Kadath::Matrice::ku
mutableprivate

Number of upper-diagonals in the band representation.

Definition at line 49 of file matrice.hpp.

◆ lu

Array<double>* Kadath::Matrice::lu
mutableprivate

Pointer on the first array of the LU-representation.

Definition at line 61 of file matrice.hpp.

◆ permute

Array<int>* Kadath::Matrice::permute
mutableprivate

Pointer on the second array of the LU-representation.

Definition at line 62 of file matrice.hpp.

◆ sizes

Dim_array Kadath::Matrice::sizes
private

Dim_array of dimension 2 containing the size of the matrix.

Definition at line 45 of file matrice.hpp.

◆ std

Array<double>* Kadath::Matrice::std
private

Pointer on the array of the standard representation.

Definition at line 46 of file matrice.hpp.


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