17 SquareMatrix::SquareMatrix() :
22 "Use class DenseMatrix instead. To be removed after Cantera 2.3.");
31 "Use class DenseMatrix instead. To be removed after Cantera 2.3.");
42 SquareMatrix& SquareMatrix::operator=(
const SquareMatrix& y)
47 DenseMatrix::operator=(y);
48 GeneralMatrix::operator=(y);
74 ct_dgetrs(ctlapack::NoTranspose, static_cast<int>(
nRows()),
79 writelogf(
"SquareMatrix::solve(): DGETRS returned INFO = %d\n", info);
82 throw CanteraError(
"SquareMatrix::solve()",
"DGETRS returned INFO = {}", info);
88 "Not Implemented when LAPACK is not available");
97 void SquareMatrix::resize(
size_t n,
size_t m, doublereal v)
102 void SquareMatrix::mult(
const doublereal* b, doublereal* prod)
const 104 DenseMatrix::mult(b, prod);
109 DenseMatrix::mult(b, prod);
124 integer n =
static_cast<int>(
nRows());
130 writelogf(
"SquareMatrix::factor(): DGETRS returned INFO = %d\n", info);
133 throw CanteraError(
"SquareMatrix::factor()",
"DGETRS returned INFO = {}", info);
139 "Not Implemented when LAPACK is not available");
158 size_t lwork =
work.size();
162 writelogf(
"SquareMatrix::factorQR(): DGEQRF returned INFO = %d\n", info);
165 throw CanteraError(
"SquareMatrix::factorQR()",
"DGEQRF returned INFO = {}", info);
168 size_t lworkOpt =
static_cast<size_t>(
work[0]);
169 if (lworkOpt > lwork) {
170 work.resize(lworkOpt);
175 "Not Implemented when LAPACK is not available");
192 size_t lwork =
work.size();
199 ct_dormqr(ctlapack::Left, ctlapack::Transpose,
m_nrows, 1,
m_nrows, &*
begin(),
m_nrows,
tau.data(), b,
m_nrows,
200 work.data(), lwork, info);
203 writelogf(
"SquareMatrix::solveQR(): DORMQR returned INFO = %d\n", info);
206 throw CanteraError(
"SquareMatrix::solveQR()",
"DORMQR returned INFO = {}", info);
209 size_t lworkOpt =
static_cast<size_t>(
work[0]);
210 if (lworkOpt > lwork) {
211 work.resize(lworkOpt);
215 ct_dtrtrs(ctlapack::UpperTriangular, ctlapack::NoTranspose, &dd,
m_nrows, 1, &*
begin(),
m_nrows, b,
219 writelogf(
"SquareMatrix::solveQR(): DTRTRS returned INFO = %d\n", info);
222 throw CanteraError(
"SquareMatrix::solveQR()",
"DTRTRS returned INFO = {}", info);
228 "Not Implemented when LAPACK is not available");
241 doublereal
rcond = 0.0;
243 throw CanteraError(
"SquareMatrix::rcond()",
"matrix isn't factored correctly");
251 writelogf(
"SquareMatrix::rcond(): DGECON returned INFO = %d\n", rinfo);
254 throw CanteraError(
"SquareMatrix::rcond()",
"DGECON returned INFO = {}", rinfo);
260 "Not Implemented when LAPACK is not available");
278 doublereal
rcond = 0.0;
280 throw CanteraError(
"SquareMatrix::rcondQR()",
"matrix isn't factored correctly");
288 writelogf(
"SquareMatrix::rcondQR(): DTRCON returned INFO = %d\n", rinfo);
291 throw CanteraError(
"SquareMatrix::rcondQR()",
"DTRCON returned INFO = {}", rinfo);
297 "Not Implemented when LAPACK is not available");
324 "To be removed after Cantera 2.3.");
343 doublereal*
const* SquareMatrix::colPts()
345 return DenseMatrix::colPts();
350 valueSmall = 1.0E300;
351 size_t iSmall =
npos;
352 for (
size_t i = 0; i <
m_nrows; i++) {
354 for (
size_t j = 0; j <
m_nrows; j++) {
355 valueS = std::max(fabs(
value(i,j)), valueS);
357 if (valueS < valueSmall) {
367 valueSmall = 1.0E300;
368 size_t jSmall =
npos;
369 for (
size_t j = 0; j <
m_nrows; j++) {
371 for (
size_t i = 0; i <
m_nrows; i++) {
372 valueS = std::max(fabs(
value(i,j)), valueS);
374 if (valueS < valueSmall) {
Dense, Square (not sparse) matrices.
virtual size_t checkRows(doublereal &valueSmall) const
Check to see if we have any zero rows in the Jacobian.
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.
virtual size_t checkColumns(doublereal &valueSmall) const
Check to see if we have any zero columns in the Jacobian.
const size_t npos
index returned by functions to indicate "no position"
int m_factored
Indicates whether the matrix is factored.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
int m_printLevel
Print Level.
doublereal * ptrColumn(size_t j)
Return a pointer to the top of column j, columns are contiguous in memory.
void resize(size_t n, size_t m, doublereal v=0.0)
Resize 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.
size_t nRowsAndStruct(size_t *const iStruct=0) const
Return the size and structure of the matrix.
vector_fp tau
Work vector for QR algorithm.
virtual vector_fp::iterator begin()
Return an iterator pointing to the first element.
int solve(doublereal *b, size_t nrhs=1, size_t ldb=0)
Solves the Ax = b system returning x in the b spot.
virtual size_t nRows() const
Return the number of rows in the matrix.
void zero()
Zero 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 int factorAlgorithm() const
Returns the factor algorithm used.
Base class for exceptions thrown by Cantera classes.
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.
vector_fp & data()
Return a reference to the data vector.
virtual GeneralMatrix * duplMyselfAsGeneralMatrix() const
Duplicator member function.
doublereal & value(size_t i, size_t j)
Returns a changeable reference to position in the matrix.
void writelogf(const char *fmt, const Args &... args)
Write a formatted message to the screen.
vector_int iwork_
Integer work vector for QR algorithms.
virtual doublereal oneNorm() const
Calculate the one norm of the matrix.
Contains declarations for string manipulation functions within Cantera.
virtual doublereal * ptrColumn(size_t j)
Return a pointer to the top of column j, columns are assumed to be contiguous in memory.
virtual void leftMult(const doublereal *const b, doublereal *const prod) const
Left-multiply the matrix by transpose(b), and write the result to prod.
virtual doublereal rcondQR()
Returns an estimate of the inverse of the condition number for the matrix.
int useQR_
Use the QR algorithm to factor and invert the matrix.
int m_useReturnErrorCode
Error Handling Flag.
void setFactorFlag()
set the factored flag
Namespace for the Cantera kernel.
doublereal a1norm_
1-norm of the matrix.
size_t nColumns() const
Number of columns.
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.