|
reconciliation_lib 0.1
Library for data reconciliation algorithms
|
RAII wrapper around a heap-allocated gsl_matrix.
More...
#include <gsl_wrapper.h>
Public Member Functions | |
| matrix (int n1, int n2, bool id=false, const double *diag=nullptr) | |
Allocate an n1 × n2 matrix. | |
| matrix (int n1, int n2, const double *x) | |
Allocate an n1 × n2 matrix and copy values from the row-major array x. | |
| template<int n> | |
| matrix (int n1, int n2, const double(*x)[n]) | |
Allocate an n1 × n2 matrix from a 2-D C array. | |
| matrix (const matrix &src) | |
| Copy constructor. | |
| matrix (const gsl_matrix *src) | |
Construct from an existing (non-owned) gsl_matrix pointer. | |
| ~matrix () | |
| Destructor — frees the underlying GSL allocation. | |
| gsl_matrix * | gsl_internal () |
Return a pointer to the underlying gsl_matrix (mutable). | |
| const gsl_matrix * | gsl_internal () const |
Return a pointer to the underlying gsl_matrix (read-only). | |
| int | size1 () const |
| Return the number of rows. | |
| int | size2 () const |
| Return the number of columns. | |
| void | set (int i, int j, double val) |
Set element (i, j) to val. | |
| double | get (int i, int j) const |
Return element (i, j). | |
| vector_view | operator[] (int i) |
Return a mutable view of row i. | |
| const vector_view | operator[] (int i) const |
Return a read-only view of row i. | |
| matrix & | operator= (const matrix &src) |
| Copy-assign from another matrix. | |
| matrix & | operator= (const matrix_view &src) |
| Copy-assign from a view. | |
| matrix | operator+ (const matrix &src) const |
| matrix & | operator+= (const matrix &src) |
| matrix | operator- (const matrix &src) const |
| matrix & | operator-= (const matrix &src) |
| matrix | operator- () const |
Unary negation — returns -(*this). | |
| vector | operator* (const vector &src) const |
| Matrix–vector product. | |
| matrix | operator* (const matrix &src) const |
| Matrix–matrix product. | |
| matrix | operator* (double d) const |
Return a copy scaled by d. | |
| matrix & | operator*= (double d) |
Scale all elements by d in place. | |
| matrix | transpose () const |
| Return the transpose. | |
| matrix | inverse () const |
| Return the inverse (via LU decomposition). | |
| vector | linsolve (const vector &b) const |
Solve the linear system A*x = b and return x. | |
| void | svd (matrix &U, matrix &V, vector &s) const |
Compute the full singular value decomposition A = U * diag(s) * V^T. | |
| vector | svd () const |
| Compute and return only the singular values. | |
| matrix_view | submatrix (int k1, int k2, int n1, int n2) |
Return a view of the n1 × n2 sub-matrix starting at (k1, k2). | |
| const matrix_view | submatrix (int k1, int k2, int n1, int n2) const |
Return a view of the n1 × n2 sub-matrix starting at (k1, k2). | |
Private Attributes | |
| gsl_matrix * | m |
Friends | |
| class | matrix_view |
RAII wrapper around a heap-allocated gsl_matrix.
Owns the underlying GSL allocation and frees it on destruction. Row access via operator[] returns a vector_view into the matrix data.
Allocate an n1 × n2 matrix.
| [in] | n1 | Number of rows. |
| [in] | n2 | Number of columns. |
| [in] | id | If true, initialise as identity (requires n1 == n2 when diag is null). |
| [in] | diag | Optional array of n1 diagonal values; if non-null overrides id. |
Allocate an n1 × n2 matrix and copy values from the row-major array x.
Allocate an n1 × n2 matrix from a 2-D C array.
The template parameter n must match n2.
| dvrlib::matrix::matrix | ( | const gsl_matrix * | src | ) |
Construct from an existing (non-owned) gsl_matrix pointer.
| dvrlib::matrix::~matrix | ( | ) |
Destructor — frees the underlying GSL allocation.
| gsl_matrix * dvrlib::matrix::gsl_internal | ( | ) |
Return a pointer to the underlying gsl_matrix (mutable).
| const gsl_matrix * dvrlib::matrix::gsl_internal | ( | ) | const |
Return a pointer to the underlying gsl_matrix (read-only).
| matrix dvrlib::matrix::inverse | ( | ) | const |
Return the inverse (via LU decomposition).
Solve the linear system A*x = b and return x.
| [in] | b | Right-hand side vector (length size1()). |
| matrix dvrlib::matrix::operator- | ( | ) | const |
Unary negation — returns -(*this).
| matrix & dvrlib::matrix::operator= | ( | const matrix_view & | src | ) |
Copy-assign from a view.
| vector_view dvrlib::matrix::operator[] | ( | int | i | ) |
Return a mutable view of row i.
| const vector_view dvrlib::matrix::operator[] | ( | int | i | ) | const |
Return a read-only view of row i.
| int dvrlib::matrix::size1 | ( | ) | const |
Return the number of rows.
| int dvrlib::matrix::size2 | ( | ) | const |
Return the number of columns.
| matrix_view dvrlib::matrix::submatrix | ( | int | k1, |
| int | k2, | ||
| int | n1, | ||
| int | n2 | ||
| ) |
Return a view of the n1 × n2 sub-matrix starting at (k1, k2).
| [in] | k1 | Starting row index (0-based). |
| [in] | k2 | Starting column index (0-based). |
| [in] | n1 | Number of rows in the sub-matrix. |
| [in] | n2 | Number of columns in the sub-matrix. |
Return a view of the n1 × n2 sub-matrix starting at (k1, k2).
| [in] | k1 | Starting row index (0-based). |
| [in] | k2 | Starting column index (0-based). |
| [in] | n1 | Number of rows in the sub-matrix. |
| [in] | n2 | Number of columns in the sub-matrix. |
| vector dvrlib::matrix::svd | ( | ) | const |
Compute and return only the singular values.
| matrix dvrlib::matrix::transpose | ( | ) | const |
Return the transpose.
|
friend |
|
private |