|
ampsci
High-precision calculations for one- and two-valence atomic systems
|
Matrix class; row-major. More...
#include <Matrix.hpp>
Inheritance diagram for LinAlg::Matrix< T >:Public Member Functions | |
| Matrix () | |
| Default initialiser. | |
| Matrix (std::size_t rows, std::size_t cols) | |
| Initialise a blank matrix rows*cols, filled with 0. | |
| Matrix (std::size_t rows, std::size_t cols, const T &value) | |
| Initialise a matrix rows*cols, filled with 'value'. | |
| Matrix (std::size_t dimension) | |
| Initialise a blank square matrix dimension*dimension, filled with 0. | |
| Matrix (std::initializer_list< std::initializer_list< T > > ll) | |
| Initialise a matrix from initialiser list. {{},{},{}}. Each row must be same length. | |
| Matrix (std::size_t rows, std::size_t cols, std::initializer_list< T > l) | |
| Initialise a matrix from single initialiser list. {...}. | |
| Matrix (std::size_t rows, std::size_t cols, std::vector< T > &&v) | |
| Initialise a matrix from single initialiser list. {...}. | |
| Matrix (std::size_t rows, std::size_t cols, const std::vector< T > &v) | |
| Initialise a matrix from single initialiser list. {...}. | |
| void | resize (std::size_t rows, std::size_t cols) |
| Resizes matrix to new dimension; all values reset to default. | |
| void | resize (std::size_t rows, std::size_t cols, const T &value) |
| Resizes matrix to new dimension; all values reset to 'value'. | |
| std::size_t | rows () const |
| Return rows [major index size]. | |
| std::size_t | cols () const |
| Return columns [minor index size]. | |
| std::size_t | size () const |
| Return rows*columns [total array size]. | |
| T * | data () |
| Returns pointer to first element. Note: for std::complex<T>, this is a pointer to complex<T>, not T. | |
| const T * | data () const |
| As above, but const. | |
| const T * | operator[] (std::size_t i) const |
| [] index access (with no range checking). [i][j] returns ith row, jth col | |
| T * | operator[] (std::size_t i) |
| As above, but const. | |
| T & | at (std::size_t row_i, std::size_t col_j) |
| () index access (with range checking). (i,j) returns ith row, jth col | |
| T | at (std::size_t row_i, std::size_t col_j) const |
| const () index access (with range checking). (i,j) ith row, jth col | |
| const T & | atc (std::size_t row_i, std::size_t col_j) const |
| const ref () index access (with range checking). (i,j) ith row, jth col | |
| T & | operator() (std::size_t i, std::size_t j) |
| () index access (with range checking). (i,j) returns ith row, jth col | |
| T | operator() (std::size_t i, std::size_t j) const |
| As above, but const. | |
| auto | begin () |
| iterators for underlying std::vector (entire data) | |
| auto | cbegin () const |
| auto | end () |
| auto | cend () const |
| const T * | row (std::size_t row) const |
| Returns raw c pointer to start of a row. | |
| View< T > | row_view (std::size_t row) |
| Returns a mutable 'View' of a row. | |
| View< const T > | row_view (std::size_t row) const |
| Returns an immutable 'View' of a row. | |
| View< T > | column_view (std::size_t col) |
| Returns a mutable 'View' of a column. | |
| View< const T > | column_view (std::size_t col) const |
| Returns an immutable 'View' of a column. | |
| auto | as_gsl_view () |
| Returns gsl_matrix_view (or _float_view, _complex_view, _complex_float_view). Call .matrix to use as a GSL matrix (no copy is involved). Allows one to use all GSL built-in functions. Note: non-owning pointer - matrix AND gsl_view must remain in scope. | |
| auto | as_gsl_view () const |
| As above, but const. | |
| T | determinant () const |
Returns the determinant. Uses GSL; via LU decomposition. Only works for double/complex<double> | |
| Matrix< T > & | invert_in_place () |
Inverts the matrix, in place. Uses GSL; via LU decomposition. Only works for double/complex<double>. | |
| Matrix< T > | inverse () const |
Returns inverse of the matrix. Leaves original matrix intact. Uses GSL; via LU decomposition. Only works for double/complex<double> | |
| Matrix< T > | transpose () const |
| Returns transpose of matrix. | |
| Matrix< T > & | make_identity () |
| Constructs a diagonal unit matrix (identity), in place; only for square. | |
| Matrix< T > & | zero () |
| Sets all elements to zero, in place. | |
| Matrix< T > | conj () const |
| Returns conjugate of matrix. | |
| auto | real () const |
| Returns real part of complex matrix (changes type; returns a real matrix) | |
| auto | imag () const |
| Returns imag part of complex matrix (changes type; returns a real matrix) | |
| auto | complex () const |
| Converts a real to complex matrix (changes type; returns a complex matrix) | |
| Matrix< T > & | conj_in_place () |
| Conjugates matrix, in place. | |
| Matrix< T > & | mult_elements_by (const Matrix< T > &a) |
| Muplitplies all the elements by those of matrix a, in place: M_ij *= a_ij. | |
| Matrix< T > & | operator+= (const Matrix< T > &rhs) |
| Overload standard operators: do what expected. | |
| Matrix< T > & | operator-= (const Matrix< T > &rhs) |
| Matrix< T > & | operator*= (const T x) |
| Matrix< T > & | operator/= (const T x) |
| Matrix< T > & | operator+= (T aI) |
| Matrix<T> += T : T assumed to be *Identity! | |
| Matrix< T > & | operator-= (T aI) |
| Matrix<T> -= T : T assumed to be *Identity! | |
Protected Attributes | |
| std::size_t | m_rows |
| std::size_t | m_cols |
| std::vector< T > | m_data {} |
Friends | |
| Matrix< T > | mult_elements (Matrix< T > a, const Matrix< T > &b) |
| Returns new matrix, C_ij = A_ij*B_ij. | |
| Matrix< T > | operator+ (Matrix< T > lhs, const Matrix< T > &rhs) |
| Matrix< T > | operator- (Matrix< T > lhs, const Matrix< T > &rhs) |
| Matrix< T > | operator* (const T x, Matrix< T > rhs) |
| Matrix< T > | operator* (Matrix< T > lhs, const T x) |
| Matrix< T > | operator/ (Matrix< T > lhs, const T x) |
| Matrix< T > | operator+ (Matrix< T > M, T aI) |
| Matrix< T > | operator- (Matrix< T > M, T aI) |
| template<typename U > | |
| Matrix< U > | operator* (const Matrix< U > &a, const Matrix< U > &b) |
| Matrix multiplication: C_ij = sum_k A_ik*B_kj. | |
| template<typename U > | |
| std::ostream & | operator<< (std::ostream &os, const Matrix< U > &a) |
Matrix class; row-major.
|
inline |
Default initialiser.
|
inline |
Initialise a blank matrix rows*cols, filled with 0.
|
inline |
Initialise a matrix rows*cols, filled with 'value'.
|
inlineexplicit |
Initialise a blank square matrix dimension*dimension, filled with 0.
|
inline |
Initialise a matrix from initialiser list. {{},{},{}}. Each row must be same length.
|
inline |
Initialise a matrix from single initialiser list. {...}.
|
inline |
Initialise a matrix from single initialiser list. {...}.
|
inline |
Initialise a matrix from single initialiser list. {...}.
|
inline |
Resizes matrix to new dimension; all values reset to default.
|
inline |
Resizes matrix to new dimension; all values reset to 'value'.
|
inline |
Return rows [major index size].
|
inline |
Return columns [minor index size].
|
inline |
Return rows*columns [total array size].
|
inline |
Returns pointer to first element. Note: for std::complex<T>, this is a pointer to complex<T>, not T.
|
inline |
As above, but const.
|
inline |
[] index access (with no range checking). [i][j] returns ith row, jth col
|
inline |
As above, but const.
|
inline |
() index access (with range checking). (i,j) returns ith row, jth col
|
inline |
const () index access (with range checking). (i,j) ith row, jth col
|
inline |
const ref () index access (with range checking). (i,j) ith row, jth col
|
inline |
() index access (with range checking). (i,j) returns ith row, jth col
|
inline |
As above, but const.
|
inline |
iterators for underlying std::vector (entire data)
|
inline |
Returns raw c pointer to start of a row.
|
inline |
Returns a mutable 'View' of a row.
|
inline |
Returns an immutable 'View' of a row.
|
inline |
Returns a mutable 'View' of a column.
|
inline |
Returns an immutable 'View' of a column.
| auto LinAlg::Matrix< T >::as_gsl_view | ( | ) |
Returns gsl_matrix_view (or _float_view, _complex_view, _complex_float_view). Call .matrix to use as a GSL matrix (no copy is involved). Allows one to use all GSL built-in functions. Note: non-owning pointer - matrix AND gsl_view must remain in scope.
| auto LinAlg::Matrix< T >::as_gsl_view | ( | ) | const |
As above, but const.
| T LinAlg::Matrix< T >::determinant | ( | ) | const |
Returns the determinant. Uses GSL; via LU decomposition. Only works for double/complex<double>
| Matrix< T > & LinAlg::Matrix< T >::invert_in_place | ( | ) |
Inverts the matrix, in place. Uses GSL; via LU decomposition. Only works for double/complex<double>.
| Matrix< T > LinAlg::Matrix< T >::inverse | ( | ) | const |
Returns inverse of the matrix. Leaves original matrix intact. Uses GSL; via LU decomposition. Only works for double/complex<double>
| Matrix< T > LinAlg::Matrix< T >::transpose | ( | ) | const |
Returns transpose of matrix.
| Matrix< T > & LinAlg::Matrix< T >::make_identity | ( | ) |
Constructs a diagonal unit matrix (identity), in place; only for square.
| Matrix< T > & LinAlg::Matrix< T >::zero | ( | ) |
Sets all elements to zero, in place.
| Matrix< T > LinAlg::Matrix< T >::conj | ( | ) | const |
Returns conjugate of matrix.
| auto LinAlg::Matrix< T >::real | ( | ) | const |
Returns real part of complex matrix (changes type; returns a real matrix)
| auto LinAlg::Matrix< T >::imag | ( | ) | const |
Returns imag part of complex matrix (changes type; returns a real matrix)
| auto LinAlg::Matrix< T >::complex | ( | ) | const |
Converts a real to complex matrix (changes type; returns a complex matrix)
| Matrix< T > & LinAlg::Matrix< T >::conj_in_place | ( | ) |
Conjugates matrix, in place.
| Matrix< T > & LinAlg::Matrix< T >::mult_elements_by | ( | const Matrix< T > & | a | ) |
Muplitplies all the elements by those of matrix a, in place: M_ij *= a_ij.
| Matrix< T > & LinAlg::Matrix< T >::operator+= | ( | const Matrix< T > & | rhs | ) |
Overload standard operators: do what expected.
| Matrix< T > & LinAlg::Matrix< T >::operator+= | ( | T | aI | ) |
Matrix<T> += T : T assumed to be *Identity!
| Matrix< T > & LinAlg::Matrix< T >::operator-= | ( | T | aI | ) |
Matrix<T> -= T : T assumed to be *Identity!
|
friend |
Returns new matrix, C_ij = A_ij*B_ij.
|
friend |
Matrix multiplication: C_ij = sum_k A_ik*B_kj.