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)
519 gsl_set_error_handler(oldHandler);
524 "matrix is not positive definite",
534 unsigned int nCols = this->
numCols();
564 unsigned int nCols = this->
numCols();
568 "GslMatrix::svdSolve()",
573 "GslMatrix::svdSolve()",
581 <<
", this->numCols() = " << this->
numCols()
587 <<
"\n rhsVec.sizeLocal() = " << rhsVec.
sizeLocal()
588 <<
"\n solVec.sizeLocal() = " << solVec.
sizeLocal()
601 unsigned int nCols = this->
numCols();
605 "GslMatrix::svdSolve()",
610 "GslMatrix::svdSolve()",
615 "GslMatrix::svdSolve()",
616 "rhsMat and solMat are not compatible");
621 for (
unsigned int j = 0; j < rhsMat.
numCols(); ++j) {
623 iRC = this->
svdSolve(rhsVec, solVec);
658 unsigned int nCols = this->
numCols();
661 "GslMatrix::internalSvd()",
662 "GSL only supports cases where nRows >= nCols");
675 struct timeval timevalBegin;
676 gettimeofday(&timevalBegin, NULL);
677 gsl_error_handler_t* oldHandler;
678 oldHandler = gsl_set_error_handler_off();
686 std::cerr <<
"In GslMatrix::internalSvd()"
688 <<
", gsl error message = " << gsl_strerror(iRC)
691 gsl_set_error_handler(oldHandler);
693 struct timeval timevalNow;
694 gettimeofday(&timevalNow, NULL);
702 "GslMatrix::internalSvd()",
717 unsigned int nCols = this->
numCols();
721 "GslMatrix::zeroLower()",
722 "routine works only for square matrices");
726 if (includeDiagonal) {
727 for (
unsigned int i = 0; i < nRows; i++) {
728 for (
unsigned int j = 0; j <= i; j++) {
734 for (
unsigned int i = 0; i < nRows; i++) {
735 for (
unsigned int j = 0; j < i; j++) {
748 unsigned int nCols = this->
numCols();
752 "GslMatrix::zeroUpper()",
753 "routine works only for square matrices");
757 if (includeDiagonal) {
758 for (
unsigned int i = 0; i < nRows; i++) {
759 for (
unsigned int j = i; j < nCols; j++) {
765 for (
unsigned int i = 0; i < nRows; i++) {
766 for (
unsigned int j = (i+1); j < nCols; j++) {
779 unsigned int nCols = this->
numCols();
780 for (
unsigned int i = 0; i < nRows; ++i) {
781 for (
unsigned int j = 0; j < nCols; ++j) {
782 double aux = (*this)(i,j);
785 (-thresholdValue < aux)) {
789 (thresholdValue > aux)) {
802 unsigned int nCols = this->
numCols();
803 for (
unsigned int i = 0; i < nRows; ++i) {
804 for (
unsigned int j = 0; j < nCols; ++j) {
805 double aux = (*this)(i,j);
808 (-thresholdValue > aux)) {
812 (thresholdValue < aux)) {
825 unsigned int nCols = this->
numCols();
829 "GslMatrix::transpose()",
830 "routine works only for square matrices");
833 for (
unsigned int row = 0; row < nRows; ++row) {
834 for (
unsigned int col = 0; col < nCols; ++col) {
835 mat(row,col) = (*this)(col,row);
846 unsigned int nCols = this->
numCols();
850 "GslMatrix::inverse()",
851 "matrix is not square");
856 unitVector.
cwSet(0.);
858 for (
unsigned int j = 0; j < nCols; ++j) {
859 if (j > 0) unitVector[j-1] = 0.;
862 for (
unsigned int i = 0; i < nRows; ++i) {
863 (*m_inverse)(i,j) = multVector[i];
875 <<
"\n M = " << *
this
877 <<
"\n M*M^{-1} = " << (*this)*(*m_inverse)
878 <<
"\n M^{-1}*M = " << (*m_inverse)*(*this)
887 unsigned int initialTargetRowId,
888 unsigned int initialTargetColId,
889 const std::vector<const GslMatrix* >& matrices,
890 bool checkForExactNumRowsMatching,
891 bool checkForExactNumColsMatching)
893 unsigned int sumNumRowsLocals = 0;
894 unsigned int sumNumCols = 0;
895 for (
unsigned int i = 0; i < matrices.size(); ++i) {
896 sumNumRowsLocals += matrices[i]->numRowsLocal();
897 sumNumCols += matrices[i]->numCols();
901 "GslMatrix::fillWithBlocksDiagonally(const)",
902 "too big number of rows");
905 "GslMatrix::fillWithBlocksDiagonally(const)",
906 "inconsistent number of rows");
909 "GslMatrix::fillWithBlocksDiagonally(const)",
910 "too big number of cols");
913 "GslMatrix::fillWithBlocksDiagonally(const)",
914 "inconsistent number of cols");
916 unsigned int cumulativeRowId = 0;
917 unsigned int cumulativeColId = 0;
918 for (
unsigned int i = 0; i < matrices.size(); ++i) {
919 unsigned int nRows = matrices[i]->numRowsLocal();
920 unsigned int nCols = matrices[i]->numCols();
921 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
922 for (
unsigned int colId = 0; colId < nCols; ++colId) {
923 (*this)(initialTargetRowId + cumulativeRowId + rowId, initialTargetColId + cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
926 cumulativeRowId += nRows;
927 cumulativeColId += nCols;
935 unsigned int initialTargetRowId,
936 unsigned int initialTargetColId,
937 const std::vector<GslMatrix* >& matrices,
938 bool checkForExactNumRowsMatching,
939 bool checkForExactNumColsMatching)
941 unsigned int sumNumRowsLocals = 0;
942 unsigned int sumNumCols = 0;
943 for (
unsigned int i = 0; i < matrices.size(); ++i) {
944 sumNumRowsLocals += matrices[i]->numRowsLocal();
945 sumNumCols += matrices[i]->numCols();
949 "GslMatrix::fillWithBlocksDiagonally()",
950 "too big number of rows");
953 "GslMatrix::fillWithBlocksDiagonally()",
954 "inconsistent number of rows");
957 "GslMatrix::fillWithBlocksDiagonally()",
958 "too big number of cols");
961 "GslMatrix::fillWithBlocksDiagonally()",
962 "inconsistent number of cols");
964 unsigned int cumulativeRowId = 0;
965 unsigned int cumulativeColId = 0;
966 for (
unsigned int i = 0; i < matrices.size(); ++i) {
967 unsigned int nRows = matrices[i]->numRowsLocal();
968 unsigned int nCols = matrices[i]->numCols();
969 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
970 for (
unsigned int colId = 0; colId < nCols; ++colId) {
971 (*this)(initialTargetRowId + cumulativeRowId + rowId, initialTargetColId + cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
974 cumulativeRowId += nRows;
975 cumulativeColId += nCols;
983 unsigned int initialTargetRowId,
984 unsigned int initialTargetColId,
985 const std::vector<const GslMatrix* >& matrices,
986 bool checkForExactNumRowsMatching,
987 bool checkForExactNumColsMatching)
989 unsigned int sumNumCols = 0;
990 for (
unsigned int i = 0; i < matrices.size(); ++i) {
993 "GslMatrix::fillWithBlocksHorizontally(const)",
994 "too big number of rows");
997 "GslMatrix::fillWithBlocksHorizontally(const)",
998 "inconsistent number of rows");
999 sumNumCols += matrices[i]->numCols();
1003 "GslMatrix::fillWithBlocksHorizontally(const)",
1004 "too big number of cols");
1007 "GslMatrix::fillWithBlocksHorizontally(const)",
1008 "inconsistent number of cols");
1010 unsigned int cumulativeColId = 0;
1011 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1012 unsigned int nRows = matrices[i]->numRowsLocal();
1013 unsigned int nCols = matrices[i]->numCols();
1014 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
1015 for (
unsigned int colId = 0; colId < nCols; ++colId) {
1016 (*this)(initialTargetRowId + rowId, initialTargetColId + cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
1019 cumulativeColId += nCols;
1027 unsigned int initialTargetRowId,
1028 unsigned int initialTargetColId,
1029 const std::vector<GslMatrix* >& matrices,
1030 bool checkForExactNumRowsMatching,
1031 bool checkForExactNumColsMatching)
1033 unsigned int sumNumCols = 0;
1034 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1037 "GslMatrix::fillWithBlocksHorizontally()",
1038 "too big number of rows");
1041 "GslMatrix::fillWithBlocksHorizontally()",
1042 "inconsistent number of rows");
1043 sumNumCols += matrices[i]->numCols();
1047 "GslMatrix::fillWithBlocksHorizontally()",
1048 "too big number of cols");
1051 "GslMatrix::fillWithBlocksHorizontally()",
1052 "inconsistent number of cols");
1054 unsigned int cumulativeColId = 0;
1055 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1056 unsigned int nRows = matrices[i]->numRowsLocal();
1057 unsigned int nCols = matrices[i]->numCols();
1058 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
1059 for (
unsigned int colId = 0; colId < nCols; ++colId) {
1060 (*this)(initialTargetRowId + rowId, initialTargetColId + cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
1063 cumulativeColId += nCols;
1071 unsigned int initialTargetRowId,
1072 unsigned int initialTargetColId,
1073 const std::vector<const GslMatrix* >& matrices,
1074 bool checkForExactNumRowsMatching,
1075 bool checkForExactNumColsMatching)
1077 unsigned int sumNumRows = 0;
1078 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1081 "GslMatrix::fillWithBlocksVertically(const)",
1082 "too big number of cols");
1085 "GslMatrix::fillWithBlocksVertically(const)",
1086 "inconsistent number of cols");
1087 sumNumRows += matrices[i]->numRowsLocal();
1091 "GslMatrix::fillWithBlocksVertically(const)",
1092 "too big number of rows");
1095 "GslMatrix::fillWithBlocksVertically(const)",
1096 "inconsistent number of rows");
1098 unsigned int cumulativeRowId = 0;
1099 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1100 unsigned int nRows = matrices[i]->numRowsLocal();
1101 unsigned int nCols = matrices[i]->numCols();
1102 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
1103 for (
unsigned int colId = 0; colId < nCols; ++colId) {
1104 (*this)(initialTargetRowId + cumulativeRowId + rowId, initialTargetColId + colId) = (*(matrices[i]))(rowId,colId);
1107 cumulativeRowId += nRows;
1115 unsigned int initialTargetRowId,
1116 unsigned int initialTargetColId,
1117 const std::vector<GslMatrix* >& matrices,
1118 bool checkForExactNumRowsMatching,
1119 bool checkForExactNumColsMatching)
1121 unsigned int sumNumRows = 0;
1122 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1125 "GslMatrix::fillWithBlocksVertically()",
1126 "too big number of cols");
1129 "GslMatrix::fillWithBlocksVertically()",
1130 "inconsistent number of cols");
1131 sumNumRows += matrices[i]->numRowsLocal();
1135 "GslMatrix::fillWithBlocksVertically()",
1136 "too big number of rows");
1139 "GslMatrix::fillWithBlocksVertically()",
1140 "inconsistent number of rows");
1142 unsigned int cumulativeRowId = 0;
1143 for (
unsigned int i = 0; i < matrices.size(); ++i) {
1144 unsigned int nRows = matrices[i]->numRowsLocal();
1145 unsigned int nCols = matrices[i]->numCols();
1146 for (
unsigned int rowId = 0; rowId < nRows; ++rowId) {
1147 for (
unsigned int colId = 0; colId < nCols; ++colId) {
1148 (*this)(initialTargetRowId + cumulativeRowId + rowId, initialTargetColId + colId) = (*(matrices[i]))(rowId,colId);
1151 cumulativeRowId += nRows;
1159 unsigned int initialTargetRowId,
1160 unsigned int initialTargetColId,
1163 bool checkForExactNumRowsMatching,
1164 bool checkForExactNumColsMatching)
1168 "GslMatrix::fillTensorProduct(mat and mat)",
1169 "too big number of rows");
1172 "GslMatrix::fillTensorProduct(mat and mat)",
1173 "inconsistent number of rows");
1176 "GslMatrix::fillTensorProduct(mat and mat)",
1177 "too big number of columns");
1180 "GslMatrix::fillTensorProduct(mat and mat)",
1181 "inconsistent number of columns");
1183 for (
unsigned int rowId1 = 0; rowId1 < mat1.
numRowsLocal(); ++rowId1) {
1184 for (
unsigned int colId1 = 0; colId1 < mat1.
numCols(); ++colId1) {
1185 double multiplicativeFactor = mat1(rowId1,colId1);
1186 unsigned int targetRowId = rowId1 * mat2.
numRowsLocal();
1187 unsigned int targetColId = colId1 * mat2.
numCols();
1188 for (
unsigned int rowId2 = 0; rowId2 < mat2.
numRowsLocal(); ++rowId2) {
1189 for (
unsigned int colId2 = 0; colId2 < mat2.
numCols(); ++colId2) {
1190 (*this)(initialTargetRowId + targetRowId + rowId2, initialTargetColId + targetColId + colId2) = multiplicativeFactor * mat2(rowId2,colId2);
1201 unsigned int initialTargetRowId,
1202 unsigned int initialTargetColId,
1205 bool checkForExactNumRowsMatching,
1206 bool checkForExactNumColsMatching)
1210 "GslMatrix::fillTensorProduct(mat and vec)",
1211 "too big number of rows");
1214 "GslMatrix::fillTensorProduct(mat and vec)",
1215 "inconsistent number of rows");
1218 "GslMatrix::fillTensorProduct(mat and vec)",
1219 "too big number of columns");
1222 "GslMatrix::fillTensorProduct(mat and vec)",
1223 "inconsistent number of columns");
1225 for (
unsigned int rowId1 = 0; rowId1 < mat1.
numRowsLocal(); ++rowId1) {
1226 for (
unsigned int colId1 = 0; colId1 < mat1.
numCols(); ++colId1) {
1227 double multiplicativeFactor = mat1(rowId1,colId1);
1228 unsigned int targetRowId = rowId1 * vec2.
sizeLocal();
1229 unsigned int targetColId = colId1 * 1;
1230 for (
unsigned int rowId2 = 0; rowId2 < vec2.
sizeLocal(); ++rowId2) {
1231 for (
unsigned int colId2 = 0; colId2 < 1; ++colId2) {
1232 (*this)(initialTargetRowId + targetRowId + rowId2, initialTargetColId + targetColId + colId2) = multiplicativeFactor * vec2[rowId2];
1244 unsigned int initialTargetRowId,
1245 unsigned int initialTargetColId,
1247 bool checkForExactNumRowsMatching,
1248 bool checkForExactNumColsMatching)
1251 unsigned int nCols = mat.
numCols();
1254 "GslMatrix::fillWithTranspose()",
1255 "too big number of rows");
1258 "GslMatrix::fillWithTranspose()",
1259 "inconsistent number of rows");
1262 "GslMatrix::fillWithTranspose()",
1263 "too big number of cols");
1266 "GslMatrix::fillWithTranspose()",
1267 "inconsistent number of cols");
1269 for (
unsigned int row = 0; row < nRows; ++row) {
1270 for (
unsigned int col = 0; col < nCols; ++col) {
1271 (*this)(initialTargetRowId + col, initialTargetColId + row) = mat(row,col);
1287 <<
": before 'this->invertMultiply()'"
1293 <<
": after 'this->invertMultiply()'"
1299 <<
": before 'gsl_linalg_LU_det()'"
1305 <<
": after 'gsl_linalg_LU_det()'"
1311 <<
": after 'gsl_linalg_LU_lndet()'"
1328 <<
": before 'this->invertMultiply()'"
1334 <<
": after 'this->invertMultiply()'"
1340 <<
": before 'gsl_linalg_LU_det()'"
1346 <<
": after 'gsl_linalg_LU_det()'"
1352 <<
": before 'gsl_linalg_LU_lndet()'"
1368 if (relativeVec[0] > 0.) {
1369 relativeVec = (1./relativeVec[0])*relativeVec;
1372 unsigned int rankValue = 0;
1373 for (
unsigned int i = 0; i < relativeVec.
sizeLocal(); ++i) {
1374 if (( (*
m_svdSvec)[i] >= absoluteZeroThreshold ) &&
1375 ( relativeVec [i] >= relativeZeroThreshold )) {
1383 <<
", this->numCols() = " << this->
numCols()
1384 <<
", absoluteZeroThreshold = " << absoluteZeroThreshold
1385 <<
", relativeZeroThreshold = " << relativeZeroThreshold
1386 <<
", rankValue = " << rankValue
1388 <<
", relativeVec = " << relativeVec
1401 "GslMatrix::multiply(), return vector",
1402 "matrix and vector have incompatible sizes");
1417 "GslMatrix::multiply(), vector return void",
1418 "matrix and x have incompatible sizes");
1422 "GslMatrix::multiply(), vector return void",
1423 "matrix and y have incompatible sizes");
1425 unsigned int sizeX = this->
numCols();
1427 for (
unsigned int i = 0; i < sizeY; ++i) {
1429 for (
unsigned int j = 0; j < sizeX; ++j) {
1430 value += (*this)(i,j)*x[j];
1444 "GslMatrix::invertMultiply(), return vector",
1445 "matrix and rhs have incompatible sizes");
1460 "GslMatrix::invertMultiply(), return void",
1461 "matrix and rhs have incompatible sizes");
1465 "GslMatrix::invertMultiply(), return void",
1466 "solution and rhs have incompatible sizes");
1472 "GslMatrix::invertMultiply()",
1473 "m_permutation should be NULL");
1478 "GslMatrix::invertMultiply()",
1479 "gsl_matrix_calloc() failed");
1481 iRC = gsl_matrix_memcpy(m_LU,
m_mat);
1484 "GslMatrix::invertMultiply()",
1485 "gsl_matrix_memcpy() failed");
1490 "GslMatrix::invertMultiply()",
1491 "gsl_permutation_calloc() failed");
1494 std::cout <<
"In GslMatrix::invertMultiply()"
1495 <<
": before LU decomposition, m_LU = ";
1496 gsl_matrix_fprintf(stdout, m_LU,
"%f");
1497 std::cout << std::endl;
1500 gsl_error_handler_t* oldHandler;
1501 oldHandler = gsl_set_error_handler_off();
1504 <<
": before 'gsl_linalg_LU_decomp()'"
1507 iRC = gsl_linalg_LU_decomp(m_LU,m_permutation,&
m_signum);
1509 std::cerr <<
"In GslMatrix::invertMultiply()"
1510 <<
", after gsl_linalg_LU_decomp()"
1511 <<
": iRC = " << iRC
1512 <<
", gsl error message = " << gsl_strerror(iRC)
1515 gsl_set_error_handler(oldHandler);
1518 <<
": after 'gsl_linalg_LU_decomp()'"
1519 <<
", IRC = " << iRC
1524 "GslMatrix::invertMultiply()",
1525 "gsl_linalg_LU_decomp() failed");
1528 std::cout <<
"In GslMatrix::invertMultiply()"
1529 <<
": after LU decomposition, m_LU = ";
1530 gsl_matrix_fprintf(stdout, m_LU,
"%f");
1531 std::cout << std::endl;
1535 gsl_error_handler_t* oldHandler;
1536 oldHandler = gsl_set_error_handler_off();
1539 <<
": before 'gsl_linalg_LU_solve()'"
1545 std::cerr <<
"In GslMatrix::invertMultiply()"
1546 <<
", after gsl_linalg_LU_solve()"
1547 <<
": iRC = " << iRC
1548 <<
", gsl error message = " << gsl_strerror(iRC)
1551 gsl_set_error_handler(oldHandler);
1554 <<
": after 'gsl_linalg_LU_solve()'"
1555 <<
", IRC = " << iRC
1566 std::cout <<
"In GslMatrix::invertMultiply()"
1567 <<
": ||b - Ax||_2 = " << tmpVec.
norm2()
1568 <<
": ||b - Ax||_2/||b||_2 = " << tmpVec.
norm2()/b.
norm2()
1592 "GslMatrix::invertMultiply()",
1593 "Matrices B and X are incompatible");
1598 "GslMatrix::invertMultiply()",
1599 "This and X matrices are incompatible");
1605 for(
unsigned int j = 0; j < B.
numCols(); ++j )
1625 "GslMatrix::invertMultiply(), return vector",
1626 "matrix and rhs have incompatible sizes");
1641 "GslMatrix::invertMultiplyForceLU(), return void",
1642 "matrix and rhs have incompatible sizes");
1646 "GslMatrix::invertMultiplyForceLU(), return void",
1647 "solution and rhs have incompatible sizes");
1651 if (
m_LU == NULL ) {
1654 "GslMatrix::invertMultiplyForceLU()",
1655 "m_permutation should be NULL");
1660 "GslMatrix::invertMultiplyForceLU()",
1661 "gsl_matrix_calloc() failed");
1666 "GslMatrix::invertMultiplyForceLU()",
1667 "gsl_matrix_memcpy() failed");
1672 "GslMatrix::invertMultiplyForceLU()",
1673 "gsl_permutation_calloc() failed");
1678 "GslMatrix::invertMultiplyForceLU()",
1679 "gsl_linalg_LU_decomp() failed");
1687 "GslMatrix::invertMultiplyForceLU()",
1688 "gsl_linalg_LU_solve() failed");
1696 unsigned int n = eigenValues.
sizeLocal();
1700 "GslMatrix::eigen()",
1701 "invalid input vector size");
1706 "GslVector::eigen()",
1707 "different input vector sizes");
1710 if (eigenVectors == NULL) {
1711 gsl_eigen_symm_workspace* w = gsl_eigen_symm_alloc((
size_t) n);
1712 gsl_eigen_symm(
m_mat,eigenValues.
data(),w);
1713 gsl_eigen_symm_free(w);
1716 gsl_eigen_symmv_workspace* w = gsl_eigen_symmv_alloc((
size_t) n);
1718 gsl_eigen_symmv_sort(eigenValues.
data(),eigenVectors->
m_mat,GSL_EIGEN_SORT_VAL_ASC);
1719 gsl_eigen_symmv_free(w);
1730 unsigned int n = eigenVector.
sizeLocal();
1734 "GslMatrix::largestEigen()",
1735 "invalid input vector size");
1744 const unsigned int max_num_iterations = 10000;
1745 const double tolerance = 1.0e-13;
1759 for(
unsigned int k = 0; k < max_num_iterations; ++k )
1766 index = (w.
abs()).getMaxValueIndex();
1770 z = (1.0/lambda) * w;
1774 residual = ( (*this)*z - lambda*z ).norm2();
1776 if( residual < tolerance )
1778 eigenValue = lambda;
1793 "GslMatrix::largestEigen()",
1794 "Maximum num iterations exceeded");
1804 unsigned int n = eigenVector.
sizeLocal();
1808 "GslMatrix::smallestEigen()",
1809 "invalid input vector size");
1818 const unsigned int max_num_iterations = 1000;
1819 const double tolerance = 1.0e-13;
1831 double one_over_lambda;
1834 for(
unsigned int k = 0; k < max_num_iterations; ++k )
1836 w = (*this).invertMultiplyForceLU( z );
1841 index = (w.
abs()).getMaxValueIndex();
1844 one_over_lambda = w[index];
1846 lambda = 1.0/one_over_lambda;
1852 residual = ( (*this)*z - lambda*z ).norm2();
1854 if( residual < tolerance )
1856 eigenValue = lambda;
1871 "GslMatrix::smallestEigen()",
1872 "Maximum num iterations exceeded");
1883 "GslMatrix::getColumn",
1884 "Specified row number not within range");
1888 "GslMatrix::getColumn",
1889 "column vector not same size as this matrix");
1892 gsl_vector* gsl_column = gsl_vector_alloc( column.
sizeLocal() );
1894 int error_code = gsl_matrix_get_col( gsl_column,
m_mat, column_num );
1897 "GslMatrix::getColumn()",
1898 "gsl_matrix_get_col failed");
1901 for(
unsigned int i = 0; i < column.
sizeLocal(); ++i )
1903 column[i] = gsl_vector_get( gsl_column, i );
1907 gsl_vector_free( gsl_column );
1918 "GslMatrix::getRow",
1919 "Specified row number not within range");
1923 "GslMatrix::getRow",
1924 "row vector not same size as this matrix");
1927 gsl_vector* gsl_row = gsl_vector_alloc( row.
sizeLocal() );
1929 int error_code = gsl_matrix_get_row( gsl_row,
m_mat, row_num );
1932 "GslMatrix::getRow()",
1933 "gsl_matrix_get_row failed");
1936 for(
unsigned int i = 0; i < row.
sizeLocal(); ++i )
1938 row[i] = gsl_vector_get( gsl_row, i );
1942 gsl_vector_free( gsl_row );
1955 this->
getRow( row_num, row );
1980 "GslMatrix::setRow",
1981 "Specified row number not within range");
1985 "GslMatrix::setRow",
1986 "row vector not same size as this matrix");
1988 gsl_vector* gsl_row = row.
data();
1990 int error_code = gsl_matrix_set_row(
m_mat, row_num, gsl_row );
1993 "GslMatrix::setRow()",
1994 "gsl_matrix_set_row failed");
2006 "GslMatrix::setColumn",
2007 "Specified column number not within range");
2011 "GslMatrix::setColumn",
2012 "column vector not same size as this matrix");
2014 gsl_vector* gsl_column = column.
data();
2016 int error_code = gsl_matrix_set_col(
m_mat, column_num, gsl_column );
2019 "GslMatrix::setColumn()",
2020 "gsl_matrix_set_col failed");
2032 "GslMatrix::mpiSum()",
2033 "local and global matrices incompatible");
2037 std::vector<double> local( size, 0.0 );
2038 std::vector<double> global( size, 0.0 );
2041 for(
unsigned int i = 0; i < this->
numRowsLocal(); i++ )
2043 for(
unsigned int j = 0; j < this->
numCols(); j++ )
2047 local[k] = (*this)(i,j);
2052 "GslMatrix::mpiSum()",
2053 "failed MPI.Allreduce()");
2055 for(
unsigned int i = 0; i < this->
numRowsLocal(); i++ )
2057 for(
unsigned int j = 0; j < this->
numCols(); j++ )
2061 M_global(i,j) = global[k];
2076 "GslMatrix::matlabLinearInterpExtrap()",
2077 "invalid 'x1' size");
2081 "GslMatrix::matlabLinearInterpExtrap()",
2082 "invalid 'x1' and 'y1' sizes");
2086 "GslMatrix::matlabLinearInterpExtrap()",
2087 "invalid 'x2' and 'this' sizes");
2091 "GslMatrix::matlabLinearInterpExtrap()",
2092 "invalid 'y1' and 'this' sizes");
2096 for (
unsigned int colId = 0; colId < y1Mat.
numCols(); ++colId) {
2115 unsigned int nCols = this->
numCols();
2118 for (
unsigned int i = 0; i < nRows; ++i) {
2119 for (
unsigned int j = 0; j < nCols; ++j) {
2123 if (i != (nRows-1)) os <<
"; ";
2128 for (
unsigned int i = 0; i < nRows; ++i) {
2129 for (
unsigned int j = 0; j < nCols; ++j) {
2142 const std::string& varNamePrefix,
2143 const std::string& fileName,
2144 const std::string& fileType,
2145 const std::set<unsigned int>& allowedSubEnvIds)
const
2149 "GslMatrix::subWriteContents()",
2150 "unexpected subRank");
2154 "GslMatrix::subWriteContents()",
2155 "implemented just for sequential vectors for now");
2164 unsigned int nCols = this->
numCols();
2165 *filePtrSet.ofsVar << varNamePrefix <<
"_sub" <<
m_env.
subIdString() <<
" = zeros(" << nRows
2169 *filePtrSet.ofsVar << varNamePrefix <<
"_sub" <<
m_env.
subIdString() <<
" = [";
2171 for (
unsigned int i = 0; i < nRows; ++i) {
2172 for (
unsigned int j = 0; j < nCols; ++j) {
2173 *filePtrSet.ofsVar << (*this)(i,j)
2176 *filePtrSet.ofsVar <<
"\n";
2178 *filePtrSet.ofsVar <<
"];\n";
2188 const std::string& fileName,
2189 const std::string& fileType,
2190 const std::set<unsigned int>& allowedSubEnvIds)
2194 "GslMatrix::subReadContents()",
2195 "unexpected subRank");
2199 "GslMatrix::subReadContents()",
2200 "implemented just for sequential vectors for now");
2212 unsigned int idOfMyFirstLine = 1;
2213 unsigned int idOfMyLastLine = nRowsLocal;
2214 unsigned int nCols = this->
numCols();
2218 std::string tmpString;
2221 *filePtrSet.ifsVar >> tmpString;
2225 *filePtrSet.ifsVar >> tmpString;
2229 "GslMatrix::subReadContents()",
2230 "string should be the '=' sign");
2233 *filePtrSet.ifsVar >> tmpString;
2235 unsigned int posInTmpString = 6;
2238 char nRowsString[tmpString.size()-posInTmpString+1];
2239 unsigned int posInRowsString = 0;
2243 "GslMatrix::subReadContents()",
2244 "symbol ',' not found in first line of file");
2245 nRowsString[posInRowsString++] = tmpString[posInTmpString++];
2246 }
while (tmpString[posInTmpString] !=
',');
2247 nRowsString[posInRowsString] =
'\0';
2251 char nColsString[tmpString.size()-posInTmpString+1];
2252 unsigned int posInColsString = 0;
2256 "GslMatrix::subReadContents()",
2257 "symbol ')' not found in first line of file");
2258 nColsString[posInColsString++] = tmpString[posInTmpString++];
2259 }
while (tmpString[posInTmpString] !=
')');
2260 nColsString[posInColsString] =
'\0';
2263 unsigned int numRowsInFile = (
unsigned int) strtod(nRowsString,NULL);
2264 unsigned int numColsInFile = (
unsigned int) strtod(nColsString,NULL);
2268 <<
", numRowsInFile = " << numRowsInFile
2269 <<
", numColsInFile = " << numColsInFile
2270 <<
", nRowsLocal = " << nRowsLocal
2271 <<
", nCols = " << nCols
2278 "GslMatrix::subReadContents()",
2279 "size of vec in file is not big enough");
2284 "GslMatrix::subReadContents()",
2285 "number of parameters of vec in file is different than number of parameters in this vec object");
2288 unsigned int maxCharsPerLine = 64*nCols;
2290 unsigned int lineId = 0;
2291 while (lineId < idOfMyFirstLine) {
2292 filePtrSet.ifsVar->ignore(maxCharsPerLine,
'\n');
2298 <<
": beginning to read input actual data"
2305 *filePtrSet.ifsVar >> tmpString;
2309 *filePtrSet.ifsVar >> tmpString;
2313 "GslMatrix::subReadContents()",
2314 "in core 0, string should be the '=' sign");
2317 std::streampos tmpPos = filePtrSet.ifsVar->tellg();
2318 filePtrSet.ifsVar->seekg(tmpPos+(std::streampos)2);
2322 <<
": beginning to read lines with numbers only"
2323 <<
", lineId = " << lineId
2324 <<
", idOfMyFirstLine = " << idOfMyFirstLine
2325 <<
", idOfMyLastLine = " << idOfMyLastLine
2330 while (lineId <= idOfMyLastLine) {
2331 for (
unsigned int j = 0; j < nCols; ++j) {
2332 *filePtrSet.ifsVar >> tmpRead;
2333 (*this)(lineId-idOfMyFirstLine,j) = tmpRead;
2367 unsigned int m1Cols = m1.
numCols();
2369 unsigned int m2Cols = m2.
numCols();
2373 "GslMatrix operator*(matrix,matrix)",
2374 "different sizes m1Cols and m2Rows");
2380 unsigned int commonSize = m1Cols;
2381 for (
unsigned int row1 = 0; row1 < m1Rows; ++row1) {
2382 for (
unsigned int col2 = 0; col2 < m2Cols; ++col2) {
2384 for (
unsigned int k = 0; k < commonSize; ++k) {
2385 result += m1(row1,k)*m2(k,col2);
2387 mat(row1,col2) = result;
2415 for (
unsigned int i = 0; i < nRows; ++i) {
2416 double value1 = v1[i];
2417 for (
unsigned int j = 0; j < nCols; ++j) {
2418 answer(i,j) = value1*v2[j];
2429 unsigned int mCols = mat.
numCols();
2433 "GslMatrix leftDiagScaling(vector,matrix)",
2434 "size of vector is different from the number of rows in matrix");
2438 "GslMatrix leftDiagScaling(vector,matrix)",
2439 "routine currently works for square matrices only");
2442 for (
unsigned int i = 0; i < mRows; ++i) {
2443 double vecValue = vec[i];
2444 for (
unsigned int j = 0; j < mCols; ++j) {
2445 answer(i,j) *= vecValue;
2456 unsigned int mCols = mat.
numCols();
2460 "GslMatrix rightDiagScaling(matrix,vector)",
2461 "size of vector is different from the number of cols in matrix");
2465 "GslMatrix rightDiagScaling(matrix,vector)",
2466 "routine currently works for square matrices only");
2469 for (
unsigned int j = 0; j < mCols; ++j) {
2470 double vecValue = vec[j];
2471 for (
unsigned int i = 0; i < mRows; ++i) {
2472 answer(i,j) *= vecValue;
int internalSvd() const
This function factorizes the M-by-N matrix A into the singular value decomposition A = U S V^T for M ...
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.
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.
The QUESO MPI Communicator Class.
const GslMatrix & svdMatV() const
This function calls private member GslMatrix::internalSvd() to set a N-by-N orthogonal square matrix ...
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).
int subRank() const
Access function for sub-rank.
void copy(const GslMatrix &src)
In this function this matrix receives a copy of matrix src.
A class for partitioning vectors and matrices.
void smallestEigen(double &eigenValue, GslVector &eigenVector) const
This function finds smallest eigenvalue, namely eigenValue, of this matrix and its corresponding eige...
const BaseEnvironment & env() const
GslMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
GslVector multiply(const GslVector &x) const
This function multiplies this matrix by vector x and returns the resulting vector.
double norm2() const
Returns the 2-norm (Euclidean norm) of the vector.
gsl_matrix * data()
Returns this matrix.
#define UQ_RC_MACRO(macroIRc, givenRank, where, what, retValue)
Macros.
unsigned int sizeLocal() const
Returns the length of this vector.
int worldRank() const
Returns the process world rank.
GslVector invertMultiplyForceLU(const GslVector &b) const
This function calculates the inverse of this matrix and multiplies it with vector b...
#define RawValue_MPI_DOUBLE
unsigned int checkingLevel() const
Access function to private attribute m_checkingLevel.
void setColumn(const unsigned int column_num, const GslVector &column)
This function copies vector column into the column_num-th column of this matrix.
gsl_permutation * m_permutation
The permutation matrix of a LU decomposition.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
const int UQ_MATRIX_SVD_FAILED_RC
GslVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
GslMatrix operator+(const GslMatrix &m1, const GslMatrix &m2)
GslMatrix operator-(const GslMatrix &m1, const GslMatrix &m2)
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.
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...
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.
virtual void copy(const Matrix &src)
Copies matrix src to this matrix.
void subReadContents(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds)
Read contents of subenvironment from file fileName.
unsigned int numRowsGlobal() const
Returns the global row dimension of this matrix.
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...
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.
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
GslMatrix & operator*=(double a)
Stores in this the coordinate-wise multiplication of this and a.
gsl_matrix * m_LU
GSL matrix for the LU decomposition of m_mat.
void filterSmallValues(double thresholdValue)
This function sets to zero (filters) all entries of this matrix which are smaller than thresholdValue...
const BaseEnvironment & env() const
void eigen(GslVector &eigenValues, GslMatrix *eigenVectors) const
This function computes the eigenvalues of a real symmetric matrix.
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
std::ostream & operator<<(std::ostream &os, const BaseEnvironment &obj)
void largestEigen(double &eigenValue, GslVector &eigenVector) const
This function finds largest eigenvalue, namely eigenValue, of this matrix and its corresponding eigen...
void cwSet(double value)
Component-wise sets all values to this with value.
Class for vector operations using GSL library.
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...
void setRow(const unsigned int row_num, const GslVector &row)
This function copies vector row into the row_num-th column of this matrix.
#define UQ_FATAL_RC_MACRO(macroIRc, givenRank, where, what)
int chol()
Computes Cholesky factorization of a real symmetric positive definite matrix this.
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 cwExtract(unsigned int rowId, unsigned int colId, GslMatrix &mat) const
double m_determinant
The determinant of this matrix.
unsigned int numCols() const
Returns the column dimension of this matrix.
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
GslMatrix & operator/=(double a)
Stores in this the coordinate-wise division of this by a.
Map * m_svdColMap
Mapping for matrices involved in the singular value decomposition (svd) routine.
Class for matrix operations (virtual).
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
GslMatrix * m_inverse
Inverse matrix of this.
Struct for handling data input and output from files.
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).
GslMatrix rightDiagScaling(const GslMatrix &mat, const GslVector &vec)
double max() const
Returns the maximum element value of the matrix.
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.
void matlabLinearInterpExtrap(const GslVector &x1Vec, const GslVector &y1Vec, const GslVector &x2Vec)
GslMatrix & operator=(const GslMatrix &rhs)
Copies values from matrix rhs to this.
const int UQ_MATRIX_IS_NOT_POS_DEFINITE_RC
void zeroUpper(bool includeDiagonal=false)
This function sets all the entries above the main diagonal of this matrix to zero.
bool m_inDebugMode
Flag for either or not QUESO is in debug mode.
int fullRank() const
Returns the process full rank.
int m_signum
m_signum stores the sign of the permutation of the LU decomposition PA = LU.
const Map & m_map
Mapping variable.
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.
bool m_printHorizontally
Flag for either or not print this matrix.
double normFrob() const
Returns the Frobenius norm of this matrix.
GslVector abs() const
This function returns absolute value of elements in this.
GslMatrix()
Default Constructor.
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...
GslMatrix operator*(double a, const GslMatrix &mat)
void filterLargeValues(double thresholdValue)
This function sets to zero (filters) all entries of this matrix which are greater than thresholdValue...
const BaseEnvironment & m_env
QUESO environment variable.
gsl_vector * data() const
bool m_isSingular
Indicates whether or not this matrix is singular.
GslMatrix & operator-=(const GslMatrix &rhs)
Stores in this the coordinate-wise subtraction of this by rhs.
unsigned int displayVerbosity() const
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
GslMatrix & operator+=(const GslMatrix &rhs)
Stores in this the coordinate-wise addition of this and rhs.
GslMatrix matrixProduct(const GslVector &v1, const GslVector &v2)
double normMax() const
Returns the Frobenius norm of this matrix.
void matlabLinearInterpExtrap(const GslVector &x1Vec, const GslMatrix &y1Mat, const GslVector &x2Vec)
void zeroLower(bool includeDiagonal=false)
This function sets all the entries bellow the main diagonal of this matrix to zero.
const GslMatrix & svdMatU() const
This function calls private member GslMatrix::internalSvd() to set a M-by-N orthogonal matrix U of th...
double determinant() const
Calculates the determinant of this matrix.
double lnDeterminant() const
Calculates the ln(determinant) of this matrix.
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...
GslMatrix leftDiagScaling(const GslVector &vec, const GslMatrix &mat)
double m_lnDeterminant
The natural logarithm of the determinant 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_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
Class for matrix operations using GSL library.
unsigned int numOfProcsForStorage() const
void cwSet(double value)
Component-wise set all values to this with value.
GslMatrix transpose() const
This function calculated the transpose of this matrix (square).