25 if (row < 0 || col < 0 || row >this->
fRow || col >this->
fCol)
27 cout<<
"ERRO! em TPZVerySparseMatrix::PutVal: The row i or column j are incompatible with the rows or columns of a matrix"<< endl;
31 pair <int64_t,int64_t> position(row,col);
32 typename std::map <std::pair<int64_t, int64_t>, TVar>::iterator it = this->
fExtraSparseData.find(position);
51 for(int64_t i=0; i<this->
fRow; i++)
53 for(int64_t j=0; j<this->
fCol; j++)
64 int64_t rows = this->
Rows();
65 int64_t cols = this->
Cols();
69 cerr <<
"Error: Simetrize only work for square matrices";
73 typename std::map <std::pair<int64_t, int64_t>, TVar>::iterator it = this->
fExtraSparseData.begin();
74 typename std::map <std::pair<int64_t, int64_t>, TVar>::iterator end = this->
fExtraSparseData.end();
75 typename std::map <std::pair<int64_t, int64_t>, TVar>::iterator next;
77 std::list< std::pair< std::pair<int64_t, int64_t>, TVar > > temp;
79 for(; it != end; it=next) {
80 const std::pair<int64_t, int64_t>& key = it->first;
84 if(key.first < key.second) {
85 temp.push_back( std::pair< std::pair<int64_t, int64_t>, TVar > (std::pair<int64_t, int64_t>(key.second, key.first), it->second));
87 else if (key.first > key.second) {
92 typename std::list< std::pair< std::pair<int64_t, int64_t>, TVar > >::iterator at = temp.begin();
93 typename std::list< std::pair< std::pair<int64_t, int64_t>, TVar > >::iterator atEnd = temp.end();
95 for(; at != atEnd; at++) {
103 int64_t rows = this->
Rows();
104 int64_t cols = this->
Cols();
107 typename std::map <std::pair<int64_t, int64_t>, TVar>::const_iterator it = this->
fExtraSparseData.begin();
108 typename std::map <std::pair<int64_t, int64_t>, TVar>::const_iterator end = this->
fExtraSparseData.end();
110 for (; it != end; it++) {
111 const std::pair<int64_t, int64_t>& key = it->first;
112 T->
fExtraSparseData[std::pair<int64_t,int64_t>(key.second, key.first)] = it->second;
119 if (row < 0 || col < 0 || row >this->
fRow || col >this->
fCol)
121 cout<<
"ERRO! em TPZVerySparseMatrix::GetVal: The row i or column j are incompatible with the rows or columns of a matrix"<< endl;
125 pair <int64_t,int64_t> position(row,col);
126 typename map<pair<int64_t,int64_t>, TVar>::const_iterator it;
139 const TVar alpha,
const TVar beta,
const int opt)
const 145 cout <<
"\nERROR! em TPZVerySparseMatrix::MultiplyAdd: incompatible dimensions in opt=false\n";
152 cout <<
"\nERROR! em TPZVerySparseMatrix::MultiplyAdd: incompatible dimensions in opt=true\n";
157 cout <<
"\nERROR! em TPZVerySparseMatrix::MultiplyAdd : incompatible dimensions in x, y or z\n";
161 int64_t xcols = x.
Cols();
166 for (ic = 0; ic < xcols; ic++)
170 typename map< pair<int64_t,int64_t>, TVar>::const_iterator it;
174 pair <int64_t, int64_t> position(it->first);
177 TVar matrixval = it->second;
179 val = z(r,ic) + alpha * matrixval * x.
GetVal(c,ic);
184 typename map<pair<int64_t,int64_t>, TVar>::const_iterator it;
188 pair <int64_t, int64_t> posicao(it->first);
191 TVar matrixval = it->second;
192 z(r,ic) += (alpha*matrixval)*x.
GetVal(c,ic);
211 int mapsz = TheMap.size();
212 buf.
Write(&mapsz, 1);
213 typename std::map<std::pair<int64_t, int64_t>, TVar>::const_iterator it;
214 for(it = TheMap.begin(); it != TheMap.end(); it++)
217 ii = it->first.first;
218 jj = it->first.second;
221 buf.
Write(&it->second, 1);
243 for(i = 0; i < size; i++)
249 std::pair<int64_t, int64_t> item(ii, jj);
251 std::pair<std::pair<int64_t, int64_t>, TVar > fullitem(item, value);
252 TheMap.insert(fullitem);
void WriteMap(TPZStream &buf, int withclassid, const std::map< std::pair< int64_t, int64_t >, TVar > &TheMap) const
Auxiliary functions only reading and writing a map as the third paremeter.
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
std::map< std::pair< int64_t, int64_t >, TVar > fExtraSparseData
Save elements different from zero, of Sparse matrix.
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.
REAL val(STATE &number)
Returns value of the variable.
char fDefPositive
Definite Posistiveness of current matrix.
virtual ~TPZVerySparseMatrix()
static TVar gZero
Initializing value to static variable.
virtual const TVar & GetVal(const int64_t row, const int64_t col) const override
Get values checking bounds.
void Read(TPZStream &buf, void *context) override
Unpacks the object structure from a stream of bytes.
virtual void Write(const bool val)
void ReadMap(TPZStream &buf, void *context, std::map< std::pair< int64_t, int64_t >, TVar > &TheMap)
Implements a matrix whose nonzero elements are stored in binary tree. Matrix.
int64_t Rows() const
Returns number of rows.
Full matrix class. Matrix.
int64_t fCol
Number of cols in matrix.
void Simetrize() override
Simetrizes copies the data of the matrix to make its data simetric.
int PutVal(const int64_t row, const int64_t col, const TVar &val) override
Put values checking bounds.
Contains TPZVerySparseMatrix class which implements a matrix whose nonzero elements are stored in bin...
int64_t Cols() const
Returns number of cols.
Defines the interface for saving and reading data. Persistency.
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
It computes z = beta * y + alpha * opt(this)*x but z and x can not overlap in memory.
void Write(TPZStream &buf, int withclassid) const override
Packs the object structure in a stream of bytes.
int ClassId() const override
Saveable methods.
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.
virtual void Read(bool &val)
virtual void Transpose(TPZVerySparseMatrix< TVar > *T) const
It makes *T the transpose of current matrix.
Root matrix class (abstract). Matrix.