12 static LoggerPtr logger(Logger::getLogger(
"pz.StrMatrix"));
24 int64_t numbl = blockgraphindex.
NElements()-1;
27 for(ibl=0; ibl<numbl; ibl++)
29 this->
fBlockSize[ibl] = blockgraphindex[ibl+1]-blockgraphindex[ibl];
39 LOGPZ_DEBUG(logger,
"Constructor of TPZSparseBlockDiagonal");
40 int64_t numbl = blockgraphindex.
NElements()-1;
42 int64_t ibl,iblcount,graphsize = 0;
43 for(ibl=0, iblcount=0; ibl<numbl; ibl++)
45 if(colors[ibl]==color)
47 this->
fBlockSize[iblcount++] = blockgraphindex[ibl+1]-blockgraphindex[ibl];
54 for(ibl=0, iblcount=0; ibl<numbl; ibl++)
56 if(colors[ibl]==color)
58 int64_t
first = blockgraphindex[ibl];
59 int64_t last = blockgraphindex[ibl+1];
64 for(ieq=first,ieqcp=firstcp; ieq<last; ieq++,ieqcp++)
66 fBlock[ieqcp] = blockgraph[ieq];
86 int64_t rblock,rblockindex,cblock,cblockindex;
88 if(rblock == -1)
return this->
gZero;
90 if(cblock != rblock)
return this->
gZero;
91 int64_t pos = rblockindex + cblockindex*this->
fBlockSize[rblock];
98 int64_t rblock,rblockindex,cblock,cblockindex;
100 if(rblock == -1)
return this->
gZero;
102 if(cblock != rblock)
return this->
gZero;
103 int64_t pos = rblockindex + cblockindex*this->
fBlockSize[rblock];
107 template <
class TVar>
110 int64_t rblock,rblockindex,cblock,cblockindex;
112 if(rblock == -1)
return -1;
114 if(cblock != rblock)
return -1;
115 int64_t pos = rblockindex + cblockindex*this->
fBlockSize[rblock];
123 int64_t rblock,rblockindex,cblock,cblockindex;
125 if(rblock == -1)
return -1;
127 if(cblock != rblock)
return -1;
128 int64_t pos = rblockindex + cblockindex*this->
fBlockSize[rblock];
135 int64_t rblock,rblockindex,cblock,cblockindex;
137 if(rblock == -1)
return this->
gZero;
139 if(cblock != rblock)
return this->
gZero;
140 int64_t pos = rblockindex + cblockindex*this->
fBlockSize[rblock];
159 int64_t rblock,rblockindex,cblock,cblockindex;
161 if(rblock == -1)
return this->
gZero;
163 if(cblock != rblock)
return this->
gZero;
164 int64_t pos = rblockindex + cblockindex*this->
fBlockSize[rblock];
174 out <<
"Equations for each block " << endl;
177 for(ibl = 0; ibl<nbl ; ibl++)
181 out <<
"Block " << ibl <<
" : ";
183 for(i=first; i<last; i++) out <<
fBlock[i] <<
" ";
198 LOGPZ_DEBUG(logger,
"TPZSparseBlockDiagonal::BuildFromMatrix");
202 for(ibl=0; ibl<nbl; ibl++)
208 for(iel=0; iel<nel; iel++) indices[iel] =
fBlock[first+iel];
209 matrix.
GetSub(indices,submat);
223 LOGPZ_DEBUG(logger,
"TPZSparseBlockDiagonal::MultAdd");
243 for(ibl = 0; ibl<numbl; ibl++)
250 blockind = ieq-fBlockIndex[ibl];
266 int64_t nc = in.
Cols();
268 for(ic=0; ic<nc; ic++)
270 for(ieq=0; ieq<neq; ieq++) out(
fBlock[ieq],ic) += in.
GetVal(ieq,ic);
281 int64_t nc = in.
Cols();
283 for(ic=0; ic<nc; ic++)
285 for(ieq=0; ieq<neq; ieq++) out(ieq,ic) = in.
GetVal(
fBlock[ieq],ic);
295 LOGPZ_DEBUG(logger,
"TPZSparseBlockDiagonal::UpdateFrom");
298 cout << __PRETTY_FUNCTION__ <<
" called with zero argument\n";
305 for(b=0; b<nblock; b++) {
312 mat->GetSub(indices,block);
317 template <
class TVar>
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.
~TPZSparseBlockDiagonal()
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
Contains TPZSparseBlockDiagonal class which implements a block diagonal matrix where the blocks are n...
virtual int Substitution(TPZFMatrix< TVar > *B) const override
Makes the backward and forward substitutions whether the matrix was LU decomposed.
const TVar & Get(const int64_t row, const int64_t col) const override
Get value with bound checking.
virtual void UpdateFrom(TPZAutoPointer< TPZMatrix< TVar > > mat) override
Updates the values of the matrix based on the values of the matrix.
MatrixOutputFormat
Defines output format.
int64_t fRow
Number of rows in matrix.
Implements a block diagonal matrix where the blocks are not contiguous. Matrix.
char fDecomposed
Decomposition type used to decompose the current matrix.
TinyFad< 8, T > abs(const TinyFad< 8, T > &in)
int Put(const int64_t row, const int64_t col, const TVar &value) override
Put values with bounds checking if DEBUG variable is defined.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
static TVar gZero
Initializing value to static variable.
virtual int GetSub(const int64_t sRow, const int64_t sCol, const int64_t rowSize, const int64_t colSize, TPZFMatrix< TVar > &Target) const
Gets submatrix storing it on Target.
int PutVal(const int64_t row, const int64_t col, const TVar &value) override
This method don't make verification if the element exist. It is fast than Put.
TPZSkylMatrix< REAL > matrix
virtual void Print(const char *message, std::ostream &out=std::cout, const MatrixOutputFormat format=EFormatted) const override
Prints current matrix data.
void GetBlock(int64_t i, TPZFMatrix< TVar > &block)
void Gather(const TPZFMatrix< TVar > &in, TPZFMatrix< TVar > &out) const
int Zero() override
Makes Zero all the elements.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
void Scatter(const TPZFMatrix< TVar > &in, TPZFMatrix< TVar > &out) const
int ClassId() const override
Define the class id associated with the class.
TPZVec< int > fBlockSize
Stores block sizes data.
void SetBlock(int64_t i, TPZFMatrix< TVar > &block)
Sets a block in the current matrix.
TPZVec< int64_t > fBlockIndex
Index to first element of each block.
void AddBlock(int64_t i, TPZFMatrix< TVar > &block)
Adds a block to current matrix.
Full matrix class. Matrix.
int32_t Hash(std::string str)
const TVar & GetVal(const int64_t row, const int64_t col) const override
This method don't make verification if the element exist. It is fast than Get.
int64_t fCol
Number of cols in matrix.
void Initialize(const TPZVec< int > &blocksize)
Initializes current matrix based on blocksize.
virtual int Substitution(TPZFMatrix< TVar > *B) const override
Makes the backward and forward substitutions whether the matrix was LU decomposed.
TPZVec< TVar > fStorage
Stores matrix data.
void GetBlock(int64_t i, TPZFMatrix< TVar > &block)
Gets a block from current matrix.
TPZVec< int64_t > fBlockPos
Stores blocks data.
void BuildFromMatrix(TPZMatrix< TVar > &matrix)
int64_t Cols() const
Returns number of cols.
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
void FindBlockIndex(int64_t glob, int64_t &block, int64_t &blockind) const
TPZVec< int64_t > fBlock
Equation numbers for each block.
int64_t NElements() const
Returns the number of elements of the vector.
virtual void Print(const char *message, std::ostream &out, const MatrixOutputFormat=EFormatted) const override
Prints current matrix data.
void MultAdd(const TPZFMatrix< TVar > &x, const TPZFMatrix< TVar > &y, TPZFMatrix< TVar > &z, const TVar alpha, const TVar beta, const int opt) const override
Computes z = alpha * opt(this)*x + beta * y.
virtual TVar & s(const int64_t row, const int64_t col) override
The operators check on the bounds if the DEBUG variable is defined.
const TVar & GetVal(const int64_t row, const int64_t col) const override
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
void AddBlock(int64_t i, TPZFMatrix< TVar > &block)
Root matrix class (abstract). Matrix.
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.