16#include <Matrice_Morse_Sym.h>
17#include <Matrice_Bloc_Sym.h>
18#include <Matrice_Base.h>
19#include <Matrix_tools.h>
20#include <TRUSTArrays.h>
53 (*this).get_bloc(i,j)->imprimer(os);
59 for(
int i=0; i<
N_; i++)
61 for(
int j=i; j<
M_; j++)
63 os<<
"----------"<<finl;
64 os<<
"Bloc ("<<i<<
","<<j<<
"):"<<finl;
65 os<<
"----------"<<finl;
66 (*this).get_bloc(i,j)->imprimer_formatte(os);
75 const double * const_x_addr = x.
addr();
76 double* x_addr = (
double *) const_x_addr;
77 double* y_addr = y.
addr();
88 for(
int i=0; i<
N_; i++)
92 for(
int j=0; j<i; j++)
98 for(
int j=i; j<
N_; j++)
101 if(!nbr_lignes) nbr_lignes=mij.
nb_lignes();
103 if (nbr_colonnes>0 && nbr_lignes>0)
105 xtmp.
ref_data(x_addr+decalx,nbr_colonnes);
106 assert((decalx+nbr_colonnes)<=x.
size_array());
107 ytmp.
ref_data(y_addr+decaly,nbr_lignes);
112 xtmp.
ref_data(x_addr+decaly,nbr_lignes);
114 ytmp.
ref_data(y_addr+decalx,nbr_colonnes);
115 assert((decalx+nbr_colonnes)<=y.
size_array());
118 decalx+=nbr_colonnes;
129 Cerr <<
"Matrice_Bloc_Sym::ajouter_multvectT_ is not coded"<<finl<<flush;
137 Cerr <<
"Matrice_Bloc_Sym::ajouter_multTab_ is not coded"<<finl<<flush;
146 Cerr <<
"Conversion BlocSymToMatMorseSym..." << finl;
217 for (
int i=0; i<x.
size(); i++)
225 Journal() <<
"Test Conversion Natif/Morse " << i <<
"/" << x.
size() <<
":" << mp_norme_vect(resu1) <<
" " << mp_norme_vect(resu2) << finl;
226 for (
int j=0; j<x.
size(); j++)
228 if (!est_egal(resu1(j),resu2(j)))
230 Journal() <<
"Test Conversion Natif/Morse A(" << i <<
"," << j <<
") : " << resu1(j) <<
" " << resu2(j) << finl;
231 Journal()<<
"Format Matrice_Bloc_Sym:" <<finl;
233 Journal()<<
"Format Morse:" <<finl;
235 Cerr<<
"Error in Matrice_Bloc_Sym::BlocSymToMatMorseSym" << finl;
236 Cerr<<
"See the .log files of the calculation." << finl;
264 Cerr <<
"Trying to size a Matrice_Bloc_Sym type matrix not squared !!"
276 if (j<i || i<0 || i>=
N_ || j<0 || j>=
M_)
278 Cerr <<
"Matrice_Bloc_Sym::bloc("<<i<<
","<<j<<
") does not exist." << finl;
281 return blocs_[i*(
N_-1)-i*(i-1)/2+j];
286 if (j<i || i<0 || i>=
N_ || j<0 || j>=
M_)
288 Cerr <<
"Matrice_Bloc_Sym::bloc(" << i <<
"," << j <<
") out of range : N=" <<
N_ <<
" M_=" <<
M_ << finl;
291 return blocs_[i*(
N_-1)-i*(i-1)/2+j];
298 Stencil symmetric_stencil;
314 VECT( Stencil ) local_stencils;
315 local_stencils.dimensionner( nb_stencils );
323 for (
int i=0; i<nb_line_blocks; ++i )
325 for (
int j=i; j<nb_column_blocks; ++j )
331 jprev = ( i==j ) ? jmax : jprev;
333 int stencil_index = i *( nb_line_blocks - 1 ) - i * ( i - 1) / 2 + j;
335 Stencil& local_stencil_ = local_stencils[ stencil_index ];
346 const int size = local_stencil_.
dimension( 0 );
347 for (
int k=0; k<size; ++k )
349 local_stencil_( k, 0 ) += imin;
350 local_stencil_( k, 1 ) += jmin;
359 ArrOfInt offsets( nb_lines + 1 );
362 for (
int i=0; i<nb_stencils; ++i )
364 const Stencil& local_stencil_ = local_stencils[ i ];
365 const int size = local_stencil_.
dimension( 0 );
367 for (
int k=0; k<size; ++k )
369 const int line = local_stencil_( k, 0 );
370 offsets[ line + 1 ] += 1;
374 for (
int i=0; i<nb_lines; ++i )
376 offsets[ i + 1 ] += offsets[ i ];
379 const int stencil_size = offsets[ nb_lines ];
380 stencil.
resize( stencil_size, 2 );
384 for (
int i=0; i<nb_stencils; ++i )
386 const Stencil& local_stencil_ = local_stencils[ i ];
387 const int size = local_stencil_.
dimension( 0 );
389 for (
int k=0; k<size; ++k )
391 const int line = local_stencil_( k, 0 );
392 const int column = local_stencil_( k, 1 );
393 const int index = offsets[ line ];
395 assert( stencil( index, 0 ) < 0 );
396 assert( stencil( index, 1 ) < 0 );
397 assert( index < offsets[ line + 1 ] );
399 stencil( index, 0 ) = line;
400 stencil( index, 1 ) = column;
402 offsets[ line ] += 1;
408 StencilCoeffs& coefficients )
const
412 Stencil symmetric_stencil;
413 StencilCoeffs symmetric_coefficients;
418 symmetric_coefficients,
424 StencilCoeffs& coefficients )
const
432 VECT( Stencil ) local_stencils;
433 local_stencils.dimensionner( nb_stencils );
435 VECT( StencilCoeffs ) local_coefficients;
436 local_coefficients.dimensionner( nb_stencils );
444 for (
int i=0; i<nb_line_blocks; ++i )
446 for (
int j=i; j<nb_column_blocks; ++j )
452 jprev = ( i==j ) ? jmax : jprev;
454 int stencil_index = i *( nb_line_blocks - 1 ) - i * ( i - 1) / 2 + j;
456 Stencil& local_stencil_ = local_stencils[ stencil_index ];
457 StencilCoeffs& coefficients_ = local_coefficients[ stencil_index ];
468 const int size = local_stencil_.
dimension( 0 );
469 for (
int k=0; k<size; ++k )
471 local_stencil_( k, 0 ) += imin;
472 local_stencil_( k, 1 ) += jmin;
481 ArrOfInt offsets( nb_lines + 1 );
484 for (
int i=0; i<nb_stencils; ++i )
486 const Stencil& local_stencil_ = local_stencils[ i ];
487 const int size = local_stencil_.
dimension( 0 );
489 for (
int k=0; k<size; ++k )
491 const int line = local_stencil_( k, 0 );
492 offsets[ line + 1 ] += 1;
496 for (
int i=0; i<nb_lines; ++i )
498 offsets[ i + 1 ] += offsets[ i ];
501 const int stencil_size = offsets[ nb_lines ];
502 stencil.
resize( stencil_size, 2 );
507 for (
int i=0; i<nb_stencils; ++i )
509 const Stencil& local_stencil_ = local_stencils[ i ];
510 const StencilCoeffs& coefficients_ = local_coefficients[ i ];
512 const int size = local_stencil_.
dimension( 0 );
513 assert( coefficients_.
size_array( ) == size );
515 for (
int k=0; k<size; ++k )
517 const int line = local_stencil_( k, 0 );
518 const int column = local_stencil_( k, 1 );
519 const double coefficient = coefficients_[ k ];
520 const int index = offsets[ line ];
522 assert( stencil( index, 0 ) < 0 );
523 assert( stencil( index, 1 ) < 0 );
524 assert( index < offsets[ line + 1 ] );
526 stencil( index, 0 ) = line;
527 stencil( index, 1 ) = column;
528 coefficients[ index ] = coefficient;
530 offsets[ line ] += 1;
540 for (
int i=0; i<nb_line_blocks; ++i )
542 int nb_lines =
get_bloc( i, i ).valeur( ).nb_lignes( );
543 int nb_columns =
get_bloc( i, i ).valeur( ).nb_colonnes( );
545 if ( nb_lines != nb_columns )
547 Cerr <<
"bloc( " << i <<
", " << i <<
" ) is not square" << finl;
551 for (
int j=0; j<i; ++j )
555 Cerr <<
"Invalid number of columns in bloc ( " << j <<
", " << i <<
" )" << finl;
560 for (
int j=i; j<nb_column_blocks; ++j )
564 Cerr <<
"Invalid number of lines in bloc ( " << i <<
", " << j <<
" )" << finl;
578 Cerr <<
"Error in 'Matrice_Bloc_Sym::assert_check_symmetric_block_matrix_structure( )':" << finl;
579 Cerr <<
" Exiting..." << finl;
Class defining operators and methods for all reading operation in an input flow (file,...
Classe Matrice_Base Classe de base de la hierarchie des matrices.
virtual void get_symmetric_stencil(Stencil &stencil) const
virtual void get_stencil(Stencil &stencil) const
virtual DoubleVect & ajouter_multvect_(const DoubleVect &x, DoubleVect &r) const =0
virtual int nb_lignes() const =0
Return local number of lines (=size on the current proc).
virtual int nb_colonnes() const =0
Return local number of columns (=size on the current proc).
virtual DoubleVect & multvect(const DoubleVect &, DoubleVect &) const
Multiplication d'un vecteur par la matrice.
virtual void get_symmetric_stencil_and_coefficients(Stencil &stencil, StencilCoeffs &coefficients) const
virtual void get_stencil_and_coefficients(Stencil &stencil, StencilCoeffs &coefficients) const
virtual DoubleVect & ajouter_multvectT_(const DoubleVect &x, DoubleVect &r) const =0
const Matrice & get_bloc(int i, int j) const override
void BlocSymToMatMorseSym(Matrice_Morse_Sym &mat) const
void dimensionner(int N, int M) override
void get_stencil(Stencil &stencil) const override
void get_stencil_and_coefficients(Stencil &stencil, StencilCoeffs &coefficients) const override
DoubleVect & ajouter_multvect_(const DoubleVect &x, DoubleVect &y) const override
DoubleTab & ajouter_multTab_(const DoubleTab &x, DoubleTab &y) const override
void get_symmetric_stencil_and_coefficients(Stencil &stencil, StencilCoeffs &coefficients) const override
Sortie & imprimer(Sortie &s) const override
DoubleVect & ajouter_multvectT_(const DoubleVect &x, DoubleVect &y) const override
Sortie & imprimer_formatte(Sortie &s) const override
bool check_symmetric_block_matrix_structure() const
void assert_check_symmetric_block_matrix_structure() const
void get_symmetric_stencil(Stencil &stencil) const override
Matrice_Bloc_Sym(int N=0, int M=0)
Matrice_Bloc(int N=0, int M=0)
int nb_bloc_lignes() const
int nb_bloc_colonnes(void) const
int nb_lignes() const override
Return local number of lines (=size on the current proc).
int nb_colonnes() const override
Return local number of columns (=size on the current proc).
Classe Matrice_Morse_Sym Represente une matrice M (creuse) symetrique stockee au format Morse.
Sortie & imprimer_formatte(Sortie &s) const override
void set_est_definie(int)
int get_est_definie() const
void unsymmetrize_stencil_and_coefficients(const int nb_lines, const Stencil &symmetric_stencil, const StencilCoeffs &symmetric_coefficients, Stencil &stencil, StencilCoeffs &coefficients) const
void unsymmetrize_stencil(const int nb_lines, const Stencil &symmetric_stencil, Stencil &stencil) const
Classe Matrice Classe generique de la hierarchie des matrices.
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
static Sortie & Journal(int message_level=0)
Renvoie un objet statique de type Sortie qui sert de journal d'evenements.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Classe de base des flux de sortie.
_SIZE_ size_array() const
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension(int d) const
void ref_data(_TYPE_ *ptr, _SIZE_ new_size) override