NeoPZ
pzblockdiag.h
Go to the documentation of this file.
1 
6 #ifndef _TBLOCKDIAG_
7 #define _TBLOCKDIAG_
8 
9 
10 #include <iostream>
11 #include "pzmatrix.h"
12 #include "pzvec.h"
13 
20 template <class TVar>
21 class TPZBlockDiagonal : public TPZMatrix<TVar>
22 {
23 
24 public:
32  TPZBlockDiagonal (const TPZVec<int> &blocksizes, const TPZFMatrix<TVar> &glob );
37  TPZBlockDiagonal (const TPZVec<int> &blocksizes);
40 
44 
45  int Put(const int64_t row,const int64_t col,const TVar& value ) override;
46  const TVar &Get(const int64_t row,const int64_t col ) const override;
47 
48  TVar &operator()(const int64_t row, const int64_t col);
49  virtual TVar &s(const int64_t row, const int64_t col) override;
50 
52  int PutVal(const int64_t row,const int64_t col,const TVar& value ) override;
54  const TVar &GetVal(const int64_t row,const int64_t col ) const override;
55 
58  void MultAdd(const TPZFMatrix<TVar> &x,const TPZFMatrix<TVar> &y, TPZFMatrix<TVar> &z,
59  const TVar alpha=1.,const TVar beta = 0.,const int opt = 0) const override;
60 
61  int64_t Dim() const override { return this->Rows(); }
62 
64  int Zero() override;
65 
70  int GetSizeofBlock(int64_t blockid) {return fBlockSize[blockid];}
71 
72  void Transpose(TPZMatrix<TVar> *const T) const override;
73  virtual int Decompose_LU() override;
74  virtual int Decompose_LU(std::list<int64_t> &singular) override;
75 
77  virtual int Substitution( TPZFMatrix<TVar> * B ) const override;
78 
80  virtual void UpdateFrom(TPZAutoPointer<TPZMatrix<TVar> > mat) override;
81 
83  static int main();
84 
86  void AutoFill(int64_t dim, int64_t dimj, int symmetric);
87 
88 private:
89 
91  int Clear() override;
92 
93 public:
98  void Initialize(const TPZVec<int> &blocksize);
104  void AddBlock(int64_t i, TPZFMatrix<TVar> &block);
110  void SetBlock(int64_t i, TPZFMatrix<TVar> &block);
111 
117  void GetBlock(int64_t i, TPZFMatrix<TVar> &block);
118 
130  virtual void Print(const char *message, std::ostream &out = std::cout, const MatrixOutputFormat format =EFormatted) const override;
131 
132  int64_t NumberofBlocks() {return fBlockSize.NElements();}
133  public:
134 int ClassId() const override;
135 
136 protected:
143 };
144 
145 template<class TVar>
146 inline TVar &TPZBlockDiagonal<TVar>::s(const int64_t row, const int64_t col) {
147  // verificando se o elemento a inserir esta dentro da matriz
148  return this->operator()(row,col);
149 }
150 
151 #endif
152 
virtual void UpdateFrom(TPZAutoPointer< TPZMatrix< TVar > > mat) override
Updates the values of the matrix based on the values of the matrix.
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 = alpha * opt(this)*x + beta * y.
virtual int Substitution(TPZFMatrix< TVar > *B) const override
Makes the backward and forward substitutions whether the matrix was LU decomposed.
void Transpose(TPZMatrix< TVar > *const T) const override
It makes *T the transpose of current matrix.
Templated vector implementation.
MatrixOutputFormat
Defines output format.
Definition: pzmatrix.h:55
void BuildFromMatrix(TPZMatrix< TVar > &matrix)
Builds a block from matrix.
int Clear() override
Clean data matrix. Zeroes number of columns and rows.
~TPZBlockDiagonal()
Simple destructor.
TPZSkylMatrix< REAL > matrix
Definition: numatst.cpp:255
virtual void Print(const char *message, std::ostream &out=std::cout, const MatrixOutputFormat format=EFormatted) const override
Prints current matrix data.
int Put(const int64_t row, const int64_t col, const TVar &value) override
Put values with bounds checking if DEBUG variable is defined.
int64_t Rows() const
Returns number of rows.
Definition: pzmatrix.h:803
TPZVec< int > fBlockSize
Stores block sizes data.
Definition: pzblockdiag.h:142
void SetBlock(int64_t i, TPZFMatrix< TVar > &block)
Sets a block in the current matrix.
Definition: pzblockdiag.cpp:39
void AutoFill(int64_t dim, int64_t dimj, int symmetric)
int64_t NumberofBlocks()
Definition: pzblockdiag.h:132
virtual int Decompose_LU() override
const TVar & GetVal(const int64_t row, const int64_t col) const override
This method don&#39;t make verification if the element exist. It is fast than Get.
void AddBlock(int64_t i, TPZFMatrix< TVar > &block)
Adds a block to current matrix.
Definition: pzblockdiag.cpp:25
Full matrix class. Matrix.
Definition: pzfmatrix.h:32
Contains TPZMatrix<TVar>class, root matrix class.
const TVar & Get(const int64_t row, const int64_t col) const override
Get value with bound checking.
void Initialize(const TPZVec< int > &blocksize)
Initializes current matrix based on blocksize.
Definition: pzblockdiag.cpp:64
Defines block diagonal matrices. Matrix.
Definition: pzblockdiag.h:21
int GetSizeofBlock(int64_t blockid)
Return the choosen block size.
Definition: pzblockdiag.h:70
int Zero() override
Zeroes all the elements of the matrix.
TPZVec< TVar > fStorage
Stores matrix data.
Definition: pzblockdiag.h:138
int PutVal(const int64_t row, const int64_t col, const TVar &value) override
This method don&#39;t make verification if the element exist. It is fast than Put.
TPZBlockDiagonal()
Simple constructor.
void GetBlock(int64_t i, TPZFMatrix< TVar > &block)
Gets a block from current matrix.
Definition: pzblockdiag.cpp:52
TVar & operator()(const int64_t row, const int64_t col)
static int main()
This method checks the working of the class.
TPZVec< int64_t > fBlockPos
Stores blocks data.
Definition: pzblockdiag.h:140
#define CLONEDEF(A)
To create clone matrix.
Definition: pzmatrix.h:28
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
int64_t Dim() const override
Returns the dimension of the matrix if the matrix is square.
Definition: pzblockdiag.h:61
virtual TVar & s(const int64_t row, const int64_t col) override
The operators check on the bounds if the DEBUG variable is defined.
Definition: pzblockdiag.h:146
Root matrix class (abstract). Matrix.
Definition: pzmatrix.h:60
This class implements a reference counter mechanism to administer a dynamically allocated object...
int ClassId() const override
Define the class id associated with the class.