queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::TeuchosMatrix Class Reference

Class for matrix operations using Teuchos (Trilinos). More...

#include <TeuchosMatrix.h>

Inheritance diagram for QUESO::TeuchosMatrix:
QUESO::Matrix

Public Member Functions

Constructor/Destructor methods
 TeuchosMatrix (const BaseEnvironment &env, const Map &map, unsigned int numCols)
 Shaped Constructor: creates a shaped matrix with numCols columns. More...
 
 TeuchosMatrix (const BaseEnvironment &env, const Map &map, double diagValue)
 Shaped Constructor: creates a square matrix with size map.NumGlobalElements() and diagonal values all equal to diagValue. More...
 
 TeuchosMatrix (const TeuchosVector &v, double diagValue)
 Shaped Constructor: creates a square matrix with size v.sizeLocal() and diagonal values all equal to diagValue. More...
 
 TeuchosMatrix (const TeuchosVector &v)
 Shaped Constructor: creates a square matrix with size v.sizeLocal(). More...
 
 TeuchosMatrix (const TeuchosMatrix &B)
 Shaped Constructor: this matrix is a copy of matrix B. More...
 
 ~TeuchosMatrix ()
 Destructor. More...
 
Set methods
TeuchosMatrixoperator= (const TeuchosMatrix &rhs)
 Copies values from matrix rhs to this. More...
 
TeuchosMatrixoperator*= (double a)
 Stores in this the coordinate-wise multiplication of this and a. More...
 
TeuchosMatrixoperator/= (double a)
 Stores in this the coordinate-wise division of this by a. More...
 
TeuchosMatrixoperator+= (const TeuchosMatrix &rhs)
 Stores in this the coordinate-wise addition of this and rhs. More...
 
TeuchosMatrixoperator-= (const TeuchosMatrix &rhs)
 Stores in this the coordinate-wise subtraction of this by rhs. More...
 
Accessor methods
double & operator() (unsigned int i, unsigned int j)
 Element access method (non-const). More...
 
const double & operator() (unsigned int i, unsigned int j) const
 Element access method (const). More...
 
Attribute methods
unsigned int numRowsLocal () const
 Returns the local row dimension of this matrix. More...
 
unsigned int numRowsGlobal () const
 Returns the global row dimension of this matrix. More...
 
unsigned int numCols () const
 Returns the column dimension of this matrix. More...
 
double * values ()
 Returns a pointer to the first element of this matrix. More...
 
int stride ()
 Returns the stride between the columns of this matrix in memory. More...
 
double max () const
 Returns the maximum element value of the matrix. More...
 
unsigned int rank (double absoluteZeroThreshold, double relativeZeroThreshold) const
 This function returns the number of singular values of this matrix (rank). More...
 
TeuchosMatrix transpose () const
 This function calculates the transpose of this matrix (square). More...
 
TeuchosMatrix inverse () const
 This function calculates the inverse of this matrix (square). More...
 
double determinant () const
 Calculates the determinant of this matrix. More...
 
double lnDeterminant () const
 Calculates the ln(determinant) of this matrix. More...
 
Norm methods
double normFrob () const
 Returns the Frobenius norm of this matrix. More...
 
double normMax () const
 Returns the Frobenius norm of this matrix. More...
 
Mathematical methods
int chol ()
 Computes Cholesky factorization of this, a real symmetric positive definite matrix. More...
 
int svd (TeuchosMatrix &matU, TeuchosVector &vecS, TeuchosMatrix &matVt) const
 Checks for the dimension of this matrix, matU, VecS and matVt, and calls the protected routine internalSvd to compute the singular values of this. More...
 
const TeuchosMatrixsvdMatU () const
 This function calls private member TeuchosMatrix::internalSvd() to set a M-by-N orthogonal matrix U of the singular value decomposition (svd) of a general rectangular M-by-N matrix A. More...
 
const TeuchosMatrixsvdMatV () const
 This function calls private member TeuchosMatrix::internalSvd() to set a N-by-N orthogonal square matrix V of the singular value decomposition (svd) of a general rectangular M-by-N matrix A. More...
 
