47 static LoggerPtr logger(Logger::getLogger(
"pz.matrix.tpzskylmatrix"));
63 fElem(row + 1), fElemb(row + 1), fStorage(0), fStorageb(0)
118 template <
class TVar>
127 template <
class TVar>
131 int64_t i, nelem = 0;
132 for (i = 0; i < dim; i++)
133 nelem += i - skyline[i] + 1;
137 template <
class TVar>
149 point[0] = &storage[0];
150 point[dim] = &storage[0] + nel;
156 for (i = 1; i < dim + 1; i++)
157 point[i] = point[i - 1] + (i - 1) - skyline[i - 1] + 1;
163 template <
class TVar>
170 cout <<
"ComputeMaxSkyline : incompatible dimension";
173 int64_t i, dim = first.
Rows();
176 for (i = 1; i < dim + 1; i++)
179 int64_t aux = (first.
Size(i) > second.
Size(i)) ? first.
Size(i) : second.
Size(i);
180 res[i] = i - aux - 1;
184 template <
class TVar>
187 int64_t row(r), col(c);
191 int64_t index = col - row;
192 if (index >=
Size(col))
198 return fElem[col][index];
203 int64_t index = row - col;
204 if (index >=
Size(row))
210 return fElemb[row][index];
214 template <
class TVar>
220 template <
class TVar>
228 template <
class TVar>
232 int64_t row(r), col(c);
236 int64_t index = col - row;
240 cout <<
"TPZSkylMatrix::PutVal Size" <<
Size(col);
244 else if (index >=
Size(col))
246 fElem[col][index] = value;
253 int64_t index = row - col;
257 cout <<
"TPZSkylMatrix::PutVal Size" <<
Size(col);
261 else if (index >=
Size(row))
263 fElemb[row][index] = value;
271 template <
class TVar>
279 " <matrixs with incompatible dimensions>");
285 cout <<
"x.Cols = " << x.
Cols() <<
" y.Cols()" << y.
Cols()
286 <<
" z.Cols() " << z.
Cols() <<
" x.Rows() " << x.
Rows()
287 <<
" y.Rows() " << y.
Rows() <<
" z.Rows() " << z.
Rows() << endl;
291 int64_t rows = this->
Rows();
292 int64_t xcols = x.
Cols();
294 for (ic = 0; ic < xcols; ic++)
296 for (r = 0; r < rows; r++)
298 int64_t offset =
Size(r);
300 const TVar *p = &x.
g((r - offset + 1), ic);
301 TVar *diag, *diaglast;
304 diag =
fElemb[r] + offset - 1;
309 diag =
fElem[r] + offset - 1;
312 while (diag > diaglast)
317 if (diag == diaglast)
322 z(r, ic) += val * alpha;
323 TVar *zp = &z((r - offset + 1), ic);
327 diag =
fElem[r] + offset - 1;
332 diag =
fElemb[r] + offset - 1;
335 while (diag > diaglast)
337 *zp += alpha * *diag--*
val;
346 template <
class TVar>
499 template <
class TVar>
503 int64_t row(r), col(c);
506 if (row >= this->
Dim() || col >= this->
Dim() || row < 0 || col < 0)
508 cout <<
"TPZSkylMatrix::GetVal index out of range row = " << row <<
509 " col = " << col << endl;
513 int64_t index = col - row;
516 if (index <
Size(col))
517 return(
fElem[col][index]);
520 if (this->
gZero != TVar(0.))
522 cout <<
"TPZSkylMatrix gZero = " << this->
gZero << endl;
531 if (row >= this->
Dim() || col >= this->
Dim() || row < 0 || col < 0)
533 cout <<
"TPZSkylMatrix::GetVal index out of range row = " << row <<
534 " col = " << col << endl;
538 int64_t index = row - col;
541 if (index <
Size(row))
542 return(
fElemb[row][index]);
545 if (this->
gZero != TVar(0.))
547 cout <<
"TPZSkylMatrix gZero = " << this->
gZero << endl;
558 template <
class TVar>
562 int64_t row(r), col(c);
563 int64_t index = col - row;
566 if (row >= this->
Dim() || col >= this->
Dim() || row < 0 || col < 0)
568 cout <<
"TPZSkylMatrix::GetVal index out of range row = " << row <<
569 " col = " << col << endl;
572 if (index <
Size(col))
576 return(
fElem[col][index]);
579 template <
class TVar>
583 int64_t row(r), col(c);
584 int64_t index = row - col;
587 if (row >= this->
Dim() || col >= this->
Dim() || row < 0 || col < 0)
589 cout <<
"TPZSkylMatrix::GetVal index out of range row = " << row <<
590 " col = " << col << endl;
593 if (index <
Size(col))
597 return(
fElem[row][index]);
867 template <
class TVar>
874 "Decompose_LU <Matrix already Decomposed>");
891 PZError <<
"CUIDADO, A MATRIZ NAO TEM POSICOES NA LINHA " << k <<
"\n";
898 TVar *elem_k =
fElem[k] + 1;
899 TVar *elem_kb =
fElemb[k] + 1;
901 for (; elem_k < end_k; elem_k++, elem_kb++)
903 sum += (*elem_k) * (*elem_kb);
909 pivot =
fElem[k][0] - sum;
910 if (
fabs(pivot) < 1.e-25)
913 "TPZSkylNSymMatrix<TVar>::Decompose_LU a matrix nao e positiva definida" 924 for (int64_t j = 2; i <
dimension; j++, i++)
933 TVar *elem_i = &
fElem[i][j];
934 TVar *end_i =
fElem[i + 1];
937 while ((elem_i < end_i) && (elem_k < end_k))
938 sum += (*elem_i++) * (*elem_k++);
947 elem_k = &(
fElem[k][1]);
949 while ((elem_i < end_i) && (elem_k < end_k))
950 sum += (*elem_i++) * (*elem_k++);
955 else if (
Size(i) == j)
957 fElemb[i][j - 1] /= pivot;
1026 template <
class TVar>
1033 "TPZSkylMatrix::Subst_Backward not decomposed with LU");
1037 int64_t Dimension = this->
Dim();
1041 for (j = 0; j < B->
Cols(); j++)
1043 int64_t k = Dimension - 1;
1044 while (k > 0 && (*B)(k, j) == TVar(0.))
1055 TVar *elem_ki =
fElem[k];
1056 TVar *end_ki =
fElem[k + 1];
1057 TVar *BPtr = &(*B)(k, j);
1058 *BPtr /= *elem_ki++;
1062 while (elem_ki < end_ki)
1063 * --BPtr -= (*elem_ki++) * val;
1066 for (j = 0; j < B->
Cols(); j++)
1067 (*B)(0, j) /=
fElem[0][0];
1077 template <
class TVar>
1086 for (int64_t j = 0; j < B->
Cols(); j++)
1091 TVar *elem_ki =
fElemb[k] + 1;
1092 TVar *end_ki =
fElemb[k + 1];
1093 TVar *BPtr = &(*B)(k, j);
1094 while (elem_ki < end_ki)
1095 sum += (*elem_ki++) * (*--BPtr);
1203 template <
class TVar>
1220 template <
class TVar>
1523 template <
class TVar>
1532 TVar *ptr = 0, *ptr2 = 0;
1539 for (int64_t i=0; i<this->
Rows()+1; i++) {
1540 fElem[i] = skyl[i] + ptr;
1541 fElemb[i] = skyl2[i] + ptr2;
1545 template <
class TVar>
1552 TVar *ptr = 0, *ptr2 = 0;
1557 for (int64_t i=0; i<this->
Rows()+1; i++) {
1558 skyl[i] =
fElem[i] - ptr;
1559 skyl2[i] =
fElemb[i] - ptr2;
1566 template <
class TVar>
1575 for (int64_t i=0; i<this->
Rows(); i++) {
1576 int randcol = rand()%(i+1);
1577 skyline[i] = randcol;
1583 for(i=0;i<this->
Rows();i++) {
1584 for(j=skyline[i];j<=i ;j++) {
1585 val = ((TVar)rand())/((TVar)RAND_MAX);
1588 this->
Error(
"AutoFill (TPZMatrix) failed.");
1590 if (symmetric == 0) {
1591 val = ((TVar)rand())/((TVar)RAND_MAX);
1595 this->
Error(
"AutoFill (TPZMatrix) failed.");
1599 for (i=0; i<this->
Rows(); i++)
1602 for (j=0; j<this->
Rows(); j++)
1604 sum += this->
GetVal(i,j);
1608 PutVal(i,i,sum+(TVar)1.);
void Write(TPZStream &buf, int withclassid) const override
Packs the object structure in a stream of bytes.
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 & GetValB(const int64_t row, const int64_t col) const
Pega o valor abaixo da diagonal (below)
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
TVar & operator()(const int64_t row, const int64_t col)
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
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.
void Write(TPZStream &buf, int withclassid) const override
Packs the object structure in a stream of bytes.
int ClassId() const override
Return the id of the matrix defined pzmatrixid.h.
const TVar & GetValSup(const int64_t row, const int64_t col) const
Pega o valor na diagonal ou parte de cima da diagonal.
static int Error(const char *msg, const char *msg2=0)
Returns error messages.
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
virtual void MultAdd(const TPZFMatrix< TVar > &x, const TPZFMatrix< TVar > &y, TPZFMatrix< TVar > &z, const TVar alpha, const TVar beta, const int opt=0) const override
It computes z = beta * y + alpha * opt(this)*x but z and x can not overlap in memory.
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.
void PrepareZ(const TPZFMatrix< TVar > &y, TPZFMatrix< TVar > &z, const TVar beta, const int opt) const
Is an auxiliar method used by MultiplyAdd.
char fDecomposed
Decomposition type used to decompose the current matrix.
void Copy(const TPZSkylNSymMatrix &)
Implements a skyline storage format.
REAL val(STATE &number)
Returns value of the variable.
char fDefPositive
Definite Posistiveness of current matrix.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
static TVar gZero
Initializing value to static variable.
TPZSkylMatrix< REAL > matrix
const TVar & GetVal(const int64_t row, const int64_t col) const override
int Decompose_LU() override
TPZManVector< TVar > fStorage
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...
int PutVal(const int64_t row, const int64_t col, const TVar &element) override
void SetSkyline(const TPZVec< int64_t > &skyline)
virtual void Write(const bool val)
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
static int64_t NumElements(const TPZVec< int64_t > &skyline)
virtual void UpdateFrom(TPZAutoPointer< TPZMatrix< TVar > > mat) override
Updates the values of the matrix based on the values of the matrix.
int64_t Rows() const
Returns number of rows.
Contains TPZSkyline class which implements a skyline storage format.
void Read(TPZStream &buf, void *context) override
Unpacks the object structure from a stream of bytes.
static void ComputeMaxSkyline(const TPZSkylNSymMatrix &first, const TPZSkylNSymMatrix &second, TPZVec< int > &res)
Full matrix class. Matrix.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
virtual int64_t Dim() const
Returns the dimension of the matrix if the matrix is square.
void Shrink()
It reallocates storage to fit the necessary storage exactly.
int64_t fCol
Number of cols in matrix.
int Subst_Backward(TPZFMatrix< TVar > *b) const override
void AutoFill(int64_t nrow, int64_t ncol, int symmetric)
Fill matrix storage with randomic values.
void Read(TPZStream &buf, void *context) override
Unpacks the object structure from a stream of bytes.
void Fill(const T ©, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
int64_t Cols() const
Returns number of cols.
int Size(const int64_t column) const
TPZManVector< TVar > fStorageb
Defines the interface for saving and reading data. Persistency.
int64_t NElements() const
Returns the number of elements of the vector.
static void InitializeElem(const TPZVec< int64_t > &skyline, TPZManVector< TVar > &storage, TPZVec< TVar *> &elem)
int Subst_LForward(TPZFMatrix< TVar > *b) const override
TVar & g(const int64_t row, const int64_t col) const
Implements an interface to register a class id and a restore function. Persistence.
#define PZError
Defines the output device to error messages and the DebugStop() function.
virtual void Read(bool &val)
Root matrix class (abstract). Matrix.
This class implements a reference counter mechanism to administer a dynamically allocated object...