NABLA
Nabla Ain't Basic Linear Algebra
|
Shaped matrix expression template class. More...
Friends | |
util::non_zero_in_column < shape >::first_type | first_non_zero_in_column (const expr_t &m, size_t column) |
Returns index of the first non zero element in column column. | |
util::non_zero_in_row< shape > ::first_type | first_non_zero_in_row (const expr_t &m, size_t row) |
Returns index of the first non zero element in row row. | |
util::non_zero_in_column < shape >::last_type | last_non_zero_in_column (const expr_t &m, size_t column) |
Returns index of the last non zero element in column column. | |
util::non_zero_in_row< shape > ::last_type | last_non_zero_in_row (const expr_t &m, size_t row) |
Returns index of the last non zero element in row row. |
Related Functions | |
(Note that these are not member functions.) | |
Miscellaneous | |
template<typename value_t , typename expr_t , typename shape > | |
void | swap (shaped_expression< value_t, expr_t, tag::storage, shape > &a, shaped_expression< value_t, expr_t, tag::storage, shape > &b) |
Swaps contents of two matrices. | |
Matrix operations | |
template<typename value_t , typename expr_t , typename tag , typename shape > | |
const unary< shaped_expression < value_t, expr_t, tag, shape > , op::plus > | operator+ (const shaped_expression< value_t, expr_t, tag, shape > &a) |
Unary plus operator. | |
template<typename value_t , typename expr_t , typename tag , typename shape > | |
const unary< shaped_expression < value_t, expr_t, tag, shape > , op::minus > | operator- (const shaped_expression< value_t, expr_t, tag, shape > &a) |
Unary minus operator. | |
template<typename value_t , typename expr_t , typename tag , typename shape > | |
const unary< shaped_expression < value_t, expr_t, tag, shape > , op::conj > | conj (const shaped_expression< value_t, expr_t, tag, shape > &a) |
Returns conjugated matrix. | |
template<typename value_t , typename expr_t , typename tag , typename shape > | |
const transposed < shaped_expression< value_t, expr_t, tag, shape > > | transpose (const shaped_expression< value_t, expr_t, tag, shape > &a) |
Returns transposed matrix. | |
template<typename value_t , typename expr_t , typename tag > | |
const expr_t & | transpose (const shaped_expression< value_t, expr_t, tag, symmetric > &a) |
Returns transposed matrix. | |
template<typename value_t , typename expr_t , typename tag > | |
const reshaped < shaped_expression< value_t, expr_t, tag, lower_triangular > , upper_triangular, lower_triangular > | transpose (const shaped_expression< value_t, expr_t, tag, lower_triangular > &a) |
Returns transposed matrix. | |
template<typename value_t , typename expr_t , typename tag > | |
const reshaped < shaped_expression< value_t, expr_t, tag, upper_triangular > , lower_triangular, upper_triangular > | transpose (const shaped_expression< value_t, expr_t, tag, upper_triangular > &a) |
Returns transposed matrix. | |
template<typename value_t , typename expr_t , typename tag , typename shape > | |
const scaled < shaped_expression< value_t, expr_t, tag, shape > > | operator* (const shaped_expression< value_t, expr_t, tag, shape > &a, const typename expr_t::value_type &s) |
Binary multiplication operator. | |
template<typename value_t , typename expr_t , typename tag , typename shape > | |
const scaled < shaped_expression< value_t, expr_t, tag, shape > > | operator* (const typename expr_t::value_type &s, const shaped_expression< value_t, expr_t, tag, shape > &a) |
Binary multiplication operator. | |
template<typename value_t , typename expr1 , typename tag1 , typename shape1 , typename expr2 , typename tag2 , typename shape2 > | |
const binary < shaped_expression< value_t, expr1, tag1, shape1 > , shaped_expression< value_t, expr2, tag2, shape1 >, op::add > | operator+ (const shaped_expression< value_t, expr1, tag1, shape1 > &left, const shaped_expression< value_t, expr2, tag2, shape2 > &right) |
Binary addition operator. | |
template<typename value_t , typename expr1 , typename tag1 , typename shape1 , typename expr2 , typename tag2 , typename shape2 > | |
const binary < shaped_expression< value_t, expr1, tag1, shape1 > , shaped_expression< value_t, expr2, tag2, shape2 >, op::sub > | operator- (const shaped_expression< value_t, expr1, tag1, shape1 > &left, const shaped_expression< value_t, expr2, tag2, shape2 > &right) |
Binary subtraction operator. | |
template<typename value_t , typename expr1 , typename tag1 , typename shape1 , typename expr2 , typename tag2 , typename shape2 > | |
const binary < shaped_expression< value_t, expr1, tag1, shape1 > , shaped_expression< value_t, expr2, tag2, shape2 >, op::mul > | mul (const shaped_expression< value_t, expr1, tag1, shape1 > &left, const shaped_expression< value_t, expr2, tag2, shape2 > &right) |
Binary element-wise multiplication operation. | |
template<typename value_t , typename expr1 , typename tag1 , typename shape1 , typename expr2 , typename tag2 , typename shape2 > | |
const binary < shaped_expression< value_t, expr1, tag1, shape1 > , shaped_expression< value_t, expr2, tag2, shape2 >, op::div > | div (const shaped_expression< value_t, expr1, tag1, shape1 > &left, const shaped_expression< value_t, expr2, tag2, shape2 > &right) |
Binary element-wise multiplication operation. | |
template<typename value_t , typename expr1 , typename tag1 , typename shape1 , typename expr2 , typename tag2 , typename shape2 > | |
product< shaped_expression < value_t, expr1, tag1, shape1 > , shaped_expression< value_t, expr2, tag2, shape2 > > | operator* (const shaped_expression< value_t, expr1, tag1, shape1 > &left, const shaped_expression< value_t, expr2, tag2, shape2 > &right) |
Binary matrix multiplication operator. | |
template<typename value_t , typename expr1 , typename shape , typename expr2 , typename tag2 > | |
expr1 & | operator+= (shaped_expression< value_t, expr1, tag::storage, shape > &left, const shaped_expression< value_t, expr2, tag2, shape > &right) |
Matrix addition assignment operator. | |
template<typename value_t , typename expr1 , typename shape , typename expr2 , typename tag2 > | |
expr1 & | operator-= (shaped_expression< value_t, expr1, tag::storage, shape > &left, const shaped_expression< value_t, expr2, tag2, shape > &right) |
Matrix subtraction assignment operator. | |
template<typename value_t , typename expr_t , typename shape > | |
expr_t & | operator*= (shaped_expression< value_t, expr_t, tag::storage, shape > &left, const value_t &right) |
Matrix multiplication assignment operator. | |
template<typename value_t , typename expr1 , typename expr2 , typename tag2 > | |
expr1 & | operator*= (shaped_expression< value_t, expr1, tag::storage, lower_triangular > &left, const shaped_expression< value_t, expr2, tag2, lower_triangular > &right) |
Matrix multiplication assignment operator. | |
template<typename value_t , typename expr1 , typename expr2 , typename tag2 > | |
expr1 & | operator*= (shaped_expression< value_t, expr1, tag::storage, upper_triangular > &left, const shaped_expression< value_t, expr2, tag2, upper_triangular > &right) |
Matrix multiplication assignment operator. |
Shaped matrix expression template class.
This class helps to restrict use of matrix expressions which have a shape other than rectangular
. See also Matrix Shape.
For details about matrix expressions in general see documentation for matrix_expression
.
This is an extension of matrix_expression
concept to allow handling of matrices of different shapes, e.g. symmetric (see Extending Matrix Expressions). It is obvious that when two, say, upper triangular matrices are added or subtracted the resulting matrix is also upper triangular. This also applies to any shape. It's not obvious but can be proved that a product of two upper triangular matrices... guess what? ...is also upper triangular. The same story with lower triangular matrices.
This class and it's supporting routines implement such design.
At the same time an arbitrarily shaped matrix can always be presented as a rectangular matrix, whatever the shape is. So any shaped matrix expression can be handled as ordinary matrix_expression
if needed. Furthermore if a function explicitly wants a rectangular storage type (see Using Matrix Expressions)
shaped storage types (like matrix<double, symmetric>
) will not be handled because the function is only aware of general rectangular shape and not of symmetric
. This happens because every shaped expression simultaneously acts as an expression tagged with tag::expression<complexity>
(read read only expression) which is incompatible with mutable expressions (and thus with foo()
signature). This appears to be the only safe way to interact with it as a general rectangular matrix.
To define a shaped matrix expression one needs to inherit shaped_expression
like this:
This is very similar to the case of matrix_expression
(see Defining Matrix Expressions).
Additionally if you want your operation to handle such expressions you have to overload it:
(compare to the definition in section Using Matrix Expressions). Now shaped expressions with the same shape (notice corresponding template argument) are handled by bar()
defined above while any other combination of shapes is handled by
bar(const matrix_expression<value_t, expr1, tag1>&, const matrix_expression<value_t, expr2, tag2>&)
.
|
related |
|
related |
Binary element-wise multiplication operation.
This is an overload for shaped matrix expressions.
Sizes of argument matrices must be equal. Otherwise an exception (size_error
) is thrown.
|
related |
Binary element-wise multiplication operation.
This is an overload for shaped matrix expressions.
Sizes of argument matrices must be equal. Otherwise an exception (size_error
) is thrown.
|
related |
|
related |
|
related |
Binary matrix multiplication operator.
This is an overload for shaped matrix expressions.
Sizes of argument matrices must be equal. Otherwise an exception (size_error
) is thrown.
Note that a product of two upper or lower triangular matrices has respective shape. Any other combination of shapes produces rectangular matrix, including a product of two symmetric matrices.
|
related |
|
related |
|
related |
|
related |
|
related |
Binary addition operator.
This is an overload for shaped matrix expressions.
Sizes of argument matrices must be equal. Otherwise an exception (size_error
) is thrown.
|
related |
|
related |
|
related |
Binary subtraction operator.
This is an overload for shaped matrix expressions.
Sizes of argument matrices must be equal. Otherwise an exception (size_error
) is thrown.
|
related |
|
related |
Swaps contents of two matrices.
This template function handles all shaped matrix expressions with storage
tag. Such expressions are meant to be storage types and by definition provide efficient swap operation.
The actual effect of this function is
This function is not meant to throw any exceptions.
|
related |
|
related |
Returns transposed matrix.
This is an overload for symmetric matrix expressions.
Since a transposed symmetric matrix is itself (A==AT) this function returns a reference to the argument. The equivalent effect is
|
related |
Returns transposed matrix.
This is an overload for lower triangular matrix expressions.
Since a transposed lower triangular matrix is an upper triangular one this function returnes reshaped
expression. The equivalent effect is
|
related |