NeoPZ
pzsysmp.h
Go to the documentation of this file.
1 
7 #ifndef SYSMPMATH
8 #define SYSMPMATH
9 
10 #include "pzmatrix.h"
11 #include "pzfmatrix.h"
12 
13 #ifdef USING_MKL
14 
15 #include "TPZPardisoControl.h"
16 #endif
17 
21 template<class TVar>
22 class TPZSYsmpMatrix : public TPZMatrix<TVar>{
23 
24 #ifdef USING_MKL
25  friend class TPZPardisoControl<TVar>;
26 #endif
27 
28 public :
32  TPZSYsmpMatrix(const int64_t rows, const int64_t cols );
36  TPZMatrix<TVar>(cp), fIA(cp.fIA), fJA(cp.fJA), fA(cp.fA), fDiag(cp.fDiag)
37 #ifdef USING_MKL
38  , fPardisoControl(cp.fPardisoControl)
39 #endif
40  {
41 #ifdef USING_MKL
42  fPardisoControl.SetMatrix(this);
43 #endif
44  }
45 
47 
50  virtual ~TPZSYsmpMatrix();
51 
53  virtual int IsSimetric() const override { return 1; }
55  inline int IsSquare() const { return 1;}
56 
58  virtual int Zero() override {
59  fA.Fill(0.);
60  fDiag.Fill(0.);
61 #ifndef USING_MKL
63 #endif
64  return 0;
65 
66  }
67 
68 
71  void AutoFill(int64_t nrow, int64_t ncol, int symmetric);
72 
74  virtual const TVar &GetVal(const int64_t row, const int64_t col ) const override;
75 
79  virtual int PutVal(const int64_t /*row*/,const int64_t /*col*/,const TVar & val ) override;
80 
81 
84  virtual void MultAdd(const TPZFMatrix<TVar> &x,const TPZFMatrix<TVar> &y, TPZFMatrix<TVar> &z,
85  const TVar alpha=1.,const TVar beta = 0.,const int opt = 0) const override;
86 
88  virtual void SetData(const TPZVec<int64_t> &IA,const TPZVec<int64_t> &JA, const TPZVec<TVar> &A );
89 
92  {
93  return fA;
94  }
95 
97  {
98  return fIA;
99  }
100 
102  {
103  return fJA;
104  }
105 
107  virtual void Print(const char *title, std::ostream &out = std::cout ,const MatrixOutputFormat = EFormatted ) const override;
108 
109 #ifdef USING_MKL
110 
122  virtual int Decompose_LDLt(std::list<int64_t> &singular) override;
124  virtual int Decompose_LDLt() override;
125 
127  virtual int Decompose_Cholesky() override;
132  virtual int Decompose_Cholesky(std::list<int64_t> &singular) override;
133 
134 
147  virtual int Subst_LForward( TPZFMatrix<TVar>* b ) const override;
148 
153  virtual int Subst_LBackward( TPZFMatrix<TVar>* b ) const override;
154 
159  virtual int Subst_Diag( TPZFMatrix<TVar>* b ) const override;
160 
165  virtual int Subst_Forward( TPZFMatrix<TVar>* b ) const override;
166 
171  virtual int Subst_Backward( TPZFMatrix<TVar>* b ) const override;
172 
173 
177 #endif
178  public:
179 int ClassId() const override;
180 
181  void ComputeDiagonal();
182 
183 private:
184 
185 
189 
190 #ifdef USING_MKL
191  TPZPardisoControl<TVar> fPardisoControl;
192 #endif
193 
195 };
196 
197 template<class TVar>
199 {
200  // Pass the data to the class.
201  fIA = IA;
202  fJA = JA;
203  fA = A;
204  ComputeDiagonal();
205 }
206 
207 #endif
int ClassId() const override
Define the class id associated with the class.
Definition: pzsysmp.cpp:373
virtual int PutVal(const int64_t, const int64_t, const TVar &val) override
Put values without bounds checking This method is faster than "Put" if DEBUG is defined.
Definition: pzsysmp.cpp:92
void AutoFill(int64_t nrow, int64_t ncol, int symmetric)
Fill matrix storage with randomic values.
Definition: pzsysmp.cpp:206
virtual void Print(const char *title, std::ostream &out=std::cout, const MatrixOutputFormat=EFormatted) const override
Print the matrix along with a identification title.
Definition: pzsysmp.cpp:162
MatrixOutputFormat
Defines output format.
Definition: pzmatrix.h:55
virtual int Subst_LBackward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is upper triangular with A(i,i)=1.
Definition: pzmatrix.cpp:1358
REAL val(STATE &number)
Returns value of the variable.
Definition: pzartdiff.h:23
virtual int Subst_Forward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is lower triangular.
Definition: pzmatrix.cpp:1284
virtual int Decompose_LDLt()
Decomposes the current matrix using LDLt.
Definition: pzmatrix.cpp:1184
TPZVec< TVar > & A()
Access function for the coefficients.
Definition: pzsysmp.h:91
virtual void SetData(const TPZVec< int64_t > &IA, const TPZVec< int64_t > &JA, const TPZVec< TVar > &A)
Sets data to the class.
Definition: pzsysmp.h:198
virtual void MultAdd(const TPZFMatrix< TVar > &x, const TPZFMatrix< TVar > &y, TPZFMatrix< TVar > &z, const TVar alpha=1., const TVar beta=0., const int opt=0) const override
Computes z = beta * y + alpha * opt(this)*x.
Definition: pzsysmp.cpp:123
TPZVec< int64_t > fJA
Definition: pzsysmp.h:187
TPZVec< int64_t > fIA
Definition: pzsysmp.h:186
TPZSYsmpMatrix(const TPZSYsmpMatrix< TVar > &cp)
Copy constructor.
Definition: pzsysmp.h:34
Contains TPZMatrixclass which implements full matrix (using column major representation).
TPZSYsmpMatrix()
Constructor based on number of rows and columns.
Definition: pzsysmp.cpp:19
TPZSYsmpMatrix & operator=(const TPZSYsmpMatrix< TVar > &copy)
Definition: pzsysmp.cpp:52
virtual int IsSimetric() const override
Checks if the current matrix is symmetric.
Definition: pzsysmp.h:53
virtual int Subst_Diag(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is diagonal matrix.
Definition: pzmatrix.cpp:1384
TPZVec< TVar > fA
Definition: pzsysmp.h:188
TPZVec< int64_t > & IA()
Definition: pzsysmp.h:96
Full matrix class. Matrix.
Definition: pzfmatrix.h:32
virtual int Subst_LForward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is lower triangular with A(i,i)=1.
Definition: pzmatrix.cpp:1333
TPZVec< TVar > fDiag
Definition: pzsysmp.h:194
Contains TPZMatrix<TVar>class, root matrix class.
int IsSquare() const
Checks if current matrix is square.
Definition: pzsysmp.h:55
virtual int Zero() override
Zeroes the matrix.
Definition: pzsysmp.h:58
virtual int Decompose_Cholesky()
Decomposes the current matrix using Cholesky method. The current matrix has to be symmetric...
Definition: pzmatrix.cpp:1252
void ComputeDiagonal()
Definition: pzsysmp.cpp:196
Implements a symmetric sparse matrix. Matrix.
Definition: pzsysmp.h:22
void Fill(const T &copy, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
Definition: pzvec.h:460
#define CLONEDEF(A)
To create clone matrix.
Definition: pzmatrix.h:28
virtual ~TPZSYsmpMatrix()
Destructor.
Definition: pzsysmp.cpp:44
virtual const TVar & GetVal(const int64_t row, const int64_t col) const override
Get the matrix entry at (row,col) without bound checking.
Definition: pzsysmp.cpp:74
TPZVec< int64_t > & JA()
Definition: pzsysmp.h:101
virtual int Subst_Backward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is upper triangular.
Definition: pzmatrix.cpp:1309
Root matrix class (abstract). Matrix.
Definition: pzmatrix.h:60