39 static LoggerPtr logger(Logger::getLogger(
"pz.matrix.tpzfmatrix"));
40 static LoggerPtr loggerCheck(Logger::getLogger(
"pz.checkconsistency"));
61 TPZMatrix<TVar>(mat), fElem(0),fGiven(0),fSize(0) {
67 for(j=0; j<this->
fCol; j++) {
68 for(i=0; i<this->
fRow; i++) {
83 int64_t size = this->
fRow * this->
fCol;
85 fElem =
new TVar[ size ] ;
87 if ( size &&
fElem == NULL )
Error(
"Constructor <memory allocation error>." );
92 memcpy((
void *)(p),(
void *)(src),(
size_t)size*
sizeof(TVar));
103 int64_t size = this->
fRow * this->
fCol;
105 fElem =
new TVar[ size ] ;
108 if ( size &&
fElem == NULL )
Error(
"Constructor <memory allocation error>." );
111 typename std::map <std::pair<int64_t, int64_t>, TVar>::const_iterator it = A.
MapBegin();
112 typename std::map <std::pair<int64_t, int64_t>, TVar>::const_iterator end = A.
MapEnd();
115 memset((
void *)p, 0, (
size_t)size*
sizeof(TVar));
117 for (; it != end; it++) {
118 const std::pair<int64_t, int64_t>& key = it->first;
119 PutVal(key.first, key.second, it->second);
132 if(
this == &A)
return *
this;
135 TVar * newElem =
fElem;
136 if(fSize < size && size != this->
fRow*this->
fCol) {
139 }
else if (
fSize >= size) {
143 if ( newElem == NULL && size > 0)
Error(
"Operator= <memory allocation error>." );
150 memcpy((
void *)(
fElem),(
void *)(A.
fElem),(
size_t)size*
sizeof(TVar));
158 template<
class TVar >
162 auto it = list.begin();
163 auto it_end = list.end();
165 for (; it != it_end; it++, aux++)
171 template<
class TVar >
173 size_t n_row = list.size();
176 auto row_it = list.begin();
177 auto row_it_end = list.end();
180 bool col_n_found =
false;
181 for (
auto it = row_it; it != row_it_end; it++) {
187 if (n_col != it->size())
188 Error(
"TPZFMatrix constructor: inconsistent number of columns in initializer list");
192 n_col = row_it->size();
196 for (uint32_t row_n = 0; row_it != row_it_end; row_it++, row_n++) {
197 auto col_it = row_it->begin();
198 auto col_it_end = row_it->end();
199 for (uint32_t col_n = 0; col_it != col_it_end; col_it++, col_n++) {
200 fElem[col_n * this->
fRow + row_n] = *col_it;
208 template <
class TVar>
211 PZError <<
"TPZFMatrix::AddFel number of columns does not correspond\n";
215 int64_t ncol = this->
Cols();
216 int64_t nrow = rhs.
Rows();
218 for(j=0; j<ncol; j++) {
219 for(i=0; i<nrow; i++) {
228 PZError <<
"TPZFMatrix::AddFel number of columns does not correspond\n";
232 int64_t ncol = this->
Cols();
235 for(j=0; j<ncol; j++) {
236 for(i=0; i<nrow; i++) {
237 operator()(destination[i],j) += rhs(source[i],j);
245 PZError <<
"TPZFMatrix::AddFel number of columns does not correspond\n";
249 int64_t ncol = this->
Cols();
252 for(j=0; j<ncol; j++) {
253 for(i=0; i<nrow; i++) {
255 operator()(destination[i],j) += rhs(source[i],j);
263 PZError <<
"TPZFMatrix::AddFel number of columns does not correspond\n";
267 int64_t ncol = this->
Cols();
270 for(j=0; j<ncol; j++) {
271 for(i=0; i<nrow; i++) {
273 operator()(destination[i],j) += rhs(source[i],j);
283 template <
class TVar>
286 Error(
"Operator+ <matrixs with different dimensions>" );
290 int64_t size = ((int64_t)this->
Rows()) * this->
Cols();
293 TVar * pr = res.
fElem;
295 while(pm < plast) *pr++ = (*pm++) + (*pa++);
302 template <
class TVar>
305 Error(
"Operator- <matrixs with different dimensions>" );
309 int64_t size = ((int64_t)this->
Rows()) * this->
Cols();
312 TVar * pr = res.
fElem, *prlast =pr+size;
314 while(pr < prlast) *pr++ = (*pm++) - (*pa++);
321 std::cout <<
"Nothing to do\n";
340 template <
class TVar>
344 if (logger->isDebugEnabled())
346 std::stringstream sout;
347 Print(
"GrSchmidt Entrada",sout);
353 for(int64_t j = 0; j < this->
Cols(); j++)
356 for(int64_t i = 0; i < this->
Rows(); i++)
363 if((1.)/norm > scale) scale = (1.)/norm;
369 int64_t QTDcomp = this->
Rows();
370 int64_t QTDvec = this->
Cols();
371 Orthog.
Resize(QTDcomp,QTDvec);
374 for(int64_t r = 0; r < QTDcomp; r++)
376 for(int64_t c = 0; c < QTDvec; c++)
378 Orthog(r,c) =
GetVal(r,c);
384 for(int64_t c = 0; c < QTDvec; c++)
387 for(int64_t r = 0; r < QTDcomp; r++)
391 if(
fabs(summ) < 0.00001)
393 std::stringstream sout;
394 sout <<
"Null Vector on Gram-Schmidt Method! Col = " << c <<
"\n";
402 for(int64_t c = 1; c < QTDvec; c++)
404 for(int64_t stop = 0; stop < c; stop++)
408 for(int64_t r = 0; r < QTDcomp; r++)
410 dotUp +=
GetVal(r,c)*Orthog(r,stop);
411 dotDown += Orthog(r,stop)*Orthog(r,stop);
413 if(
fabs(dotDown) < 1.E-8)
418 std::stringstream sout;
419 sout <<
"Parallel Vectors on Gram-Schmidt Method! Col = " << stop <<
"\n";
424 for(int64_t r = 0; r < QTDcomp; r++)
432 if (logger->isDebugEnabled())
434 std::stringstream sout;
435 sout <<
"dotdown = " << dotDown <<
" dotup = " << dotUp;
440 for(int64_t r = 0; r < QTDcomp; r++)
442 Orthog(r,c) -= dotUp*Orthog(r,stop)/dotDown;
447 for(int64_t c = 0; c < QTDvec; c++)
450 for(int64_t r = 0; r < QTDcomp; r++)
452 dotUp += Orthog(r,c)*Orthog(r,c);
454 if(
fabs(dotUp) > 1.e-8)
456 for(int64_t r = 0; r < QTDcomp; r++)
458 Orthog(r,c) = Orthog(r,c)/
sqrt(dotUp);
463 std::stringstream sout;
464 sout <<
"Linearly dependent columns dotUp = " << dotUp;
468 for(int64_t r = 0; r < QTDcomp; r++)
475 Orthog.
Multiply(*
this,TransfToOrthog,1);
478 TransfToOrthog.operator*= ( 1./scale );
481 if (logger->isDebugEnabled())
483 std::stringstream sout;
485 sout <<
"Output GS" << endl;
486 Orthog.
Print(
"Orthog matrix",sout);
487 TransfToOrthog.
Print(
"TransfToOrthog matrix",sout);
502 std::cout << __PRETTY_FUNCTION__ <<
" please implement me\n";
506 template <
class TVar>
512 for(r=0; r<this->
Rows(); r++) inverse(r,r) = 1.;
515 for(r=0; r<this->
Rows(); r++) determinant *= copy(r,r);
520 template <
class TVar>
525 for(int64_t i = 0; i < this->
Rows(); i++){
532 template <
class TVar>
534 const TVar alpha,
const TVar beta ,
const int opt)
538 if ((!opt && cols != x.
Rows()) || (opt && rows != x.
Rows())) {
539 Error(
"TPZFMatrix::MultAdd matrix x with incompatible dimensions>" );
542 if(beta != (TVar)0. && ((!opt && rows != y.
Rows()) || (opt && cols != y.
Rows()) || y.
Cols() != x.
Cols())) {
543 Error(
"TPZFMatrix::MultAdd matrix y with incompatible dimensions>" );
555 unsigned numeq = opt ? cols : rows;
556 int64_t xcols = x.
Cols();
558 if(!(rows*cols))
return;
559 for (ic = 0; ic < xcols; ic++) {
560 TVar *zp = &z(0,ic), *zlast = zp+numeq;
561 if(beta != (TVar)0.) {
562 const TVar *yp = &y.
g(0,ic);
564 memcpy((
void *)zp,(
void *)yp,numeq*
sizeof(TVar));
566 for(int64_t i=0; i< numeq; i++)
for(int64_t c=0; c<xcols; c++) z(i,c) *= beta;
576 for (ic = 0; ic < xcols; ic++) {
578 for ( c = 0; c<cols; c++) {
579 TVar * zp = &z(0,ic), *zlast = zp+rows;
580 const TVar * fp = ptr +rows*c;
581 const TVar * xp = &x.
g(c,ic);
583 *zp += alpha* *fp++ * *xp;
588 const TVar * fp = ptr;
590 for (c = 0; c<cols; c++) {
594 const TVar *xp = &x.
g(0,ic);
595 const TVar *xlast = xp + rows;
615 const double alpha,
const double beta,
const int opt)
const {
618 if ((!opt && this->
Cols() != x.
Rows()) || (opt && this->
Rows() != x.
Rows())) {
619 Error(
"TPZFMatrix::MultAdd matrix x with incompatible dimensions>" );
622 if(beta != (
double)0. && ((!opt && this->
Rows() != y.
Rows()) || (opt && this->
Cols() != y.
Rows()) || y.
Cols() != x.
Cols())) {
623 Error(
"TPZFMatrix::MultAdd matrix y with incompatible dimensions>" );
636 if(this->
Cols() == 0) {
644 if (beta != (
double)0.) {
651 cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, this->
Rows(), x.
Cols(), this->
Cols(),
654 cblas_dgemm(CblasColMajor, CblasTrans, CblasNoTrans, this->
Cols(), x.
Cols(), this->
Rows(),
661 const float alpha,
const float beta,
const int opt)
const {
664 if ((!opt && this->
Cols() != x.
Rows()) || (opt && this->
Rows() != x.
Rows())) {
665 Error(
"TPZFMatrix::MultAdd matrix x with incompatible dimensions>" );
668 if(beta != (
float)0. && ((!opt && this->
Rows() != y.
Rows()) || (opt && this->
Cols() != y.
Rows()) || y.
Cols() != x.
Cols())) {
669 Error(
"TPZFMatrix::MultAdd matrix y with incompatible dimensions>" );
682 if(this->
Cols() == 0) {
690 if (beta != (
float)0.) {
697 cblas_sgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, this->
Rows(), x.
Cols(), this->
Cols(),
700 cblas_sgemm(CblasColMajor, CblasTrans, CblasNoTrans, this->
Cols(), x.
Cols(), this->
Rows(),
708 const std::complex<double> alpha,
const std::complex<double> beta,
const int opt)
const {
711 if ((!opt && this->
Cols() != x.
Rows()) || (opt && this->
Rows() != x.
Rows())) {
712 Error(
"TPZFMatrix::MultAdd matrix x with incompatible dimensions>" );
715 if(beta.real() != 0. && ((!opt && this->
Rows() != y.
Rows()) || (opt && this->
Cols() != y.
Rows()) || y.
Cols() != x.
Cols())) {
716 Error(
"TPZFMatrix::MultAdd matrix y with incompatible dimensions>" );
729 if(this->
Cols() == 0) {
732 if (beta.real() != 0.) {
736 cblas_zgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, this->
Rows(), x.
Cols(), this->
Cols(),
739 cblas_zgemm(CblasColMajor, CblasTrans, CblasNoTrans, this->
Cols(), x.
Cols(), this->
Rows(),
745 #endif // USING_LAPACK 756 template <
class TVar>
758 const TVar alpha,
const TVar beta,
const int opt)
const {
760 if ((!opt && this->
Cols() != x.
Rows()) || (opt && this->
Rows() != x.
Rows())) {
761 Error(
"TPZFMatrix::MultAdd matrix x with incompatible dimensions>" );
764 if(beta != (TVar)0. && ((!opt && this->
Rows() != y.
Rows()) || (opt && this->
Cols() != y.
Rows()) || y.
Cols() != x.
Cols())) {
765 Error(
"TPZFMatrix::MultAdd matrix y with incompatible dimensions>" );
777 if(this->
Cols() == 0)
781 unsigned numeq = opt ? this->
Cols() : this->
Rows();
782 int64_t rows = this->
Rows();
783 int64_t cols = this->
Cols();
784 int64_t xcols = x.
Cols();
788 for (ic = 0; ic < xcols; ic++) {
789 TVar *zp = &z(0,ic), *zlast = zp+numeq;
790 if(beta != (TVar)0.) {
791 const TVar *yp = &y.
g(0,ic);
793 memcpy((
void *)zp,(
void *)yp,numeq*
sizeof(TVar));
795 for(int64_t i=0; i< numeq; i++) z(i,ic) *= beta;
806 if(!(rows*cols))
return;
808 for (ic = 0; ic < xcols; ic++) {
810 for ( c = 0; c<cols; c++) {
811 TVar * zp = &z(0,ic), *zlast = zp+rows;
812 TVar * fp =
fElem +rows*c;
813 const TVar * xp = &x.
g(c,ic);
815 *zp += alpha* *fp++ * *xp;
820 TVar * fp =
fElem, *zp = &z(0,ic);
821 for (c = 0; c<cols; c++) {
825 const TVar *xp = &x.
g(0,ic);
826 const TVar *xlast = xp + rows;
841 template <
class TVar>
844 Error(
"Operator+= <matrixs with different dimensions>" );
846 int64_t size = ((int64_t)this->
Rows()) * this->
Cols();
847 TVar * pm =
fElem, *pmlast=pm+size;
849 while(pm < pmlast) (*pm++) += (*pa++);
855 template <
class TVar>
858 Error(
"Operator-= <matrixs with different dimensions>" );
860 int64_t size = ((int64_t)this->
Rows()) * this->
Cols();
864 for ( int64_t i = 0; i < size; i++ ) *pm++ -= *pa++;
874 cblas_daxpy(size, alpha, &p.
fElem[0], 1, &
fElem[0], 1);
878 template <
class TVar>
884 while(pt < ptlast) *pt++ += alpha * *pp++;
892 cblas_dscal(size,beta,
fElem,1);
919 template <
class TVar>
921 int64_t arows = A.
Rows();
922 int64_t acols = A.
Cols();
923 int64_t size = arows * acols;
931 fElem =
new TVar[ arows * acols ] ;
936 for ( int64_t c = 0; c < this->
fCol; c++ )
937 for ( int64_t r = 0; r < this->
fRow; r++ )
938 *dst++ = A.
Get( r, c );
947 template <
class TVar>
949 int64_t size = ((int64_t)this->
fRow) * this->
fCol;
951 for ( int64_t i = 0; i < size; i++ )
961 template <
class TVar>
963 int64_t size = ((int64_t)this->
Rows()) * this->
Cols();
965 TVar * dst =
fElem, *dstlast = dst+size;
966 while ( dst < dstlast ) *dst++ += value;
974 template <
class TVar>
977 int64_t size = ((int64_t)this->
Rows()) * this->
Cols();
979 TVar * dst = res.
fElem, *dstlast = dst+size;
980 while ( dst < dstlast )
986 template <
class TVar>
995 template <
class TVar>
1005 template <
class TVar>
1007 int64_t size = ((int64_t)this->
Rows()) * this->
Cols();
1008 TVar * dst =
fElem, *dstlast = dst+size;
1009 while ( dst < dstlast ) *dst++ *= value;
1015 template <
class TVar>
1017 if ( newRows == this->
Rows() && newCols == this->
Cols() )
return( 1 );
1018 int64_t newsize = ((int64_t)newRows)*newCols;
1025 newElem =
new TVar[ newRows * newCols ] ;
1027 if ( newElem == NULL )
1028 Error(
"Resize <memory allocation error>." );
1030 int64_t minRow = ( this->
fRow < newRows ? this->
fRow : newRows );
1031 int64_t minCol = ( this->
fCol < newCols ? this->
fCol : newCols );
1036 for ( c = 0; c < minCol; c++ ) {
1039 dst = newElem + c*newRows;
1041 for ( r = 0; r < minRow; r++ ) *dst++ = *src++;
1045 for ( ; r < newRows; r++ ) *dst++ = 0.0;
1049 for ( ;c < newCols; c++ )
1051 dst = newElem + c*newRows;
1052 for (r = 0 ; r < newRows; r++ ) *dst++ = 0.0;
1057 this->
fRow = newRows;
1058 this->
fCol = newCols;
1062 template <
class TVar>
1064 if(newRows*newCols != this->
fRow*this->
fCol)
return -1;
1065 this->
fRow = newRows;
1066 this->fCol = newCols;
1072 template <
class TVar>
1077 for ( int64_t c = 0; c < this->
Cols(); c++ ) {
1078 for ( int64_t r = 0; r < this->
Rows(); r++ ) {
1085 template <
class TVar>
1103 if ( this->
Rows() != this->
Cols() ) {
1104 cout <<
"TPZFPivotMatrix::DecomposeLU ERRO : A Matriz não é quadrada" << endl;
1109 int nRows = this->
Rows();
1113 fPivot.Resize(nRows);
1122 sgesv_(&nRows,&zero,
fElem,&nRows,&fPivot[0],&b,&nRows,&info);
1137 if ( this->
Rows() != this->
Cols() ) {
1138 cout <<
"TPZFPivotMatrix::DecomposeLU ERRO : A Matriz não é quadrada" << endl;
1143 int nRows = this->
Rows();
1147 fPivot.Resize(nRows);
1156 dgesv_(&nRows,&zero,
fElem,&nRows,&fPivot[0],&b,&nRows,&info);
1161 #endif //USING_LAPACK 1163 template <
class TVar>
1168 if ( this->
Rows() != this->
Cols() ) {
1169 cout <<
"TPZFPivotMatrix::DecomposeLU ERRO : A Matriz não é quadrada" << endl;
1175 int64_t nRows = this->
Rows();
1176 int64_t nCols = this->
Cols();
1180 for (i=0;i<nRows;i++) index[i] = i;
1183 for (j=0;j<nCols;j++){
1188 sum += this->
Get(i,k) * this->
Get(k,j);
1190 TVar aux = this->
Get(i,j);
1195 TVar piv = this->
Get(j,j);
1198 for (i=j+1;i<nRows;i++){
1200 for (k=0;k<(j);k++){
1201 sum += this->
Get(i,k) * this->
Get(k,j);
1203 TVar aux = this->
Get(i,j);
1208 piv = this->
Get(i,j);
1215 for (k=0;k<nCols;k++){
1216 TVar aux = this->
Get(j,k);
1223 index[j] = index[row];
1227 for (i=j+1;i<nRows;i++){
1228 if (
fabs(piv) <
fabs((TVar)1e-12)) {
1229 cout <<
"Pivot < 1e-12. Probably matrix is singular." << endl;
1232 TVar aux = this->
Get(i,j) / piv;
1245 template <
class TVar>
1248 #ifndef USING_LAPACK 1255 const int min = ( this->
Cols() < (this->
Rows()) ) ? this->
Cols() : this->
Rows();
1256 const int nrows = this->
Rows();
1257 const int ncols = this->
Cols();
1259 for (
int k = 0; k < min ; k++ ) {
1260 TVar pivot =
GetVal(k, k);
1262 singular.push_back(k);
1266 for (
int i = k+1; i < nrows; i++ ) {
1269 for (
int j = k+1; j < ncols; j++ ){
1273 const TVar kjVal =
GetVal(k,j);
1274 for ( ; i < nrows; i++, elemPtr++, ikPtr++ ) {
1275 (*elemPtr) -= (*ikPtr)*kjVal;
1282 fPivot.resize(nrows);
1283 for (
int i=0; i<nrows; i++) {
1287 #endif //USING_LAPACK 1304 #endif //USING_LAPACK 1306 template <
class TVar>
1309 std::list<int64_t> fake;
1322 template <
class TVar>
1325 int64_t rowb = B->
Rows();
1326 int64_t colb = B->
Cols();
1327 if ( rowb != rows )
Error(
"static::SubstitutionLU <incompatible dimensions>" );
1329 for ( i = 0; i < rowb; i++ ) {
1330 for ( int64_t col = 0; col < colb; col++ )
1331 for (j = 0; j < i; j++ )
1333 PUTVAL(B, rowb, i, col,
GETVAL(B, rowb, i, col) -
SELECTEL(ptr, rows, i, j) *
GETVAL(B, rowb, j, col));
1336 for (int64_t col=0; col<colb; col++){
1337 for ( i = rowb-1; i >= 0; i-- ) {
1338 for (j = i+1; j < rowb ; j++ )
1340 PUTVAL(B, rowb, i, col,
GETVAL(B, rowb, i, col) -
SELECTEL(ptr, rows, i, j) *
GETVAL(B, rowb, j, col));
1344 if (
fabs(tmp) >
fabs(((TVar)1e-12))) {
1345 Error(
"static::BackSub(SubstitutionLU) <Matrix is singular even after Power Plus..." );
1347 }
else Error(
"static::BackSub(SubstitutionLU) <Matrix is singular" );
1349 PUTVAL(B, rowb, i, col,
GETVAL(B, rowb, i, col)/
SELECTEL(ptr, rows, i, i));
1363 template <
class TVar>
1367 Error(
"TPZFMatrix::Decompose_LU substitution called for a wrongly decomposed matrix");
1371 Error(
"TPZFMatrix::Decompose_LU substitution called for a wrongly decomposed matrix");
1374 int64_t rowb = B->
Rows();
1375 int64_t colb = B->
Cols();
1376 int64_t row = this->
Rows();
1377 if ( rowb != this->
Rows() )
Error(
"SubstitutionLU <incompatible dimensions>" );
1381 for ( i = 0; i < rowb; i++ ) {
1382 for ( int64_t col = 0; col < colb; col++ )
1383 for (j = 0; j < i; j++ )
1385 PUTVAL(B, rowb, i, col,
GETVAL(B, rowb, i, col) -
GETVAL(
this, row, i, j) *
GETVAL(B, rowb, j, col));
1388 for (int64_t col=0; col<colb; col++){
1389 for ( i = rowb-1; i >= 0; i-- ) {
1390 for (j = i+1; j < rowb ; j++ )
1392 PUTVAL(B, rowb, i, col,
GETVAL(B, rowb, i, col) -
GETVAL(
this, row, i, j) *
GETVAL(B, rowb, j, col));
1395 TVar diff =
GETVAL(B, rowb, i, col) -
GETVAL(
this, row, i, i);
1396 if (
fabs(diff) > 1e-12){
1397 Error(
"BackSub(SubstitutionLU) <Matrix is singular even after Power Plus..." );
1399 }
else Error(
"BackSub(SubstitutionLU) <Matrix is singular" );
1401 PUTVAL(B, rowb, i, col,
GETVAL(B, rowb, i, col)/
GETVAL(
this, row, i, i));
1415 PZError << __PRETTY_FUNCTION__ <<
"TPZFMatrix<>*B eh nulo" << endl;
1422 PZError << __PRETTY_FUNCTION__ <<
"Matriz não decomposta" << endl;
1427 PZError << __PRETTY_FUNCTION__ <<
"\nfDecomposed != ELUPivot" << endl;
1435 int nRows = this->
Rows();
1437 int BCols = B->
Cols();
1440 sgetrs_(¬rans,&nRows,&BCols,
fElem,&nRows,&fPivot[0],B->
fElem,&nRows,&info);
1456 PZError << __PRETTY_FUNCTION__ <<
"TPZFMatrix<>*B eh nulo" << endl;
1462 PZError << __PRETTY_FUNCTION__ <<
"Matriz não decomposta" << endl;
1467 PZError << __PRETTY_FUNCTION__ <<
"\nfDecomposed != ELUPivot" << endl;
1475 int nRows = this->
Rows();
1477 int BCols = B->
Cols();
1480 dgetrs_(¬rans,&nRows,&BCols,
fElem,&nRows,&fPivot[0],B->
fElem,&nRows,&info);
1492 #endif //USING_LAPACK 1495 template<
class TVar>
1499 PZError << __PRETTY_FUNCTION__ <<
"TPZFMatrix<>*B eh nulo" << endl;
1506 PZError << __PRETTY_FUNCTION__ <<
"Matriz não decomposta" << endl;
1511 PZError << __PRETTY_FUNCTION__ <<
"\nfDecomposed != ELUPivot" << endl;
1514 int nRows = this->
Rows();
1518 cout <<
"TMatrix::Substituicao ERRO : vetores com dimensões incompativeis:\n" 1519 <<
"this->fIndex = " << index.
NElements() <<
" b = " << b.
Rows() << endl;
1523 int64_t ncols = B->
Cols();
1524 for(int64_t ic = 0; ic<ncols; ic++)
1532 for (i=0;i<nRows;i++)
1534 v[i] = b(index[i],ic);
1538 for (i=0;i<nRows;i++)
1541 for (j=0;j<(i);j++) sum +=this->
Get(i,j) * v[j];
1546 for (i=(nRows-1);i>-1;i--)
1549 for (j=(i+1);j<nRows;j++) sum += this->
Get(i,j) * v[j];
1550 v[i] = (v[i] - sum) / this->
Get(i,i);
1553 for (i=0;i<nRows;i++) b(i,ic) = v[i];
1569 #endif //USING_LAPACK 1573 template <
class TVar>
1575 std::list<int64_t> fake;
1588 if ( this->
Rows() != this->
Cols() )
Error(
"Decompose_Cholesky <Matrix must be square>" );
1589 int dim=this->
Dim();
1597 spotrf_(&uplo, &dim, A, &dim, &info);
1609 if ( this->
Rows() != this->
Cols() )
Error(
"Decompose_Cholesky <Matrix must be square>" );
1610 int dim=this->
Dim();
1617 dpotrf_(&uplo, &dim, A, &dim, &info);
1625 #endif //USING_LAPACK 1627 template <
class TVar>
1632 if ( this->
Rows() != this->
Cols() )
Error(
"Decompose_Cholesky <Matrix must be square>" );
1635 int dim=this->
Dim();
1637 for (
int i=0 ; i<dim; i++) {
1640 for(
int k=0; k<i; k++) {
1646 singular.push_back(i);
1650 (*diagPtr) =
sqrt(*diagPtr);
1652 for (
int j=i+1;j<dim; j++) {
1658 for(; k<i; k++, kjPtr++, ikPtr++) {
1659 sum += (*ikPtr)*(*kjPtr);
1665 (*ijPtr) /= (*diagPtr);
1675 template <
class TVar>
1680 PZError << __PRETTY_FUNCTION__ <<
"TPZFMatrix<>*B eh nulo" << endl;
1690 cout <<
"TMatrix::Substituicao ERRO : vetores com dimensões incompativeis:\n" 1691 <<
"this->fIndex = " << index.
NElements() <<
" b = " << b.
Rows() << endl;
1701 for (i=0;i<rows;i++)
1707 for (i=0;i<rows;i++)
1710 for (j=0;j<(i);j++) sum +=
SELECTEL(ptr,rows,i,j) * v[j];
1715 for (i=(rows-1);i>-1;i--)
1718 for (j=(i+1);j<rows;j++) sum +=
SELECTEL(ptr,rows,i,j) * v[j];
1719 v[i] = (v[i] - sum) /
SELECTEL(ptr,rows,i,i);
1722 for (i=0;i<rows;i++) b(i) = v[i];
1731 Error(
"Decompose_LDLt <Matrix already Decomposed with other scheme> " );
1735 if ( this->
Rows()!=this->
Cols() )
Error(
"Decompose_LDLt <Matrix must be square>" );
1739 fPivot.Resize(dim,0);
1741 int worksize = 3*dim;
1753 ssysv_(&uplo, &dim, &nrhs,
fElem, &dim, &fPivot[0], &B, &dim, &fWork[0], &worksize, &info);
1762 Error(
"Decompose_LDLt <Matrix already Decomposed with other scheme> " );
1766 if ( this->
Rows()!=this->
Cols() )
Error(
"Decompose_LDLt <Matrix must be square>" );
1770 fPivot.Resize(dim,0);
1772 int worksize = 3*dim;
1784 dsysv_(&uplo, &dim, &nrhs,
fElem, &dim, &fPivot[0], &B, &dim, &fWork[0], &worksize, &info);
1789 #endif //USING_LAPACK 1791 template <
class TVar>
1795 Error(
"Decompose_LDLt <Matrix already Decomposed with other scheme> " );
1799 if ( this->
Rows()!=this->
Cols() )
Error(
"Decompose_LDLt <Matrix must be square>" );
1801 int64_t j,k,l,dim=this->
Rows();
1803 for ( j = 0; j < dim; j++ ) {
1804 for ( k=0; k<j; k++) {
1807 for ( k=0; k<j; k++) {
1808 for( l=j+1; l<dim;l++) {
1814 if (
IsZero(tmp) )
Error(
"Decompose_LDLt <Zero on diagonal>" );
1815 for( l=j+1; l<dim;l++) {
1837 char left[]=
"Left", upper[] =
"Upper", transpose[] =
"Transpose", non_unit[] =
"Non-unit";
1838 int ncol = b->
Cols();
1841 cblas_strsm(CblasColMajor, CblasLeft, CblasUpper, CblasTrans, CblasNonUnit, dim, ncol, 1.,
fElem, dim, b->
fElem, dim);
1862 char left[]=
"Left", upper[] =
"Upper", transpose[] =
"Transpose", non_unit[] =
"Non-unit";
1863 int ncol = b->
Cols();
1866 cblas_dtrsm(CblasColMajor, CblasLeft, CblasUpper, CblasTrans, CblasNonUnit, dim, ncol, 1.,
fElem, dim, b->
fElem, dim);
1881 template<
class TVar>
1891 template<
class TVar>
1906 char left[]=
"Left", upper[] =
"Upper", transpose[] =
"Transpose", non_unit[] =
"Non-unit";
1907 int ncol = b->
Cols();
1912 cblas_strsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans, CblasNonUnit, dim, ncol, 1.,
fElem, dim, b->
fElem, dim);
1936 char left[]=
"Left", upper[] =
"Upper", transpose[] =
"Transpose", non_unit[] =
"Non-unit";
1937 int ncol = b->
Cols();
1942 cblas_dtrsm(CblasColMajor, CblasLeft, CblasUpper, CblasNoTrans, CblasNonUnit, dim, ncol, 1.,
fElem, dim, b->
fElem, dim);
1973 int nrhs = b->
Cols();
1978 ssytrs_(&uplo, &dim, &nrhs,
fElem, &dim, &fPivot[0], b->
fElem, &dim, &info);
1997 int nrhs = b->
Cols();
2000 if (dim == 0 || nrhs == 0) {
2003 dsytrs_(&uplo, &dim, &nrhs,
fElem, &dim, &fPivot[0], b->
fElem, &dim, &info);
2013 template<
class TVar>
2044 template<
class TVar>
2074 template<
class TVar>
2079 #endif //USING_LAPACK 2082 template<
class TVar>
2084 int64_t size = (A.
Rows())*A.
Cols();
2086 if(!size)
return result;
2096 const TVar *fpA = &A.
g(0,0), *fpB = &B.
g(0,0);
2097 const TVar *fpLast = fpA+size;
2100 result += (*fpA++ * *fpB++);
2107 std::complex<float>
Dot(
const TPZFMatrix< std::complex<float> > &A,
const TPZFMatrix< std::complex<float> > &B);
2110 std::complex<double>
Dot(
const TPZFMatrix< std::complex<double> > &A,
const TPZFMatrix< std::complex<double> > &B);
2113 std::complex<long double>
Dot(
const TPZFMatrix< std::complex<long double> > &A,
const TPZFMatrix< std::complex<long double> > &B);
2145 template <
class TVar>
2147 return( A + value );
2151 template <
class TVar>
2153 return( A - value );
2160 template<
class TVar>
2163 out <<
"TPZFMatrix::" << msg1;
2164 if(msg2) out << msg2;
2174 template <
class TVar>
2204 template <
class TVar>
2207 int64_t row = this->
fRow;
2208 int64_t col = this->
fCol;
2224 template <
class TVar>
2235 template<
class TVar>
2239 if(!fmat)
return false;
2242 int64_t nel = this->
fRow*this->
fCol;
2246 for(iel=0; iel<nel; iel++)
2258 std::stringstream sout;
2259 sout << __PRETTY_FUNCTION__ <<
" did not compare ";
2260 sout <<
" number different terms " << numdif <<
" number terms " << this->
fRow*this->
fCol;
2261 sout <<
" difference in norm L1 " << diff;
2264 if(!matresult &&
override)
2276 template<
class TVar>
2280 if(!fmat)
return false;
2283 int64_t nel = this->
fRow*this->
fCol;
2287 for(iel=0; iel<nel; iel++)
2299 std::stringstream sout;
2300 sout << __PRETTY_FUNCTION__ <<
" did not compare ";
2301 sout <<
" number different terms " << numdif <<
" number terms " << this->
fRow*this->
fCol;
2302 sout <<
" difference in norm L1 " << diff;
2305 if(!matresult &&
override)
2320 template <
class TVar>
2324 out <<
"Writing matrix '";
2325 if(name) out << name;
2326 out <<
"' (" << rows <<
" x " << cols <<
"):\n";
2328 for ( int64_t row = 0; row < rows; row++) {
2330 for ( int64_t col = 0; col < cols; col++ ) {
2331 out <<
SELECTEL(ptr,rows, row, col) <<
" ";
2337 out << rows <<
" " << cols << endl;
2338 for ( int64_t row = 0; row < rows; row++) {
2339 for ( int64_t col = 0; col < cols; col++ ) {
2341 if(val != (TVar)0.) out << row <<
' ' << col <<
' ' << val << std::endl;
2344 out <<
"-1 -1 0.\n";
2348 out << name <<
"\n{ ";
2349 for ( int64_t row = 0; row < rows; row++) {
2351 for ( int64_t col = 0; col < cols; col++ ) {
2353 sprintf(number,
"%16.16lf", (
double)
fabs(val));
2357 if((col+1) % 6 == 0)out << std::endl;
2370 template<
class TVar>
2375 template <
class TVar>
2377 int64_t newsize = ((int64_t)newRows)*newCols;
2378 int64_t oldsize = this->
fRow*this->
fCol;
2379 if(newsize == oldsize)
return 1;
2390 fElem =
new TVar[ newRows * newCols ] ;
2392 if (newsize &&
fElem == NULL )
2393 Error(
"Resize <memory allocation error>." );
2400 template <
class TVar>
2407 template <
class TVar>
2420 char jobvl[] =
"None", jobvr[] =
"None";
2424 int lwork = 10+20*dim;
2426 std::complex<float> I(0,1.);
2432 sgeev_(jobvl, jobvr, &dim, temp.
fElem, &dim, &realeigen[0], &imageigen[0], VL.fElem, &dim, VR.
fElem, &dim, &work[0], &lwork, &info);
2439 eigenvalues.Resize(dim,0.);
2440 for(
int i = 0 ; i < dim ; i ++){
2442 eigenvalues[i] = realeigen[i] + I*imageigen[i];
2453 char jobvl[] =
"None", jobvr[] =
"Vectors";
2457 int lwork = 10+20*dim;
2459 std::complex<float> I(0,1.);
2465 sgeev_(jobvl, jobvr, &dim, temp.
fElem, &dim, &realeigen[0], &imageigen[0], VL.fElem, &dim, VR.
fElem, &dim, &work[0], &lwork, &info);
2472 eigenvectors.Redim(dim,dim);
2473 eigenvalues.Resize(dim,0.);
2474 for(
int i = 0 ; i < dim ; i ++){
2475 eigenvalues[i] = realeigen[i] + I*imageigen[i];
2477 for(
int i = 0 ; i < dim ; i ++){
2478 if(imageigen[i] == 0){
2479 for(
int iV = 0 ; iV < dim ; iV++ ){
2480 eigenvectors(iV,i) = VR(iV,i);
2484 for(
int iV = 0 ; iV < dim ; iV++ ){
2485 eigenvectors(iV,i) = VR(iV,i) + I * VR(iV,i+1) ;
2486 eigenvectors(iV,i + 1) = VR(iV,i) - I * VR(iV,i+1) ;
2501 char jobvl[] =
"None", jobvr[] =
"None";
2505 int lwork = 10+20*dim;
2507 std::complex<double> I(0,1.);
2513 dgeev_(jobvl, jobvr, &dim, temp.
fElem, &dim, &realeigen[0], &imageigen[0], VL.fElem, &dim, VR.
fElem, &dim, &work[0], &lwork, &info);
2520 eigenvalues.Resize(dim,0.);
2521 for(
int i = 0 ; i < dim ; i ++){
2522 eigenvalues[i] = realeigen[i] + I*imageigen[i];
2533 char jobvl[] =
"None", jobvr[] =
"Vectors";
2537 int lwork = 10+50*dim;
2539 std::complex<double> I(0,1.);
2545 dgeev_(jobvl, jobvr, &dim, temp.
fElem, &dim, &realeigen[0], &imageigen[0], VL.fElem, &dim, VR.
fElem, &dim, &work[0], &lwork, &info);
2552 eigenvectors.Redim(dim,dim);
2553 eigenvalues.Resize(dim,0.);
2554 for(
int i = 0 ; i < dim ; i ++){
2555 eigenvalues[i] = realeigen[i] + I*imageigen[i];
2557 for(
int i = 0 ; i < dim ; i ++){
2558 if(imageigen[i] == 0){
2559 for(
int iV = 0 ; iV < dim ; iV++ ){
2560 eigenvectors(iV,i) = VR(iV,i);
2564 double *realVRptr = VR.
fElem;
2565 double *imagVRptr = VR.
fElem + dim;
2566 for(
int iV = 0 ; iV < dim ; iV++ ){
2567 eigenvectors(iV,i) = VR(iV,i) + I * VR(iV,i+1) ;
2568 eigenvectors(iV,i + 1) = VR(iV,i) - I * VR(iV,i+1) ;
2583 char jobvl[] =
"None", jobvr[] =
"Vectors";
2587 int lwork = 10+20*dim;
2589 std::complex<double> I(0,1.);
2598 zgeev_(jobvl, jobvr, &dim, (vardoublecomplex *)temp.
fElem, &dim, (vardoublecomplex *)&eigen[0], (vardoublecomplex *)VL.fElem, &dim, (vardoublecomplex *)VR.
fElem, &dim, (vardoublecomplex *)&work[0], &lwork, &rwork[0], &info);
2604 eigenvalues.Resize(dim,0.);
2605 for(
int i = 0 ; i < dim ; i ++){
2606 eigenvalues[i] = eigen[i];
2618 char jobvl[] =
"None", jobvr[] =
"Vectors";
2622 int lwork = 10+20*dim;
2624 std::complex<double> I(0,1.);
2632 typedef MKL_Complex16 vardoublecomplex;
2634 typedef __CLPK_doublecomplex vardoublecomplex ;
2638 zgeev_(jobvl, jobvr, &dim, (vardoublecomplex *)temp.
fElem, &dim, (vardoublecomplex *)&eigen[0], (vardoublecomplex *)VL.fElem, &dim, (vardoublecomplex *)VR.
fElem, &dim, (vardoublecomplex *)&work[0], &lwork, &rwork[0], &info);
2645 eigenvectors.Redim(dim,dim);
2646 eigenvalues.Resize(dim,0.);
2647 for(
int i = 0 ; i < dim ; i ++){
2648 eigenvalues[i] = eigen[i];
2650 for(
int i = 0 ; i < dim ; i ++){
2652 for(
int iV = 0 ; iV < dim ; iV++ ){
2653 eigenvectors(iV,i) = VR(iV,i);
2667 char jobvl[] =
"None", jobvr[] =
"Vectors";
2671 int lwork = 10+20*dim;
2673 std::complex<float> I(0,1.);
2680 cgeev_(jobvl, jobvr, &dim, (varfloatcomplex *)temp.
fElem, &dim, (varfloatcomplex *)&eigen[0], (varfloatcomplex *)VL.fElem, &dim, (varfloatcomplex *)VR.
fElem, &dim, (varfloatcomplex *)&work[0], &lwork, &rwork[0], &info);
2687 eigenvalues.Resize(dim,0.);
2688 for(
int i = 0 ; i < dim ; i ++){
2689 eigenvalues[i] = eigen[i];
2700 char jobvl[] =
"None", jobvr[] =
"Vectors";
2704 int lwork = 10+20*dim;
2706 std::complex<float> I(0,1.);
2713 cgeev_(jobvl, jobvr, &dim, (varfloatcomplex *)temp.
fElem, &dim, (varfloatcomplex *)&eigen[0], (varfloatcomplex *)VL.fElem, &dim, (varfloatcomplex *)VR.
fElem, &dim, (varfloatcomplex *)&work[0], &lwork, &rwork[0], &info);
2720 eigenvectors.Redim(dim,dim);
2721 eigenvalues.Resize(dim,0.);
2722 for(
int i = 0 ; i < dim ; i ++){
2723 eigenvalues[i] = eigen[i];
2725 for(
int i = 0 ; i < dim ; i ++){
2727 for(
int iV = 0 ; iV < dim ; iV++ ){
2728 eigenvectors(iV,i) = VR(iV,i);
2737 template<
class TVar>
2741 TPZMatrix<TVar>::Error(__PRETTY_FUNCTION__,
"SolveGeneralisedEigenProblem <LAPACK does not support this specific data type>" );
2744 template<
class TVar>
2748 TPZMatrix<TVar>::Error(__PRETTY_FUNCTION__,
"SolveGeneralisedEigenProblem <LAPACK does not support this specific data type>" );
2761 char jobvl[] =
"None", jobvr[] =
"Vectors";
2765 int lwork = 10+20*dim;
2767 std::complex<float> I(0,1.);
2776 sggev_(jobvl, jobvr, &dim, temp.fElem, &dim , tempB.
fElem, &dim , &realeigen[0], &imageigen[0], &beta[0] , VL.fElem, &dim , VR.
fElem, &dim, &work[0], &lwork, &info);
2783 eigenvectors.Redim(dim,dim);
2784 eigenvalues.Resize(dim,0.);
2785 for(
int i = 0 ; i < dim ; i ++){
2790 eigenvalues[i] = (realeigen[i] + I*imageigen[i]) / beta[i];
2793 for(
int i = 0 ; i < dim ; i ++){
2794 if(imageigen[i] == 0){
2795 for(
int iV = 0 ; iV < dim ; iV++ ){
2796 eigenvectors(iV,i) = VR(iV,i);
2800 for(
int iV = 0 ; iV < dim ; iV++ ){
2801 eigenvectors(iV,i) = VR(iV,i) + I * VR(iV,i+1) ;
2802 eigenvectors(iV,i + 1) = VR(iV,i) - I * VR(iV,i+1) ;
2821 char jobvl[] =
"None", jobvr[] =
"None";
2825 int lwork = 10+20*dim;
2827 std::complex<float> I(0,1.);
2836 sggev_(jobvl, jobvr, &dim, temp.fElem, &dim , tempB.
fElem, &dim , &realeigen[0], &imageigen[0], &beta[0] , VL.fElem, &dim , VR.
fElem, &dim, &work[0], &lwork, &info);
2843 eigenvalues.Resize(dim,0.);
2844 for(
int i = 0 ; i < dim ; i ++){
2849 eigenvalues[i] = (realeigen[i] + I*imageigen[i]) / beta[i];
2864 char jobvl[] =
"None", jobvr[] =
"Vectors";
2868 int lwork = 10+20*dim;
2870 std::complex<double> I(0,1.);
2879 dggev_(jobvl, jobvr, &dim, temp.fElem, &dim , tempB.
fElem, &dim , &realeigen[0], &imageigen[0], &beta[0] , VL.fElem, &dim , VR.
fElem, &dim, &work[0], &lwork, &info);
2886 eigenvectors.Redim(dim,dim);
2887 eigenvalues.Resize(dim,0.);
2888 for(
int i = 0 ; i < dim ; i ++){
2893 eigenvalues[i] = (realeigen[i] + I*imageigen[i]) / beta[i];
2896 for(
int i = 0 ; i < dim ; i ++){
2897 if(imageigen[i] == 0){
2898 for(
int iV = 0 ; iV < dim ; iV++ ){
2899 eigenvectors(iV,i) = VR(iV,i);
2903 for(
int iV = 0 ; iV < dim ; iV++ ){
2904 eigenvectors(iV,i) = VR(iV,i) + I * VR(iV,i+1) ;
2905 eigenvectors(iV,i + 1) = VR(iV,i) - I * VR(iV,i+1) ;
2924 char jobvl[] =
"None", jobvr[] =
"None";
2928 int lwork = 10+20*dim;
2930 std::complex<double> I(0,1.);
2939 dggev_(jobvl, jobvr, &dim, temp.fElem, &dim , tempB.
fElem, &dim , &realeigen[0], &imageigen[0], &beta[0] , VL.fElem, &dim , VR.
fElem, &dim, &work[0], &lwork, &info);
2946 eigenvalues.Resize(dim,0.);
2947 for(
int i = 0 ; i < dim ; i ++){
2952 eigenvalues[i] = (realeigen[i] + I*imageigen[i]) / beta[i];
2968 char jobvl[] =
"None", jobvr[] =
"Vectors";
2972 int lwork = 10+20*dim;
2982 cggev_(jobvl, jobvr, &dim, (varfloatcomplex *)temp.fElem, &dim , (varfloatcomplex *)tempB.
fElem, &dim , (varfloatcomplex *)&eigen[0], (varfloatcomplex *)&beta[0] , (varfloatcomplex *)VL.fElem, &dim , (varfloatcomplex *)VR.
fElem, &dim, (varfloatcomplex *)&work[0], &lwork, &rwork[0], &info);
2989 eigenvectors.Redim(dim,dim);
2990 eigenvalues.Resize(dim,0.);
2991 for(
int i = 0 ; i < dim ; i ++){
2996 eigenvalues[i] = eigen[i] / beta[i];
2999 for(
int i = 0 ; i < dim ; i ++){
3000 for(
int iV = 0 ; iV < dim ; iV++ ){
3001 eigenvectors(iV,i) = VR(iV,i);
3018 char jobvl[] =
"None", jobvr[] =
"None";
3022 int lwork = 10+20*dim;
3032 cggev_(jobvl, jobvr, &dim, (varfloatcomplex *)temp.fElem, &dim , (varfloatcomplex *)tempB.
fElem, &dim , (varfloatcomplex *)&eigen[0], (varfloatcomplex *)&beta[0] , (varfloatcomplex *)VL.fElem, &dim , (varfloatcomplex *)VR.
fElem, &dim, (varfloatcomplex *)&work[0], &lwork, &rwork[0], &info);
3039 eigenvalues.Resize(dim,0.);
3040 for(
int i = 0 ; i < dim ; i ++){
3045 eigenvalues[i] = eigen[i] / beta[i];
3061 char jobvl[] =
"None", jobvr[] =
"Vectors";
3065 int lwork = 10+20*dim;
3075 zggev_(jobvl, jobvr, &dim, (vardoublecomplex *)temp.fElem, &dim , (vardoublecomplex *)tempB.
fElem, &dim , (vardoublecomplex *)&eigen[0], (vardoublecomplex *)&beta[0] , (vardoublecomplex *)VL.fElem, &dim , (vardoublecomplex *)VR.
fElem, &dim, (vardoublecomplex *)&work[0], &lwork, &rwork[0], &info);
3082 eigenvectors.Redim(dim,dim);
3083 eigenvalues.Resize(dim,0.);
3084 for(
int i = 0 ; i < dim ; i ++){
3089 eigenvalues[i] = eigen[i] / beta[i];
3092 for(
int i = 0 ; i < dim ; i ++){
3093 for(
int iV = 0 ; iV < dim ; iV++ ){
3094 eigenvectors(iV,i) = VR(iV,i);
3111 char jobvl[] =
"None", jobvr[] =
"None";
3115 int lwork = 10+20*dim;
3125 zggev_(jobvl, jobvr, &dim, (vardoublecomplex *)temp.fElem, &dim , (vardoublecomplex *)tempB.
fElem, &dim , (vardoublecomplex *)&eigen[0], (vardoublecomplex *)&beta[0] , (vardoublecomplex *)VL.fElem, &dim , (vardoublecomplex *)VR.
fElem, &dim, (vardoublecomplex *)&work[0], &lwork, &rwork[0], &info);
3132 eigenvalues.Resize(dim,0.);
3133 for(
int i = 0 ; i < dim ; i ++){
3138 eigenvalues[i] = eigen[i] / beta[i];
3146 #endif // USING_LAPACK 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
Contains declaration of the TPZSavable class which defines the interface to save and restore objects ...
TPZFMatrix< TVar > operator*(TPZFMatrix< TVar > A) const
void ZAXPY(const TVar alpha, const TPZFMatrix< TVar > &p)
Performs an ZAXPY operation being *this += alpha * p.
bool IsZero(long double a)
Returns if the value a is close Zero as the allowable tolerance.
int Solve_LU(TPZFMatrix< TVar > *B, std::list< int64_t > &singular)
Solves the linear system using LU method .
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.
TVar & operator()(const int64_t row, const int64_t col)
void GramSchmidt(TPZFMatrix< TVar > &Orthog, TPZFMatrix< TVar > &TransfToOrthog)
This method implements a Gram Schimidt method. this = Orthog.TransfToOrthog.
static int Error(const char *msg, const char *msg2=0)
Returns error messages.
void AddFel(TPZFMatrix< TVar > &rhs, TPZVec< int64_t > &destination)
Performs a right hand side assemblage.
TPZFMatrix< TVar > & operator*=(const TVar val)
Templated vector implementation.
TPZFMatrix< TVar > & operator-=(const TPZFMatrix< TVar > &A)
MatrixOutputFormat
Defines output format.
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.
virtual const TVar & Get(const int64_t row, const int64_t col) const
Get value with bound checking.
static int Error(const char *msg1, const char *msg2=0)
virtual int Decompose_LU() override
char fDecomposed
Decomposition type used to decompose the current matrix.
TVar Dot(const TPZFMatrix< TVar > &A, const TPZFMatrix< TVar > &B)
Implement dot product for matrices.
virtual int Subst_LBackward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is upper triangular with A(i,i)=1.
TPZFMatrix< TVar > & operator+=(const TPZFMatrix< TVar > &A)
REAL val(STATE &number)
Returns value of the variable.
virtual int Subst_Forward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is lower triangular.
AutoPointerMutexArrayInit tmp
int ClassId() const override
Routines to send and receive messages.
char fDefPositive
Definite Posistiveness of current matrix.
virtual const TVar & GetVal(const int64_t, const int64_t) const
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
virtual int Decompose_LDLt() override
Decomposes the current matrix using LDLt. The current matrix has to be symmetric. "L" is lower triangular with 1.0 in its diagonal and "D" is a Diagonal matrix.
TPZFMatrix< TVar > operator-(const TPZFMatrix< TVar > &A) 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...
virtual void Write(const bool val)
TVar Norm(const TPZFMatrix< TVar > &A)
Returns the norm of the matrix A.
Contains TPZMatrixclass which implements full matrix (using column major representation).
#define DebugStop()
Returns a message to user put a breakpoint in.
Implements a matrix whose nonzero elements are stored in binary tree. Matrix.
#define LOGPZ_DEBUG(A, B)
Define log for debug info.
virtual bool Compare(TPZSavable *copy, bool override=false) override
Compare the object for identity with the object pointed to, eventually copy the object.
int64_t Rows() const
Returns number of rows.
virtual int Subst_Diag(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is diagonal matrix.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
virtual TPZFMatrix & operator=(const TPZFMatrix< TVar > &A)
Generic operator with FULL matrices.
static int Substitution(const TVar *ptr, int64_t rows, TPZFMatrix< TVar > *B)
#define GETVAL(MAT, rows, row, col)
MACRO to get MAT(row,col) entry.
void Read(TPZStream &buf, void *context) override
Unpacks the object structure from a stream of bytes.
#define LOGPZ_ERROR(A, B)
Define log for errors (cout)
Full matrix class. Matrix.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
virtual int Subst_LForward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is lower triangular with A(i,i)=1.
virtual int64_t Dim() const
Returns the dimension of the matrix if the matrix is square.
int32_t Hash(std::string str)
Contains TPZMatrix<TVar>class, root matrix class.
int64_t fCol
Number of cols in matrix.
#define PUTVAL(MAT, rows, row, col, val)
MACRO to put value val into MAT(row,col) entry.
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.
void Read(TPZStream &buf, void *context) override
read objects from the stream
int Clear() override
It clears data structure.
virtual void Multiply(const TPZFMatrix< TVar > &A, TPZFMatrix< TVar > &res, int opt=0) const
It mutiplies itself by TPZMatrix<TVar>A putting the result in res.
void TimesBetaPlusZ(const TVar beta, const TPZFMatrix< TVar > &z)
Performs an operation *this = this * beta + z.
int Remodel(const int64_t newRows, const int64_t wCols)
Remodel the shape of the matrix, but keeping the same dimension.
This class implements floating point number associated with a counter of the operations performed wit...
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.
Contains TPZVerySparseMatrix class which implements a matrix whose nonzero elements are stored in bin...
int64_t Cols() const
Returns number of cols.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ exp
virtual void Print(std::ostream &out) const
int Resize(const int64_t newRows, const int64_t wCols) override
Redimension a matrix, but maintain your elements.
virtual int Decompose_Cholesky() override
Cholesky Decomposition Optmized. for walks in the direction of the vector that composes the matrix...
Defines the interface for saving and reading data. Persistency.
int64_t NElements() const
Returns the number of elements of the vector.
void DeterminantInverse(TVar &determinant, TPZFMatrix< TVar > &inverse)
std::map< std::pair< int64_t, int64_t >, TVar >::const_iterator MapEnd() const
#define SELECTEL(ptr, rows, row, col)
MACRO to get the entry of the vector (ptr[col*rows+row]) as matrix ( ptr(row,col) ) ...
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
int SetSize(int64_t newRows, int64_t newCols)
Redimension the matrix doing nothing with the elements.
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
static void PrintStatic(const TVar *ptr, int64_t rows, int64_t cols, const char *name, std::ostream &out, const MatrixOutputFormat form)
virtual bool Compare(TPZSavable *copy, bool override=false) override
Compare the object for identity with the object pointed to, eventually copy the object.
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.
void Transpose(TPZMatrix< TVar > *const T) const override
It makes *T the transpose of current matrix.
TVar & g(const int64_t row, const int64_t col) const
TPZFMatrix< TVar > operator+(const TPZFMatrix< TVar > &A) const
std::map< std::pair< int64_t, int64_t >, TVar >::const_iterator MapBegin() const
Implements an interface to register a class id and a restore function. Persistence.
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
#define PZError
Defines the output device to error messages and the DebugStop() function.
int ClassId() const override
Define the class id associated with the class.
virtual void Read(bool &val)
virtual int Subst_Backward(TPZFMatrix< TVar > *b) const
Computes B = Y, where A*Y = B, A is upper triangular.
TPZFMatrix()
Simple constructor.
Root matrix class (abstract). Matrix.