TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Matrice_Dense.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16
17#ifndef Matrice_Dense_included
18#define Matrice_Dense_included
19
20#include <Matrice_Base.h>
21#include <TRUSTTab.h>
22class Matrice_Morse;
23
25{
26
27 Declare_instanciable_sans_constructeur( Matrice_Dense );
28
29public :
31 Matrice_Dense( const int nb_lines , const int nb_cols );
32 void dimensionner( const int nb_lines , const int nb_cols );
33 void read_from_file( const Nom& filename );
34 void convert_to_morse_matrix( Matrice_Morse& morse_matrix ) const;
35 inline const double& operator( )( const int line , const int col ) const;
36 inline double& operator( )( const int line , const int col );
37 friend Matrice_Dense operator+(const Matrice_Dense& A, const Matrice_Dense& B);
38 friend Matrice_Dense operator*(const double& a, const Matrice_Dense& B);
39 void build_matrix_from_coefficients_line_by_line( const DoubleVect& coefficients );
40 void build_matrix_from_coefficients_column_by_column( const DoubleVect& coefficients );
41 bool is_the_same( const Matrice_Dense& other_matrix , const double tol=1e-14 ) const;
42 void build_the_transposed( Matrice_Dense& transposed ) const;
43 void set_coefficient( const int i , const int j , const double value );
44 Sortie& imprimer_formatte( Sortie& s ) const override;
45
46 int ordre() const override;
47 int nb_lignes() const override;
48 int nb_colonnes() const override;
49
50 DoubleVect& ajouter_multvect_(const DoubleVect& x, DoubleVect& r) const override;
51 DoubleVect& ajouter_multvectT_(const DoubleVect& x, DoubleVect& r) const override;
52 DoubleTab& ajouter_multTab_(const DoubleTab& x, DoubleTab& r) const override;
53
54 void scale( const double x ) override ;
55 void clean() override;
56 void get_stencil( Stencil& stencil ) const override;
57
58 // Perform the matrix inversion
59 void inverse();
60 void solve(const ArrOfDouble& b, ArrOfDouble& x);
61
62 // Perform a matrix multipication : (*this) * B = RES
63 void multiplyToRight(const Matrice_Dense& B, Matrice_Dense& RES) const;
64 inline DoubleTab& coeffs()
65 {
66 return Matrix_;
67 }
68private :
69
70 DoubleTab Matrix_ ;
71 ArrOfInt ipiv;
72 ArrOfDouble work;
73};
74
75// Access operators
76inline const double& Matrice_Dense::operator( )(const int line, const int col) const
77{
78 assert( line < nb_lignes( ) );
79 assert( col < nb_colonnes( ) );
80 return Matrix_( line , col );
81}
82
83inline double& Matrice_Dense::operator( )(const int line, const int col)
84{
85 assert( line < nb_lignes( ) );
86 assert( col < nb_colonnes( ) );
87 return Matrix_( line , col );
88}
89
90#endif
Classe Matrice_Base Classe de base de la hierarchie des matrices.
void scale(const double x) override
int nb_colonnes() const override
Return local number of columns (=size on the current proc).
void read_from_file(const Nom &filename)
int ordre() const override
If square matrix, returns number of lines, otherwise 0.
void build_matrix_from_coefficients_line_by_line(const DoubleVect &coefficients)
DoubleVect & ajouter_multvectT_(const DoubleVect &x, DoubleVect &r) const override
Operation de multiplication-accumulation (saxpy) matrice vecteur, par la matrice transposee.
void dimensionner(const int nb_lines, const int nb_cols)
void solve(const ArrOfDouble &b, ArrOfDouble &x)
Solves the linear system A*x = b using LU factorization.
void build_the_transposed(Matrice_Dense &transposed) const
void build_matrix_from_coefficients_column_by_column(const DoubleVect &coefficients)
int nb_lignes() const override
Return local number of lines (=size on the current proc).
friend Matrice_Dense operator+(const Matrice_Dense &A, const Matrice_Dense &B)
Sortie & imprimer_formatte(Sortie &s) const override
DoubleTab & coeffs()
void convert_to_morse_matrix(Matrice_Morse &morse_matrix) const
friend Matrice_Dense operator*(const double &a, const Matrice_Dense &B)
bool is_the_same(const Matrice_Dense &other_matrix, const double tol=1e-14) const
void clean() override
void set_coefficient(const int i, const int j, const double value)
void multiplyToRight(const Matrice_Dense &B, Matrice_Dense &RES) const
DoubleTab & ajouter_multTab_(const DoubleTab &x, DoubleTab &r) const override
DoubleVect & ajouter_multvect_(const DoubleVect &x, DoubleVect &r) const override
Operation de multiplication-accumulation (saxpy) matrice vecteur.
void get_stencil(Stencil &stencil) const override
Classe Matrice_Morse Represente une matrice M (creuse), non necessairement carree.
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
friend class Sortie
Definition Objet_U.h:75