22 SquareMatrix::SquareMatrix() :
44 m_factored(y.m_factored),
81 ct_dgetrs(ctlapack::NoTranspose, static_cast<int>(
nRows()),
86 writelogf(
"SquareMatrix::solve(): DGETRS returned INFO = %d\n", info);
105 (void) memset((
void*) sm, 0, nn *
sizeof(double));
109 void SquareMatrix::resize(
size_t n,
size_t m, doublereal v)
114 void SquareMatrix::mult(
const doublereal* b, doublereal* prod)
const
116 DenseMatrix::mult(b, prod);
121 DenseMatrix::mult(b, prod);
135 integer n =
static_cast<int>(
nRows());
141 writelogf(
"SquareMatrix::factor(): DGETRS returned INFO = %d\n", info);
169 size_t lwork =
work.size();
173 writelogf(
"SquareMatrix::factorQR(): DGEQRF returned INFO = %d\n", info);
179 size_t lworkOpt =
static_cast<size_t>(
work[0]);
180 if (lworkOpt > lwork) {
181 work.resize(lworkOpt);
201 size_t lwork =
work.size();
210 ct_dormqr(ctlapack::Left, ctlapack::Transpose,
m_nrows, 1,
m_nrows, &(*(
begin())),
m_nrows,
DATA_PTR(
tau), b,
m_nrows,
214 writelogf(
"SquareMatrix::solveQR(): DORMQR returned INFO = %d\n", info);
220 size_t lworkOpt =
static_cast<size_t>(
work[0]);
221 if (lworkOpt > lwork) {
222 work.resize(lworkOpt);
227 ct_dtrtrs(ctlapack::UpperTriangular, ctlapack::NoTranspose, &dd,
m_nrows, 1, &(*(
begin())),
m_nrows, b,
231 writelogf(
"SquareMatrix::solveQR(): DTRTRS returned INFO = %d\n", info);
250 doublereal
rcond = 0.0;
252 throw CELapackError(
"SquareMatrix::rcond()",
"matrix isn't factored correctly");
263 writelogf(
"SquareMatrix::rcond(): DGECON returned INFO = %d\n", rinfo);
286 doublereal
rcond = 0.0;
288 throw CELapackError(
"SquareMatrix::rcondQR()",
"matrix isn't factored correctly");
296 writelogf(
"SquareMatrix::rcondQR(): DTRCON returned INFO = %d\n", rinfo);
356 doublereal*
const* SquareMatrix::colPts()
358 return DenseMatrix::colPts();
363 valueSmall = 1.0E300;
364 size_t iSmall =
npos;
365 for (
size_t i = 0; i <
m_nrows; i++) {
367 for (
size_t j = 0; j <
m_nrows; j++) {
368 if (fabs(
value(i,j)) > valueS) {
369 valueS = fabs(
value(i,j));
372 if (valueS < valueSmall) {
382 valueSmall = 1.0E300;
383 size_t jSmall =
npos;
384 for (
size_t j = 0; j <
m_nrows; j++) {
386 for (
size_t i = 0; i <
m_nrows; i++) {
387 if (fabs(
value(i,j)) > valueS) {
388 valueS = fabs(
value(i,j));
391 if (valueS < valueSmall) {
DenseMatrix & operator=(const DenseMatrix &y)
Assignment operator.
virtual bool factored() const
true if the current factorization is up to date with the matrix
Dense, Square (not sparse) matrices.
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
virtual doublereal rcond(doublereal a1norm)
Returns an estimate of the inverse of the condition number for the matrix.
vector_fp m_data
Data stored in a single array.
vector_fp work
Work vector for QR algorithm.
const size_t npos
index returned by functions to indicate "no position"
void copyData(const Array2D &y)
Copy the data from one array into another without doing any checking.
int m_printLevel
Print Level.
doublereal * ptrColumn(size_t j)
Return a pointer to the top of column j, columns are contiguous in memory.
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, HTML_logs (see Input File Handling, Diagnostic Output, Writing messages to the screen and Writing HTML Logfiles).
SquareMatrix & operator=(const SquareMatrix &right)
Assignment operator.
int m_factored
the factor flag
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the matrix.
void writelogf(const char *fmt,...)
Write a formatted message to the screen.
virtual GeneralMatrix * duplMyselfAsGeneralMatrix() const
Duplicator member function.
int solve(doublereal *b)
Solves the Ax = b system returning x in the b spot.
virtual size_t checkColumns(doublereal &valueSmall) const
Check to see if we have any zero columns in the jacobian.
vector_fp tau
Work vector for QR algorithm.
virtual vector_fp::iterator begin()
Return an iterator pointing to the first element.
virtual void leftMult(const doublereal *const b, doublereal *const prod) const
Left-multiply the matrix by transpose(b), and write the result to prod.
void zero()
Zero the matrix.
size_t nColumns() const
Number of columns.
virtual doublereal oneNorm() const
Calculate the one norm of the matrix.
A class for full (non-sparse) matrices with Fortran-compatible data storage.
int factor()
Factors the A matrix, overwriting A.
size_t m_nrows
Number of rows.
doublereal ct_dtrcon(const char *norm, ctlapack::upperlower_t uplot, const char *diag, size_t n, doublereal *a, size_t lda, doublereal *work, int *iwork, int &info)
virtual void useFactorAlgorithm(int fAlgorithm)
Change the way the matrix is factored.
int solveQR(doublereal *b)
Solves the linear problem Ax=b using the QR algorithm returning x in the b spot.
doublereal & value(size_t i, size_t j)
Returns a changeable reference to position in the matrix.
virtual void leftMult(const double *const b, double *const prod) const
Left-multiply the matrix by transpose(b), and write the result to prod.
virtual size_t checkRows(doublereal &valueSmall) const
Check to see if we have any zero rows in the jacobian.
virtual void copyData(const GeneralMatrix &y)
Copy the data from one array into another without doing any checking.
virtual size_t nRows() const
Return the number of rows in the matrix.
Contains declarations for string manipulation functions within Cantera.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
virtual int factorAlgorithm() const
Returns the factor algorithm used.
virtual doublereal * ptrColumn(size_t j)
Return a pointer to the top of column j, columns are assumed to be contiguous in memory.
virtual doublereal rcondQR()
Returns an estimate of the inverse of the condition number for the matrix.
std::vector< int > iwork_
Integer work vector for QR algorithms.
Exception thrown when an LAPACK error is encountered associated with inverting or solving a matrix...
GeneralMatrix & operator=(const GeneralMatrix &right)
Assignment operator.
int useQR_
Use the QR algorithm to factor and invert the matrix.
size_t nRowsAndStruct(size_t *const iStruct=0) const
Return the size and structure of the matrix.
int m_useReturnErrorCode
Error Handling Flag.
void setFactorFlag()
set the factored flag
doublereal a1norm_
1-norm of the matrix. This is determined immediately before every factorization
vector_int & ipiv()
Return a changeable value of the pivot vector.
SquareMatrix()
Base Constructor.
A class for full (non-sparse) matrices with Fortran-compatible data storage, which adds matrix operat...
virtual int factorQR()
Factors the A matrix using the QR algorithm, overwriting A.
virtual void clearFactorFlag()
clear the factored flag