int svdSolve (const TeuchosVector &rhsVec, TeuchosVector &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 TeuchosMatrix::svd (x=solVec, b=rhsVec). More...
 
int svdSolve (const TeuchosMatrix &rhsMat, TeuchosMatrix &solMat) 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 TeuchosMatrix::svd (x=solMat, b=rhsMat). More...
 
TeuchosVector multiply (const TeuchosVector &x) const
 This function multiplies this matrix by vector x and returns a vector. More...
 
void invertMultiply (const TeuchosVector &b, TeuchosVector &x) const
 This function calculates the inverse of this matrix, multiplies it with vector b and stores the result in vector x. More...
 
TeuchosVector invertMultiply (const TeuchosVector &b) const
 This function calculates the inverse of this matrix and multiplies it with vector b. More...
 
void invertMultiply (const TeuchosMatrix &B, TeuchosMatrix &X) const
 This function calculates the inverse of this matrix, multiplies it with matrix B and stores the result in matrix X. More...
 
TeuchosMatrix invertMultiply (const TeuchosMatrix &B) const
 This function calculates the inverse of this matrix and multiplies it with matrix B. More...
 
void invertMultiplyForceLU (const TeuchosVector &b, TeuchosVector &x) const
 This function calculates the inverse of this matrix, multiplies it with vector b and stores the result in vector x. More...
 
TeuchosVector invertMultiplyForceLU (const TeuchosVector &b) const
 This function calculates the inverse of this matrix and multiplies it with vector b. More...
 
void eigen (TeuchosVector &eigenValues, TeuchosMatrix *eigenVectors) const
 This function computes the eigenvalues of a real symmetric matrix. More...
 
void largestEigen (double &eigenValue, TeuchosVector &eigenVector) const
 This function finds largest eigenvalue, namely eigenValue, of this matrix and its corresponding eigenvector, namely eigenVector. More...
 
void smallestEigen (double &eigenValue, TeuchosVector &eigenVector) const
 This function finds smallest eigenvalue, namely eigenValue, of this matrix and its corresponding eigenvector, namely eigenVector. More...
 
Get/Set methods
void cwSet (double value)
 Component-wise set all values to this with value. More...
 
void cwSet (unsigned int rowId, unsigned int colId, const TeuchosMatrix &mat)
 Set the components of which positions are greater than (rowId,colId) with the value of mat(rowId,colId). More...
 
void getColumn (const unsigned int column_num, TeuchosVector &column) const
 This function gets the column_num-th column of this matrix and stores it into vector column. More...
 
TeuchosVector getColumn (const unsigned int column_num) const
 This function gets the column_num-th column of this matrix. More...
 
void setColumn (const unsigned int column_num, const TeuchosVector &column)
 This function copies vector column into the column_num-th column of this matrix. More...
 
void getRow (const unsigned int row_num, TeuchosVector &row) const
 This function gets the row_num-th column of this matrix and stores it into vector row. More...
 
TeuchosVector getRow (const unsigned int row_num) const
 This function gets the row_num-th column of this matrix. More...
 
void setRow (const unsigned int row_num, const TeuchosVector &row)
 This function copies vector row into the row_num-th column of this matrix. More...
 
void zeroLower (bool includeDiagonal=false)
 This function sets all the entries above the main diagonal (inclusive or not) of this matrix to zero. More...
 
void zeroUpper (bool includeDiagonal=false)
 This function sets all the entries bellow the main diagonal (inclusive or not) of this matrix to zero. More...
 
void filterSmallValues (double thresholdValue)
 This function sets to zero (filters) all entries of this matrix which are smaller than thresholdValue. More...
 
void filterLargeValues (double thresholdValue)
 This function sets to zero (filters) all entries of this matrix which are greater than thresholdValue. More...
 
void fillWithTranspose (const TeuchosMatrix &mat)
 This function stores the transpose of this matrix into this matrix. More...
 
void fillWithBlocksDiagonally (const std::vector< const TeuchosMatrix * > &matrices)
 This function fills this matrix diagonally with const block matrices. More...
 
void fillWithBlocksDiagonally (const std::vector< TeuchosMatrix * > &matrices)
 This function fills this matrix diagonally with block matrices. More...
 
void fillWithBlocksHorizontally (const std::vector< const TeuchosMatrix * > &matrices)
 This function fills this matrix horizontally with const block matrices. More...
 
void fillWithBlocksHorizontally (const std::vector< TeuchosMatrix * > &matrices)
 This function fills this matrix horizontally with block matrices. More...
 
void fillWithBlocksVertically (const std::vector< const TeuchosMatrix * > &matrices)
 This function fills this matrix vertically with const block matrices. More...
 
void fillWithBlocksVertically (const std::vector< TeuchosMatrix * > &matrices)
 This function fills this matrix vertically with block matrices. More...
 
void fillWithTensorProduct (const TeuchosMatrix &mat1, const TeuchosMatrix &mat2)
 This function calculates the tensor product of matrices mat1 and mat2 and stores it in this matrix. More...
 
void fillWithTensorProduct (const TeuchosMatrix &mat1, const TeuchosVector &vec2)
 This function calculates the tensor product of matrix mat1 and vector vec2 and stores it in this matrix. More...
 
Miscellaneous methods
void mpiSum (const MpiComm &comm, TeuchosMatrix &M_global) const
 
void matlabLinearInterpExtrap (const TeuchosVector &x1Vec, const TeuchosMatrix &y1Mat, const TeuchosVector &x2Vec)
 
I/O methods
void print (std::ostream &os) const
 Print method. Defines the behavior of the ostream << operator inherited from the Object class. More...
 
void subReadContents (const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds)
 Read contents of subenvironment from file fileName. More...
 
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. More...
 
- Public Member Functions inherited from QUESO::Matrix
 Matrix (const BaseEnvironment &env, const Map &map)
 Shaped constructor. More...
 
virtual ~Matrix ()
 Virtual Destructor. More...
 
const BaseEnvironmentenv () const
 
const Mapmap () const
 
unsigned int numOfProcsForStorage () const
 
void setPrintHorizontally (bool value) const
 Determines whether the matrix should be printed horizontally. More...
 
bool getPrintHorizontally () const
 Checks if matrix will be is printed horizontally. More...
 
void setInDebugMode (bool value) const
 Determines whether QUESO will run through this class in debug mode. More...
 
bool getInDebugMode () const
 Checks if QUESO will run through this class in debug mode. More...
 

Private Member Functions

 TeuchosMatrix ()
 Default Constructor. More...
 
void copy (const TeuchosMatrix &src)
 In this function this matrix receives a copy of matrix src. More...
 
void resetLU ()
 In this function resets the LU decomposition of this matrix, as well as deletes the private member pointers, if existing. More...
 
void multiply (const TeuchosVector &x, TeuchosVector &y) const
 This function multiplies this matrix by vector x and stores the resulting vector in y. More...
 
int internalSvd () const
 This function factorizes the M-by-N matrix A into the singular value decomposition A = U S V^T for M >= N. On output the matrix A is replaced by U. More...
 

Private Attributes

Teuchos::SerialDenseMatrix
< int, double > 
m_mat
 Teuchos matrix, also referred to as this matrix. More...
 
Teuchos::SerialDenseMatrix
< int, double > 
m_LU
 Teuchos matrix for the LU decomposition of m_mat. More...
 
TeuchosMatrixm_inverse
 Stores the inverse of this matrix. More...
 
Mapm_svdColMap
 Mapping for matrices involved in the singular value decomposition (svd) routine. More...
 
TeuchosMatrixm_svdUmat
 m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix. More...
 
TeuchosVectorm_svdSvec
 m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular value decomposition of a matrix. More...
 
TeuchosMatrixm_svdVmat
 m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a matrix. More...
 
TeuchosMatrixm_svdVTmat
 m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular value decomposition of a matrix. More...
 
double m_determinant
 The determinant of this matrix. More...
 
double m_lnDeterminant
 The natural logarithm of the determinant of this matrix. More...
 
TeuchosMatrixm_permutation
 
int * v_pivoting
 The pivoting vector of a LU decomposition. More...
 
int m_signum
 
bool m_isSingular
 Indicates whether or not this matrix is singular. More...
 

Additional Inherited Members

- Protected Member Functions inherited from QUESO::Matrix
virtual void base_copy (const Matrix &src)
 Copies base data from matrix src to this matrix. More...
 
- Protected Attributes inherited from QUESO::Matrix
const BaseEnvironmentm_env
 QUESO environment variable. More...
 
const Map m_map
 Mapping variable. More...
 
const Mapm_map
 Mapping variable. More...
 
bool m_printHorizontally
 Flag for either or not print this matrix. More...
 
bool m_inDebugMode
 Flag for either or not QUESO is in debug mode. More...
 

Detailed Description

Class for matrix operations using Teuchos (Trilinos).

This class creates and provides basic support for matrices of templated type as a specialization of Matrix using Teuchos matrices (from Trilinos), which are defined by an encapsulated Teuchos::SerialDenseMatrix structure.

Definition at line 53 of file TeuchosMatrix.h.

Constructor & Destructor Documentation

QUESO::TeuchosMatrix::TeuchosMatrix ( const BaseEnvironment env,
const Map map,
unsigned int  numCols 
)

Shaped Constructor: creates a shaped matrix with numCols columns.

Definition at line 43 of file TeuchosMatrix.C.

References m_LU, m_mat, and QUESO::Map::NumGlobalElements().

47  :
48  Matrix (env,map),
49  m_inverse (NULL),
50  m_svdColMap (NULL),
51  m_svdUmat (NULL),
52  m_svdSvec (NULL),
53  m_svdVmat (NULL),
54  m_svdVTmat (NULL),
55  m_determinant (-INFINITY),
56  m_lnDeterminant(-INFINITY),
57  v_pivoting (NULL),
58  m_signum (0),
59  m_isSingular (false)
60 {
61  m_mat.shape(map.NumGlobalElements(),nCols);
62  m_LU.shape(0,0);
63 }
const BaseEnvironment & env() const
Definition: Matrix.C:47
Map * m_svdColMap
Mapping for matrices involved in the singular value decomposition (svd) routine.
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
TeuchosMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
double m_lnDeterminant
The natural logarithm of the determinant of this matrix.
TeuchosMatrix * m_inverse
Stores the inverse of this matrix.
int * v_pivoting
The pivoting vector of a LU decomposition.
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
TeuchosMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
bool m_isSingular
Indicates whether or not this matrix is singular.
double m_determinant
The determinant of this matrix.
const Map & map() const
Definition: Matrix.C:54
Matrix()
Default constructor.
QUESO::TeuchosMatrix::TeuchosMatrix ( const BaseEnvironment env,
const Map map,
double  diagValue 
)

Shaped Constructor: creates a square matrix with size map.NumGlobalElements() and diagonal values all equal to diagValue.

Definition at line 67 of file TeuchosMatrix.C.

References m_LU, m_mat, and QUESO::Map::NumGlobalElements().

71  :
72  Matrix (env,map),
73  m_inverse (NULL),
74  m_svdColMap (NULL),
75  m_svdUmat (NULL),
76  m_svdSvec (NULL),
77  m_svdVmat (NULL),
78  m_svdVTmat (NULL),
79  m_determinant (-INFINITY),
80  m_lnDeterminant(-INFINITY),
81  v_pivoting (NULL),
82  m_signum (0),
83  m_isSingular (false)
84 {
86  m_LU.shape(0,0);
87 
88  for (unsigned int i = 0; i < (unsigned int) m_mat.numRows(); ++i) {
89  m_mat(i,i) = diagValue;
90  }
91 }
const BaseEnvironment & env() const
Definition: Matrix.C:47
Map * m_svdColMap
Mapping for matrices involved in the singular value decomposition (svd) routine.
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
TeuchosMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
double m_lnDeterminant
The natural logarithm of the determinant of this matrix.
TeuchosMatrix * m_inverse
Stores the inverse of this matrix.
int * v_pivoting
The pivoting vector of a LU decomposition.
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
TeuchosMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
bool m_isSingular
Indicates whether or not this matrix is singular.
double m_determinant
The determinant of this matrix.
const Map & map() const
Definition: Matrix.C:54
Matrix()
Default constructor.
QUESO::TeuchosMatrix::TeuchosMatrix ( const TeuchosVector v,
double  diagValue 
)

Shaped Constructor: creates a square matrix with size v.sizeLocal() and diagonal values all equal to diagValue.

Definition at line 95 of file TeuchosMatrix.C.

References m_LU, m_mat, and QUESO::TeuchosVector::sizeLocal().

98  :
99  Matrix (v.env(),v.map()),
100  m_inverse (NULL),
101  m_svdColMap (NULL),
102  m_svdUmat (NULL),
103  m_svdSvec (NULL),
104  m_svdVmat (NULL),
105  m_svdVTmat (NULL),
106  m_determinant (-INFINITY),
107  m_lnDeterminant(-INFINITY),
108  v_pivoting (NULL),
109  m_signum (0),
110  m_isSingular (false)
111 {
112  m_mat.shape (v.sizeLocal(),v.sizeLocal());
113  m_LU.shape(0,0);
114 
115  for (unsigned int i = 0; i < (unsigned int) m_mat.numRows(); ++i) {
116  m_mat(i,i) = diagValue;
117  }
118 }
Map * m_svdColMap
Mapping for matrices involved in the singular value decomposition (svd) routine.
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
TeuchosMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
double m_lnDeterminant
The natural logarithm of the determinant of this matrix.
TeuchosMatrix * m_inverse
Stores the inverse of this matrix.
int * v_pivoting
The pivoting vector of a LU decomposition.
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
TeuchosMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
bool m_isSingular
Indicates whether or not this matrix is singular.
double m_determinant
The determinant of this matrix.
Matrix()
Default constructor.
QUESO::TeuchosMatrix::TeuchosMatrix ( const TeuchosVector v)

Shaped Constructor: creates a square matrix with size v.sizeLocal().

The diagonal values of this matrix are the elements in vector v.

Definition at line 123 of file TeuchosMatrix.C.

References dim, m_LU, m_mat, and QUESO::TeuchosVector::sizeLocal().

124  :
125  Matrix (v.env(),v.map()),
126  m_inverse (NULL),
127  m_svdColMap (NULL),
128  m_svdUmat (NULL),
129  m_svdSvec (NULL),
130  m_svdVmat (NULL),
131  m_svdVTmat (NULL),
132  m_determinant (-INFINITY),
133  m_lnDeterminant(-INFINITY),
134  v_pivoting (NULL),
135  m_signum (0),
136  m_isSingular (false)
137 {
138  m_mat.shape (v.sizeLocal(),v.sizeLocal());
139  m_LU.shape(0,0);
140 
141  unsigned int dim = v.sizeLocal();
142 
143  for (unsigned int i = 0; i < dim; ++i) {
144  m_mat(i,i) = v[i];
145  }
146 }
Map * m_svdColMap
Mapping for matrices involved in the singular value decomposition (svd) routine.
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
TeuchosMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
double m_lnDeterminant
The natural logarithm of the determinant of this matrix.
TeuchosMatrix * m_inverse
Stores the inverse of this matrix.
int * v_pivoting
The pivoting vector of a LU decomposition.
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
TeuchosMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
bool m_isSingular
Indicates whether or not this matrix is singular.
double m_determinant
The determinant of this matrix.
int dim
Definition: ann_test.cpp:472
Matrix()
Default constructor.
QUESO::TeuchosMatrix::TeuchosMatrix ( const TeuchosMatrix B)

Shaped Constructor: this matrix is a copy of matrix B.

Definition at line 150 of file TeuchosMatrix.C.

References QUESO::Matrix::base_copy(), copy(), m_LU, m_mat, numCols(), and numRowsLocal().

151  :
152  Matrix (B.env(),B.map()),
153  m_inverse (NULL),
154  m_svdColMap (NULL),
155  m_svdUmat (NULL),
156  m_svdSvec (NULL),
157  m_svdVmat (NULL),
158  m_svdVTmat (NULL),
159  m_determinant (-INFINITY),
160  m_lnDeterminant(-INFINITY),
161  v_pivoting (NULL),
162  m_signum (0),
163  m_isSingular (false)
164 {
165  m_mat.shape (B.numRowsLocal(),B.numCols());
166  m_LU.shape(0,0);
167 
168  this->Matrix::base_copy(B);
169  this->copy(B);
170 }
Map * m_svdColMap
Mapping for matrices involved in the singular value decomposition (svd) routine.
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
TeuchosMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
double m_lnDeterminant
The natural logarithm of the determinant of this matrix.
TeuchosMatrix * m_inverse
Stores the inverse of this matrix.
int * v_pivoting
The pivoting vector of a LU decomposition.
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
TeuchosMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
bool m_isSingular
Indicates whether or not this matrix is singular.
double m_determinant
The determinant of this matrix.
virtual void base_copy(const Matrix &src)
Copies base data from matrix src to this matrix.
Definition: Matrix.C:99
void copy(const TeuchosMatrix &src)
In this function this matrix receives a copy of matrix src.
Matrix()
Default constructor.
QUESO::TeuchosMatrix::~TeuchosMatrix ( )

Destructor.

Definition at line 174 of file TeuchosMatrix.C.

References resetLU().

175 {
176  this->resetLU();
177 }
void resetLU()
In this function resets the LU decomposition of this matrix, as well as deletes the private member po...
QUESO::TeuchosMatrix::TeuchosMatrix ( )
private

Default Constructor.

Creates an empty matrix vector of no dimension. It should not be used by user.

Referenced by internalSvd(), inverse(), and svdSolve().

Member Function Documentation

int QUESO::TeuchosMatrix::chol ( )
virtual

Computes Cholesky factorization of this, a real symmetric positive definite matrix.

In case fails to be symmetric and positive definite, an error will be returned.

Implements QUESO::Matrix.

Definition at line 568 of file TeuchosMatrix.C.

References QUESO::Matrix::m_env, m_mat, QUESO::UQ_MATRIX_IS_NOT_POS_DEFINITE_RC, and QUESO::BaseEnvironment::worldRank().

569 {
570  int return_success =0 ;
571 /* If UPLO = 'L', the leading N-by-N lower triangular part of A contains the lower
572  * triangular part of the matrix A (lets call it L), and the strictly upper
573  * triangular part of A is not referenced. Thus, the upper triangular part
574  * of A +++must be manually+++ overwritten with L^T. */
575 
576  Teuchos::LAPACK<int, double> lapack;
577  int info;//= 0: successful exit
578  //< 0: if INFO = -i, the i-th argument had an illegal value
579  //> 0: if INFO = i, the leading minor of order i is not
580  // positive definite, and the factorization could not be
581  // completed.
582  char UPLO = 'U';
583  //= 'U': Upper triangle of A is stored;
584  //= 'L': Lower triangle of A is stored.
585 
586  lapack.POTRF (UPLO, m_mat.numRows(), m_mat.values(), m_mat.stride(), &info);
587 
588  // Overwriting the upper triangular part of the input matrix A with L^T
589  //(the diagonal terms are identical for both L and L^T)
590 
591  for (int i=0;i<m_mat.numRows();i++){
592  for (int j=i+1;j<m_mat.numCols();j++)
593  m_mat(i,j) = m_mat(j,i) ;
594  }
595 
596  if (info != 0) {
597  std::cerr << "In TeuchosMtrix::chol()"
598  << ": INFO = " << info
599  << ",\n INFO < 0: if INFO = -i, the i-th argument had an illegal value."
600  << "\n INFO > 0: if INFO = i, the leading minor of order i is not "
601  << " positive definite, and the factorization could not be completed."
602  << std::endl;
603  return_success =1 ;
604  }
605 
606  UQ_RC_MACRO(info, // Yes, *not* a fatal check on RC
607  m_env.worldRank(),
608  "TeuchosMatrix::chol()",
609  "matrix is not positive definite",
611 
612  return return_success;
613 };
const int UQ_MATRIX_IS_NOT_POS_DEFINITE_RC
Definition: Defines.h:100
int worldRank() const
Returns the same thing as fullRank()
Definition: Environment.C:262
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void QUESO::TeuchosMatrix::copy ( const TeuchosMatrix src)
private

In this function this matrix receives a copy of matrix src.

Definition at line 1931 of file TeuchosMatrix.C.

References m_mat, numCols(), numRowsLocal(), and resetLU().

Referenced by operator=(), and TeuchosMatrix().

1932 {
1933  // FIXME - should we be calling Matrix::base_copy here? - RHS
1934  this->resetLU();
1935  unsigned int i,j, nrows=src.numRowsLocal(), ncols=src.numCols();
1936 
1937  for(i=0; i< nrows ; i++)
1938  for (j = 0; j < ncols; j++)
1939  m_mat(i,j) = src(i,j);
1940 
1941  return;
1942 }
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos 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 QUESO::TeuchosMatrix::cwSet ( double  value)

Component-wise set all values to this with value.

Definition at line 1189 of file TeuchosMatrix.C.

References m_mat.

1190 {
1191  m_mat.putScalar(value);
1192  return;
1193 }
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
void QUESO::TeuchosMatrix::cwSet ( unsigned int  rowId,
unsigned int  colId,
const TeuchosMatrix mat 
)

Set the components of which positions are greater than (rowId,colId) with the value of mat(rowId,colId).

Definition at line 1198 of file TeuchosMatrix.C.

References numCols(), and numRowsLocal().

1199 {
1200  queso_require_less_msg(rowId, this->numRowsLocal(), "invalid rowId");
1201 
1202  queso_require_less_equal_msg((rowId + mat.numRowsLocal()), this->numRowsLocal(), "invalid vec.numRowsLocal()");
1203 
1204  queso_require_less_msg(colId, this->numCols(), "invalid colId");
1205 
1206  queso_require_less_equal_msg((colId + mat.numCols()), this->numCols(), "invalid vec.numCols()");
1207 
1208  for (unsigned int i = 0; i < mat.numRowsLocal(); ++i) {
1209  for (unsigned int j = 0; j < mat.numCols(); ++j) {
1210  (*this)(rowId+i,colId+j) = mat(i,j);
1211  }
1212  }
1213 
1214  return;
1215 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
unsigned int numCols() const
Returns the column dimension of this matrix.
double QUESO::TeuchosMatrix::determinant ( ) const

Calculates the determinant of this matrix.

Definition at line 442 of file TeuchosMatrix.C.

References QUESO::BaseEnvironment::displayVerbosity(), invertMultiply(), m_determinant, QUESO::Matrix::m_env, m_lnDeterminant, m_LU, QUESO::Matrix::m_map, and QUESO::BaseEnvironment::subDisplayFile().

443 {
444  if (m_determinant == -INFINITY)
445  {
446  if(m_LU.numRows() ==0 && m_LU.numCols() ==0) //dummy
447  {
448  TeuchosVector tmpB(m_env,m_map);
449  TeuchosVector tmpX(m_env,m_map);
450  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
451  *m_env.subDisplayFile() << "In TeuchosMatrix::lnDeterminant()"
452  << ": before 'this->invertMultiply()'"
453  << std::endl;
454  }
455  this->invertMultiply(tmpB,tmpX);
456  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
457  *m_env.subDisplayFile() << "In TeuchosMatrix::lnDeterminant()"
458  << ": after 'this->invertMultiply()'"
459  << std::endl;
460  }
461  }
462  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
463  *m_env.subDisplayFile() << "In TeuchosMatrix::lnDeterminant()"
464  << ": before computing det"
465  << std::endl;
466  }
467 
468  double det = 1.0;
469  double lnDet = 0.0;
470  for (int i=0;i<m_LU.numCols();i++) {
471  det *= m_LU(i,i);
472  lnDet += std::log(m_LU(i,i));
473  }
474 
475  m_determinant = det;
476  m_lnDeterminant = lnDet;
477 
478  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
479  *m_env.subDisplayFile() << "In TeuchosMatrix::lnDeterminant()"
480  << ": after computing det"
481  << std::endl;
482  }
483  }
484 
485  return m_determinant;
486 }
const Map m_map
Mapping variable.
Definition: Matrix.h:121
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
double m_lnDeterminant
The natural logarithm of the determinant of this matrix.
double m_determinant
The determinant of this matrix.
unsigned int displayVerbosity() const
Definition: Environment.C:450
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void invertMultiply(const TeuchosVector &b, TeuchosVector &x) const
This function calculates the inverse of this matrix, multiplies it with vector b and stores the resul...
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
void QUESO::TeuchosMatrix::eigen ( TeuchosVector eigenValues,
TeuchosMatrix eigenVectors 
) const

This function computes the eigenvalues of a real symmetric matrix.

Definition at line 1039 of file TeuchosMatrix.C.

References m_mat, numRowsLocal(), QUESO::queso_require_equal_to_msg, QUESO::queso_require_not_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

