NeoPZ
pzsespmat.h
Go to the documentation of this file.
1 
6 #ifndef TSESPMATH
7 #define TSESPMATH
8 
9 #include "pzlink.h"
10 #include "pzmatrix.h"
11 #include "pzfmatrix.h"
12 #include "pzsfulmat.h"
13 #include "pzespmat.h"
14 
15 #ifdef OOPARLIB
16 
17 #include "pzsaveable.h"
18 #include "pzmatdefs.h"
19 
20 #endif
21 
26 template<class TVar>
27 class TPZSSpMatrix : public TPZMatrix<TVar>
28 {
29 public:
30  TPZSSpMatrix() : TPZMatrix<TVar>(0,0) {}
31  TPZSSpMatrix(const int64_t dim ) : TPZMatrix<TVar>(dim,dim), fMat(dim, dim) {}
33 
35 
36  inline int PutVal(const int64_t row,const int64_t col,const TVar& element );
37  inline const TVar & GetVal(const int64_t row,const int64_t col ) const;
38 
40  // @{
46  // @}
47 
49  // @{
52  // @}
53 
55  // @{
56  TPZSSpMatrix operator* (const TVar v ) const;
57  TPZSSpMatrix &operator*=(const TVar v );
58  // @}
59 
61  int Resize(const int64_t newDim ,const int64_t )
62  { this->fRow = this->fCol = newDim; return fMat.Resize( newDim, newDim ); }
63 
65  int Redim(const int64_t newDim) { return Redim(newDim,newDim);}
66  int Redim(const int64_t newDim ,const int64_t )
67  { this->fRow = this->fCol = newDim; return fMat.Redim( newDim, newDim ); }
68 
69  // Zeroes all the elements
70  int Zero()
71  {return fMat.Zero();}
72 
73 
74  /*** @brief To solve linear systems ***/
75  // @{
76  int Decompose_Cholesky(); // Faz A = GGt.
77  int Decompose_LDLt (); // Faz A = LDLt.
78  int Decompose_Cholesky(std::list<int64_t> &singular); // Faz A = GGt.
79  int Decompose_LDLt (std::list<int64_t> &singular); // Faz A = LDLt.
80 
81  int Subst_Forward ( TPZFMatrix<TVar> *b ) const;
82  //int Subst_Backward ( TPZMatrix<>*b );
83  int Subst_LForward ( TPZFMatrix<TVar> *b ) const;
84  //int Subst_LBackward( TPZMatrix<>*b );
85  int Subst_Diag ( TPZFMatrix<TVar> *b ) const;
86  // @}
87 
88 #ifdef OOPARLIB
89 
90  virtual int Unpack( TReceiveStorage *buf );
91  static TSaveable *CreateInstance(TReceiveStorage *buf);
92  virtual int Pack( TSendStorage *buf ) const;
93  virtual std::string ClassName() const { return( "TPZSSpMatrix"); }
94  virtual int DerivedFrom(const int64_t Classid) const;
95  virtual int DerivedFrom(const char *classname) const; // a class with name classname
96 
97 #endif
98 
99 private:
109  TPZLink<TPZSpMatrix<REAL>::TPZNode> *row_j, int64_t k );
110 
112 };
113 
114 
115 /**************/
116 /*** PutVal ***/
117 //
118 // Escreve um elemento na matriz, sem verificar fronteiras.
119 // O valor da linha (row) deve ser maior ou igual ao da coluna
120 // (col).
121 //
122 template<class TVar>
123 inline int
124 TPZSSpMatrix<TVar>::PutVal(const int64_t r,const int64_t c,const TVar& value )
125 {
126  // Inicializando row e col para trabalhar com a matriz
127  // triangular inferior.
128  int64_t row(r),col(c);
129  if ( row < col )
130  this->Swap( &row, &col );
131 
132  this->fDecomposed = 0;
133  return( fMat.PutVal( row, col, value ) );
134 }
135 
136 /**************/
137 /*** GetVal ***/
138 //
139 // Le um elemento da matriz, sem verificar fronteiras. O valor
140 // da linha (row) deve ser maior ou igual ao da coluna (col).
141 //
142 template<class TVar>
143 inline const TVar &
144 TPZSSpMatrix<TVar>::GetVal(const int64_t r,const int64_t c ) const
145 {
146  // inicializando row e col para trabalhar com a matriz
147  // triangular inferior.
148  int64_t row(r),col(c);
149  if ( row < col )
150  this->Swap( &row, &col );
151 
152  return( fMat.GetVal( row, col ) );
153 }
154 
155 #endif
TPZSSpMatrix operator+(const TPZSSpMatrix< TVar > &A) const
Definition: pzsespmat.cpp:61
int Redim(const int64_t newDim)
Resize the array and resets its entirety.
Definition: pzsespmat.h:65
TPZSSpMatrix & operator*=(const TVar v)
Definition: pzsespmat.cpp:159
int64_t fRow
Number of rows in matrix.
Definition: pzmatrix.h:779
TPZSpMatrix< TVar > fMat
Definition: pzsespmat.h:111
char fDecomposed
Decomposition type used to decompose the current matrix.
Definition: pzmatrix.h:783
TVar ProdEsc(TPZLink< TPZSpMatrix< REAL >::TPZNode > *row_i, TPZLink< TPZSpMatrix< REAL >::TPZNode > *row_j, int64_t k)
Calcula o produto escalar entre as linhas &#39;row_i&#39; e &#39;row_j&#39; usando apenas os elementos pertencentes &#39;...
Definition: pzsespmat.cpp:478
int Subst_Diag(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is diagonal matrix.
Definition: pzsespmat.cpp:431
Defines sparce matrix class. Matrix.
Definition: pzespmat.h:37
const TVar & GetVal(const int64_t row, const int64_t col) const
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
Definition: pzsespmat.h:144
TPZSSpMatrix & operator+=(const TPZSSpMatrix< TVar > &A)
Definition: pzsespmat.cpp:94
Implements sparce symmetric matrix using a linked list of elements. Matrix.
Definition: pzespmat.h:27
Defines a node.
Definition: pzespmat.h:49
int Subst_Forward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is lower triangular.
Definition: pzsespmat.cpp:357
TPZSSpMatrix & operator-=(const TPZSSpMatrix< TVar > &A)
Definition: pzsespmat.cpp:111
Contains TPZMatrixclass which implements full matrix (using column major representation).
int Subst_LForward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is lower triangular with A(i,i)=1.
Definition: pzsespmat.cpp:397
Contains TPZSpMatrix class which defines sparse matrix class.
static TPZSavable * CreateInstance(const int &classId)
Definition: TPZSavable.cpp:120
int PutVal(const int64_t row, const int64_t col, const TVar &element)
Put values without bounds checking This method is faster than "Put" if DEBUG is defined.
Definition: pzsespmat.h:124
Full matrix class. Matrix.
Definition: pzfmatrix.h:32
Contains TPZMatrix<TVar>class, root matrix class.
int Decompose_LDLt()
Decomposes the current matrix using LDLt.
Definition: pzsespmat.cpp:262
int64_t fCol
Number of cols in matrix.
Definition: pzmatrix.h:781
TPZSSpMatrix & operator=(const TPZSSpMatrix< TVar > &A)
Operators with SYMMETRIC sparse matrices.
Definition: pzsespmat.cpp:45
int Redim(const int64_t newDim, const int64_t)
Redimensions the matrix reinitializing it with zero.
Definition: pzsespmat.h:66
TPZSSpMatrix operator-(const TPZSSpMatrix< TVar > &A) const
Definition: pzsespmat.cpp:77
static void Swap(int64_t *a, int64_t *b)
Swaps contents of a in b and b in a.
Definition: pzmatrix.h:949
int Resize(const int64_t newDim, const int64_t)
Resize the array but keeps its entirety.
Definition: pzsespmat.h:61
#define CLONEDEF(A)
To create clone matrix.
Definition: pzmatrix.h:28
TPZSSpMatrix(const int64_t dim)
Definition: pzsespmat.h:31
int Zero()
Zeroes the matrix.
Definition: pzsespmat.h:70
int Decompose_Cholesky()
Decomposes the current matrix using Cholesky method. The current matrix has to be symmetric...
Definition: pzsespmat.cpp:181
Contains TPZSFMatrix class which implements a symmetric full matrix.
TPZSSpMatrix operator*(const TVar v) const
Operators with numeric values.
Definition: pzsespmat.cpp:144
Root matrix class (abstract). Matrix.
Definition: pzmatrix.h:60