NABLA  Nabla Ain't Basic Linear Algebra
reshaped Class Reference

Reshaped matrix expression template class. More...

Detailed Description

Reshaped matrix expression template class.

template<typename expression_type, typename target_shape, typename side>
class nabla::reshaped< expression_type, target_shape, side >

Template Parameters
expression_typeType of matrix expression to be reshaped.
target_shapeTarget shape of the expression.
sideDetermines 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

typedef reshaped<
matrix_expression<double, matrix<double>, tag::storage>,
> reshaped_matrix_type;
reshaped_matrix_type(m);

Since it is itself a matrix expression it can take part in different expressions like:

matrix<double> m;
matrix<double, upper_tr> u, u1;
//... //'m' must be of size n*n
u1 = u*reshaped_matrix_type(m);

Instead of this, one may use a more convenient way – reshape() function:

//... //'m' must be of size n*n
u1 = u*reshape<upper_tr>(m);

There are only two specializations defined:

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.

See Also
reshape(), matrix_expression

The documentation for this class was generated from the following file: