|
HermesCommon 1.0
|
Contains operation on dense matrices. More...
Functions | |
| template<typename T > | |
| T ** | new_matrix (unsigned int m, unsigned int n=0) |
| template<typename T > | |
| T ** | new_matrix_malloc (unsigned int m, unsigned int n=0) |
| template<typename T > | |
| void | copy_matrix (T **dest, T **src, unsigned int m, unsigned int n=0) |
| template<typename T > | |
| void | save_matrix_octave (const std::string &matrix_name, T **matrix, unsigned int m, unsigned int n=0, const std::string &filename=std::string()) |
| Saves a dense matrix to a octave file format. | |
| template<typename T > | |
| void | save_sparse_matrix_octave (const std::string &matrix_name, const T *Ax, const int *Ap, const int *Ai, unsigned int m, const std::string &filename=std::string()) |
| Saves MxM sparse matrix to a octave file format. | |
| template<typename T > | |
| void | transpose (T **matrix, unsigned int m, unsigned int n) |
| template<typename T > | |
| void | chsgn (T **matrix, unsigned int m, unsigned int n) |
| Changes the sign of a matrix. | |
| HERMES_API void | ludcmp (double **a, int n, int *indx, double *d) |
| template<typename T > | |
| void | lubksb (double **a, int n, int *indx, T *b) |
| HERMES_API void | choldc (double **a, int n, double p[]) |
| template<typename T > | |
| void | cholsl (double **a, int n, double p[], T b[], T x[]) |
Contains operation on dense matrices.
| void Hermes::Algebra::DenseMatrixOperations::choldc | ( | double ** | a, |
| int | n, | ||
| double | p[] | ||
| ) |
Given a positive-definite symmetric matrix a[n][n], this routine constructs its Cholesky decomposition, A = L*L^T . On input, only the upper triangle of a need be given; it is not modified. The Cholesky factor L is returned in the lower triangle of a, except for its diagonal elements which are returned in p[n].
Definition at line 99 of file matrix.cpp.
| void Hermes::Algebra::DenseMatrixOperations::cholsl | ( | double ** | a, |
| int | n, | ||
| double | p[], | ||
| T | b[], | ||
| T | x[] | ||
| ) |
Solves the set of n linear equations A*x = b, where a is a positive-definite symmetric matrix. a[n][n] and p[n] are input as the output of the routine choldc. Only the lower subdiagonal portion of a is accessed. b[n] is input as the right-hand side vector. The solution vector is returned in x[n]. a, n, and p are not modified and can be left in place for successive calls with different right-hand sides b. b is not modified unless you identify b and x in the calling sequence, which is allowed. The right-hand side b can be complex, in which case the solution x is also complex.
| void Hermes::Algebra::DenseMatrixOperations::copy_matrix | ( | T ** | dest, |
| T ** | src, | ||
| unsigned int | m, | ||
| unsigned int | n = 0 |
||
| ) |
| void Hermes::Algebra::DenseMatrixOperations::lubksb | ( | double ** | a, |
| int | n, | ||
| int * | indx, | ||
| T * | b | ||
| ) |
Solves the set of n linear equations AX = B. Here a[n][n] is input, not as the matrix A but rather as its LU decomposition, determined by the routine ludcmp. indx[n] is input as the permutation vector returned by ludcmp. b[n] is input as the right-hand side vector B, and returns with the solution vector X. a, n, and indx are not modified by this routine and can be left in place for successive calls with different right-hand sides b. This routine takes into account the possibility that b will begin with many zero elements, so it is efficient for use in matrix inversion.
| void Hermes::Algebra::DenseMatrixOperations::ludcmp | ( | double ** | a, |
| int | n, | ||
| int * | indx, | ||
| double * | d | ||
| ) |
Given a matrix a[n][n], this routine replaces it by the LU decomposition of a rowwise permutation of itself. a and n are input. a is output, arranged as in equation (2.3.14) above; indx[n] is an output vector that records the row permutation effected by the partial pivoting; d is output as +-1 depending on whether the number of row interchanges was even or odd, respectively. This routine is used in combination with lubksb to solve linear equations or invert a matrix.
Definition at line 37 of file matrix.cpp.
| T** Hermes::Algebra::DenseMatrixOperations::new_matrix | ( | unsigned int | m, |
| unsigned int | n = 0 |
||
| ) |
Creates a new (full) matrix with m rows and n columns with entries of the type T. The entries can be accessed by matrix[i][j]. To delete the matrix, just do "delete matrix".
Definition at line 52 of file matrix.h.
Referenced by Hermes::Algebra::CSCMatrix< Scalar >::duplicate().
| void Hermes::Algebra::DenseMatrixOperations::save_matrix_octave | ( | const std::string & | matrix_name, |
| T ** | matrix, | ||
| unsigned int | m, | ||
| unsigned int | n = 0, |
||
| const std::string & | filename = std::string() |
||
| ) |
Saves a dense matrix to a octave file format.
| [in] | matrix_name | A name of a matrix in Octave. It can be used to create an output filename. |
| [in] | matrix | A pointer to an array of pointers to a rows of the matrix. Such a structure can be generated using new_matrix() or it can be a pointer to an 1D C-array. |
| [in] | m | A number of rows of the matrix. Set to 1 if the matrix is a pointer to a 1D C-array. |
| [in] | n | A number of columns of the matrix. If zero, it is assumed to be equal to m. |
| [in] | filename | An output filename. If not specified, matrix_name will be used by concatenating it with a suffix '.mat'. |
| void Hermes::Algebra::DenseMatrixOperations::transpose | ( | T ** | matrix, |
| unsigned int | m, | ||
| unsigned int | n | ||
| ) |
1.7.4