![]() |
Blaze
3.6
|
Classes | |
class | blaze::SubmatrixData< CSAs > |
Auxiliary class template for the data members of the Submatrix class.The auxiliary SubmatrixData class template represents an abstraction of the data members of the Submatrix class template. The necessary set of data members is selected depending on the number of compile time submatrix arguments. More... | |
Functions | |
template<size_t I, size_t J, size_t M, size_t N, typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (Matrix< MT, SO > &matrix, RSAs... args) |
Creating a view on a specific submatrix of the given matrix. More... | |
template<size_t I, size_t J, size_t M, size_t N, typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (const Matrix< MT, SO > &matrix, RSAs... args) |
Creating a view on a specific submatrix of the given constant matrix. More... | |
template<size_t I, size_t J, size_t M, size_t N, typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (Matrix< MT, SO > &&matrix, RSAs... args) |
Creating a view on a specific submatrix of the given temporary matrix. More... | |
template<AlignmentFlag AF, size_t I, size_t J, size_t M, size_t N, typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (Matrix< MT, SO > &matrix, RSAs... args) |
Creating a view on a specific submatrix of the given matrix. More... | |
template<AlignmentFlag AF, size_t I, size_t J, size_t M, size_t N, typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (const Matrix< MT, SO > &matrix, RSAs... args) |
Creating a view on a specific submatrix of the given constant matrix. More... | |
template<AlignmentFlag AF, size_t I, size_t J, size_t M, size_t N, typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (Matrix< MT, SO > &&matrix, RSAs... args) |
Creating a view on a specific submatrix of the given temporary matrix. More... | |
template<typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args) |
Creating a view on a specific submatrix of the given matrix. More... | |
template<typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (const Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args) |
Creating a view on a specific submatrix of the given constant matrix. More... | |
template<typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (Matrix< MT, SO > &&matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args) |
Creating a view on a specific submatrix of the given temporary matrix. More... | |
template<AlignmentFlag AF, typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args) |
Creating a view on a specific submatrix of the given matrix. More... | |
template<AlignmentFlag AF, typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (const Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args) |
Creating a view on a specific submatrix of the given constant matrix. More... | |
template<AlignmentFlag AF, typename MT , bool SO, typename... RSAs> | |
decltype(auto) | blaze::submatrix (Matrix< MT, SO > &&matrix, size_t row, size_t column, size_t m, size_t n, RSAs... args) |
Creating a view on a specific submatrix of the given temporary matrix. More... | |
Submatrices provide views on a specific part of a dense or sparse matrix just as subvectors provide views on specific parts of vectors. As such, submatrices act as a reference to a specific block within a matrix. This reference is valid and can be used in evary way any other dense or sparse matrix can be used as long as the matrix containing the submatrix is not resized or entirely destroyed. The submatrix also acts as an alias to the matrix elements in the specified block: Changes made to the elements (e.g. modifying values, inserting or erasing elements) are immediately visible in the matrix and changes made via the matrix are immediately visible in the submatrix.
A view on a dense or sparse submatrix can be created very conveniently via the submatrix()
function. It can be included via the header file
The first and second parameter specify the row and column of the first element of the submatrix. The third and fourth parameter specify the number of rows and columns, respectively. The four parameters can be specified either at compile time or at runtime:
The submatrix()
function returns an expression representing the submatrix view. The type of this expression depends on the given submatrix arguments, primarily the type of the matrix and the compile time arguments. If the type is required, it can be determined via decltype
specifier:
The resulting view can be treated as any other dense or sparse matrix, i.e. it can be assigned to, it can be copied from, and it can be used in arithmetic operations. A submatrix created from a row-major matrix will itself be a row-major matrix, a submatrix created from a column-major matrix will be a column-major matrix. The view can also be used on both sides of an assignment: The submatrix can either be used as an alias to grant write access to a specific submatrix of a matrix primitive on the left-hand side of an assignment or to grant read-access to a specific submatrix of a matrix primitive or expression on the right-hand side of an assignment. The following example demonstrates this in detail:
The elements of a submatrix can be directly accessed with the function call operator:
Alternatively, the elements of a submatrix can be traversed via (const) iterators. Just as with matrices, in case of non-const submatrices, begin()
and end()
return an iterator, which allows to manipuate the elements, in case of constant submatrices an iterator to immutable elements is returned:
Inserting/accessing elements in a sparse submatrix can be done by several alternative functions. The following example demonstrates all options:
A submatrix view can be used like any other dense or sparse matrix. For instance, the current size of the matrix, i.e. the number of rows or columns can be obtained via the rows()
and columns()
functions, the current total capacity via the capacity()
function, and the number of non-zero elements via the nonZeros()
function. However, since submatrices are views on a specific submatrix of a matrix, several operations are not possible, such as resizing and swapping:
Both dense and sparse submatrices can be used in all arithmetic operations that any other dense or sparse matrix can be used in. The following example gives an impression of the use of dense submatrices within arithmetic operations. All operations (addition, subtraction, multiplication, scaling, ...) can be performed on all possible combinations of dense and sparse matrices with fitting element types:
Usually submatrices can be defined anywhere within a matrix. They may start at any position and may have an arbitrary extension (only restricted by the extension of the underlying matrix). However, in contrast to matrices themselves, which are always properly aligned in memory and therefore can provide maximum performance, this means that submatrices in general have to be considered to be unaligned. This can be made explicit by the blaze::unaligned flag:
All of these calls to the submatrix()
function are identical. Whether the alignment flag is explicitly specified or not, it always returns an unaligned submatrix. Whereas this may provide full flexibility in the creation of submatrices, this might result in performance disadvantages in comparison to matrix primitives (even in case the specified submatrix could be aligned). Whereas matrix primitives are guaranteed to be properly aligned and therefore provide maximum performance in all operations, a general view on a matrix might not be properly aligned. This may cause a performance penalty on some platforms and/or for some operations.
However, it is also possible to create aligned submatrices. Aligned submatrices are identical to unaligned submatrices in all aspects, except that they may pose additional alignment restrictions and therefore have less flexibility during creation, but don't suffer from performance penalties and provide the same performance as the underlying matrix. Aligned submatrices are created by explicitly specifying the blaze::aligned flag:
The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). In order to be properly aligned the first element of each row/column of the submatrix must be aligned. The following source code gives some examples for a double precision row-major dynamic matrix, assuming that padding is enabled and that AVX is available, which packs 4 double
values into a SIMD vector:
Note that the discussed alignment restrictions are only valid for aligned dense submatrices. In contrast, aligned sparse submatrices at this time don't pose any additional restrictions. Therefore aligned and unaligned sparse submatrices are truly fully identical. Still, in case the blaze::aligned flag is specified during setup, an aligned submatrix is created:
Submatrices can also be created on symmetric matrices (see the SymmetricMatrix
class template):
It is important to note, however, that (compound) assignments to such submatrices have a special restriction: The symmetry of the underlying symmetric matrix must not be broken! Since the modification of element of a symmetric matrix also modifies the element
, the matrix to be assigned must be structured such that the symmetry of the symmetric matrix is preserved. Otherwise a std::invalid_argument exception is thrown:
decltype(auto) blaze::submatrix | ( | Matrix< MT, SO > & | matrix, |
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given matrix.
matrix | The matrix containing the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing the specified submatrix of the given matrix. The following example demonstrates the creation of a dense and sparse submatrix:
By default, the provided submatrix arguments are checked at runtime. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown. The checks can be skipped by providing the optional blaze::unchecked argument.
Please note that this function creates an unaligned dense or sparse submatrix. For instance, the creation of the dense submatrix is equivalent to the following function call:
In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions. However, especially in case of dense submatrices this may result in considerable performance improvements. In order to create an aligned submatrix the following function call has to be used:
Note however that in this case the given compile time arguments I, J, M, and N are subject to additional checks to guarantee proper alignment.
decltype(auto) blaze::submatrix | ( | const Matrix< MT, SO > & | matrix, |
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given constant matrix.
matrix | The constant matrix containing the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing the specified submatrix of the given constant matrix. The following example demonstrates the creation of a dense and sparse submatrix:
By default, the provided submatrix arguments are checked at runtime. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown. The checks can be skipped by providing the optional blaze::unchecked argument.
Please note that this function creates an unaligned dense or sparse submatrix. For instance, the creation of the dense submatrix is equivalent to the following three function calls:
In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions. However, especially in case of dense submatrices this may result in considerable performance improvements. In order to create an aligned submatrix the following function call has to be used:
Note however that in this case the given compile time arguments I, J, M, and N are subject to additional checks to guarantee proper alignment.
decltype(auto) blaze::submatrix | ( | Matrix< MT, SO > && | matrix, |
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given temporary matrix.
matrix | The temporary matrix containing the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing the specified submatrix of the given temporary matrix. In case the submatrix is not properly specified (i.e. if the specified row or column is greater than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown.
decltype(auto) blaze::submatrix | ( | Matrix< MT, SO > & | matrix, |
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given matrix.
matrix | The matrix containing the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing an aligned or unaligned submatrix of the given dense or sparse matrix, based on the specified alignment flag AF. The following example demonstrates the creation of both an aligned and unaligned submatrix:
By default, the provided submatrix arguments are checked at runtime. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown. The checks can be skipped by providing the optional blaze::unchecked argument.
In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions and the given I, and J arguments are subject to additional checks to guarantee proper alignment. However, especially in case of dense submatrices this may result in considerable performance improvements.
The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). In order to be properly aligned the first element of each row/column of the submatrix must be aligned. The following source code gives some examples for a double precision row-major dynamic matrix, assuming that padding is enabled and that AVX is available, which packs 4 double
values into a SIMD vector:
In case any alignment restrictions are violated, a std::invalid_argument exception is thrown.
decltype(auto) blaze::submatrix | ( | const Matrix< MT, SO > & | matrix, |
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given constant matrix.
matrix | The constant matrix containing the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing an aligned or unaligned submatrix of the given constant dense or sparse matrix, based on the specified alignment flag AF. The following example demonstrates the creation of both an aligned and unaligned submatrix:
By default, the provided submatrix arguments are checked at runtime. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown. The checks can be skipped by providing the optional blaze::unchecked argument.
In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions and the given I, and J arguments are subject to additional checks to guarantee proper alignment. However, especially in case of dense submatrices this may result in considerable performance improvements.
The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). In order to be properly aligned the first element of each row/column of the submatrix must be aligned. The following source code gives some examples for a double precision row-major dynamic matrix, assuming that padding is enabled and that AVX is available, which packs 4 double
values into a SIMD vector:
In case any alignment restrictions are violated, a std::invalid_argument exception is thrown.
decltype(auto) blaze::submatrix | ( | Matrix< MT, SO > && | matrix, |
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given temporary matrix.
matrix | The temporary matrix containing the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing an aligned or unaligned submatrix of the given temporary dense or sparse matrix, based on the specified alignment flag AF. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) or any alignment restrictions are violated, a std::invalid_argument exception is thrown.
decltype(auto) blaze::submatrix | ( | Matrix< MT, SO > & | matrix, |
size_t | row, | ||
size_t | column, | ||
size_t | m, | ||
size_t | n, | ||
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given matrix.
matrix | The matrix containing the submatrix. |
row | The index of the first row of the submatrix. |
column | The index of the first column of the submatrix. |
m | The number of rows of the submatrix. |
n | The number of columns of the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing the specified submatrix of the given matrix. The following example demonstrates the creation of a dense and sparse submatrix:
By default, the provided submatrix arguments are checked at runtime. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown. The checks can be skipped by providing the optional blaze::unchecked argument.
Please note that this function creates an unaligned dense or sparse submatrix. For instance, the creation of the dense submatrix is equivalent to the following function call:
In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions. However, especially in case of dense submatrices this may result in considerable performance improvements. In order to create an aligned submatrix the following function call has to be used:
Note however that in this case the given arguments row, column, m, and n are subject to additional checks to guarantee proper alignment.
decltype(auto) blaze::submatrix | ( | const Matrix< MT, SO > & | matrix, |
size_t | row, | ||
size_t | column, | ||
size_t | m, | ||
size_t | n, | ||
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given constant matrix.
matrix | The constant matrix containing the submatrix. |
row | The index of the first row of the submatrix. |
column | The index of the first column of the submatrix. |
m | The number of rows of the submatrix. |
n | The number of columns of the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing the specified submatrix of the given constant matrix. The following example demonstrates the creation of a dense and sparse submatrix:
By default, the provided submatrix arguments are checked at runtime. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown. The checks can be skipped by providing the optional blaze::unchecked argument.
Please note that this function creates an unaligned dense or sparse submatrix. For instance, the creation of the dense submatrix is equivalent to the following three function calls:
In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions. However, especially in case of dense submatrices this may result in considerable performance improvements. In order to create an aligned submatrix the following function call has to be used:
Note however that in this case the given arguments row, column, m, and n are subject to additional checks to guarantee proper alignment.
decltype(auto) blaze::submatrix | ( | Matrix< MT, SO > && | matrix, |
size_t | row, | ||
size_t | column, | ||
size_t | m, | ||
size_t | n, | ||
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given temporary matrix.
matrix | The temporary matrix containing the submatrix. |
row | The index of the first row of the submatrix. |
column | The index of the first column of the submatrix. |
m | The number of rows of the submatrix. |
n | The number of columns of the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing the specified submatrix of the given temporary matrix. In case the submatrix is not properly specified (i.e. if the specified row or column is greater than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown.
decltype(auto) blaze::submatrix | ( | Matrix< MT, SO > & | matrix, |
size_t | row, | ||
size_t | column, | ||
size_t | m, | ||
size_t | n, | ||
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given matrix.
matrix | The matrix containing the submatrix. |
row | The index of the first row of the submatrix. |
column | The index of the first column of the submatrix. |
m | The number of rows of the submatrix. |
n | The number of columns of the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing an aligned or unaligned submatrix of the given dense or sparse matrix, based on the specified alignment flag AF. The following example demonstrates the creation of both an aligned and unaligned submatrix:
By default, the provided submatrix arguments are checked at runtime. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown. The checks can be skipped by providing the optional blaze::unchecked argument.
In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions and the given row, and column arguments are subject to additional checks to guarantee proper alignment. However, especially in case of dense submatrices this may result in considerable performance improvements.
The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). In order to be properly aligned the first element of each row/column of the submatrix must be aligned. The following source code gives some examples for a double precision row-major dynamic matrix, assuming that padding is enabled and that AVX is available, which packs 4 double
values into a SIMD vector:
In case any alignment restrictions are violated, a std::invalid_argument exception is thrown.
decltype(auto) blaze::submatrix | ( | const Matrix< MT, SO > & | matrix, |
size_t | row, | ||
size_t | column, | ||
size_t | m, | ||
size_t | n, | ||
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given constant matrix.
matrix | The constant matrix containing the submatrix. |
row | The index of the first row of the submatrix. |
column | The index of the first column of the submatrix. |
m | The number of rows of the submatrix. |
n | The number of columns of the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing an aligned or unaligned submatrix of the given dense or sparse matrix, based on the specified alignment flag AF. The following example demonstrates the creation of both an aligned and unaligned submatrix:
By default, the provided submatrix arguments are checked at runtime. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown. The checks can be skipped by providing the optional blaze::unchecked argument.
In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions and the given row, and column arguments are subject to additional checks to guarantee proper alignment. However, especially in case of dense submatrices this may result in considerable performance improvements.
The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). In order to be properly aligned the first element of each row/column of the submatrix must be aligned. The following source code gives some examples for a double precision row-major dynamic matrix, assuming that padding is enabled and that AVX is available, which packs 4 double
values into a SIMD vector:
In case any alignment restrictions are violated, a std::invalid_argument exception is thrown.
decltype(auto) blaze::submatrix | ( | Matrix< MT, SO > && | matrix, |
size_t | row, | ||
size_t | column, | ||
size_t | m, | ||
size_t | n, | ||
RSAs... | args | ||
) |
Creating a view on a specific submatrix of the given temporary matrix.
matrix | The temporary matrix containing the submatrix. |
row | The index of the first row of the submatrix. |
column | The index of the first column of the submatrix. |
m | The number of rows of the submatrix. |
n | The number of columns of the submatrix. |
args | Optional submatrix arguments. |
std::invalid_argument | Invalid submatrix specification. |
This function returns an expression representing an aligned or unaligned submatrix of the given temporary dense or sparse matrix, based on the specified alignment flag AF. In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) or any alignment restrictions are violated, a std::invalid_argument exception is thrown.