NABLA
Nabla Ain't Basic Linear Algebra
|
Reshaped matrix expression template class. More...
Reshaped matrix expression template class.
template<typename expression_type, typename target_shape, typename side>
class nabla::reshaped< expression_type, target_shape, side >
expression_type | Type of matrix expression to be reshaped. |
target_shape | Target shape of the expression. |
side | Determines the side of original matrix to be referred to. Default is upper_triangular side. This parameter may be ignored if appropriate (e.g. when specializing for a user shape). |
With help of this class one can change properties of matrices at design time. This means that a matrix can be treated (or re-treated) as a matrix of different shape, in other words any matrix can be treated either as symmetric, or as upper or lower triangular matrix.
For example a super diagonal elements of a rectangular matrix m can act as an upper triangular shaped matrix, the code looks something like
Since it is itself a matrix expression it can take part in different expressions like:
Instead of this, one may use a more convenient way – reshape()
function:
There are only two specializations defined:
reshaped<matrix_expression<value_t, expr_t, tag, shape>, target_shape, upper_triangular>
reshaped<matrix_expression<value_t, expr_t, tag, shape>, target_shape, lower_triangular>
It is so because only these cases make sense in context of this library. Thus intantiation of this class with unsupported template arguments will not compile. However one can define a specialization for specific parameters if necessary.
reshaped
does handle all library defined shapes. In order to handle a user shape one need to specialize this template class. Specialized template class must meet matrix expression requirements (see Expression concept description). Additionally one need to define a constructor taking const expr_t&
(which is the "original
matrix" mentioned above) in order to be able to use reshape()
function.