25 #include <queso/GslMatrix.h>
26 #include <queso/GslVector.h>
27 #include <queso/Defines.h>
28 #include <gsl/gsl_linalg.h>
29 #include <gsl/gsl_eigen.h>
42 "GslMatrix::constructor(), default",
43 "should not be used by user");
52 m_mat (gsl_matrix_calloc(map.NumGlobalElements(),nCols)),
60 m_determinant (-INFINITY),
61 m_lnDeterminant(-INFINITY),
68 "GslMatrix::constructor()",
69 "null matrix generated");
79 m_mat (gsl_matrix_calloc(map.NumGlobalElements(),map.NumGlobalElements())),
87 m_determinant (-INFINITY),
88 m_lnDeterminant(-INFINITY),
95 "GslMatrix::constructor(), eye",
96 "null matrix generated");
98 for (
unsigned int i = 0; i <
m_mat->size1; ++i) {
99 (*this)(i,i) = diagValue;
108 m_mat (gsl_matrix_calloc(v.sizeLocal(),v.sizeLocal())),
116 m_determinant (-INFINITY),
117 m_lnDeterminant(-INFINITY),
118 m_permutation (NULL),
124 "GslMatrix::constructor(), eye",
125 "null matrix generated");
127 for (
unsigned int i = 0; i <
m_mat->size1; ++i) {
128 (*this)(i,i) = diagValue;
135 m_mat (gsl_matrix_calloc(v.sizeLocal(),v.sizeLocal())),
143 m_determinant (-INFINITY),
144 m_lnDeterminant(-INFINITY),
145 m_permutation (NULL),
151 "GslMatrix::constructor(), from vector",
152 "null matrix generated");
155 for (
unsigned int i = 0; i < dim; ++i) {
164 m_mat (gsl_matrix_calloc(B.numRowsLocal(),B.numCols())),
172 m_determinant (-INFINITY),
173 m_lnDeterminant(-INFINITY),
174 m_permutation (NULL),
180 "GslMatrix::constructor(), copy",
181 "null vector generated");
207 iRC = gsl_matrix_scale(
m_mat,a);
210 "GslMatrix::operator*=()",
232 "GslMatrix::operator+=()",
246 "GslMatrix::operator-=()",
257 if ((i >=
m_mat->size1) ||
258 (j >=
m_mat->size2)) {
259 std::cerr <<
"In GslMatrix::operator(i,j)"
262 <<
", m_mat->size1 = " <<
m_mat->size1
263 <<
", m_mat->size2 = " <<
m_mat->size2
267 "GslMatrix::operator(i,j)",
271 "GslMatrix::operator(i,j)",
274 return *gsl_matrix_ptr(
m_mat,i,j);
282 "GslMatrix::operator(i,j) const",
286 "GslMatrix::operator(i,j) const",
288 return *gsl_matrix_const_ptr(
m_mat,i,j);
296 iRC = gsl_matrix_memcpy(this->
m_mat, src.
m_mat);
309 gsl_matrix_free(
m_LU);
372 unsigned int nCols = this->
numCols();
374 for (
unsigned int i = 0; i < nRows; i++) {
375 for (
unsigned int j = 0; j < nCols; j++) {
390 unsigned int nCols = this->
numCols();
392 for (
unsigned int i = 0; i < nRows; i++) {
393 for (
unsigned int j = 0; j < nCols; j++) {
394 aux = fabs((*
this)(i,j));
395 if (aux > value) value = aux;
405 double value = -INFINITY;
408 unsigned int nCols = this->
numCols();
410 for (
unsigned int i = 0; i < nRows; i++) {
411 for (
unsigned int j = 0; j < nCols; j++) {
413 if (aux > value) value = aux;
424 unsigned int nCols = this->
numCols();
426 for (
unsigned int row = 0; row < nRows; ++row) {
427 for (
unsigned int col = 0; col < nCols; ++col) {
428 *gsl_matrix_ptr(
m_mat,row,col) = value;
437 unsigned int initialTargetRowId,
438 unsigned int initialTargetColId,
443 "GslMatrix::cwSet()",
444 "invalid initialTargetRowId");
448 "GslMatrix::cwSet()",
449 "invalid vec.numRowsLocal()");
453 "GslMatrix::cwSet()",
454 "invalid initialTargetColId");
458 "GslMatrix::cwSet()",
459 "invalid vec.numCols()");
462 for (
unsigned int j = 0; j < mat.
numCols(); ++j) {
463 (*this)(initialTargetRowId+i,initialTargetColId+j) = mat(i,j);
472 unsigned int initialTargetRowId,
473 unsigned int initialTargetColId,
478 "GslMatrix::cwExtract()",
479 "invalid initialTargetRowId");
483 "GslMatrix::cwExtract()",
484 "invalid vec.numRowsLocal()");
488 "GslMatrix::cwExtract()",
489 "invalid initialTargetColId");
493 "GslMatrix::cwExtract()",
494 "invalid vec.numCols()");
497 for (
unsigned int j = 0; j < mat.
numCols(); ++j) {
498 mat(i,j) = (*this)(initialTargetRowId+i,initialTargetColId+j) ;
510 gsl_error_handler_t* oldHandler;
511 oldHandler = gsl_set_error_handler_off();
512 iRC = gsl_linalg_cholesky_decomp(
m_mat);
514 std::cerr <<
"In GslMatrix::chol()"
516 <<
", gsl error message = " << gsl_strerror(iRC)
518 std::cerr <<
"Here is the offending matrix: " << std::endl;
519 std::cerr << *
this << std::endl;
521 gsl_set_error_handler(oldHandler);
526 "matrix is not positive definite",
536 unsigned int nCols = this->
numCols();
566 unsigned int nCols = this->
numCols();
570 "GslMatrix::svdSolve()",
575 "GslMatrix::svdSolve()",
583 <<
", this->numCols() = " << this->
numCols()
589 <<
"\n rhsVec.sizeLocal() = " << rhsVec.
sizeLocal()
590 <<
"\n solVec.sizeLocal() = " << solVec.
sizeLocal()
603 unsigned int nCols = this->
numCols();
607 "GslMatrix::svdSolve()",
612 "GslMatrix::svdSolve()",
617 "GslMatrix::svdSolve()",
618 "rhsMat and solMat are not compatible");
623 for (
unsigned int j = 0; j < rhsMat.
numCols(); ++j) {
625 iRC = this->
svdSolve(rhsVec, solVec);
660 unsigned int nCols = this->
numCols();
663 "GslMatrix::internalSvd()",
664 "GSL only supports cases where nRows >= nCols");
677 struct timeval timevalBegin;
678 gettimeofday(&timevalBegin, NULL);
679 gsl_error_handler_t* oldHandler;
680 oldHandler = gsl_set_error_handler_off();
688 std::cerr <<
"In GslMatrix::internalSvd()"
690 <<
", gsl error message = " << gsl_strerror(iRC)
693 gsl_set_error_handler(oldHandler);
695 struct timeval timevalNow;
696 gettimeofday(&timevalNow, NULL);
704 "GslMatrix::internalSvd()",
719 unsigned int nCols = this->
numCols();
723 "GslMatrix::zeroLower()",
724 "routine works only for square matrices");
728 if (includeDiagonal) {
729 for (
unsigned int i = 0; i < nRows; i++) {
730 for (
unsigned int j = 0; j <= i; j++) {
736 for (
unsigned int i = 0; i < nRows; i++) {
737 for (
unsigned int j = 0; j < i; j++) {
750 unsigned int nCols = this->
numCols();
754 "GslMatrix::zeroUpper()",
755 "routine works only for square matrices");
759 if (includeDiagonal) {
760 for (
unsigned int i = 0; i < nRows; i++) {
761 for (
unsigned int j = i; j < nCols; j++) {
767 for (
unsigned int i = 0; i < nRows; i++) {
768 for (
unsigned int j = (i+1); j < nCols; j++) {
781 unsigned int nCols = this->
numCols();
782 for (
unsigned int i = 0; i < nRows; ++i) {
783 for (
unsigned int j = 0; j < nCols; ++j) {
784 double aux = (*this)(i,j);
787 (-thresholdValue < aux)) {
791 (thresholdValue > aux)) {
804 unsigned int nCols = this->
numCols();
805 for (
unsigned int i = 0; i < nRows; ++i) {
806 for (
unsigned int j = 0; j < nCols; ++j) {
807 double aux = (*this)(i,j);
810 (-thresholdValue > aux)) {
814 (thresholdValue < aux)) {
827 unsigned int nCols = this->
numCols();
831 "GslMatrix::transpose()",
832 "routine works only for square matrices");
835 for (
unsigned int row = 0; row < nRows; ++row) {
836 for (
unsigned int col = 0; col < nCols; ++col) {
837 mat(row,col) = (*this)(col,row);
848 unsigned int nCols = this->
numCols();
852 "GslMatrix::inverse()",
853 "matrix is not square");
858 unitVector.
cwSet(0.);
860 for (
unsigned int j = 0; j < nCols; ++j) {
861 if (j > 0) unitVector[j-1] = 0.;
864 for (
unsigned int i = 0; i < nRows; ++i) {
865 (*m_inverse)(i,j) = multVector[i];
877 <<
"\n M = " << *
this
879 <<
"\n M*M^{-1} = " << (*this)*(*m_inverse)
880 <<
"\n M^{-1}*M = " << (*m_inverse)*(*this)
889 unsigned int initialTargetRowId,
890 unsigned int initialTargetColId,
891 const std::vector<const GslMatrix* >& matrices,
892 bool checkForExactNumRowsMatching,
893 bool checkForExactNumColsMatching)
895 unsigned int sumNumRowsLocals = 0;
896 unsigned int sumNumCols = 0;
897 for (
unsigned int i = 0; i < matrices.size(); ++i) {
898 sumNumRowsLocals += matrices[i]->numRowsLocal();
899 sumNumCols += matrices[i]->numCols();
903 "GslMatrix::fillWithBlocksDiagonally(const)",
904 "too big number of rows");
907 "GslMatrix::fillWithBlocksDiagonally(const)",
908 "inconsistent number of rows");
911 "GslMatrix::fillWithBlocksDiagonally(const)",
912 "too big number of cols");
915 "GslMatrix::fillWithBlocksDiagonally(const)",
916 "inconsistent number of cols");
918 unsigned int cumulativeRowId = 0;
919 unsigned int cumulativeColId = 0;
920 for (
unsigned int i = 0; i < matrices.size(); ++i) {
921 unsigned int nRows = matrices[i]->numRowsLocal();
922 unsigned int nCols = matrices[i]->numCols();
923 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
924 for (
unsigned int colId = 0; colId < nCols; ++colId) {
925 (*this)(initialTargetRowId + cumulativeRowId + rowId, initialTargetColId + cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
928 cumulativeRowId += nRows;
929 cumulativeColId += nCols;
937 unsigned int initialTargetRowId,
938 unsigned int initialTargetColId,
939 const std::vector<GslMatrix* >& matrices,
940 bool checkForExactNumRowsMatching,
941 bool checkForExactNumColsMatching)
943 unsigned int sumNumRowsLocals = 0;
944 unsigned int sumNumCols = 0;
945 for (
unsigned int i = 0; i < matrices.size(); ++i) {
946 sumNumRowsLocals += matrices[i]->numRowsLocal();
947 sumNumCols += matrices[i]->numCols();
951 "GslMatrix::fillWithBlocksDiagonally()",
952 "too big number of rows");
955 "GslMatrix::fillWithBlocksDiagonally()",
956 "inconsistent number of rows");
959 "GslMatrix::fillWithBlocksDiagonally()",
960 "too big number of cols");
963 "GslMatrix::fillWithBlocksDiagonally()",
964 "inconsistent number of cols");
966 unsigned int cumulativeRowId = 0;
967 unsigned int cumulativeColId = 0;
968 for (
unsigned int i = 0; i < matrices.size(); ++i) {
969 unsigned int nRows = matrices[i]->numRowsLocal();
970 unsigned int nCols = matrices[i]->numCols();
971 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
972 for (
unsigned int colId = 0; colId < nCols; ++colId) {
973 (*this)(initialTargetRowId + cumulativeRowId + rowId, initialTargetColId + cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
976 cumulativeRowId += nRows;
977 cumulativeColId += nCols;
985 unsigned int initialTargetRowId,
986 unsigned int initialTargetColId,
987 const std::vector<const GslMatrix* >& matrices,
988 bool checkForExactNumRowsMatching,
989 bool checkForExactNumColsMatching)
991 unsigned int sumNumCols = 0;
992 for (
unsigned int i = 0; i < matrices.size(); ++i) {
995 "GslMatrix::fillWithBlocksHorizontally(const)",
996 "too big number of rows");
999 "GslMatrix::fillWithBlocksHorizontally(const)",
1000 "inconsistent number of rows");
1001 sumNumCols += matrices[i]->numCols();
1005 "GslMatrix::fillWithBlocksHorizontally(const)",
1006 "too big number of cols");
1009 "GslMatrix::fillWithBlocksHorizontally(const)",
1010 "inconsistent number of cols");
1012 unsigned int cumulativeColId = 0;
1013 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1014 unsigned int nRows = matrices[i]->numRowsLocal();
1015 unsigned int nCols = matrices[i]->numCols();
1016 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
1017 for (
unsigned int colId = 0; colId < nCols; ++colId) {
1018 (*this)(initialTargetRowId + rowId, initialTargetColId + cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
1021 cumulativeColId += nCols;
1029 unsigned int initialTargetRowId,
1030 unsigned int initialTargetColId,
1031 const std::vector<GslMatrix* >& matrices,
1032 bool checkForExactNumRowsMatching,
1033 bool checkForExactNumColsMatching)
1035 unsigned int sumNumCols = 0;
1036 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1039 "GslMatrix::fillWithBlocksHorizontally()",
1040 "too big number of rows");
1043 "GslMatrix::fillWithBlocksHorizontally()",
1044 "inconsistent number of rows");
1045 sumNumCols += matrices[i]->numCols();
1049 "GslMatrix::fillWithBlocksHorizontally()",
1050 "too big number of cols");
1053 "GslMatrix::fillWithBlocksHorizontally()",
1054 "inconsistent number of cols");
1056 unsigned int cumulativeColId = 0;
1057 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1058 unsigned int nRows = matrices[i]->numRowsLocal();
1059 unsigned int nCols = matrices[i]->numCols();
1060 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
1061 for (
unsigned int colId = 0; colId < nCols; ++colId) {
1062 (*this)(initialTargetRowId + rowId, initialTargetColId + cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
1065 cumulativeColId += nCols;
1073 unsigned int initialTargetRowId,
1074 unsigned int initialTargetColId,
1075 const std::vector<const GslMatrix* >& matrices,
1076 bool checkForExactNumRowsMatching,
1077 bool checkForExactNumColsMatching)
1079 unsigned int sumNumRows = 0;
1080 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1083 "GslMatrix::fillWithBlocksVertically(const)",
1084 "too big number of cols");
1087 "GslMatrix::fillWithBlocksVertically(const)",
1088 "inconsistent number of cols");
1089 sumNumRows += matrices[i]->numRowsLocal();
1093 "GslMatrix::fillWithBlocksVertically(const)",
1094 "too big number of rows");
1097 "GslMatrix::fillWithBlocksVertically(const)",
1098 "inconsistent number of rows");
1100 unsigned int cumulativeRowId = 0;
1101 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1102 unsigned int nRows = matrices[i]->numRowsLocal();
1103 unsigned int nCols = matrices[i]->numCols();
1104 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
1105 for (
unsigned int colId = 0; colId < nCols; ++colId) {
1106 (*this)(initialTargetRowId + cumulativeRowId + rowId, initialTargetColId + colId) = (*(matrices[i]))(rowId,colId);
1109 cumulativeRowId += nRows;
1117 unsigned int initialTargetRowId,
1118 unsigned int initialTargetColId,
1119 const std::vector<GslMatrix* >& matrices,
1120 bool checkForExactNumRowsMatching,
1121 bool checkForExactNumColsMatching)
1123 unsigned int sumNumRows = 0;
1124 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1127 "GslMatrix::fillWithBlocksVertically()",
1128 "too big number of cols");
1131 "GslMatrix::fillWithBlocksVertically()",
1132 "inconsistent number of cols");
1133 sumNumRows += matrices[i]->numRowsLocal();
1137 "GslMatrix::fillWithBlocksVertically()",
1138 "too big number of rows");
1141 "GslMatrix::fillWithBlocksVertically()",
1142 "inconsistent number of rows");
1144 unsigned int cumulativeRowId = 0;
1145 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1146 unsigned int nRows = matrices[i]->numRowsLocal();
1147 unsigned int nCols = matrices[i]->numCols();
1148 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
1149 for (
unsigned int colId = 0; colId < nCols; ++colId) {
1150 (*this)(initialTargetRowId + cumulativeRowId + rowId, initialTargetColId + colId) = (*(matrices[i]))(rowId,colId);
1153 cumulativeRowId += nRows;
1161 unsigned int initialTargetRowId,
1162 unsigned int initialTargetColId,
1165 bool checkForExactNumRowsMatching,
1166 bool checkForExactNumColsMatching)
1170 "GslMatrix::fillTensorProduct(mat and mat)",
1171 "too big number of rows");
1174 "GslMatrix::fillTensorProduct(mat and mat)",
1175 "inconsistent number of rows");
1178 "GslMatrix::fillTensorProduct(mat and mat)",
1179 "too big number of columns");
1182 "GslMatrix::fillTensorProduct(mat and mat)",
1183 "inconsistent number of columns");
1185 for (
unsigned int rowId1 = 0; rowId1 < mat1.
numRowsLocal(); ++rowId1) {
1186 for (
unsigned int colId1 = 0; colId1 < mat1.
numCols(); ++colId1) {
1187 double multiplicativeFactor = mat1(rowId1,colId1);
1188 unsigned int targetRowId = rowId1 * mat2.
numRowsLocal();
1189 unsigned int targetColId = colId1 * mat2.
numCols();
1190 for (
unsigned int rowId2 = 0; rowId2 < mat2.
numRowsLocal(); ++rowId2) {
1191 for (
unsigned int colId2 = 0; colId2 < mat2.
numCols(); ++colId2) {
1192 (*this)(initialTargetRowId + targetRowId + rowId2, initialTargetColId + targetColId + colId2) = multiplicativeFactor * mat2(rowId2,colId2);
1203 unsigned int initialTargetRowId,
1204 unsigned int initialTargetColId,
1207 bool checkForExactNumRowsMatching,
1208 bool checkForExactNumColsMatching)
1212 "GslMatrix::fillTensorProduct(mat and vec)",
1213 "too big number of rows");
1216 "GslMatrix::fillTensorProduct(mat and vec)",
1217 "inconsistent number of rows");
1220 "GslMatrix::fillTensorProduct(mat and vec)",
1221 "too big number of columns");
1224 "GslMatrix::fillTensorProduct(mat and vec)",
1225 "inconsistent number of columns");
1227 for (
unsigned int rowId1 = 0; rowId1 < mat1.
numRowsLocal(); ++rowId1) {
1228 for (
unsigned int colId1 = 0; colId1 < mat1.
numCols(); ++colId1) {
1229 double multiplicativeFactor = mat1(rowId1,colId1);
1230 unsigned int targetRowId = rowId1 * vec2.
sizeLocal();
1231 unsigned int targetColId = colId1 * 1;
1232 for (
unsigned int rowId2 = 0; rowId2 < vec2.
sizeLocal(); ++rowId2) {
1233 for (
unsigned int colId2 = 0; colId2 < 1; ++colId2) {
1234 (*this)(initialTargetRowId + targetRowId + rowId2, initialTargetColId + targetColId + colId2) = multiplicativeFactor * vec2[rowId2];
1246 unsigned int initialTargetRowId,
1247 unsigned int initialTargetColId,
1249 bool checkForExactNumRowsMatching,
1250 bool checkForExactNumColsMatching)
1253 unsigned int nCols = mat.
numCols();
1256 "GslMatrix::fillWithTranspose()",
1257 "too big number of rows");
1260 "GslMatrix::fillWithTranspose()",
1261 "inconsistent number of rows");
1264 "GslMatrix::fillWithTranspose()",
1265 "too big number of cols");
1268 "GslMatrix::fillWithTranspose()",
1269 "inconsistent number of cols");
1271 for (
unsigned int row = 0; row < nRows; ++row) {
1272 for (
unsigned int col = 0; col < nCols; ++col) {
1273 (*this)(initialTargetRowId + col, initialTargetColId + row) = mat(row,col);
1289 <<
": before 'this->invertMultiply()'"
1295 <<
": after 'this->invertMultiply()'"
1301 <<
": before 'gsl_linalg_LU_det()'"
1307 <<
": after 'gsl_linalg_LU_det()'"
1313 <<
": after 'gsl_linalg_LU_lndet()'"
1330 <<
": before 'this->invertMultiply()'"
1336 <<
": after 'this->invertMultiply()'"
1342 <<
": before 'gsl_linalg_LU_det()'"
1348 <<
": after 'gsl_linalg_LU_det()'"
1354 <<
": before 'gsl_linalg_LU_lndet()'"
1370 if (relativeVec[0] > 0.) {
1371 relativeVec = (1./relativeVec[0])*relativeVec;
1374 unsigned int rankValue = 0;
1375 for (
unsigned int i = 0; i < relativeVec.
sizeLocal(); ++i) {
1376 if (( (*
m_svdSvec)[i] >= absoluteZeroThreshold ) &&
1377 ( relativeVec [i] >= relativeZeroThreshold )) {
1385 <<
", this->numCols() = " << this->
numCols()
1386 <<
", absoluteZeroThreshold = " << absoluteZeroThreshold
1387 <<
", relativeZeroThreshold = " << relativeZeroThreshold
1388 <<
", rankValue = " << rankValue
1390 <<
", relativeVec = " << relativeVec
1403 "GslMatrix::multiply(), return vector",
1404 "matrix and vector have incompatible sizes");
1419 "GslMatrix::multiply(), vector return void",
1420 "matrix and x have incompatible sizes");
1424 "GslMatrix::multiply(), vector return void",
1425 "matrix and y have incompatible sizes");
1427 unsigned int sizeX = this->
numCols();
1429 for (
unsigned int i = 0; i < sizeY; ++i) {
1431 for (
unsigned int j = 0; j < sizeX; ++j) {
1432 value += (*this)(i,j)*x[j];
1446 "GslMatrix::invertMultiply(), return vector",
1447 "matrix and rhs have incompatible sizes");
1462 "GslMatrix::invertMultiply(), return void",
1463 "matrix and rhs have incompatible sizes");
1467 "GslMatrix::invertMultiply(), return void",
1468 "solution and rhs have incompatible sizes");
1474 "GslMatrix::invertMultiply()",
1475 "m_permutation should be NULL");
1480 "GslMatrix::invertMultiply()",
1481 "gsl_matrix_calloc() failed");
1483 iRC = gsl_matrix_memcpy(m_LU,
m_mat);
1486 "GslMatrix::invertMultiply()",
1487 "gsl_matrix_memcpy() failed");
1492 "GslMatrix::invertMultiply()",
1493 "gsl_permutation_calloc() failed");
1496 std::cout <<
"In GslMatrix::invertMultiply()"
1497 <<
": before LU decomposition, m_LU = ";
1498 gsl_matrix_fprintf(stdout, m_LU,
"%f");
1499 std::cout << std::endl;
1502 gsl_error_handler_t* oldHandler;
1503 oldHandler = gsl_set_error_handler_off();
1506 <<
": before 'gsl_linalg_LU_decomp()'"
1509 iRC = gsl_linalg_LU_decomp(m_LU,m_permutation,&
m_signum);
1511 std::cerr <<
"In GslMatrix::invertMultiply()"
1512 <<
", after gsl_linalg_LU_decomp()"
1513 <<
": iRC = " << iRC
1514 <<
", gsl error message = " << gsl_strerror(iRC)
1517 gsl_set_error_handler(oldHandler);
1520 <<
": after 'gsl_linalg_LU_decomp()'"
1521 <<
", IRC = " << iRC
1526 "GslMatrix::invertMultiply()",
1527 "gsl_linalg_LU_decomp() failed");
1530 std::cout <<
"In GslMatrix::invertMultiply()"
1531 <<
": after LU decomposition, m_LU = ";
1532 gsl_matrix_fprintf(stdout, m_LU,
"%f");
1533 std::cout << std::endl;
1537 gsl_error_handler_t* oldHandler;
1538 oldHandler = gsl_set_error_handler_off();
1541 <<
": before 'gsl_linalg_LU_solve()'"
1547 std::cerr <<
"In GslMatrix::invertMultiply()"
1548 <<
", after gsl_linalg_LU_solve()"
1549 <<
": iRC = " << iRC
1550 <<
", gsl error message = " << gsl_strerror(iRC)
1553 gsl_set_error_handler(oldHandler);
1556 <<
": after 'gsl_linalg_LU_solve()'"
1557 <<
", IRC = " << iRC
1568 std::cout <<
"In GslMatrix::invertMultiply()"
1569 <<
": ||b - Ax||_2 = " << tmpVec.
norm2()
1570 <<
": ||b - Ax||_2/||b||_2 = " << tmpVec.
norm2()/b.
norm2()
1594 "GslMatrix::invertMultiply()",
1595 "Matrices B and X are incompatible");
1600 "GslMatrix::invertMultiply()",
1601 "This and X matrices are incompatible");
1607 for(
unsigned int j = 0; j < B.
numCols(); ++j )
1627 "GslMatrix::invertMultiply(), return vector",
1628 "matrix and rhs have incompatible sizes");
1643 "GslMatrix::invertMultiplyForceLU(), return void",
1644 "matrix and rhs have incompatible sizes");
1648 "GslMatrix::invertMultiplyForceLU(), return void",
1649 "solution and rhs have incompatible sizes");
1653 if (
m_LU == NULL ) {
1656 "GslMatrix::invertMultiplyForceLU()",
1657 "m_permutation should be NULL");
1662 "GslMatrix::invertMultiplyForceLU()",
1663 "gsl_matrix_calloc() failed");
1668 "GslMatrix::invertMultiplyForceLU()",
1669 "gsl_matrix_memcpy() failed");
1674 "GslMatrix::invertMultiplyForceLU()",
1675 "gsl_permutation_calloc() failed");
1680 "GslMatrix::invertMultiplyForceLU()",
1681 "gsl_linalg_LU_decomp() failed");
1689 "GslMatrix::invertMultiplyForceLU()",
1690 "gsl_linalg_LU_solve() failed");
1698 unsigned int n = eigenValues.
sizeLocal();
1702 "GslMatrix::eigen()",
1703 "invalid input vector size");
1708 "GslVector::eigen()",
1709 "different input vector sizes");
1712 if (eigenVectors == NULL) {
1713 gsl_eigen_symm_workspace* w = gsl_eigen_symm_alloc((
size_t) n);
1714 gsl_eigen_symm(
m_mat,eigenValues.
data(),w);
1715 gsl_eigen_symm_free(w);
1718 gsl_eigen_symmv_workspace* w = gsl_eigen_symmv_alloc((
size_t) n);
1720 gsl_eigen_symmv_sort(eigenValues.
data(),eigenVectors->
m_mat,GSL_EIGEN_SORT_VAL_ASC);
1721 gsl_eigen_symmv_free(w);
1732 unsigned int n = eigenVector.
sizeLocal();
1736 "GslMatrix::largestEigen()",
1737 "invalid input vector size");
1746 const unsigned int max_num_iterations = 10000;
1747 const double tolerance = 1.0e-13;
1761 for(
unsigned int k = 0; k < max_num_iterations; ++k )
1768 index = (w.
abs()).getMaxValueIndex();
1772 z = (1.0/lambda) * w;
1776 residual = ( (*this)*z - lambda*z ).norm2();
1778 if( residual < tolerance )
1780 eigenValue = lambda;
1795 "GslMatrix::largestEigen()",
1796 "Maximum num iterations exceeded");
1806 unsigned int n = eigenVector.
sizeLocal();
1810 "GslMatrix::smallestEigen()",
1811 "invalid input vector size");
1820 const unsigned int max_num_iterations = 1000;
1821 const double tolerance = 1.0e-13;
1833 double one_over_lambda;
1836 for(
unsigned int k = 0; k < max_num_iterations; ++k )
1838 w = (*this).invertMultiplyForceLU( z );
1843 index = (w.
abs()).getMaxValueIndex();
1846 one_over_lambda = w[index];
1848 lambda = 1.0/one_over_lambda;
1854 residual = ( (*this)*z - lambda*z ).norm2();
1856 if( residual < tolerance )
1858 eigenValue = lambda;
1873 "GslMatrix::smallestEigen()",
1874 "Maximum num iterations exceeded");
1885 "GslMatrix::getColumn",
1886 "Specified row number not within range");
1890 "GslMatrix::getColumn",
1891 "column vector not same size as this matrix");
1894 gsl_vector* gsl_column = gsl_vector_alloc( column.
sizeLocal() );
1896 int error_code = gsl_matrix_get_col( gsl_column,
m_mat, column_num );
1899 "GslMatrix::getColumn()",
1900 "gsl_matrix_get_col failed");
1903 for(
unsigned int i = 0; i < column.
sizeLocal(); ++i )
1905 column[i] = gsl_vector_get( gsl_column, i );
1909 gsl_vector_free( gsl_column );
1920 "GslMatrix::getRow",
1921 "Specified row number not within range");
1925 "GslMatrix::getRow",
1926 "row vector not same size as this matrix");
1929 gsl_vector* gsl_row = gsl_vector_alloc( row.
sizeLocal() );
1931 int error_code = gsl_matrix_get_row( gsl_row,
m_mat, row_num );
1934 "GslMatrix::getRow()",
1935 "gsl_matrix_get_row failed");
1938 for(
unsigned int i = 0; i < row.
sizeLocal(); ++i )
1940 row[i] = gsl_vector_get( gsl_row, i );
1944 gsl_vector_free( gsl_row );
1957 this->
getRow( row_num, row );
1982 "GslMatrix::setRow",
1983 "Specified row number not within range");
1987 "GslMatrix::setRow",
1988 "row vector not same size as this matrix");
1990 gsl_vector* gsl_row = row.
data();
1992 int error_code = gsl_matrix_set_row(
m_mat, row_num, gsl_row );
1995 "GslMatrix::setRow()",
1996 "gsl_matrix_set_row failed");
2008 "GslMatrix::setColumn",
2009 "Specified column number not within range");
2013 "GslMatrix::setColumn",
2014 "column vector not same size as this matrix");
2016 gsl_vector* gsl_column = column.
data();
2018 int error_code = gsl_matrix_set_col(
m_mat, column_num, gsl_column );
2021 "GslMatrix::setColumn()",
2022 "gsl_matrix_set_col failed");
2034 "GslMatrix::mpiSum()",
2035 "local and global matrices incompatible");
2039 std::vector<double> local( size, 0.0 );
2040 std::vector<double> global( size, 0.0 );
2043 for(
unsigned int i = 0; i < this->
numRowsLocal(); i++ )
2045 for(
unsigned int j = 0; j < this->
numCols(); j++ )
2049 local[k] = (*this)(i,j);
2054 "GslMatrix::mpiSum()",
2055 "failed MPI.Allreduce()");
2057 for(
unsigned int i = 0; i < this->
numRowsLocal(); i++ )
2059 for(
unsigned int j = 0; j < this->
numCols(); j++ )
2063 M_global(i,j) = global[k];
2078 "GslMatrix::matlabLinearInterpExtrap()",
2079 "invalid 'x1' size");
2083 "GslMatrix::matlabLinearInterpExtrap()",
2084 "invalid 'x1' and 'y1' sizes");
2088 "GslMatrix::matlabLinearInterpExtrap()",
2089 "invalid 'x2' and 'this' sizes");
2093 "GslMatrix::matlabLinearInterpExtrap()",
2094 "invalid 'y1' and 'this' sizes");
2098 for (
unsigned int colId = 0; colId < y1Mat.
numCols(); ++colId) {
2117 unsigned int nCols = this->
numCols();
2120 for (
unsigned int i = 0; i < nRows; ++i) {
2121 for (
unsigned int j = 0; j < nCols; ++j) {
2125 if (i != (nRows-1)) os <<
"; ";
2130 for (
unsigned int i = 0; i < nRows; ++i) {
2131 for (
unsigned int j = 0; j < nCols; ++j) {
2144 const std::string& varNamePrefix,
2145 const std::string& fileName,
2146 const std::string& fileType,
2147 const std::set<unsigned int>& allowedSubEnvIds)
const
2151 "GslMatrix::subWriteContents()",
2152 "unexpected subRank");
2156 "GslMatrix::subWriteContents()",
2157 "implemented just for sequential vectors for now");
2166 unsigned int nCols = this->
numCols();
2167 *filePtrSet.ofsVar << varNamePrefix <<
"_sub" <<
m_env.
subIdString() <<
" = zeros(" << nRows
2171 *filePtrSet.ofsVar << varNamePrefix <<
"_sub" <<
m_env.
subIdString() <<
" = [";
2173 for (
unsigned int i = 0; i < nRows; ++i) {
2174 for (
unsigned int j = 0; j < nCols; ++j) {
2175 *filePtrSet.ofsVar << (*this)(i,j)
2178 *filePtrSet.ofsVar <<
"\n";
2180 *filePtrSet.ofsVar <<
"];\n";
2190 const std::string& fileName,
2191 const std::string& fileType,
2192 const std::set<unsigned int>& allowedSubEnvIds)
2196 "GslMatrix::subReadContents()",
2197 "unexpected subRank");
2201 "GslMatrix::subReadContents()",
2202 "implemented just for sequential vectors for now");
2214 unsigned int idOfMyFirstLine = 1;
2215 unsigned int idOfMyLastLine = nRowsLocal;
2216 unsigned int nCols = this->
numCols();
2220 std::string tmpString;
2223 *filePtrSet.ifsVar >> tmpString;
2227 *filePtrSet.ifsVar >> tmpString;
2231 "GslMatrix::subReadContents()",
2232 "string should be the '=' sign");
2235 *filePtrSet.ifsVar >> tmpString;
2237 unsigned int posInTmpString = 6;
2240 char nRowsString[tmpString.size()-posInTmpString+1];
2241 unsigned int posInRowsString = 0;
2245 "GslMatrix::subReadContents()",
2246 "symbol ',' not found in first line of file");
2247 nRowsString[posInRowsString++] = tmpString[posInTmpString++];
2248 }
while (tmpString[posInTmpString] !=
',');
2249 nRowsString[posInRowsString] =
'\0';
2253 char nColsString[tmpString.size()-posInTmpString+1];
2254 unsigned int posInColsString = 0;
2258 "GslMatrix::subReadContents()",
2259 "symbol ')' not found in first line of file");
2260 nColsString[posInColsString++] = tmpString[posInTmpString++];
2261 }
while (tmpString[posInTmpString] !=
')');
2262 nColsString[posInColsString] =
'\0';
2265 unsigned int numRowsInFile = (
unsigned int) strtod(nRowsString,NULL);
2266 unsigned int numColsInFile = (
unsigned int) strtod(nColsString,NULL);
2270 <<
", numRowsInFile = " << numRowsInFile
2271 <<
", numColsInFile = " << numColsInFile
2272 <<
", nRowsLocal = " << nRowsLocal
2273 <<
", nCols = " << nCols
2280 "GslMatrix::subReadContents()",
2281 "size of vec in file is not big enough");
2286 "GslMatrix::subReadContents()",
2287 "number of parameters of vec in file is different than number of parameters in this vec object");
2290 unsigned int maxCharsPerLine = 64*nCols;
2292 unsigned int lineId = 0;
2293 while (lineId < idOfMyFirstLine) {
2294 filePtrSet.ifsVar->ignore(maxCharsPerLine,
'\n');
2300 <<
": beginning to read input actual data"
2307 *filePtrSet.ifsVar >> tmpString;
2311 *filePtrSet.ifsVar >> tmpString;
2315 "GslMatrix::subReadContents()",
2316 "in core 0, string should be the '=' sign");
2319 std::streampos tmpPos = filePtrSet.ifsVar->tellg();
2320 filePtrSet.ifsVar->seekg(tmpPos+(std::streampos)2);
2324 <<
": beginning to read lines with numbers only"
2325 <<
", lineId = " << lineId
2326 <<
", idOfMyFirstLine = " << idOfMyFirstLine
2327 <<
", idOfMyLastLine = " << idOfMyLastLine
2332 while (lineId <= idOfMyLastLine) {
2333 for (
unsigned int j = 0; j < nCols; ++j) {
2334 *filePtrSet.ifsVar >> tmpRead;
2335 (*this)(lineId-idOfMyFirstLine,j) = tmpRead;
2369 unsigned int m1Cols = m1.
numCols();
2371 unsigned int m2Cols = m2.
numCols();
2375 "GslMatrix operator*(matrix,matrix)",
2376 "different sizes m1Cols and m2Rows");
2382 unsigned int commonSize = m1Cols;
2383 for (
unsigned int row1 = 0; row1 < m1Rows; ++row1) {
2384 for (
unsigned int col2 = 0; col2 < m2Cols; ++col2) {
2386 for (
unsigned int k = 0; k < commonSize; ++k) {
2387 result += m1(row1,k)*m2(k,col2);
2389 mat(row1,col2) = result;
2417 for (
unsigned int i = 0; i < nRows; ++i) {
2418 double value1 = v1[i];
2419 for (
unsigned int j = 0; j < nCols; ++j) {
2420 answer(i,j) = value1*v2[j];
2431 unsigned int mCols = mat.
numCols();
2435 "GslMatrix leftDiagScaling(vector,matrix)",
2436 "size of vector is different from the number of rows in matrix");
2440 "GslMatrix leftDiagScaling(vector,matrix)",
2441 "routine currently works for square matrices only");
2444 for (
unsigned int i = 0; i < mRows; ++i) {
2445 double vecValue = vec[i];
2446 for (
unsigned int j = 0; j < mCols; ++j) {
2447 answer(i,j) *= vecValue;
2458 unsigned int mCols = mat.
numCols();
2462 "GslMatrix rightDiagScaling(matrix,vector)",
2463 "size of vector is different from the number of cols in matrix");
2467 "GslMatrix rightDiagScaling(matrix,vector)",
2468 "routine currently works for square matrices only");
2471 for (
unsigned int j = 0; j < mCols; ++j) {
2472 double vecValue = vec[j];
2473 for (
unsigned int i = 0; i < mRows; ++i) {
2474 answer(i,j) *= vecValue;
void fillWithBlocksHorizontally(unsigned int rowId, unsigned int colId, const std::vector< const GslMatrix * > &matrices, bool checkForExactNumRowsMatching, bool checkForExactNumColsMatching)
This function fills this matrix horizontally with const block matrices.
const std::string & subIdString() const
Access to the attribute m_subIdString; which stores the string for the sub-environment, and it will be used, for instance, to create the output files for each sub-environment.
bool openInputFile(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds, FilePtrSetStruct &filePtrSet) const
Opens an input file.
GslMatrix & operator/=(double a)
Stores in this the coordinate-wise division of this by a.
void setColumn(const unsigned int column_num, const GslVector &column)
This function copies vector column into the column_num-th column of this matrix.
GslMatrix & operator+=(const GslMatrix &rhs)
Stores in this the coordinate-wise addition of this and rhs.
double max() const
Returns the maximum element value of the matrix.
int subRank() const
Access function for sub-rank.
Class for matrix operations using GSL library.
GslMatrix operator*(double a, const GslMatrix &mat)
gsl_matrix * m_LU
GSL matrix for the LU decomposition of m_mat.
GslMatrix operator-(const GslMatrix &m1, const GslMatrix &m2)
GslMatrix operator+(const GslMatrix &m1, const GslMatrix &m2)
const int UQ_MATRIX_IS_NOT_POS_DEFINITE_RC
Struct for handling data input and output from files.
int worldRank() const
Returns the process world rank.
GslVector abs() const
This function returns absolute value of elements in this.
unsigned int checkingLevel() const
Access function to private attribute m_checkingLevel.
GslMatrix rightDiagScaling(const GslMatrix &mat, const GslVector &vec)
void zeroUpper(bool includeDiagonal=false)
This function sets all the entries above the main diagonal of this matrix to zero.
GslMatrix matrixProduct(const GslVector &v1, const GslVector &v2)
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
void fillWithTensorProduct(unsigned int rowId, unsigned int colId, const GslMatrix &mat1, const GslMatrix &mat2, bool checkForExactNumRowsMatching, bool checkForExactNumColsMatching)
This function calculates the tensor product of matrices mat1 and mat2 and stores it in this matrix...
#define RawValue_MPI_DOUBLE
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
std::ostream & operator<<(std::ostream &os, const BaseEnvironment &obj)
void fillWithBlocksVertically(unsigned int rowId, unsigned int colId, const std::vector< const GslMatrix * > &matrices, bool checkForExactNumRowsMatching, bool checkForExactNumColsMatching)
This function fills this matrix vertically with const block matrices.
void eigen(GslVector &eigenValues, GslMatrix *eigenVectors) const
This function computes the eigenvalues of a real symmetric matrix.
#define UQ_FATAL_RC_MACRO(macroIRc, givenRank, where, what)
GslMatrix leftDiagScaling(const GslVector &vec, const GslMatrix &mat)
GslVector invertMultiply(const GslVector &b) const
This function calculates the inverse of this matrix and multiplies it with vector b...
double & operator()(unsigned int i, unsigned int j)
Element access method (non-const).
void cwSet(double value)
Component-wise sets all values to this with value.
double normFrob() const
Returns the Frobenius norm of this matrix.
GslVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
void getRow(const unsigned int row_num, GslVector &row) const
This function gets the row_num-th column of this matrix and stores it into vector row...
GslMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
const int UQ_MATRIX_SVD_FAILED_RC
void filterLargeValues(double thresholdValue)
This function sets to zero (filters) all entries of this matrix which are greater than thresholdValue...
unsigned int numOfProcsForStorage() const
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
void print(std::ostream &os) const
Print method. Defines the behavior of the ostream << operator inherited from the Object class...
void mpiSum(const MpiComm &comm, GslMatrix &M_global) const
A class for partitioning vectors and matrices.
GslVector invertMultiplyForceLU(const GslVector &b) const
This function calculates the inverse of this matrix and multiplies it with vector b...
unsigned int sizeLocal() const
Returns the length of this vector.
#define UQ_RC_MACRO(macroIRc, givenRank, where, what, retValue)
Macros.
double m_lnDeterminant
The natural logarithm of the determinant of this matrix.
GslMatrix & operator-=(const GslMatrix &rhs)
Stores in this the coordinate-wise subtraction of this by rhs.
void getColumn(const unsigned int column_num, GslVector &column) const
This function gets the column_num-th column of this matrix and stores it into vector column...
double norm2() const
Returns the 2-norm (Euclidean norm) of the vector.
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
const Map & m_map
Mapping variable.
void zeroLower(bool includeDiagonal=false)
This function sets all the entries bellow the main diagonal of this matrix to zero.
void Allreduce(void *sendbuf, void *recvbuf, int count, RawType_MPI_Datatype datatype, RawType_MPI_Op op, const char *whereMsg, const char *whatMsg) const
Combines values from all processes and distributes the result back to all processes.
void subWriteContents(const std::string &varNamePrefix, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
Write contents of subenvironment in file fileName.
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
GslMatrix transpose() const
This function calculated the transpose of this matrix (square).
bool m_inDebugMode
Flag for either or not QUESO is in debug mode.
int svdSolve(const GslVector &rhsVec, GslVector &solVec) const
This function solves the system A x = b using the singular value decomposition (U, S, V) of A which must have been computed previously with GslMatrix::svd (x=solVec, b=rhsVec).
Class for vector operations using GSL library.
GslMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
void cwSet(double value)
Component-wise set all values to this with value.
GslMatrix & operator=(const GslMatrix &rhs)
Copies values from matrix rhs to this.
void largestEigen(double &eigenValue, GslVector &eigenVector) const
This function finds largest eigenvalue, namely eigenValue, of this matrix and its corresponding eigen...
void fillWithBlocksDiagonally(unsigned int rowId, unsigned int colId, const std::vector< const GslMatrix * > &matrices, bool checkForExactNumRowsMatching, bool checkForExactNumColsMatching)
This function fills this matrix diagonally with const block matrices.
GslMatrix()
Default Constructor.
Map * m_svdColMap
Mapping for matrices involved in the singular value decomposition (svd) routine.
const GslMatrix & svdMatV() const
This function calls private member GslMatrix::internalSvd() to set a N-by-N orthogonal square matrix ...
void setRow(const unsigned int row_num, const GslVector &row)
This function copies vector row into the row_num-th column of this matrix.
The QUESO MPI Communicator Class.
gsl_matrix * data()
Returns this matrix.
GslMatrix inverse() const
This function calculated the inverse of this matrix (square).
unsigned int rank(double absoluteZeroThreshold, double relativeZeroThreshold) const
This function returns the number of singular values of this matrix (rank).
Class for matrix operations (virtual).
void copy(const GslMatrix &src)
In this function this matrix receives a copy of matrix src.
bool m_printHorizontally
Flag for either or not print this matrix.
void smallestEigen(double &eigenValue, GslVector &eigenVector) const
This function finds smallest eigenvalue, namely eigenValue, of this matrix and its corresponding eige...
int fullRank() const
Returns the process full rank.
GslVector multiply(const GslVector &x) const
This function multiplies this matrix by vector x and returns the resulting vector.
void subReadContents(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds)
Read contents of subenvironment from file fileName.
void fillWithTranspose(unsigned int rowId, unsigned int colId, const GslMatrix &mat, bool checkForExactNumRowsMatching, bool checkForExactNumColsMatching)
This function stores the transpose of this matrix into this matrix.
GslMatrix & operator*=(double a)
Stores in this the coordinate-wise multiplication of this and a.
void filterSmallValues(double thresholdValue)
This function sets to zero (filters) all entries of this matrix which are smaller than thresholdValue...
int svd(GslMatrix &matU, GslVector &vecS, GslMatrix &matVt) const
Checks for the dimension of this matrix, matU, VecS and matVt, and calls the protected routine intern...
gsl_permutation * m_permutation
The permutation matrix of a LU decomposition.
void matlabLinearInterpExtrap(const GslVector &x1Vec, const GslVector &y1Vec, const GslVector &x2Vec)
double normMax() const
Returns the Frobenius norm of this matrix.
void matlabLinearInterpExtrap(const GslVector &x1Vec, const GslMatrix &y1Mat, const GslVector &x2Vec)
gsl_matrix * m_mat
GSL matrix, also referred to as this matrix.
void resetLU()
In this function resets the LU decomposition of this matrix, as well as deletes the private member po...
unsigned int displayVerbosity() const
unsigned int numRowsGlobal() const
Returns the global row dimension of this matrix.
int m_signum
m_signum stores the sign of the permutation of the LU decomposition PA = LU.
int internalSvd() const
This function factorizes the M-by-N matrix A into the singular value decomposition A = U S V^T for M ...
const BaseEnvironment & env() const
double determinant() const
Calculates the determinant of this matrix.
double lnDeterminant() const
Calculates the ln(determinant) of this matrix.
bool m_isSingular
Indicates whether or not this matrix is singular.
virtual void copy(const Matrix &src)
Copies matrix src to this matrix.
double m_determinant
The determinant of this matrix.
GslMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
unsigned int numCols() const
Returns the column dimension of this matrix.
bool openOutputFile(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds, bool writeOver, FilePtrSetStruct &filePtrSet) const
Opens an output file for each sub-environment that was chosen to send data to the file...
GslMatrix * m_inverse
Inverse matrix of this.
gsl_vector * data() const
const BaseEnvironment & m_env
QUESO environment variable.
void cwExtract(unsigned int rowId, unsigned int colId, GslMatrix &mat) const
const GslMatrix & svdMatU() const
This function calls private member GslMatrix::internalSvd() to set a M-by-N orthogonal matrix U of th...
const BaseEnvironment & env() const
int chol()
Computes Cholesky factorization of a real symmetric positive definite matrix this.