19 static LoggerPtr logger(Logger::getLogger(
"pz.matrix.tpzfbmatrix"));
77 cout <<
"TPZFBMatrix::Put: " << row <<
"," << col <<
"," <<
Dim();
83 return(
PutVal( row, col, value ) );
95 if ( (row >=
Dim()) || (col >=
Dim()) )
98 return(
GetVal( row, col ) );
113 if(
this == &A)
return *
this;
136 for (int64_t i=0; i<sz; i++) {
157 for (int64_t i=0; i<sz; i++) {
175 template <
class TVar>
183 for (int64_t i=0; i<sz; i++) {
203 for (int64_t i=0; i<sz; i++) {
222 const TVar alpha,
const TVar beta ,
const int opt)
const {
226 TPZMatrix<TVar>::Error(__PRETTY_FUNCTION__,
"TPZFBMatrix::MultAdd <matrixs with incompatible dimensions>" );
231 int64_t rows = this->
Rows();
232 int64_t xcols = x.
Cols();
235 for (ic = 0; ic < xcols; ic++) {
237 for ( r = 0; r < rows; r++ ) {
242 for ( int64_t i = begin ; i < end; i++ ) val += alpha *
GetVal( r, i ) * x.
GetVal( i, ic );
247 for (ic = 0; ic < xcols; ic++) {
249 for ( r = 0; r < rows; r++ ) {
254 for ( int64_t i = begin ; i < end; i++ ) val += alpha *
GetVal( i, r ) * x.
GetVal( i, ic );
290 for (int64_t i=0; i<sz; i++) {
307 if ( value.real() != 1.0 || value.imag() != 0. )
310 for (int64_t i=0; i<sz; i++) {
322 if ( value.real() != 1.0 || value.imag() != 0. )
325 for (int64_t i=0; i<sz; i++) {
339 if ( value != (TVar)1.0 )
342 for (int64_t i=0; i<sz; i++) {
350 template <
class TVar>
363 for (int64_t i=0; i<nrow; i++) {
364 int64_t jmin = i-Band;
368 int64_t jmax = i+Band+1;
380 for (; j<jmax; j++) {
381 TVar
val = ((TVar) rand())/((TVar)RAND_MAX);
385 PutVal(i, i, sum+(TVar)1.);
398 if ( newRows != newCols )
402 Redim(newRows,newRows);
414 if ( newRows != newCols )
443 for (int64_t i=0; i<size; i++) {
460 if ( newBand >=
Dim() )
461 TPZMatrix<TVar>::Error(__PRETTY_FUNCTION__,
"SetBand <the band must be lower than the matrix dimension " );
463 uint64_t newSize =
Dim()*(3 * newBand + 1);
483 for ( int64_t r = 0; r <
Dim(); r++ )
487 for ( int64_t c = begin; c < end; c++ )
512 TPZMatrix<float>::Error(__PRETTY_FUNCTION__,
"TPZFBMatrix::Decompose_LU is already decomposed with other scheme");
519 fPivot.Resize(rows, 0);
529 sgbsv_(&rows, &bandlower, &bandupper, &nrhs, &
fElem[0], &ldab,&fPivot[0], &B,&rows, &info);
546 TPZMatrix<float>::Error(__PRETTY_FUNCTION__,
"TPZFBMatrix::Decompose_LU is already decomposed with other scheme");
553 fPivot.Resize(rows, 0);
558 dgbsv_(&rows, &bandlower, &bandupper, &nrhs, &
fElem[0], &ldab,&fPivot[0], &B,&rows, &info);
575 TPZMatrix<TVar>::Error(__PRETTY_FUNCTION__,
"TPZFBMatrix::Decompose_LU is already decomposed with other scheme");
589 int nrhs = B->
Cols();
592 char notrans[]=
"No Transpose";
596 sgbtrs_(notrans, &rows, &bandlower, &bandupper, &nrhs, &
fElem[0], &ldab, &fPivot[0], &B->
s(0,0), &rows, &info);
609 int nrhs = B->
Cols();
612 char notrans[]=
"No Transpose";
616 dgbtrs_(notrans, &rows, &bandlower, &bandupper, &nrhs, &
fElem[0], &ldab, &fPivot[0], &B->
s(0,0), &rows, &info);
virtual TVar & s(const int64_t row, const int64_t col) override
The operators check on the bounds if the DEBUG variable is defined.
void Transpose(TPZMatrix< TVar > *const T) const override
It makes *T the transpose of current matrix.
const TVar & Get(const int64_t row, const int64_t col) const override
Get value with bound checking.
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
It computes z = beta * y + alpha * opt(this)*x but z and x can not overlap in memory.
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.
int SetBand(const int64_t newBand)
Sets band size.
void AutoFill(int64_t nrow, int64_t ncol, int symmetric)
static int Error(const char *msg, const char *msg2=0)
Returns error messages.
virtual void resize(const int64_t newsize)
int Resize(const int64_t newRows, const int64_t newCols) override
Redimension the matrix preserving its elements.
TPZFBMatrix & operator+=(const TPZFBMatrix< TVar > &A)
virtual int Resize(const int64_t newRows, const int64_t newCols)
Redimensions a matriz keeping the previous values.
int64_t fRow
Number of rows in matrix.
TPZFBMatrix & operator*=(const TVar val)
void PrepareZ(const TPZFMatrix< TVar > &y, TPZFMatrix< TVar > &z, const TVar beta, const int opt) const
Is an auxiliar method used by MultiplyAdd.
TPZFBMatrix operator*(const TVar val) const
char fDecomposed
Decomposition type used to decompose the current matrix.
int64_t Dim() const override
Returns the dimension of the matrix if the matrix is square.
TPZFBMatrix()
Simple constructor.
REAL val(STATE &number)
Returns value of the variable.
#define MAX(a, b)
Gets maxime value between a and b.
virtual int Substitution(TPZFMatrix< TVar > *B) const override
Computes Forward and Backward substitution for a "LU" decomposed matrix.
int64_t size() const
Returns the number of elements of the vector.
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...
TPZFBMatrix & operator-=(const TPZFBMatrix< TVar > &A)
int ClassId() const override
Define the class id associated with the class.
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
TPZFBMatrix operator+(const TPZFBMatrix< TVar > &A) const
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension the matrix and make zero its elements.
~TPZFBMatrix()
Simple destructor.
int64_t Rows() const
Returns number of rows.
int Put(const int64_t row, const int64_t col, const TVar &value) override
Put values with bounds checking if DEBUG variable is defined.
int Clear() override
It clears data structure.
#define MIN(a, b)
Gets minime value between a and b.
virtual int Redim(const int64_t newRows, const int64_t newCols)
Redimensions the matrix reinitializing it with zero.
TPZFBMatrix & operator=(const TPZFBMatrix< TVar > &A)
Full matrix class. Matrix.
int PutVal(const int64_t row, const int64_t col, const TVar &value) override
Put values without bounds checking This method is faster than "Put" if DEBUG is defined.
int32_t Hash(std::string str)
int Zero() override
Zeroes the matrix.
int64_t fCol
Number of cols in matrix.
Contains TPZFBMatrix class which defines a non symmetric banded matrix.
virtual int PutVal(const int64_t, const int64_t, const TVar &val)
Put values without bounds checking This method is faster than "Put" if DEBUG is defined.
Defines a non symmetric banded matrix. Matrix.
virtual int Decompose_LU()
TPZFBMatrix operator-() const
int64_t Cols() const
Returns number of cols.
virtual int Substitution(TPZFMatrix< TVar > *B) const
Computes Forward and Backward substitution for a "LU" decomposed matrix.
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.
int PutVal(const int64_t row, const int64_t col, const TVar &value) override
Put values without bounds checking This method is faster than "Put" if DEBUG 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.
int ClassId() const override
Define the class id associated with the class.
Root matrix class (abstract). Matrix.