Matrix container that allows simple data access, slicing, copying and resizing without loosing data. More...
#include <Matrix.h>
Matrix container that allows simple data access, slicing, copying and resizing without loosing data.
This is not meant to be a general matrix, or to be very efficient. This is just a utility for internal implementation of IterativeSolver and it only supports operations that are necessary. Memory management is not done very efficiently, because for our use subspace matrices are relatively small.
T |
Classes | |
class | CSlice |
Constant slice that cannot be assigned to. More... | |
class | Slice |
Proxy mapping to a rectangular slice of the matrix data. Implements simple assignment. More... | |
Public Types | |
using | value_type = T |
using | index_type = size_t |
using | coord_type = std::pair< size_t, size_t > |
Public Member Functions | |
Matrix (coord_type dims) | |
Matrix (std::vector< T > &&data, coord_type dims) | |
Construct a matrix by taking ownership of an existing data buffer which must be of correct size. More... | |
Matrix (const std::vector< T > &data, coord_type dims) | |
Matrix ()=default | |
~Matrix ()=default | |
Matrix (const Matrix< T > &)=default | |
Matrix (Matrix< T > &&) noexcept=default | |
Matrix< T > & | operator= (const Matrix< T > &)=default |
Matrix< T > & | operator= (Matrix< T > &&) noexcept=default |
T & | operator() (index_type i, index_type j) |
Access element. More... | |
T | operator() (index_type i, index_type j) const |
Access element. More... | |
const std::vector< T > & | data () const & |
Access the underlying data buffer. More... | |
std::vector< T > && | data () && |
Access the raw data buffer of an r-value matrix. The matrix is left empty. More... | |
bool | empty () const |
Returns true if matrix is empty. More... | |
void | clear () |
Clears all elements and sets dimensions to 0. More... | |
coord_type | to_coord (size_t ind) const |
Converts index of 1D data to matrix coordinate. More... | |
void | fill (T value) |
Sets all elements of matrix to value. More... | |
Slice | slice (coord_type upper_left, coord_type bottom_right) |
Access a rectangular slice of the matrix. More... | |
Slice | slice () |
Access the whole matrix as a slice. More... | |
CSlice | slice (coord_type upper_left, coord_type bottom_right) const |
Access a constant rectangular slice of the matrix. More... | |
CSlice | slice () const |
Access the whole matrix as a slice. More... | |
Slice | row (size_t i) |
Access row slice. More... | |
CSlice | row (size_t i) const |
Slice | col (size_t j) |
Access column slice. More... | |
CSlice | col (size_t j) const |
void | resize (const coord_type &dims) |
Resize the matrix. The old data is preserved and any new rows/cols are zeroed. More... | |
void | remove_row (index_type row) |
removes a row from the matrix More... | |
void | remove_col (index_type col) |
removes a column from the matrix More... | |
void | remove_row_col (index_type row, index_type col) |
removes row and column More... | |
index_type | rows () const |
index_type | cols () const |
coord_type | dimensions () const |
size_t | size () const |
Protected Attributes | |
index_type | m_rows = 0 |
number of rows More... | |
index_type | m_cols = 0 |
number of columns More... | |
std::vector< T > | m_buffer |
data buffer More... | |
using molpro::linalg::itsolv::subspace::Matrix< T >::coord_type = std::pair<size_t, size_t> |
using molpro::linalg::itsolv::subspace::Matrix< T >::index_type = size_t |
using molpro::linalg::itsolv::subspace::Matrix< T >::value_type = T |
|
inlineexplicit |
|
inlineexplicit |
Construct a matrix by taking ownership of an existing data buffer which must be of correct size.
|
inlineexplicit |
|
default |
|
default |
|
default |
|
defaultnoexcept |
|
inline |
Clears all elements and sets dimensions to 0.
|
inline |
Access column slice.
|
inline |
|
inline |
|
inline |
Access the raw data buffer of an r-value matrix. The matrix is left empty.
|
inline |
Access the underlying data buffer.
|
inline |
|
inline |
Returns true if matrix is empty.
|
inline |
Sets all elements of matrix to value.
|
inline |
Access element.
i | row index |
j | column index |
|
inline |
Access element.
i | row index |
j | column index |
|
default |
|
defaultnoexcept |
|
inline |
removes a column from the matrix
col | index of the column to remove |
|
inline |
removes a row from the matrix
row | index of the row to remove |
|
inline |
removes row and column
row | row incdex |
col | column index |
|
inline |
Resize the matrix. The old data is preserved and any new rows/cols are zeroed.
dims | new dimensions |
|
inline |
Access row slice.
|
inline |
|
inline |
|
inline |
|
inline |
Access the whole matrix as a slice.
|
inline |
Access the whole matrix as a slice.
|
inline |
Access a rectangular slice of the matrix.
upper_left | indices of upper left corner |
bottom_right | past the end indices of bottom right corner, so that dimensions of slice were (bottom_right-upper_left) |
|
inline |
Access a constant rectangular slice of the matrix.
upper_left | indices of upper left corner |
bottom_right | past the end indices of bottom right corner, so that dimensions of slice were (bottom_right-upper_left) |
|
inline |
Converts index of 1D data to matrix coordinate.
|
protected |
data buffer
|
protected |
number of columns
|
protected |
number of rows