1040 {
1041  unsigned int n = eigenValues.sizeLocal();
1042 
1043  queso_require_not_equal_to_msg(n, 0, "invalid input vector size");
1044 
1045  if (eigenVectors) {
1046  queso_require_equal_to_msg(eigenValues.sizeLocal(), eigenVectors->numRowsLocal(), "different input vector sizes");
1047  }
1048 
1049  // At the end of execution, Lapack funcion destroys the input matrix
1050  // So, lets not use m_mat, but instead, a copy of it
1051  Teuchos::SerialDenseMatrix<int,double> copy_m_mat;
1052  copy_m_mat = m_mat;
1053 
1054  Teuchos::LAPACK<int, double> lapack;
1055  int lwork = 3*n -1;
1056  int info;
1057  char UPLO = 'L';
1058  double *W, *WORK;
1059 
1060  W = new double[n];
1061  WORK = new double[lwork];
1062 
1063  if (eigenVectors == NULL) {
1064  char JOBZ = 'N';//eigenvalues only
1065 
1066  lapack.SYEV(JOBZ, UPLO, copy_m_mat.numRows(), copy_m_mat.values(), copy_m_mat.stride(), &W[0], &WORK[0], lwork, &info);
1067 
1068  for (unsigned int i=0; i< n; i++)
1069  eigenValues[i] = W[i];
1070 
1071  queso_require_equal_to_msg(info, 0, "invalid input vector size");
1072  }
1073  else {
1074  char JOBZ = 'V';//eigenvalues and eigenvectors
1075 
1076  lapack.SYEV(JOBZ, UPLO, copy_m_mat.numRows(), copy_m_mat.values(), copy_m_mat.stride(), &W[0], &WORK[0], lwork, &info);
1077 
1078  for (unsigned int i=0; i< n; i++)
1079  eigenValues[i] = W[i];
1080 
1081  eigenVectors->m_mat = copy_m_mat;
1082  }
1083 
1084  if (info != 0) {
1085  std::cerr << "In TeuchosMtrix::eigen()"
1086  << ": INFO = " << info
1087  << ",\n INFO < 0: if INFO = -i, the i-th argument had an illegal value."
1088  << "\n INFO > 0: if INFO = i, the algorithm failed to converge; i off-diagonal "
1089  << " elements of an intermediate tridiagonal form did not converge to zero."
1090  << std::endl;
1091  }
1092 
1093  return;
1094 }
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
void QUESO::TeuchosMatrix::fillWithBlocksDiagonally ( const std::vector< const TeuchosMatrix * > &  matrices)

This function fills this matrix diagonally with const block matrices.

Definition at line 1439 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and QUESO::queso_require_equal_to_msg.

