NABLA
Nabla Ain't Basic Linear Algebra
|
Square matrix template class. More...
Public Types | |
typedef util::sequence < value_type > ::const_reference | const_reference |
Type of reference to constant element. | |
typedef util::sequence < value_type >::reference | reference |
Type of reference to element. | |
typedef value_t | value_type |
Type of elements. |
Public Member Functions | |
matrix () | |
Default constructor. | |
matrix (const matrix &a) | |
Copy constructor. | |
matrix (temporary< matrix > &a) | |
Move constructor from temporary object. | |
template<typename expr_t , typename tag > | |
matrix (const shaped_expression< value_type, expr_t, tag, shape > &a) | |
Copy constructor from matrix expression. | |
matrix (size_t size) | |
Constructor with size initialization. | |
matrix (size_t size, const_reference value) | |
Constructor with size and value initialization. | |
~matrix () | |
Destructor. | |
template<typename expr_t , typename tag > | |
void | assign (const shaped_expression< value_type, expr_t, tag, shape > &rhs) |
Assigns symmetric matrix expression to this object. | |
size_t | cols () const |
Returns number of columns. | |
reference | operator() (size_t row, size_t column) |
Subscript operator. | |
const_reference | operator() (size_t row, size_t column) const |
Subscript operator. | |
row_ref | operator() (size_t row) |
Subscript operator. | |
const_row_ref | operator() (size_t row) const |
Subscript operator. | |
matrix & | operator= (const matrix &a) |
Assignment operator. | |
template<typename expr_t , typename tag > | |
matrix & | operator= (const shaped_expression< value_type, expr_t, tag, shape > &a) |
Assignment operator. | |
matrix & | operator= (temporary< matrix > &a) |
Move assignment operator. | |
row_ref | operator[] (size_t row) |
Subscript operator. | |
const_row_ref | operator[] (size_t row) const |
Subscript operator. | |
void | resize (size_t size) |
Resizes matrix. | |
void | resize (size_t size, const_reference value) |
Resizes matrix. | |
size_t | rows () const |
Returns number of rows. | |
void | swap (matrix &a) |
Swaps contents of two matrices. |
Square matrix template class.
See matrix<value_t, rectangular>
specialization for information about general matrix template class.
All square matrices share a restriction: matrices can not be resized to rectangular shape, i.e. can not have size other than n by n elements. This is ensured by the design and one will have to make an effort to brake this constraint. To stick to this policy all user-defined types related to square matrices in any way should also ensure this design constraint.
Depending on the specified shape there are different space optimizations, implementation details and guarantees. The remaining sections discuss that in detail. For more information about shapes consult Matrix Shape.
Such a matrix is invoked like
matrix<value_t, symmetric>
are stored in memory continuously row by row. Only lower triangular part elements are stored. This implies&m(i, j)==&m(0, 0) + (i1*(i1 + 1)/2 + j1))
i1 = max(i, j); j1 = min(i, j); i<m.rows() && j<m.cols()
. Such a matrix is invoked like
or, using a typedef for lower_triangular
,
matrix<value_t, lower_triangular>
are stored in memory continuously row by row. Only lower triangular part elements are stored. This implies&m(i, j)==&m(0, 0) + ((i*(i + 1))/2 + j)
i<m.rows() && j<m.cols() && j<=i
. Such a matrix is invoked like
or, using a typedef for upper_triangular
,
matrix<value_t, upper_triangular>
are stored in memory continuously row by row. Only upper triangular part elements are stored. This implies&m(i, j)==&m(0, 0) + ((i*(2*m.rows() - i - 1))/2 + j)
i<m.rows() && j<m.cols() && j>=i
.
|
inline |
Assigns symmetric matrix expression to this object.
This function assigns rhs in the most efficient way. It means that no temporary is introduced to store intermediate result. This circumstance can cause suprising results as stated above.Like in the STL this function doesn't care about object's previous state. The function discards all the contents (which may immediately invalidate all references to this object) and copies the result of rhs expression to this object's new contents.In other words this object should not be involved in the argument expression rhs. Otherwise this function may produce unexpected result or even crash the program.
|
inline |
Subscript operator.
Returns a reference to an element (row, column).
Since for lower and upper triangular matrices some elements are zero by definition (and hence not stored) an attempt to modify such elements will fail.
access_error
is thrown under the following circumstances:
|
inline |
|
inline |
|
inline |