1440 {
1441  unsigned int sumNumRowsLocals = 0;
1442  unsigned int sumNumCols = 0;
1443  for (unsigned int i = 0; i < matrices.size(); ++i) {
1444  sumNumRowsLocals += matrices[i]->numRowsLocal();
1445  sumNumCols += matrices[i]->numCols();
1446  }
1447  queso_require_equal_to_msg(this->numRowsLocal(), sumNumRowsLocals, "inconsistent local number of rows");
1448  queso_require_equal_to_msg(this->numCols(), sumNumCols, "inconsistent number of cols");
1449 
1450  unsigned int cumulativeRowId = 0;
1451  unsigned int cumulativeColId = 0;
1452  for (unsigned int i = 0; i < matrices.size(); ++i) {
1453  unsigned int nRows = matrices[i]->numRowsLocal();
1454  unsigned int nCols = matrices[i]->numCols();
1455  for (unsigned int rowId = 0; rowId < nRows; ++rowId) {
1456  for (unsigned int colId = 0; colId < nCols; ++colId) {
1457  (*this)(cumulativeRowId + rowId, cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
1458  }
1459  }
1460  cumulativeRowId += nRows;
1461  cumulativeColId += nCols;
1462  }
1463 
1464  return;
1465 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::fillWithBlocksDiagonally ( const std::vector< TeuchosMatrix * > &  matrices)

This function fills this matrix diagonally with block matrices.

Definition at line 1469 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and QUESO::queso_require_equal_to_msg.

1470 {
1471  unsigned int sumNumRowsLocals = 0;
1472  unsigned int sumNumCols = 0;
1473  for (unsigned int i = 0; i < matrices.size(); ++i) {
1474  sumNumRowsLocals += matrices[i]->numRowsLocal();
1475  sumNumCols += matrices[i]->numCols();
1476  }
1477  queso_require_equal_to_msg(this->numRowsLocal(), sumNumRowsLocals, "inconsistent local number of rows");
1478  queso_require_equal_to_msg(this->numCols(), sumNumCols, "inconsistent number of cols");
1479 
1480  unsigned int cumulativeRowId = 0;
1481  unsigned int cumulativeColId = 0;
1482  for (unsigned int i = 0; i < matrices.size(); ++i) {
1483  unsigned int nRows = matrices[i]->numRowsLocal();
1484  unsigned int nCols = matrices[i]->numCols();
1485  for (unsigned int rowId = 0; rowId < nRows; ++rowId) {
1486  for (unsigned int colId = 0; colId < nCols; ++colId) {
1487  (*this)(cumulativeRowId + rowId, cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
1488  }
1489  }
1490  cumulativeRowId += nRows;
1491  cumulativeColId += nCols;
1492  }
1493 
1494  return;
1495 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::fillWithBlocksHorizontally ( const std::vector< const TeuchosMatrix * > &  matrices)

This function fills this matrix horizontally with const block matrices.

Definition at line 1499 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and QUESO::queso_require_equal_to_msg.

1500 {
1501  unsigned int sumNumCols = 0;
1502  for (unsigned int i = 0; i < matrices.size(); ++i) {
1503  queso_require_equal_to_msg(this->numRowsLocal(), matrices[i]->numRowsLocal(), "inconsistent local number of rows");
1504  sumNumCols += matrices[i]->numCols();
1505  }
1506  queso_require_equal_to_msg(this->numCols(), sumNumCols, "inconsistent number of cols");
1507 
1508  unsigned int cumulativeColId = 0;
1509  for (unsigned int i = 0; i < matrices.size(); ++i) {
1510  unsigned int nRows = matrices[i]->numRowsLocal();
1511  unsigned int nCols = matrices[i]->numCols();
1512  for (unsigned int rowId = 0; rowId < nRows; ++rowId) {
1513  for (unsigned int colId = 0; colId < nCols; ++colId) {
1514  (*this)(rowId, cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
1515  }
1516  }
1517  cumulativeColId += nCols;
1518  }
1519 
1520  return;
1521 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::fillWithBlocksHorizontally ( const std::vector< TeuchosMatrix * > &  matrices)

This function fills this matrix horizontally with block matrices.

Definition at line 1526 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and QUESO::queso_require_equal_to_msg.

1527 {
1528  unsigned int sumNumCols = 0;
1529  for (unsigned int i = 0; i < matrices.size(); ++i) {
1530  queso_require_equal_to_msg(this->numRowsLocal(), matrices[i]->numRowsLocal(), "inconsistent local number of rows");
1531  sumNumCols += matrices[i]->numCols();
1532  }
1533  queso_require_equal_to_msg(this->numCols(), sumNumCols, "inconsistent number of cols");
1534 
1535  unsigned int cumulativeColId = 0;
1536  for (unsigned int i = 0; i < matrices.size(); ++i) {
1537  unsigned int nRows = matrices[i]->numRowsLocal();
1538  unsigned int nCols = matrices[i]->numCols();
1539  for (unsigned int rowId = 0; rowId < nRows; ++rowId) {
1540  for (unsigned int colId = 0; colId < nCols; ++colId) {
1541  (*this)(rowId, cumulativeColId + colId) = (*(matrices[i]))(rowId,colId);
1542  }
1543  }
1544  cumulativeColId += nCols;
1545  }
1546 
1547  return;
1548 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::fillWithBlocksVertically ( const std::vector< const TeuchosMatrix * > &  matrices)

This function fills this matrix vertically with const block matrices.

Definition at line 1553 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and QUESO::queso_require_equal_to_msg.

1554 {
1555  unsigned int sumNumRows = 0;
1556  for (unsigned int i = 0; i < matrices.size(); ++i) {
1557  queso_require_equal_to_msg(this->numCols(), matrices[i]->numCols(), "inconsistent local number of cols");
1558  sumNumRows += matrices[i]->numRowsLocal();
1559  }
1560  queso_require_equal_to_msg(this->numRowsLocal(), sumNumRows, "inconsistent number of rows");
1561 
1562  unsigned int cumulativeRowId = 0;
1563  for (unsigned int i = 0; i < matrices.size(); ++i) {
1564  unsigned int nRows = matrices[i]->numRowsLocal();
1565  unsigned int nCols = matrices[i]->numCols();
1566  for (unsigned int rowId = 0; rowId < nRows; ++rowId) {
1567  for (unsigned int colId = 0; colId < nCols; ++colId) {
1568  (*this)(cumulativeRowId + rowId, colId) = (*(matrices[i]))(rowId,colId);
1569  }
1570  }
1571  cumulativeRowId += nRows;
1572  }
1573  return;
1574 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::fillWithBlocksVertically ( const std::vector< TeuchosMatrix * > &  matrices)

This function fills this matrix vertically with block matrices.

Definition at line 1579 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and QUESO::queso_require_equal_to_msg.

1580 {
1581  unsigned int sumNumRows = 0;
1582  for (unsigned int i = 0; i < matrices.size(); ++i) {
1583  queso_require_equal_to_msg(this->numCols(), matrices[i]->numCols(), "inconsistent local number of cols");
1584  sumNumRows += matrices[i]->numRowsLocal();
1585  }
1586  queso_require_equal_to_msg(this->numRowsLocal(), sumNumRows, "inconsistent number of rows");
1587 
1588  unsigned int cumulativeRowId = 0;
1589  for (unsigned int i = 0; i < matrices.size(); ++i) {
1590  unsigned int nRows = matrices[i]->numRowsLocal();
1591  unsigned int nCols = matrices[i]->numCols();
1592  for (unsigned int rowId = 0; rowId < nRows; ++rowId) {
1593  for (unsigned int colId = 0; colId < nCols; ++colId) {
1594  (*this)(cumulativeRowId + rowId, colId) = (*(matrices[i]))(rowId,colId);
1595  }
1596  }
1597  cumulativeRowId += nRows;
1598  }
1599  return;
1600 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::fillWithTensorProduct ( const TeuchosMatrix mat1,
const TeuchosMatrix mat2 
)

This function calculates the tensor product of matrices mat1 and mat2 and stores it in this matrix.

Definition at line 1605 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and QUESO::queso_require_equal_to_msg.

1606 {
1607  queso_require_equal_to_msg(this->numRowsLocal(), (mat1.numRowsLocal() * mat2.numRowsLocal()), "inconsistent local number of rows");
1608  queso_require_equal_to_msg(this->numCols(), (mat1.numCols() * mat2.numCols()), "inconsistent number of columns");
1609 
1610  for (unsigned int rowId1 = 0; rowId1 < mat1.numRowsLocal(); ++rowId1) {
1611  for (unsigned int colId1 = 0; colId1 < mat1.numCols(); ++colId1) {
1612  double multiplicativeFactor = mat1(rowId1,colId1);
1613  unsigned int targetRowId = rowId1 * mat2.numRowsLocal();
1614  unsigned int targetColId = colId1 * mat2.numCols();
1615  for (unsigned int rowId2 = 0; rowId2 < mat2.numRowsLocal(); ++rowId2) {
1616  for (unsigned int colId2 = 0; colId2 < mat2.numCols(); ++colId2) {
1617  (*this)(targetRowId + rowId2, targetColId + colId2) = multiplicativeFactor * mat2(rowId2,colId2);
1618  }
1619  }
1620  }
1621  }
1622  return;
1623 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::fillWithTensorProduct ( const TeuchosMatrix mat1,
const TeuchosVector vec2 
)

This function calculates the tensor product of matrix mat1 and vector vec2 and stores it in this matrix.

Definition at line 1628 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

1629 {
1630  queso_require_equal_to_msg(this->numRowsLocal(), (mat1.numRowsLocal() * vec2.sizeLocal()), "inconsistent local number of rows");
1631  queso_require_equal_to_msg(this->numCols(), (mat1.numCols() * 1), "inconsistent number of columns");
1632 
1633  for (unsigned int rowId1 = 0; rowId1 < mat1.numRowsLocal(); ++rowId1) {
1634  for (unsigned int colId1 = 0; colId1 < mat1.numCols(); ++colId1) {
1635  double multiplicativeFactor = mat1(rowId1,colId1);
1636  unsigned int targetRowId = rowId1 * vec2.sizeLocal();
1637  unsigned int targetColId = colId1 * 1;
1638  for (unsigned int rowId2 = 0; rowId2 < vec2.sizeLocal(); ++rowId2) {
1639  for (unsigned int colId2 = 0; colId2 < 1; ++colId2) {
1640  (*this)(targetRowId + rowId2, targetColId + colId2) = multiplicativeFactor * vec2[rowId2];
1641  }
1642  }
1643  }
1644  }
1645  return;
1646 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::fillWithTranspose ( const TeuchosMatrix mat)

This function stores the transpose of this matrix into this matrix.

Definition at line 1420 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and QUESO::queso_require_equal_to_msg.

1421 {
1422  unsigned int nRows = mat.numRowsLocal();
1423  unsigned int nCols = mat.numCols();
1424  queso_require_equal_to_msg(this->numRowsLocal(), nCols, "inconsistent local number of rows");
1425  queso_require_equal_to_msg(this->numCols(), nRows, "inconsistent number of cols");
1426 
1427  for (unsigned int row = 0; row < nRows; ++row) {
1428  for (unsigned int col = 0; col < nCols; ++col) {
1429  (*this)(col,row) = mat(row,col);
1430  }
1431  }
1432 
1433  return;
1434 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::filterLargeValues ( double  thresholdValue)

This function sets to zero (filters) all entries of this matrix which are greater than thresholdValue.

If thresholdValue < 0 then no values will be filtered.

Definition at line 1397 of file TeuchosMatrix.C.

References numCols(), and numRowsLocal().

1398 {
1399  unsigned int nRows = this->numRowsLocal();
1400  unsigned int nCols = this->numCols();
1401 
1402  for (unsigned int i = 0; i < nRows; ++i) {
1403  for (unsigned int j = 0; j < nCols; ++j) {
1404  double aux = (*this)(i,j);
1405  // If 'thresholdValue' is negative, no values will be filtered
1406  if ( (aux < 0. ) && (-thresholdValue > aux))
1407  (*this)(i,j) = 0.;
1408 
1409  if ((aux > 0. ) && (thresholdValue < aux))
1410  (*this)(i,j) = 0.;
1411  }
1412  }
1413  return;
1414 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::filterSmallValues ( double  thresholdValue)

This function sets to zero (filters) all entries of this matrix which are smaller than thresholdValue.

If thresholdValue < 0 then no values will be filtered.

Definition at line 1375 of file TeuchosMatrix.C.

References numCols(), and numRowsLocal().

1376 {
1377  unsigned int nRows = this->numRowsLocal();
1378  unsigned int nCols = this->numCols();
1379 
1380  for (unsigned int i = 0; i < nRows; ++i) {
1381  for (unsigned int j = 0; j < nCols; ++j) {
1382  double aux = (*this)(i,j);
1383  // If 'thresholdValue' is negative, no values will be filtered
1384  if ((aux < 0. ) && (-thresholdValue < aux)) {
1385  (*this)(i,j) = 0.;
1386  }
1387  if ((aux > 0. ) && (thresholdValue > aux)) {
1388  (*this)(i,j) = 0.;
1389  }
1390  }
1391  }
1392  return;
1393 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::getColumn ( const unsigned int  column_num,
TeuchosVector column 
) const

This function gets the column_num-th column of this matrix and stores it into vector column.

Definition at line 1220 of file TeuchosMatrix.C.

References m_mat, numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

Referenced by getColumn(), invertMultiply(), matlabLinearInterpExtrap(), and svdSolve().

1221 {
1222  // Sanity checks
1223  queso_require_less_msg(column_num, this->numCols(), "Specified row number not within range");
1224 
1225  queso_require_equal_to_msg(column.sizeLocal(), this->numRowsLocal(), "column vector not same size as this matrix");
1226 
1227  // Temporary working pointer
1228  const double* temp_ptr ;
1229 
1230  // get the column_num- of matrix m_mat
1231  temp_ptr = m_mat[column_num];
1232 
1233  // Copy column from Teuchos matrix into our TeuchosVector object
1234  for (unsigned int i=0; i< column.sizeLocal();i++)
1235  column[i] = temp_ptr[i];
1236 
1237  return;
1238 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
TeuchosVector QUESO::TeuchosMatrix::getColumn ( const unsigned int  column_num) const

This function gets the column_num-th column of this matrix.

Definition at line 1242 of file TeuchosMatrix.C.

References getColumn(), QUESO::Matrix::m_env, and QUESO::Matrix::m_map.

1243 {
1244  // We rely on the void getColumn's to do sanity checks
1245  // So we don't do them here.
1246  TeuchosVector column(m_env, m_map);
1247  this->getColumn( column_num, column );
1248  return column;
1249 }
const Map m_map
Mapping variable.
Definition: Matrix.h:121
void getColumn(const unsigned int column_num, TeuchosVector &column) const
This function gets the column_num-th column of this matrix and stores it into vector column...
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void QUESO::TeuchosMatrix::getRow ( const unsigned int  row_num,
TeuchosVector row 
) const

This function gets the row_num-th column of this matrix and stores it into vector row.

Definition at line 1272 of file TeuchosMatrix.C.

References m_mat, numRowsLocal(), QUESO::queso_require_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

Referenced by getRow().

1273 {
1274  // Sanity checks
1275  queso_require_less_msg(row_num, this->numRowsLocal(), "Specified row number not within range");
1276 
1277  queso_require_equal_to_msg(row.sizeLocal(), this->numRowsLocal(), "row vector not same size as this matrix");
1278 
1279  // Copy row from Teuchos matrix into our TeuchosVector object
1280  for (unsigned int i=0; i< row.sizeLocal();i++)
1281  row[i] = m_mat(row_num,i);
1282 
1283  return;
1284 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
TeuchosVector QUESO::TeuchosMatrix::getRow ( const unsigned int  row_num) const

This function gets the row_num-th column of this matrix.

Definition at line 1289 of file TeuchosMatrix.C.

References getRow(), QUESO::Matrix::m_env, and QUESO::Matrix::m_map.

1290 {
1291  // We rely on the void getRow's to do sanity checks
1292  // So we don't do them here.
1293  TeuchosVector row(m_env, m_map);
1294  this->getRow( row_num, row );
1295  return row;
1296 }
const Map m_map
Mapping variable.
Definition: Matrix.h:121
void getRow(const unsigned int row_num, TeuchosVector &row) const
This function gets the row_num-th column of this matrix and stores it into vector row...
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
int QUESO::TeuchosMatrix::internalSvd ( ) const
private

This function factorizes the M-by-N matrix A into the singular value decomposition A = U S V^T for M >= N. On output the matrix A is replaced by U.

This function uses Teuchos GESVD computes the singular value decomposition (SVD) of a real M-by-N matrix A, optionally computing the left and/or right singular vectors. The SVD is written A = U * SIGMA * transpose(V), where SIGMA is an M-by-N matrix which is zero except for its min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA are the singular values of A; they are real and non-negative, and are returned in descending order. The first min(m,n) columns of U and V are the left and right singular vectors of A. Note that the routine returns V**T, not V.

Definition at line 2015 of file TeuchosMatrix.C.

References QUESO::Matrix::m_env, m_mat, m_svdColMap, m_svdSvec, m_svdUmat, m_svdVmat, m_svdVTmat, QUESO::Matrix::map(), numCols(), numRowsLocal(), stride(), TeuchosMatrix(), values(), and QUESO::TeuchosVector::values().

Referenced by rank(), svd(), svdMatU(), svdMatV(), and svdSolve().

2016 {
2017  if (m_svdColMap == NULL) {
2018  int nRows = (int) this->numRowsLocal();
2019  int nCols = (int) this->numCols();
2020  queso_require_greater_equal_msg(nRows, nCols, "LAPACK/Teuchos only supports cases where nRows >= nCols");
2021 
2022  m_svdColMap = new Map(this->numCols(),0,this->map().Comm()); // see 'VectorSpace<.,.>::newMap()'
2023  //in src/basic/src/TeuchosVectorSpace.C //old comment already existent in GslMatrix
2024  m_svdUmat = new TeuchosMatrix(*this); // Yes, 'this'
2025  m_svdSvec = new TeuchosVector(m_env,*m_svdColMap);
2028 
2029  int minRowsCols, maxRowsCols;
2030 
2031  if (nRows>=nCols) { minRowsCols = nCols; maxRowsCols = nRows; } else { minRowsCols = nRows; maxRowsCols = nCols; }
2032 
2033  char jobu, jobvt;
2034  int lwork, info;
2035  double *work, *rwork;
2036 
2037  jobu = 'S';
2038  jobvt = 'S';
2039 
2040  lwork = 15*maxRowsCols; // Set up the work array, larger than needed.
2041  work = new double[lwork];
2042 
2043  int aux1= 5*minRowsCols+7, aux2= 2*maxRowsCols+2*minRowsCols+1;
2044  int aux_dim;
2045 
2046  if (aux1>=aux2) { aux_dim = minRowsCols*aux1; } else {aux_dim = minRowsCols*aux2; }
2047 
2048  rwork = new double[aux_dim];
2049 
2050  Teuchos::LAPACK<int, double> lapack;
2051 
2052  lapack.GESVD(jobu,jobvt,m_mat.numRows(),m_mat.numCols(),m_mat.values(),m_mat.stride(),
2054  m_svdVTmat->stride(),&work[0],lwork,&rwork[0],&info);
2055  }
2056  return 0;
2057 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
TeuchosMatrix()
Default Constructor.
int stride()
Returns the stride between the columns of this matrix in memory.
Map * m_svdColMap
Mapping for matrices involved in the singular value decomposition (svd) routine.
TeuchosMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
double * values()
Returns a pointer to the first element of this matrix.
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
TeuchosMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
unsigned int numCols() const
Returns the column dimension of this matrix.
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
const Map & map() const
Definition: Matrix.C:54
TeuchosMatrix QUESO::TeuchosMatrix::inverse ( ) const

This function calculates the inverse of this matrix (square).

Definition at line 392 of file TeuchosMatrix.C.

References QUESO::BaseEnvironment::checkingLevel(), QUESO::TeuchosVector::cwSet(), QUESO::BaseEnvironment::displayVerbosity(), invertMultiply(), lnDeterminant(), QUESO::Matrix::m_env, m_inverse, QUESO::Matrix::m_map, numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, QUESO::BaseEnvironment::subDisplayFile(), and TeuchosMatrix().

393 {
394  unsigned int nRows = this->numRowsLocal();
395  unsigned int nCols = this->numCols();
396 
397  queso_require_equal_to_msg(nRows, nCols, "matrix is not square");
398 
399  if (m_inverse == NULL) {
400  m_inverse = new TeuchosMatrix(m_env,m_map,nCols);
401  TeuchosVector unitVector(m_env,m_map);
402  unitVector.cwSet(0.);
403  TeuchosVector multVector(m_env,m_map);
404  for (unsigned int j = 0; j < nCols; ++j) {
405  if (j > 0) unitVector[j-1] = 0.;
406  unitVector[j] = 1.;
407  this->invertMultiply(unitVector, multVector);
408  for (unsigned int i = 0; i < nRows; ++i) {
409  (*m_inverse)(i,j) = multVector[i];
410  }
411  }
412  }
413  if (m_env.checkingLevel() >= 1) {
414  *m_env.subDisplayFile() << "CHECKING In TeuchosMatrix::inverse()"
415  << ": M.lnDet = " << this->lnDeterminant()
416  << ", M^{-1}.lnDet = " << m_inverse->lnDeterminant()
417  << std::endl;
418  }
419  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
420  *m_env.subDisplayFile() << "In TeuchosMatrix::inverse():"
421  << "\n M = " << *this
422  << "\n M^{-1} = " << *m_inverse
423  << "\n M*M^{-1} = " << (*this)*(*m_inverse)
424  << "\n M^{-1}*M = " << (*m_inverse)*(*this)
425  << std::endl;
426  }
427 
428 /* cout << "Inverse ---------------------\n";
429  for (int i=0; i<m_inverse->numRowsLocal(); i++) {
430  for (int j=0; j<m_inverse->numCols(); j++)
431  cout<< m_inverse->m_mat(i,j) << " ";
432  cout << endl;
433  }
434  cout << endl;
435 */
436  return *m_inverse;
437 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
TeuchosMatrix()
Default Constructor.
const Map m_map
Mapping variable.
Definition: Matrix.h:121
TeuchosMatrix * m_inverse
Stores the inverse of this matrix.
unsigned int checkingLevel() const
Access function to private attribute m_checkingLevel.
Definition: Environment.C:464
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
double lnDeterminant() const
Calculates the ln(determinant) of this matrix.
unsigned int numCols() const
Returns the column dimension of this matrix.
unsigned int displayVerbosity() const
Definition: Environment.C:450
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void invertMultiply(const TeuchosVector &b, TeuchosVector &x) const
This function calculates the inverse of this matrix, multiplies it with vector b and stores the resul...
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
void QUESO::TeuchosMatrix::invertMultiply ( const TeuchosVector b,
TeuchosVector x 
) const

This function calculates the inverse of this matrix, multiplies it with vector b and stores the result in vector x.

It checks for a previous LU decomposition of this matrix and does not recompute it if private attribute m_LU != NULL .

Definition at line 791 of file TeuchosMatrix.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::Matrix::m_env, QUESO::Matrix::m_inDebugMode, m_isSingular, m_LU, m_mat, QUESO::TeuchosVector::norm2(), numCols(), QUESO::queso_require_equal_to_msg, QUESO::queso_require_not_equal_to_msg, QUESO::TeuchosVector::sizeLocal(), QUESO::BaseEnvironment::subDisplayFile(), and v_pivoting.

Referenced by determinant(), inverse(), invertMultiply(), and lnDeterminant().

792 {
793  queso_require_equal_to_msg(this->numCols(), b.sizeLocal(), "matrix and rhs have incompatible sizes");
794 
795  queso_require_equal_to_msg(x.sizeLocal(), b.sizeLocal(), "solution and rhs have incompatible sizes");
796 
797  if (m_LU.numCols() == 0 && m_LU.numRows() == 0)
798  {
799  queso_require_msg(!(v_pivoting), "v_pivoting should be NULL");
800 
801  //allocate m_LU and v_pivoting
802  m_LU = m_mat;
803  v_pivoting =(int *) malloc(sizeof(int)*m_LU.numCols() );
804 
805  queso_require_not_equal_to_msg(m_LU.numCols(), 0 && m_LU.numRows() == 0, "malloc() failed");
806 
807  queso_require_msg(v_pivoting, "malloc() failed");
808 
809  if (m_inDebugMode) {
810  std::cout << "In TeuchosMatrix::invertMultiply()"
811  << ": before LU decomposition, m_LU = ";
812  for (int i=0;i<3;i++){
813  for (int j=0;j<3;j++)
814  cout << m_LU(i,j) <<"\t" ;
815  cout << endl;
816  }
817  }
818 
819  // Perform an LU factorization of matrix m_LU. Checked 12/06/12
820  Teuchos::LAPACK<int, double> lapack;
821  int info;
822 
823  lapack.GETRF( m_LU.numRows(), m_LU.numCols(), m_LU.values(), m_LU.stride(), v_pivoting, &info );
824 
825  if (info != 0) {
826  std::cerr << "In TeuchosMatrix::invertMultiply()"
827  << ", after lapack.GETRF"
828  << ": INFO = " << info
829  << ",\nINFO < 0: if INFO = -i, the i-th argument had an illegal value.\n"
830  << "INFO > 0: if INFO = i, U(i,i) is exactly zero. The factorization \n"
831  << "has been completed, but the factor U is exactly singular, and division \n"
832  << "by zero will occur if it is used to solve a system of equations."
833  << std::endl;
834  }
835  queso_require_msg(!(info), "GETRF() failed");
836 
837  if (info > 0)
838  m_isSingular = true;
839 
840  if (m_inDebugMode) {
841  std::cout << "In TeuchosMatrix::invertMultiply()"
842  << ": after LU decomposition, m_LU = ";
843  for (int i=0;i<3;i++){
844  for (int j=0;j<3;j++)
845  cout << m_LU(i,j) <<"\t" ;
846  cout << endl;
847  }
848  std::cout << std::endl;
849  }
850  }
851  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
852  *m_env.subDisplayFile() << "In TeuchosMatrix::invertMultiply()"
853  << ": before 'lapack.GETRS()'"
854  << std::endl;
855  }
856 
857  // Solve the linear system.
858  Teuchos::LAPACK<int, double> lapack;
859  int NRHS = 1; // NRHS: number of right hand sides, i.e., the number
860  // of columns of the matrix B. In this case, vector b.
861  char TRANS = 'N'; // 'N': A * x= B (No transpose). Specifies the
862  // form of the system of equations.
863  int info02;
864 
865  //GETRS expects the matrix to be already factored in LU and uses the
866  //same ipiv vector, which are the pivot indices of the LU factorization
867 
868  x=b;
869  lapack.GETRS(TRANS, m_LU.numRows(), NRHS, m_LU.values(), m_LU.stride(), v_pivoting, &x[0],x.sizeLocal(), &info02 );
870 
871  if (info02 != 0) {
872  std::cerr << "In TeuchosMatrix::invertMultiply()"
873  << ", after lapack.GETRS - solve LU system"
874  << ": INFO = " << info02
875  << ",\nINFO < 0: if INFO = -i, the i-th argument had an illegal value.\n"
876  << std::endl;
877  }
878  queso_require_msg(!(info02), "GETRS() failed");
879  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
880  *m_env.subDisplayFile() << "In TeuchosMatrix::invertMultiply()"
881  << ", after lapack.GETRS() - solve LU system."
882  << std::endl;
883  }
884  if (m_inDebugMode) {
885  TeuchosVector tmpVec(b - (*this)*x);
886  std::cout << "In TeuchosMatrix::invertMultiply()"
887  << ": ||b - Ax||_2 = " << tmpVec.norm2()
888  << ": ||b - Ax||_2/||b||_2 = " << tmpVec.norm2()/b.norm2()
889  << std::endl;
890  }
891  return;
892 }
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
int * v_pivoting
The pivoting vector of a LU decomposition.
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
bool m_isSingular
Indicates whether or not this matrix is singular.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
unsigned int displayVerbosity() const
Definition: Environment.C:450
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
bool m_inDebugMode
Flag for either or not QUESO is in debug mode.
Definition: Matrix.h:134
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
TeuchosVector QUESO::TeuchosMatrix::invertMultiply ( const TeuchosVector b) const

This function calculates the inverse of this matrix and multiplies it with vector b.

It calls void TeuchosMatrix::invertMultiply(const TeuchosVector& b, TeuchosVector& x) internally.

Definition at line 778 of file TeuchosMatrix.C.

References invertMultiply(), QUESO::Matrix::m_env, QUESO::Matrix::m_map, numCols(), QUESO::queso_require_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

779 {
780  queso_require_equal_to_msg(this->numCols(), b.sizeLocal(), "matrix and rhs have incompatible sizes");
781  TeuchosVector x(m_env,m_map);
782 
783  this->invertMultiply(b,x);
784 
785  return x;
786 }
const Map m_map
Mapping variable.
Definition: Matrix.h:121
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void invertMultiply(const TeuchosVector &b, TeuchosVector &x) const
This function calculates the inverse of this matrix, multiplies it with vector b and stores the resul...
void QUESO::TeuchosMatrix::invertMultiply ( const TeuchosMatrix B,
TeuchosMatrix X 
) const

This function calculates the inverse of this matrix, multiplies it with matrix B and stores the result in matrix X.

It checks for a previous LU decomposition of this matrix and does not recompute it if private attribute m_LU != NULL .

Definition at line 906 of file TeuchosMatrix.C.

References getColumn(), invertMultiply(), QUESO::Matrix::m_env, QUESO::Matrix::m_map, numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, and setColumn().

907 {
908  // Sanity Checks
909  queso_require_msg(!((B.numRowsLocal() != X.numRowsLocal()) || (B.numCols() != X.numCols())), "Matrices B and X are incompatible");
910 
911  queso_require_equal_to_msg(this->numRowsLocal(), X.numRowsLocal(), "This and X matrices are incompatible");
912 
913  // Some local variables used within the loop.
914  TeuchosVector b(m_env, m_map);
915  TeuchosVector x(m_env, m_map);
916 
917  for( unsigned int j = 0; j < B.numCols(); ++j ) {
918  b = B.getColumn(j);
919  //invertMultiply will only do the LU factorization once and store it.
920  x = this->invertMultiply(b);
921  X.setColumn(j,x);
922  }
923  return;
924 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
const Map m_map
Mapping variable.
Definition: Matrix.h:121
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void invertMultiply(const TeuchosVector &b, TeuchosVector &x) const
This function calculates the inverse of this matrix, multiplies it with vector b and stores the resul...
TeuchosMatrix QUESO::TeuchosMatrix::invertMultiply ( const TeuchosMatrix B) const

This function calculates the inverse of this matrix and multiplies it with matrix B.

It calls void TeuchosMatrix::invertMultiply(const TeuchosMatrix& B, TeuchosMatrix& X) const internally.

Definition at line 896 of file TeuchosMatrix.C.

References invertMultiply(), QUESO::Matrix::m_env, QUESO::Matrix::m_map, and numCols().

897 {
898  TeuchosMatrix X(m_env,m_map,B.numCols());
899  this->invertMultiply(B,X);
900  return X;
901 }
TeuchosMatrix()
Default Constructor.
const Map m_map
Mapping variable.
Definition: Matrix.h:121
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void invertMultiply(const TeuchosVector &b, TeuchosVector &x) const
This function calculates the inverse of this matrix, multiplies it with vector b and stores the resul...
void QUESO::TeuchosMatrix::invertMultiplyForceLU ( const TeuchosVector b,
TeuchosVector x 
) const

This function calculates the inverse of this matrix, multiplies it with vector b and stores the result in vector x.

It recalculates the LU decomposition of this matrix.

Definition at line 941 of file TeuchosMatrix.C.

References m_isSingular, m_LU, m_mat, numCols(), QUESO::queso_require_equal_to_msg, QUESO::queso_require_not_equal_to_msg, QUESO::TeuchosVector::sizeLocal(), and v_pivoting.

Referenced by invertMultiplyForceLU().

942 {
943  queso_require_equal_to_msg(this->numCols(), b.sizeLocal(), "matrix and rhs have incompatible sizes");
944 
945  queso_require_equal_to_msg(x.sizeLocal(), b.sizeLocal(), "solution and rhs have incompatible sizes");
946 
947  if (m_LU.numCols() == 0 && m_LU.numRows() == 0) {
948  queso_require_msg(!(v_pivoting), "v_pivoting should be NULL");
949  }
950 
951  //allocate m_LU , yes outside the if above
952  m_LU = m_mat;
953 
954  queso_require_not_equal_to_msg(m_LU.numCols(), 0 && m_LU.numRows() == 0, "Teuchos atttribuition m_LU = m_mat failed");
955 
956  //allocate v_pivoting
957  if ( v_pivoting == NULL )
958  v_pivoting =(int *) malloc(sizeof(int)*m_LU.numCols() );
959 
960  queso_require_msg(v_pivoting, "malloc() for v_pivoting failed");
961 
962  // Perform an LU factorization of matrix m_LU. Checked 12/06/12
963  Teuchos::LAPACK<int, double> lapack;
964  int info;
965 
966  lapack.GETRF( m_LU.numRows(), m_LU.numCols(), m_LU.values(), m_LU.stride(), v_pivoting, &info );
967 
968  if (info != 0) {
969  std::cerr << "In TeuchosMatrix::invertMultiply()"
970  << ", after lapack.GETRF"
971  << ": INFO = " << info
972  << ",\nINFO < 0: if INFO = -i, the i-th argument had an illegal value.\n"
973  << "INFO > 0: if INFO = i, U(i,i) is exactly zero. The factorization \n"
974  << "has been completed, but the factor U is exactly singular, and division \n"
975  << "by zero will occur if it is used to solve a system of equations."
976  << std::endl;
977  }
978 
979  queso_require_msg(!(info), "GETRF() failed");
980 
981  if (info > 0)
982  m_isSingular = true;
983 
984  // Solve the linear system.
985  int NRHS = 1; // NRHS: number of right hand sides, i.e., the number
986  // of columns of the matrix B. In this case, vector b.
987  char TRANS = 'N'; // 'N': A * x= B (No transpose). Specifies the
988  // form of the system of equations.
989  int info02;
990 
991  //GETRS expects the matrix to be already factored in LU and uses the
992  //same ipiv vector, which are the pivot indices of the LU factorization
993 
994  x=b;
995  lapack.GETRS(TRANS, m_LU.numRows(), NRHS, m_LU.values(), m_LU.stride(), v_pivoting, &x[0],x.sizeLocal(), &info02 );
996 
997  if (info02 != 0) {
998  std::cerr << "In TeuchosMatrix::invertMultiply()"
999  << ", after lapack.GETRS - solve LU system"
1000  << ": INFO = " << info02
1001  << ",\nINFO < 0: if INFO = -i, the i-th argument had an illegal value.\n"
1002  << std::endl;
1003  }
1004 
1005  queso_require_msg(!(info02), "GETRS() failed");
1006 
1007  return;
1008 }
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
int * v_pivoting
The pivoting vector of a LU decomposition.
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
bool m_isSingular
Indicates whether or not this matrix is singular.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
TeuchosVector QUESO::TeuchosMatrix::invertMultiplyForceLU ( const TeuchosVector b) const

This function calculates the inverse of this matrix and multiplies it with vector b.

  It calls void TeuchosMatrix::InvertMultiplyForceLU(const TeuchosVector& b, TeuchosVector& x) const;(const TeuchosVector& b,

TeuchosVector& x) internally.

Definition at line 928 of file TeuchosMatrix.C.

References invertMultiplyForceLU(), QUESO::Matrix::m_env, QUESO::Matrix::m_map, numCols(), QUESO::queso_require_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

929 {
930  queso_require_equal_to_msg(this->numCols(), b.sizeLocal(), "matrix and rhs have incompatible sizes");
931 
932  TeuchosVector x(m_env,m_map);
933  this->invertMultiplyForceLU(b,x);
934 
935  return x;
936 }
const Map m_map
Mapping variable.
Definition: Matrix.h:121
void invertMultiplyForceLU(const TeuchosVector &b, TeuchosVector &x) const
This function calculates the inverse of this matrix, multiplies it with vector b and stores the resul...
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void QUESO::TeuchosMatrix::largestEigen ( double &  eigenValue,
TeuchosVector eigenVector 
) const

This function finds largest eigenvalue, namely eigenValue, of this matrix and its corresponding eigenvector, namely eigenVector.

Definition at line 1097 of file TeuchosMatrix.C.

References m_mat, QUESO::queso_require_not_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

1098 {
1099  unsigned int n = eigenVector.sizeLocal();
1100 
1101  queso_require_not_equal_to_msg(n, 0, "invalid input vector size");
1102  Teuchos::LAPACK<int, double> lapack;
1103 
1104  //SYEV destroys the input matrix, so lets operate in a copy
1105  Teuchos::SerialDenseMatrix<int,double> copy_m_mat;
1106  copy_m_mat = m_mat;
1107 
1108  int lwork = 3*n -1;
1109  int info;
1110  char UPLO = 'L';
1111  char JOBZ = 'V'; //eigenvalues and eigenvectors
1112  double *W, *WORK;
1113 
1114  W = new double[n];
1115  WORK = new double[lwork];
1116 
1117  lapack.SYEV(JOBZ, UPLO, copy_m_mat.numRows(), copy_m_mat.values(), copy_m_mat.stride(), &W[0], &WORK[0], lwork, &info);
1118 
1119  if (info != 0) {
1120  std::cerr << "In TeuchosMtrix::largestEigen()"
1121  << ": INFO = " << info
1122  << ",\n INFO < 0: if INFO = -i, the i-th argument had an illegal value."
1123  << "\n INFO > 0: if INFO = i, the algorithm failed to converge; i off-diagonal "
1124  << " elements of an intermediate tridiagonal form did not converge to zero."
1125  << std::endl;
1126  }
1127  // If INFO = 0, W contains the eigenvalues in ascending order.
1128  // Thus the largest eigenvalue is in W[n-1].
1129  eigenValue = W[n-1];
1130 
1131  // Eigenvector associated to the largest eigenvalue.
1132  // Stored in the n-th column of matrix copy_m_mat.
1133  for (int i=0; i< copy_m_mat.numRows(); i++)
1134  eigenVector[i] = copy_m_mat(i,n-1);
1135 
1136  return;
1137 }
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
double QUESO::TeuchosMatrix::lnDeterminant ( ) const

Calculates the ln(determinant) of this matrix.

Definition at line 491 of file TeuchosMatrix.C.

References QUESO::BaseEnvironment::displayVerbosity(), invertMultiply(), m_determinant, QUESO::Matrix::m_env, m_lnDeterminant, m_LU, QUESO::Matrix::m_map, and QUESO::BaseEnvironment::subDisplayFile().

Referenced by inverse().

492 {
493  if (m_lnDeterminant == -INFINITY)
494  {
495  if(m_LU.numRows() ==0 && m_LU.numCols() ==0) //dummy
496  {
497  TeuchosVector tmpB(m_env,m_map);
498  TeuchosVector tmpX(m_env,m_map);
499  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
500  *m_env.subDisplayFile() << "In TeuchosMatrix::lnDeterminant()"
501  << ": before 'this->invertMultiply()'"
502  << std::endl;
503  }
504  this->invertMultiply(tmpB,tmpX);
505  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
506  *m_env.subDisplayFile() << "In TeuchosMatrix::lnDeterminant()"
507  << ": after 'this->invertMultiply()'"
508  << std::endl;
509  }
510  }
511  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
512  *m_env.subDisplayFile() << "In TeuchosMatrix::lnDeterminant()"
513  << ": before computing lnDet"
514  << std::endl;
515  }
516 
517  double det = 1.0;
518  double lnDet = 0.0;
519  for (int i=0;i<m_LU.numCols();i++) {
520  det *= m_LU(i,i);
521  lnDet += std::log(m_LU(i,i));
522  }
523 
524  m_determinant = det;
525  m_lnDeterminant = lnDet;
526 
527  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
528  *m_env.subDisplayFile() << "In TeuchosMatrix::lnDeterminant()"
529  << ": after computing lnDet"
530  << std::endl;
531  }
532  }
533 
534  return m_lnDeterminant;
535 }
const Map m_map
Mapping variable.
Definition: Matrix.h:121
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
double m_lnDeterminant
The natural logarithm of the determinant of this matrix.
double m_determinant
The determinant of this matrix.
unsigned int displayVerbosity() const
Definition: Environment.C:450
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void invertMultiply(const TeuchosVector &b, TeuchosVector &x) const
This function calculates the inverse of this matrix, multiplies it with vector b and stores the resul...
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
void QUESO::TeuchosMatrix::matlabLinearInterpExtrap ( const TeuchosVector x1Vec,
const TeuchosMatrix y1Mat,
const TeuchosVector x2Vec 
)

Definition at line 1693 of file TeuchosMatrix.C.

References getColumn(), QUESO::TeuchosVector::matlabLinearInterpExtrap(), numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, setColumn(), and QUESO::TeuchosVector::sizeLocal().

1697 {
1698  queso_require_greater_msg(x1Vec.sizeLocal(), 1, "invalid 'x1' size");
1699 
1700  queso_require_equal_to_msg(x1Vec.sizeLocal(), y1Mat.numRowsLocal(), "invalid 'x1' and 'y1' sizes");
1701 
1702  queso_require_equal_to_msg(x2Vec.sizeLocal(), this->numRowsLocal(), "invalid 'x2' and 'this' sizes");
1703 
1704  queso_require_equal_to_msg(y1Mat.numCols(), this->numCols(), "invalid 'y1' and 'this' sizes");
1705 
1706  TeuchosVector y1Vec(x1Vec);
1707  TeuchosVector y2Vec(x2Vec);
1708  for (unsigned int colId = 0; colId < y1Mat.numCols(); ++colId) {
1709  y1Mat.getColumn(colId,y1Vec);
1710  y2Vec.matlabLinearInterpExtrap(x1Vec,y1Vec,x2Vec);
1711  this->setColumn(colId,y2Vec);
1712  }
1713 
1714  return;
1715 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
void setColumn(const unsigned int column_num, const TeuchosVector &column)
This function copies vector column into the column_num-th column of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
double QUESO::TeuchosMatrix::max ( ) const

Returns the maximum element value of the matrix.

Definition at line 315 of file TeuchosMatrix.C.

References numCols(), and numRowsLocal().

316 {
317  double value = -INFINITY;
318 
319  unsigned int nRows = this->numRowsLocal();
320  unsigned int nCols = this->numCols();
321  double aux = 0.;
322  for (unsigned int i = 0; i < nRows; i++) {
323  for (unsigned int j = 0; j < nCols; j++) {
324  aux = (*this)(i,j);
325  if (aux > value) value = aux;
326  }
327  }
328 
329  return value;
330 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::mpiSum ( const MpiComm comm,
TeuchosMatrix M_global 
) const

Definition at line 1653 of file TeuchosMatrix.C.

References QUESO::MpiComm::Allreduce(), numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, and QUESO::size.

1654 {
1655  // Sanity Checks
1657  M_global.numRowsLocal(),
1658  "local and global matrices incompatible");
1660  M_global.numCols(),
1661  "local and global matrices incompatible");
1662 
1663  /* TODO: Probably a better way to handle this unpacking/packing of data */
1664  int size = M_global.numRowsLocal()*M_global.numCols();
1665  std::vector<double> local( size, 0.0 );
1666  std::vector<double> global( size, 0.0 );
1667 
1668  int k;
1669  for( unsigned int i = 0; i < this->numRowsLocal(); i++ ) {
1670  for( unsigned int j = 0; j < this->numCols(); j++ ) {
1671  k = i + j*M_global.numCols();
1672  local[k] = (*this)(i,j);
1673  }
1674  }
1675 
1676  comm.Allreduce<double>(&local[0], &global[0], size, RawValue_MPI_SUM,
1677  "TeuchosMatrix::mpiSum()",
1678  "failed MPI.Allreduce()");
1679 
1680  for( unsigned int i = 0; i < this->numRowsLocal(); i++ ) {
1681  for( unsigned int j = 0; j < this->numCols(); j++ ) {
1682  k = i + j*M_global.numCols();
1683  M_global(i,j) = global[k];
1684  }
1685  }
1686 
1687  return;
1688 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
TeuchosVector QUESO::TeuchosMatrix::multiply ( const TeuchosVector x) const

This function multiplies this matrix by vector x and returns a vector.

Definition at line 765 of file TeuchosMatrix.C.

References QUESO::Matrix::m_env, QUESO::Matrix::m_map, numCols(), QUESO::queso_require_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

Referenced by QUESO::operator*().

766 {
767  queso_require_equal_to_msg(this->numCols(), x.sizeLocal(), "matrix and vector have incompatible sizes");
768 
769  TeuchosVector y(m_env,m_map);
770  this->multiply(x,y);
771 
772  return y;
773 }
const Map m_map
Mapping variable.
Definition: Matrix.h:121
TeuchosVector multiply(const TeuchosVector &x) const
This function multiplies this matrix by vector x and returns a vector.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
void QUESO::TeuchosMatrix::multiply ( const TeuchosVector x,
TeuchosVector y 
) const
private

This function multiplies this matrix by vector x and stores the resulting vector in y.

Definition at line 1993 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

1994 {
1995  queso_require_equal_to_msg(this->numCols(), x.sizeLocal(), "matrix and x have incompatible sizes");
1996 
1997  queso_require_equal_to_msg(this->numRowsLocal(), y.sizeLocal(), "matrix and y have incompatible sizes");
1998 
1999  unsigned int sizeX = this->numCols();
2000  unsigned int sizeY = this->numRowsLocal();
2001  for (unsigned int i = 0; i < sizeY; ++i) {
2002  double value = 0.;
2003  for (unsigned int j = 0; j < sizeX; ++j) {
2004  value += (*this)(i,j)*x[j];
2005  }
2006  y[i] = value;
2007  }
2008 
2009  return;
2010 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
double QUESO::TeuchosMatrix::normFrob ( ) const

Returns the Frobenius norm of this matrix.

Definition at line 541 of file TeuchosMatrix.C.

References m_mat.

542 {
543  return m_mat.normFrobenius ();
544 }
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
double QUESO::TeuchosMatrix::normMax ( ) const

Returns the Frobenius norm of this matrix.

Definition at line 548 of file TeuchosMatrix.C.

References numCols(), and numRowsLocal().

549 {
550  double value = 0.;
551 
552  unsigned int nRows = this->numRowsLocal();
553  unsigned int nCols = this->numCols();
554  double aux = 0.;
555  for (unsigned int i = 0; i < nRows; i++) {
556  for (unsigned int j = 0; j < nCols; j++) {
557  aux = fabs((*this)(i,j));
558  if (aux > value) value = aux;
559  }
560  }
561  return value;
562 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
unsigned int numCols() const
Returns the column dimension of this matrix.
unsigned int QUESO::TeuchosMatrix::numCols ( ) const
virtual
unsigned int QUESO::TeuchosMatrix::numRowsGlobal ( ) const
virtual

Returns the global row dimension of this matrix.

Implements QUESO::Matrix.

Definition at line 282 of file TeuchosMatrix.C.

References m_mat.

283 {
284  return (unsigned int) m_mat.numRows();
285 }
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
unsigned int QUESO::TeuchosMatrix::numRowsLocal ( ) const
virtual
double & QUESO::TeuchosMatrix::operator() ( unsigned int  i,
unsigned int  j 
)

Element access method (non-const).

Definition at line 244 of file TeuchosMatrix.C.

References m_mat, and resetLU().

245 {
246  this->resetLU();
247  if ((i >= (unsigned int) m_mat.numRows()) ||
248  (j >= (unsigned int) m_mat.numCols())) {
249  std::cerr << "In TeuchosMatrix::operator(i,j) (non-const)"
250  << ": i = " << i
251  << ", j = " << j
252  << ", m_mat.numRows() = " << (unsigned int) m_mat.numRows()
253  << ", m_mat.numCols() = " << (unsigned int) m_mat.numCols()
254  << std::endl;
255  queso_require_less_msg(i, (unsigned int) m_mat.numRows(), "i is too large");
256  queso_require_less_msg(j, (unsigned int) m_mat.numCols(), "j is too large");
257  }
258  return m_mat(i,j);
259 }
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos 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...
const double & QUESO::TeuchosMatrix::operator() ( unsigned int  i,
unsigned int  j 
) const

Element access method (const).

Definition at line 262 of file TeuchosMatrix.C.

References m_mat.

263 {
264  queso_require_less_msg(i, (unsigned int) m_mat.numRows(), "i is too large");
265  queso_require_less_msg(j, (unsigned int) m_mat.numCols(), "j is too large");
266  return m_mat(i,j);
267 }
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
TeuchosMatrix & QUESO::TeuchosMatrix::operator*= ( double  a)

Stores in this the coordinate-wise multiplication of this and a.

Definition at line 192 of file TeuchosMatrix.C.

References m_mat, and resetLU().

193 {
194  this->resetLU();
195  int iRC;
196  iRC = m_mat.scale(a);
197  queso_require_msg(!(iRC), "scaling failed");
198  return *this;
199 }
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos 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...
TeuchosMatrix & QUESO::TeuchosMatrix::operator+= ( const TeuchosMatrix rhs)

Stores in this the coordinate-wise addition of this and rhs.

Definition at line 212 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and resetLU().

213 {
214  this->resetLU();
215 
216  unsigned int i,j, nrows=rhs.numRowsLocal(), ncols=rhs.numCols();
217 
218  for(i=0; i< nrows ; i++)
219  for (j = 0; j < ncols; j++)
220  (*this)(i,j) += rhs(i,j);
221 
222  return *this;
223 }
void resetLU()
In this function resets the LU decomposition of this matrix, as well as deletes the private member po...
TeuchosMatrix & QUESO::TeuchosMatrix::operator-= ( const TeuchosMatrix rhs)

Stores in this the coordinate-wise subtraction of this by rhs.

Definition at line 227 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), and resetLU().

228 {
229  this->resetLU();
230 
231  unsigned int i,j, nrows=rhs.numRowsLocal(), ncols=rhs.numCols();
232 
233  for(i=0; i< nrows ; i++)
234  for (j = 0; j < ncols; j++)
235  (*this)(i,j) -= rhs(i,j);
236 
237  return *this;
238 }
void resetLU()
In this function resets the LU decomposition of this matrix, as well as deletes the private member po...
TeuchosMatrix & QUESO::TeuchosMatrix::operator/= ( double  a)

Stores in this the coordinate-wise division of this by a.

Definition at line 203 of file TeuchosMatrix.C.

References m_mat, and resetLU().

204 {
205  this->resetLU();
206  m_mat.scale(1./a);
207  return *this;
208 }
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos 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...
TeuchosMatrix & QUESO::TeuchosMatrix::operator= ( const TeuchosMatrix rhs)

Copies values from matrix rhs to this.

Definition at line 183 of file TeuchosMatrix.C.

References copy(), and resetLU().

184 {
185  this->resetLU();
186  this->copy(obj);
187  return *this;
188 }
void resetLU()
In this function resets the LU decomposition of this matrix, as well as deletes the private member po...
void copy(const TeuchosMatrix &src)
In this function this matrix receives a copy of matrix src.
void QUESO::TeuchosMatrix::print ( std::ostream &  os) const
virtual

Print method. Defines the behavior of the ostream << operator inherited from the Object class.

Implements QUESO::Matrix.

Definition at line 1721 of file TeuchosMatrix.C.

References QUESO::Matrix::m_printHorizontally, numCols(), and numRowsLocal().

Referenced by QUESO::operator<<().

1722 {
1723  unsigned int nRows = this->numRowsLocal();
1724  unsigned int nCols = this->numCols();
1725 
1726  if (m_printHorizontally) {
1727  for (unsigned int i = 0; i < nRows; ++i) {
1728  for (unsigned int j = 0; j < nCols; ++j) {
1729  os << (*this)(i,j)
1730  << " ";
1731  }
1732  if (i != (nRows-1)) os << "; ";
1733  }
1734  //os << std::endl;
1735  }
1736  else {
1737  for (unsigned int i = 0; i < nRows; ++i) {
1738  for (unsigned int j = 0; j < nCols; ++j) {
1739  os << (*this)(i,j)
1740  << " ";
1741  }
1742  os << std::endl;
1743  }
1744  }
1745 
1746  return;
1747 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
bool m_printHorizontally
Flag for either or not print this matrix.
Definition: Matrix.h:131
unsigned int numCols() const
Returns the column dimension of this matrix.
unsigned int QUESO::TeuchosMatrix::rank ( double  absoluteZeroThreshold,
double  relativeZeroThreshold 
) const

This function returns the number of singular values of this matrix (rank).

The rank function provides an estimate of the number of linearly independent rows or columns of a full matrix.

Definition at line 335 of file TeuchosMatrix.C.

References QUESO::BaseEnvironment::displayVerbosity(), internalSvd(), QUESO::Matrix::m_env, m_svdSvec, numCols(), numRowsLocal(), QUESO::TeuchosVector::sizeLocal(), and QUESO::BaseEnvironment::subDisplayFile().

336 {
337  int iRC = 0;
338  iRC = internalSvd();
339  if (iRC) {}; // just to remove compiler warning
340 
341  TeuchosVector relativeVec(*m_svdSvec);
342  if (relativeVec[0] > 0.) {
343  relativeVec = (1./relativeVec[0])*relativeVec;
344  }
345 
346  unsigned int rankValue = 0;
347  for (unsigned int i = 0; i < relativeVec.sizeLocal(); ++i) {
348  if (( (*m_svdSvec)[i] >= absoluteZeroThreshold ) &&
349  ( relativeVec [i] >= relativeZeroThreshold )) {
350  rankValue += 1;
351  }
352  }
353 
354  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
355  *m_env.subDisplayFile() << "In TeuchosMatrix::rank()"
356  << ": this->numRowsLocal() = " << this->numRowsLocal()
357  << ", this->numCols() = " << this->numCols()
358  << ", absoluteZeroThreshold = " << absoluteZeroThreshold
359  << ", relativeZeroThreshold = " << relativeZeroThreshold
360  << ", rankValue = " << rankValue
361  << ", m_svdSvec = " << *m_svdSvec
362  << ", relativeVec = " << relativeVec
363  << std::endl;
364  }
365 
366  return rankValue;
367 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
int internalSvd() const
This function factorizes the M-by-N matrix A into the singular value decomposition A = U S V^T for M ...
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
unsigned int numCols() const
Returns the column dimension of this matrix.
unsigned int displayVerbosity() const
Definition: Environment.C:450
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
void QUESO::TeuchosMatrix::resetLU ( )
private

In this function resets the LU decomposition of this matrix, as well as deletes the private member pointers, if existing.

Definition at line 1946 of file TeuchosMatrix.C.

References m_determinant, m_inverse, m_isSingular, m_lnDeterminant, m_LU, m_signum, m_svdColMap, m_svdSvec, m_svdUmat, m_svdVmat, m_svdVTmat, and v_pivoting.

Referenced by copy(), operator()(), operator*=(), operator+=(), operator-=(), operator/=(), operator=(), setColumn(), zeroLower(), zeroUpper(), and ~TeuchosMatrix().

1947 {
1948  if (m_LU.numCols() >0 || m_LU.numRows() > 0) {
1949  m_LU.reshape(0,0); //Kemelli, 12/06/12, dummy
1950  }
1951  if (m_inverse) {
1952  delete m_inverse;
1953  m_inverse = NULL;
1954  }
1955  if (m_svdColMap) {
1956  delete m_svdColMap;
1957  m_svdColMap = NULL;
1958  }
1959  if (m_svdUmat) {
1960  delete m_svdUmat;
1961  m_svdUmat = NULL;
1962  }
1963  if (m_svdSvec) {
1964  delete m_svdSvec;
1965  m_svdSvec = NULL;
1966  }
1967  if (m_svdVmat) {
1968  delete m_svdVmat;
1969  m_svdVmat = NULL;
1970  }
1971  if (m_svdVTmat) {
1972  delete m_svdVTmat;
1973  m_svdVTmat = NULL;
1974  }
1975  m_determinant = -INFINITY;
1976  m_lnDeterminant = -INFINITY;
1977 
1978  if (v_pivoting) { //Kemelli added 12/09/12
1979  free(v_pivoting);
1980  v_pivoting = NULL;
1981 
1982  }
1983  m_signum = 0;
1984  m_isSingular = false;
1985 
1986  return;
1987 }
Map * m_svdColMap
Mapping for matrices involved in the singular value decomposition (svd) routine.
Teuchos::SerialDenseMatrix< int, double > m_LU
Teuchos matrix for the LU decomposition of m_mat.
TeuchosMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
double m_lnDeterminant
The natural logarithm of the determinant of this matrix.
TeuchosMatrix * m_inverse
Stores the inverse of this matrix.
int * v_pivoting
The pivoting vector of a LU decomposition.
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
TeuchosMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
bool m_isSingular
Indicates whether or not this matrix is singular.
double m_determinant
The determinant of this matrix.
void QUESO::TeuchosMatrix::setColumn ( const unsigned int  column_num,
const TeuchosVector column 
)

This function copies vector column into the column_num-th column of this matrix.

Definition at line 1255 of file TeuchosMatrix.C.

References m_mat, numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, resetLU(), and QUESO::TeuchosVector::sizeLocal().

Referenced by invertMultiply(), matlabLinearInterpExtrap(), and svdSolve().

1256 {
1257  this->resetLU();
1258  // Sanity checks
1259  queso_require_less_msg(column_num, this->numCols(), "Specified column number not within range");
1260 
1261  queso_require_equal_to_msg(column.sizeLocal(), this->numRowsLocal(), "column vector not same size as this matrix");
1262 
1263  for (unsigned int i =0; i < column.sizeLocal(); i++)
1264  m_mat(i,column_num) = column[i];
1265 
1266  return;
1267 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos 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...
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::setRow ( const unsigned int  row_num,
const TeuchosVector row 
)

This function copies vector row into the row_num-th column of this matrix.

Definition at line 1301 of file TeuchosMatrix.C.

References m_mat, numRowsLocal(), QUESO::queso_require_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

1302 {
1303  // Sanity checks
1304  queso_require_less_msg(row_num, this->numRowsLocal(), "Specified row number not within range");
1305 
1306  queso_require_equal_to_msg(row.sizeLocal(), this->numRowsLocal(), "row vector not same size as this matrix");
1307 
1308  // Copy our TeuchosVector object to our Teuchos Matrix
1309  for (unsigned int i=0; i< row.sizeLocal();i++)
1310  m_mat(row_num,i) = row[i] ;
1311 
1312  return;
1313 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
void QUESO::TeuchosMatrix::smallestEigen ( double &  eigenValue,
TeuchosVector eigenVector 
) const

This function finds smallest eigenvalue, namely eigenValue, of this matrix and its corresponding eigenvector, namely eigenVector.

Definition at line 1141 of file TeuchosMatrix.C.

References m_mat, QUESO::queso_require_not_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

1142 {
1143  unsigned int n = eigenVector.sizeLocal();
1144 
1145  queso_require_not_equal_to_msg(n, 0, "invalid input vector size");
1146  Teuchos::LAPACK<int, double> lapack;
1147 
1148  //SYEV destroys the input matrix, so lets operate in a copy
1149  Teuchos::SerialDenseMatrix<int,double> copy_m_mat;
1150  copy_m_mat = m_mat;
1151 
1152  int lwork = 3*n -1;
1153  int info;
1154  char UPLO = 'L';
1155  char JOBZ = 'V';//eigenvalues and eigenvectors
1156  double *W, *WORK;
1157 
1158  W = new double[n];
1159  WORK = new double[lwork];
1160 
1161  lapack.SYEV(JOBZ, UPLO, copy_m_mat.numRows(), copy_m_mat.values(), copy_m_mat.stride(), &W[0], &WORK[0], lwork, &info);
1162 
1163  if (info != 0) {
1164  std::cerr << "In TeuchosMtrix::smallestEigen()"
1165  << ": INFO = " << info
1166  << ",\n INFO < 0: if INFO = -i, the i-th argument had an illegal value."
1167  << "\n INFO > 0: if INFO = i, the algorithm failed to converge; i off-diagonal "
1168  << " elements of an intermediate tridiagonal form did not converge to zero."
1169  << std::endl;
1170  }
1171 
1172  // If INFO = 0, W contains the eigenvalues in ascending order.
1173  // Thus the smallest eigenvalue is in W[0].
1174  eigenValue = W[0];
1175 
1176  // Eigenvector associated to the smallest eigenvalue.
1177  // Stored in the n-th column of matrix copy_m_mat.
1178  for (int i=0; i< copy_m_mat.numRows(); i++)
1179  eigenVector[i] = copy_m_mat(i,0);
1180 
1181  return;
1182 }
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
int QUESO::TeuchosMatrix::stride ( )

Returns the stride between the columns of this matrix in memory.

Definition at line 306 of file TeuchosMatrix.C.

References m_mat.

Referenced by internalSvd(), and svdSolve().

307 {
308  return m_mat.stride();
309 };
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
void QUESO::TeuchosMatrix::subReadContents ( const std::string &  fileName,
const std::string &  fileType,
const std::set< unsigned int > &  allowedSubEnvIds 
)

Read contents of subenvironment from file fileName.

Definition at line 1751 of file TeuchosMatrix.C.

References QUESO::BaseEnvironment::closeFile(), QUESO::BaseEnvironment::fullRank(), QUESO::FilePtrSetStruct::ifsVar, QUESO::Matrix::m_env, numCols(), QUESO::Matrix::numOfProcsForStorage(), numRowsLocal(), QUESO::BaseEnvironment::openInputFile(), QUESO::queso_require_equal_to_msg, QUESO::BaseEnvironment::subDisplayFile(), and QUESO::BaseEnvironment::subRank().

1755 {
1756  queso_require_greater_equal_msg(m_env.subRank(), 0, "unexpected subRank");
1757 
1758  queso_require_less_equal_msg(this->numOfProcsForStorage(), 1, "implemented just for sequential vectors for now");
1759 
1760  FilePtrSetStruct filePtrSet;
1761  if (m_env.openInputFile(fileName,
1762  fileType, // "m or hdf"
1763  allowedSubEnvIds,
1764  filePtrSet)) {
1765 
1766  // palms
1767  unsigned int nRowsLocal = this->numRowsLocal();
1768 
1769  // In the logic below, the id of a line' begins with value 0 (zero)
1770  unsigned int idOfMyFirstLine = 1;
1771  unsigned int idOfMyLastLine = nRowsLocal;
1772  unsigned int nCols = this->numCols();
1773 
1774  // Read number of matrix rows in the file by taking care of the first line,
1775  // which resembles something like 'variable_name = zeros(n_rows,n_cols);'
1776  std::string tmpString;
1777 
1778  // Read 'variable name' string
1779  *filePtrSet.ifsVar >> tmpString;
1780 
1781  // Read '=' sign
1782  *filePtrSet.ifsVar >> tmpString;
1783 
1784  queso_require_equal_to_msg(tmpString, "=", "string should be the '=' sign");
1785 
1786  // Read 'zeros(n_rows,n_cols)' string
1787  *filePtrSet.ifsVar >> tmpString;
1788 
1789  unsigned int posInTmpString = 6;
1790 
1791  // Isolate 'n_rows' in a string
1792  char nRowsString[tmpString.size()-posInTmpString+1];
1793  unsigned int posInRowsString = 0;
1794  do {
1795  queso_require_less_msg(posInTmpString, tmpString.size(), "symbol ',' not found in first line of file");
1796  nRowsString[posInRowsString++] = tmpString[posInTmpString++];
1797  } while (tmpString[posInTmpString] != ',');
1798  nRowsString[posInRowsString] = '\0';
1799 
1800  // Isolate 'n_cols' in a string
1801  posInTmpString++; // Avoid reading ',' char
1802  char nColsString[tmpString.size()-posInTmpString+1];
1803  unsigned int posInColsString = 0;
1804  do {
1805  queso_require_less_msg(posInTmpString, tmpString.size(), "symbol ')' not found in first line of file");
1806  nColsString[posInColsString++] = tmpString[posInTmpString++];
1807  } while (tmpString[posInTmpString] != ')');
1808  nColsString[posInColsString] = '\0';
1809 
1810  // Convert 'n_rows' and 'n_cols' strings to numbers
1811  unsigned int numRowsInFile = (unsigned int) strtod(nRowsString,NULL);
1812  unsigned int numColsInFile = (unsigned int) strtod(nColsString,NULL);
1813  if (m_env.subDisplayFile()) {
1814  *m_env.subDisplayFile() << "In TeuchosMatrix::subReadContents()"
1815  << ": fullRank " << m_env.fullRank()
1816  << ", numRowsInFile = " << numRowsInFile
1817  << ", numColsInFile = " << numColsInFile
1818  << ", nRowsLocal = " << nRowsLocal
1819  << ", nCols = " << nCols
1820  << std::endl;
1821  }
1822 
1823  // Check if [num of rows in file] == [requested matrix row size]
1824  queso_require_equal_to_msg(numRowsInFile, nRowsLocal, "size of vec in file is not big enough");
1825 
1826  // Check if [num of cols in file] == [num cols in current matrix]
1827  queso_require_equal_to_msg(numColsInFile, nCols, "number of parameters of vec in file is different than number of parameters in this vec object");
1828 
1829  // Code common to any core in a communicator
1830  unsigned int maxCharsPerLine = 64*nCols; // Up to about 60 characters to represent each parameter value
1831 
1832  unsigned int lineId = 0;
1833  while (lineId < idOfMyFirstLine) {
1834  filePtrSet.ifsVar->ignore(maxCharsPerLine,'\n');
1835  lineId++;
1836  };
1837 
1838  if (m_env.subDisplayFile()) {
1839  *m_env.subDisplayFile() << "In TeuchosMatrix::subReadContents()"
1840  << ": beginning to read input actual data"
1841  << std::endl;
1842  }
1843 
1844  // Take care of initial part of the first data line,
1845  // which resembles something like 'variable_name = [value1 value2 ...'
1846  // Read 'variable name' string
1847  *filePtrSet.ifsVar >> tmpString;
1848  //std::cout << "Core 0 just read '" << tmpString << "'" << std::endl;
1849 
1850  // Read '=' sign
1851  *filePtrSet.ifsVar >> tmpString;
1852  //std::cout << "Core 0 just read '" << tmpString << "'" << std::endl;
1853  queso_require_equal_to_msg(tmpString, "=", "in core 0, string should be the '=' sign");
1854 
1855  // Take into account the ' [' portion
1856  std::streampos tmpPos = filePtrSet.ifsVar->tellg();
1857  filePtrSet.ifsVar->seekg(tmpPos+(std::streampos)2);
1858 
1859  if (m_env.subDisplayFile()) {
1860  *m_env.subDisplayFile() << "In TeuchosMatrix::subReadContents()"
1861  << ": beginning to read lines with numbers only"
1862  << ", lineId = " << lineId
1863  << ", idOfMyFirstLine = " << idOfMyFirstLine
1864  << ", idOfMyLastLine = " << idOfMyLastLine
1865  << std::endl;
1866  }
1867 
1868  double tmpRead;
1869  while (lineId <= idOfMyLastLine) {
1870  for (unsigned int j = 0; j < nCols; ++j) {
1871  *filePtrSet.ifsVar >> tmpRead;
1872  (*this)(lineId-idOfMyFirstLine,j) = tmpRead;
1873  }
1874  lineId++;
1875  };
1876 
1877  m_env.closeFile(filePtrSet,fileType);
1878  }
1879 
1880  return;
1881 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
unsigned int numOfProcsForStorage() const
Definition: Matrix.C:62
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
Definition: Environment.C:1084
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
int fullRank() const
Returns the rank of the MPI process in QUESO&#39;s full communicator.
Definition: Environment.C:268
bool openInputFile(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds, FilePtrSetStruct &filePtrSet) const
Opens an input file.
Definition: Environment.C:896
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
void QUESO::TeuchosMatrix::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.

Definition at line 1885 of file TeuchosMatrix.C.

References QUESO::BaseEnvironment::closeFile(), QUESO::Matrix::m_env, numCols(), QUESO::Matrix::numOfProcsForStorage(), numRowsLocal(), QUESO::FilePtrSetStruct::ofsVar, QUESO::BaseEnvironment::openOutputFile(), QUESO::BaseEnvironment::subIdString(), and QUESO::BaseEnvironment::subRank().

1890 {
1891  queso_require_greater_equal_msg(m_env.subRank(), 0, "unexpected subRank");
1892 
1893  queso_require_less_equal_msg(this->numOfProcsForStorage(), 1, "implemented just for sequential vectors for now");
1894 
1895  FilePtrSetStruct filePtrSet;
1896  if (m_env.openOutputFile(fileName,
1897  fileType, // "m or hdf"
1898  allowedSubEnvIds,
1899  false,
1900  filePtrSet)) {
1901  unsigned int nRows = this->numRowsLocal();
1902  unsigned int nCols = this->numCols();
1903  *filePtrSet.ofsVar << varNamePrefix << "_sub" << m_env.subIdString() << " = zeros(" << nRows
1904  << "," << nCols
1905  << ");"
1906  << std::endl;
1907  *filePtrSet.ofsVar << varNamePrefix << "_sub" << m_env.subIdString() << " = [";
1908 
1909  for (unsigned int i = 0; i < nRows; ++i) {
1910  for (unsigned int j = 0; j < nCols; ++j) {
1911  *filePtrSet.ofsVar << (*this)(i,j)
1912  << " ";
1913  }
1914  *filePtrSet.ofsVar << "\n";
1915  }
1916  *filePtrSet.ofsVar << "];\n";
1917 
1918  m_env.closeFile(filePtrSet,fileType);
1919  }
1920 
1921  return;
1922 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
unsigned int numOfProcsForStorage() const
Definition: Matrix.C:62
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
Definition: Environment.C:1084
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
unsigned int numCols() const
Returns the column dimension of this matrix.
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.
Definition: Environment.C:348
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
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...
Definition: Environment.C:521
int QUESO::TeuchosMatrix::svd ( TeuchosMatrix matU,
TeuchosVector vecS,
TeuchosMatrix matVt 
) const

Checks for the dimension of this matrix, matU, VecS and matVt, and calls the protected routine internalSvd to compute the singular values of this.

Definition at line 617 of file TeuchosMatrix.C.

References internalSvd(), m_svdSvec, m_svdUmat, m_svdVTmat, numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, and QUESO::TeuchosVector::sizeLocal().

618 {
619  unsigned int nRows = this->numRowsLocal();
620  unsigned int nCols = this->numCols();
621 
622  queso_require_msg(!((matU.numRowsLocal() != nRows) || (matU.numCols() != nCols)), "invalid matU");
623 
624  queso_require_equal_to_msg(vecS.sizeLocal(), nCols, "invalid vecS");
625 
626  queso_require_msg(!((matVt.numRowsLocal() != nCols) || (matVt.numCols() != nCols)), "invalid matVt");
627 
628  int iRC = internalSvd();
629 
630  matU = *m_svdUmat;
631  vecS = *m_svdSvec;
632  matVt = *m_svdVTmat;
633 
634  return iRC;
635 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
int internalSvd() const
This function factorizes the M-by-N matrix A into the singular value decomposition A = U S V^T for M ...
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
TeuchosMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
const TeuchosMatrix & QUESO::TeuchosMatrix::svdMatU ( ) const

This function calls private member TeuchosMatrix::internalSvd() to set a M-by-N orthogonal matrix U of the singular value decomposition (svd) of a general rectangular M-by-N matrix A.

A general rectangular M-by-N matrix A has a singular value decomposition (svd) into the product of an M-by-N orthogonal matrix U, an N-by-N diagonal matrix of singular values S and the transpose of an N-by-N orthogonal square matrix V, A = U S V^T.

Definition at line 639 of file TeuchosMatrix.C.

References internalSvd(), and m_svdUmat.

Referenced by svdSolve().

640 {
641  int iRC = 0;
642  iRC = internalSvd();
643  if (iRC) {}; // just to remove compiler warning
644  return *m_svdUmat;
645 }
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
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 TeuchosMatrix & QUESO::TeuchosMatrix::svdMatV ( ) const

This function calls private member TeuchosMatrix::internalSvd() to set a N-by-N orthogonal square matrix V of the singular value decomposition (svd) of a general rectangular M-by-N matrix A.

A general rectangular M-by-N matrix A has a singular value decomposition (svd) into the product of an M-by-N orthogonal matrix U, an N-by-N diagonal matrix of singular values S and the transpose of an N-by-N orthogonal square matrix V, A = U S V^T.

Definition at line 649 of file TeuchosMatrix.C.

References internalSvd(), and m_svdVmat.

650 {
651  int iRC = 0;
652  iRC = internalSvd();
653  if (iRC) {}; // just to remove compiler warning
654  return *m_svdVmat;
655 }
TeuchosMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
int internalSvd() const
This function factorizes the M-by-N matrix A into the singular value decomposition A = U S V^T for M ...
int QUESO::TeuchosMatrix::svdSolve ( const TeuchosVector rhsVec,
TeuchosVector 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 TeuchosMatrix::svd (x=solVec, b=rhsVec).

An orthogonal matrix A has a norm-preserving property, i.e. for any vector v,

\[ ||Av|| = ||v|| \]

Then:

\[ min( ||Ax - b||^2) = min(||Ax - b||) = min(||U D V^T x - b||) = min(||D V x - U b||)\]

Substituting

\[ y = V^T x \]

and

\[ b' = U^T b \]

gives us

\[ Dy = b'\]

with D being a diagonal matrix. Or,

\[ y = inv(D) U^T b \]

and we only have to solve the linear system:

\[ V^T x = y\]

Definition at line 667 of file TeuchosMatrix.C.

References QUESO::BaseEnvironment::displayVerbosity(), internalSvd(), QUESO::Matrix::m_env, m_svdSvec, m_svdUmat, m_svdVmat, m_svdVTmat, numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, QUESO::TeuchosVector::sizeLocal(), stride(), QUESO::BaseEnvironment::subDisplayFile(), svdMatU(), TeuchosMatrix(), transpose(), values(), and QUESO::TeuchosVector::values().

Referenced by svdSolve().

668 {
669  unsigned int nRows = this->numRowsLocal();
670  unsigned int nCols = this->numCols();
671  unsigned int i;
672 
673  queso_require_equal_to_msg(rhsVec.sizeLocal(), nRows, "invalid rhsVec");
674 
675  queso_require_equal_to_msg(solVec.sizeLocal(), nCols, "invalid solVec");
676 
677  int iRC = internalSvd();
678 
679  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
680  *m_env.subDisplayFile() << "In TeuchosMatrix::svdSolve():"
681  << "\n this->numRowsLocal() = " << this->numRowsLocal()
682  << ", this->numCols() = " << this->numCols()
683  << "\n m_svdUmat->numRowsLocal() = " << m_svdUmat->numRowsLocal()
684  << ", m_svdUmat->numCols() = " << m_svdUmat->numCols()
685  << "\n m_svdVmat->numRowsLocal() = " << m_svdVmat->numRowsLocal()
686  << ", m_svdVmat->numCols() = " << m_svdVmat->numCols()
687  << "\n m_svdSvec->sizeLocal() = " << m_svdSvec->sizeLocal()
688  << "\n rhsVec.sizeLocal() = " << rhsVec.sizeLocal()
689  << "\n solVec.sizeLocal() = " << solVec.sizeLocal()
690  << std::endl;
691  }
692 
693  if (iRC == 0)
694  {
695  TeuchosMatrix invD = TeuchosMatrix(solVec);
696  TeuchosMatrix auxMatrix = TeuchosMatrix(solVec);
697 
698  for (i=0; i<nRows; i++){
699  invD(i,i) = 1./(m_svdSvec->values()[i]);
700  }
701 
702  // GESV: For a system Ax=b, on entry, b contains the right-hand side b;
703  // on exit it contains the solution x.
704  // Thus, intead of doing y = inv(D)*UT*rhsVec = auxMatrix*rhsVec, with
705  // auxMatrix = inv(D)*UT; and then assigning solVec=y (requirement for using GESV)
706  // lets do solVec= auxMatrix*rhsVec, and save one step in the calculation
707 
708  auxMatrix = invD * svdMatU().transpose();
709  solVec = auxMatrix*rhsVec;
710 
711  // solve the linear system VT * solVec = y
712  // GESV changes the values of the matrix, so lets make a copy of it and use it.
713 
714  TeuchosMatrix* aux_m_svdVTmat = new TeuchosMatrix(*m_svdVTmat);
715 
716  int ipiv[0], info;
717  Teuchos::LAPACK<int, double> lapack;
718  lapack.GESV(nCols, 1, aux_m_svdVTmat->values(), aux_m_svdVTmat->stride(), ipiv, &solVec[0], solVec.sizeLocal(), &info );
719 
720  /* GESV output INFO: = 0: successful exit
721  * < 0: if INFO = -i, the i-th argument had an illegal value
722  * > 0: if INFO = i, U(i,i) is exactly zero. The factorization
723  * has been completed, but the factor U is exactly
724  * singular, so the solution could not be computed. */
725 
726  iRC = info;
727  delete aux_m_svdVTmat;
728  }
729  return iRC;
730 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
TeuchosMatrix()
Default Constructor.
unsigned int sizeLocal() const
Returns the length of this vector.
TeuchosMatrix * m_svdVmat
m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a ma...
TeuchosMatrix * m_svdUmat
m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix...
const TeuchosMatrix & svdMatU() const
This function calls private member TeuchosMatrix::internalSvd() to set a M-by-N orthogonal matrix U o...
int internalSvd() const
This function factorizes the M-by-N matrix A into the singular value decomposition A = U S V^T for M ...
TeuchosVector * m_svdSvec
m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular v...
TeuchosMatrix transpose() const
This function calculates the transpose of this matrix (square).
TeuchosMatrix * m_svdVTmat
m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular ...
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
unsigned int displayVerbosity() const
Definition: Environment.C:450
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
int QUESO::TeuchosMatrix::svdSolve ( const TeuchosMatrix rhsMat,
TeuchosMatrix solMat 
) 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 TeuchosMatrix::svd (x=solMat, b=rhsMat).

Note that solMat is a matrix. Thus, to solve the system of equations ' * solMath = rhsMat', this method calls svdSolve(const TeuchosVector& rhsVec, TeuchosVector& solVec) passing one column of solMat with its respective column of rhsMat, .

Definition at line 735 of file TeuchosMatrix.C.

References getColumn(), QUESO::Matrix::m_env, QUESO::Matrix::map(), numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, setColumn(), and svdSolve().

736 {
737  unsigned int nRows = this->numRowsLocal();
738  unsigned int nCols = this->numCols();
739 
740  queso_require_equal_to_msg(rhsMat.numRowsLocal(), nRows, "invalid rhsMat");
741 
742  queso_require_equal_to_msg(solMat.numRowsLocal(), nCols, "invalid solMat");
743 
744  queso_require_equal_to_msg(rhsMat.numCols(), solMat.numCols(), "rhsMat and solMat are not compatible");
745 
746  TeuchosVector rhsVec(m_env,rhsMat.map());
747  TeuchosVector solVec(m_env,solMat.map());
748  int iRC = 0;
749  for (unsigned int j = 0; j < rhsMat.numCols(); ++j) {
750  rhsVec = rhsMat.getColumn(j);
751  iRC = this->svdSolve(rhsVec, solVec);
752  if (iRC) break;
753  solMat.setColumn(j,solVec);
754  }
755 
756  return iRC;
757 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
int svdSolve(const TeuchosVector &rhsVec, TeuchosVector &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 TeuchosMatrix::svd (x=solVec, b=rhsVec).
TeuchosMatrix QUESO::TeuchosMatrix::transpose ( ) const

This function calculates the transpose of this matrix (square).

Definition at line 372 of file TeuchosMatrix.C.

References QUESO::Matrix::m_env, QUESO::Matrix::m_map, numCols(), numRowsLocal(), and QUESO::queso_require_equal_to_msg.

Referenced by svdSolve().

373 {
374  unsigned int nRows = this->numRowsLocal();
375  unsigned int nCols = this->numCols();
376 
377  queso_require_equal_to_msg(nRows, nCols, "routine works only for square matrices");
378 
379  TeuchosMatrix mat(m_env,m_map,nCols);
380  for (unsigned int row = 0; row < nRows; ++row) {
381  for (unsigned int col = 0; col < nCols; ++col) {
382  mat(row,col) = (*this)(col,row);
383  }
384  }
385 
386  return mat;
387 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
TeuchosMatrix()
Default Constructor.
const Map m_map
Mapping variable.
Definition: Matrix.h:121
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:116
double * QUESO::TeuchosMatrix::values ( )

Returns a pointer to the first element of this matrix.

Definition at line 298 of file TeuchosMatrix.C.

References m_mat.

Referenced by internalSvd(), and svdSolve().

299 {
300  return m_mat.values();
301 };
Teuchos::SerialDenseMatrix< int, double > m_mat
Teuchos matrix, also referred to as this matrix.
void QUESO::TeuchosMatrix::zeroLower ( bool  includeDiagonal = false)
virtual

This function sets all the entries above the main diagonal (inclusive or not) of this matrix to zero.

If \c includeDiagonal = false, then only the entries above the main diagonal are set to zero;

if includeDiagonal = true, then the elements of the matrix diagonal are also set to zero.

Implements QUESO::Matrix.

Definition at line 1318 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, and resetLU().

1319 {
1320  unsigned int nRows = this->numRowsLocal();
1321  unsigned int nCols = this->numCols();
1322 
1323  queso_require_equal_to_msg(nRows, nCols, "routine works only for square matrices");
1324  this->resetLU();
1325 
1326  if (includeDiagonal) {
1327  for (unsigned int i = 0; i < nRows; i++) {
1328  for (unsigned int j = 0; j <= i; j++) {
1329  (*this)(i,j) = 0.;
1330  }
1331  }
1332  }
1333  else {
1334  for (unsigned int i = 0; i < nRows; i++) {
1335  for (unsigned int j = 0; j < i; j++) {
1336  (*this)(i,j) = 0.;
1337  }
1338  }
1339  }
1340 
1341  return;
1342 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
void resetLU()
In this function resets the LU decomposition of this matrix, as well as deletes the private member po...
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.
void QUESO::TeuchosMatrix::zeroUpper ( bool  includeDiagonal = false)
virtual

This function sets all the entries bellow the main diagonal (inclusive or not) of this matrix to zero.

If \c includeDiagonal = false, then only the entries bellow the main diagonal are set to zero;

if includeDiagonal = true, then the elements of the matrix diagonal are also set to zero.

Implements QUESO::Matrix.

Definition at line 1347 of file TeuchosMatrix.C.

References numCols(), numRowsLocal(), QUESO::queso_require_equal_to_msg, and resetLU().

1348 {
1349  unsigned int nRows = this->numRowsLocal();
1350  unsigned int nCols = this->numCols();
1351 
1352  queso_require_equal_to_msg(nRows, nCols, "routine works only for square matrices");
1353  this->resetLU();
1354 
1355  if (includeDiagonal) {
1356  for (unsigned int i = 0; i < nRows; i++) {
1357  for (unsigned int j = i; j < nCols; j++) {
1358  (*this)(i,j) = 0.;
1359  }
1360  }
1361  }
1362  else {
1363  for (unsigned int i = 0; i < nRows; i++) {
1364  for (unsigned int j = (i+1); j < nCols; j++) {
1365  (*this)(i,j) = 0.;
1366  }
1367  }
1368  }
1369 
1370  return;
1371 }
unsigned int numRowsLocal() const
Returns the local row dimension of this matrix.
void resetLU()
In this function resets the LU decomposition of this matrix, as well as deletes the private member po...
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
unsigned int numCols() const
Returns the column dimension of this matrix.

Member Data Documentation

double QUESO::TeuchosMatrix::m_determinant
mutableprivate

The determinant of this matrix.

Definition at line 376 of file TeuchosMatrix.h.

Referenced by determinant(), lnDeterminant(), and resetLU().

TeuchosMatrix* QUESO::TeuchosMatrix::m_inverse
mutableprivate

Stores the inverse of this matrix.

Definition at line 358 of file TeuchosMatrix.h.

Referenced by inverse(), and resetLU().

bool QUESO::TeuchosMatrix::m_isSingular
mutableprivate

Indicates whether or not this matrix is singular.

Definition at line 390 of file TeuchosMatrix.h.

Referenced by invertMultiply(), invertMultiplyForceLU(), and resetLU().

double QUESO::TeuchosMatrix::m_lnDeterminant
mutableprivate

The natural logarithm of the determinant of this matrix.

Definition at line 379 of file TeuchosMatrix.h.

Referenced by determinant(), lnDeterminant(), and resetLU().

Teuchos::SerialDenseMatrix<int,double> QUESO::TeuchosMatrix::m_LU
mutableprivate

Teuchos matrix for the LU decomposition of m_mat.

Definition at line 355 of file TeuchosMatrix.h.

Referenced by determinant(), invertMultiply(), invertMultiplyForceLU(), lnDeterminant(), resetLU(), and TeuchosMatrix().

Teuchos::SerialDenseMatrix<int,double> QUESO::TeuchosMatrix::m_mat
private
TeuchosMatrix* QUESO::TeuchosMatrix::m_permutation
mutableprivate

Definition at line 381 of file TeuchosMatrix.h.

int QUESO::TeuchosMatrix::m_signum
mutableprivate

Definition at line 387 of file TeuchosMatrix.h.

Referenced by resetLU().

Map* QUESO::TeuchosMatrix::m_svdColMap
mutableprivate

Mapping for matrices involved in the singular value decomposition (svd) routine.

Definition at line 361 of file TeuchosMatrix.h.

Referenced by internalSvd(), and resetLU().

TeuchosVector* QUESO::TeuchosMatrix::m_svdSvec
mutableprivate

m_svdSvec stores the diagonal of the N-by-N diagonal matrix of singular values S after the singular value decomposition of a matrix.

Definition at line 367 of file TeuchosMatrix.h.

Referenced by internalSvd(), rank(), resetLU(), svd(), and svdSolve().

TeuchosMatrix* QUESO::TeuchosMatrix::m_svdUmat
mutableprivate

m_svdUmat stores the M-by-N orthogonal matrix U after the singular value decomposition of a matrix.

Definition at line 364 of file TeuchosMatrix.h.

Referenced by internalSvd(), resetLU(), svd(), svdMatU(), and svdSolve().

TeuchosMatrix* QUESO::TeuchosMatrix::m_svdVmat
mutableprivate

m_svdVmat stores the N-by-N orthogonal square matrix V after the singular value decomposition of a matrix.

Definition at line 370 of file TeuchosMatrix.h.

Referenced by internalSvd(), resetLU(), svdMatV(), and svdSolve().

TeuchosMatrix* QUESO::TeuchosMatrix::m_svdVTmat
mutableprivate

m_svdVmatT stores the transpose of N-by-N orthogonal square matrix V, namely V^T, after the singular value decomposition of a matrix.

Definition at line 373 of file TeuchosMatrix.h.

Referenced by internalSvd(), resetLU(), svd(), and svdSolve().

int* QUESO::TeuchosMatrix::v_pivoting
mutableprivate

The pivoting vector of a LU decomposition.

Definition at line 384 of file TeuchosMatrix.h.

Referenced by invertMultiply(), invertMultiplyForceLU(), and resetLU().


The documentation for this class was generated from the following files:

Generated on Tue Jun 5 2018 19:49:12 for queso-0.57.1 by  doxygen 1.8.5