![]() |
Efficient implementation of a customizable matrix.The CustomMatrix class template provides the functionality to represent an external array of elements of arbitrary type and a fixed size as a native Blaze dense matrix data structure. Thus in contrast to all other dense matrix types a custom matrix does not perform any kind of memory allocation by itself, but it is provided with an existing array of element during construction. A custom matrix can therefore be considered an alias to the existing array. More...
#include <CustomMatrix.h>
Inherits blaze::DenseMatrix< CustomMatrix< Type, AF, PF, SO >, SO >.
Classes | |
struct | Rebind |
Rebind mechanism to obtain a CustomMatrix with different data/element type. More... | |
Public Types | |
enum | { vectorizable = IsVectorizable<Type>::value } |
Compilation flag for intrinsic optimization. More... | |
enum | { smpAssignable = !IsSMPAssignable<Type>::value } |
Compilation flag for SMP assignments. More... | |
typedef CustomMatrix< Type, AF, PF, SO > | This |
Type of this CustomMatrix instance. | |
typedef DynamicMatrix< Type, SO > | ResultType |
Result type for expression template evaluations. | |
typedef DynamicMatrix< Type,!SO > | OppositeType |
Result type with opposite storage order for expression template evaluations. | |
typedef DynamicMatrix< Type,!SO > | TransposeType |
Transpose type for expression template evaluations. | |
typedef Type | ElementType |
Type of the matrix elements. | |
typedef IT::Type | IntrinsicType |
Intrinsic type of the matrix elements. | |
typedef const Type & | ReturnType |
Return type for expression template evaluations. | |
typedef const This & | CompositeType |
Data type for composite expression templates. | |
typedef Type & | Reference |
Reference to a non-constant matrix value. | |
typedef const Type & | ConstReference |
Reference to a constant matrix value. | |
typedef Type * | Pointer |
Pointer to a non-constant matrix value. | |
typedef const Type * | ConstPointer |
Pointer to a constant matrix value. | |
typedef DenseIterator< Type, AF > | Iterator |
Iterator over non-constant elements. | |
typedef DenseIterator< const Type, AF > | ConstIterator |
Iterator over constant elements. | |
typedef MT | MatrixType |
Type of the matrix. | |
Public Member Functions | |
template<typename Other , size_t M, size_t N> | |
CustomMatrix< Type, AF, PF, SO > & | operator= (const Other(&array)[M][N]) |
Array assignment to all matrix elements. More... | |
template<typename MT , bool SO2> | |
CustomMatrix< Type, AF, PF, SO > & | operator= (const Matrix< MT, SO2 > &rhs) |
Assignment operator for different matrices. More... | |
template<typename MT , bool SO2> | |
CustomMatrix< Type, AF, PF, SO > & | operator+= (const Matrix< MT, SO2 > &rhs) |
Addition assignment operator for the addition of a matrix ( ![]() | |
template<typename MT , bool SO2> | |
CustomMatrix< Type, AF, PF, SO > & | operator-= (const Matrix< MT, SO2 > &rhs) |
Subtraction assignment operator for the subtraction of a matrix ( ![]() | |
template<typename MT , bool SO2> | |
CustomMatrix< Type, AF, PF, SO > & | operator*= (const Matrix< MT, SO2 > &rhs) |
Multiplication assignment operator for the multiplication of a matrix ( ![]() | |
template<typename Other > | |
EnableIf< IsNumeric< Other >, CustomMatrix< Type, AF, PF, SO > >::Type & | operator*= (Other rhs) |
Multiplication assignment operator for the multiplication between a matrix and a scalar value ( ![]() | |
template<typename Other > | |
EnableIf< IsNumeric< Other >, CustomMatrix< Type, AF, PF, SO > >::Type & | operator/= (Other rhs) |
Division assignment operator for the division of a matrix by a scalar value ( ![]() | |
template<typename Other > | |
CustomMatrix< Type, AF, PF, SO > & | scale (const Other &scalar) |
Scaling of the matrix by the scalar value scalar ( ![]() | |
template<typename MT > | |
DisableIf< typename CustomMatrix< Type, AF, PF, SO >::BLAZE_TEMPLATE VectorizedAssign< MT > >::Type | assign (const DenseMatrix< MT, SO > &rhs) |
Default implementation of the assignment of a row-major dense matrix. More... | |
template<typename MT > | |
EnableIf< typename CustomMatrix< Type, AF, PF, SO >::BLAZE_TEMPLATE VectorizedAssign< MT > >::Type | assign (const DenseMatrix< MT, SO > &rhs) |
Intrinsic optimized implementation of the assignment of a row-major dense matrix. More... | |
template<typename MT > | |
DisableIf< typename CustomMatrix< Type, AF, PF, SO >::BLAZE_TEMPLATE VectorizedAddAssign< MT > >::Type | addAssign (const DenseMatrix< MT, SO > &rhs) |
Default implementation of the addition assignment of a row-major dense matrix. More... | |
template<typename MT > | |
EnableIf< typename CustomMatrix< Type, AF, PF, SO >::BLAZE_TEMPLATE VectorizedAddAssign< MT > >::Type | addAssign (const DenseMatrix< MT, SO > &rhs) |
Intrinsic optimized implementation of the addition assignment of a row-major dense matrix. More... | |
template<typename MT > | |
DisableIf< typename CustomMatrix< Type, AF, PF, SO >::BLAZE_TEMPLATE VectorizedSubAssign< MT > >::Type | subAssign (const DenseMatrix< MT, SO > &rhs) |
Default implementation of the subtraction assignment of a row-major dense matrix. More... | |
template<typename MT > | |
EnableIf< typename CustomMatrix< Type, AF, PF, SO >::BLAZE_TEMPLATE VectorizedSubAssign< MT > >::Type | subAssign (const DenseMatrix< MT, SO > &rhs) |
Intrinsic optimized implementation of the subtraction assignment of a row-major dense matrix. More... | |
template<typename Arg > | |
DisableIf< IsClass< Arg > >::Type | construct (Type *ptr, size_t m, size_t n, Arg arg) |
Finalizing the construction of an unmanaged custom matrix. More... | |
template<typename Arg > | |
EnableIf< IsClass< Arg > >::Type | construct (Type *ptr, size_t m, size_t n, Arg arg) |
Finalizing the construction of a managed custom matrix. More... | |
BLAZE_ALWAYS_INLINE MatrixType & | operator~ () |
Conversion operator for non-constant matrices. More... | |
BLAZE_ALWAYS_INLINE const MatrixType & | operator~ () const |
Conversion operator for constant matrices. More... | |
Constructors | |
CustomMatrix () | |
The default constructor for CustomMatrix. | |
CustomMatrix (Type *ptr, size_t m, size_t n) | |
Constructor for a matrix of size ![]() | |
CustomMatrix (Type *ptr, size_t m, size_t n, size_t nn) | |
Constructor for a matrix of size ![]() | |
template<typename Deleter > | |
CustomMatrix (Type *ptr, size_t m, size_t n, Deleter D) | |
Constructor for a matrix of size ![]() | |
template<typename Deleter > | |
CustomMatrix (Type *ptr, size_t m, size_t n, size_t nn, Deleter D) | |
Constructor for a matrix of size ![]() | |
CustomMatrix (const CustomMatrix &m) | |
The copy constructor for CustomMatrix. More... | |
Data access functions | |
Reference | operator() (size_t i, size_t j) |
2D-access to the matrix elements. More... | |
ConstReference | operator() (size_t i, size_t j) const |
2D-access to the matrix elements. More... | |
Reference | at (size_t i, size_t j) |
Checked access to the matrix elements. More... | |
ConstReference | at (size_t i, size_t j) const |
Checked access to the matrix elements. More... | |
Pointer | data () |
Low-level data access to the matrix elements. More... | |
ConstPointer | data () const |
Low-level data access to the matrix elements. More... | |
Pointer | data (size_t i) |
Low-level data access to the matrix elements of row/column i. More... | |
ConstPointer | data (size_t i) const |
Low-level data access to the matrix elements of row/column i. More... | |
Iterator | begin (size_t i) |
Returns an iterator to the first element of row/column i. More... | |
ConstIterator | begin (size_t i) const |
Returns an iterator to the first element of row/column i. More... | |
ConstIterator | cbegin (size_t i) const |
Returns an iterator to the first element of row/column i. More... | |
Iterator | end (size_t i) |
Returns an iterator just past the last element of row/column i. More... | |
ConstIterator | end (size_t i) const |
Returns an iterator just past the last element of row/column i. More... | |
ConstIterator | cend (size_t i) const |
Returns an iterator just past the last element of row/column i. More... | |
Assignment operators | |
template<typename Other , size_t M, size_t N> | |
CustomMatrix & | operator= (const Other(&array)[M][N]) |
CustomMatrix & | operator= (const Type &set) |
Homogenous assignment to all matrix elements. More... | |
CustomMatrix & | operator= (const CustomMatrix &rhs) |
Copy assignment operator for CustomMatrix. More... | |
template<typename MT , bool SO2> | |
CustomMatrix & | operator= (const Matrix< MT, SO2 > &rhs) |
template<typename MT , bool SO2> | |
CustomMatrix & | operator+= (const Matrix< MT, SO2 > &rhs) |
template<typename MT , bool SO2> | |
CustomMatrix & | operator-= (const Matrix< MT, SO2 > &rhs) |
template<typename MT , bool SO2> | |
CustomMatrix & | operator*= (const Matrix< MT, SO2 > &rhs) |
template<typename Other > | |
EnableIf< IsNumeric< Other >, CustomMatrix >::Type & | operator*= (Other rhs) |
template<typename Other > | |
EnableIf< IsNumeric< Other >, CustomMatrix >::Type & | operator/= (Other rhs) |
Utility functions | |
size_t | rows () const |
Returns the current number of rows of the matrix. More... | |
size_t | columns () const |
Returns the current number of columns of the matrix. More... | |
size_t | spacing () const |
Returns the spacing between the beginning of two rows/columns. More... | |
size_t | capacity () const |
Returns the maximum capacity of the matrix. More... | |
size_t | capacity (size_t i) const |
Returns the current capacity of the specified row/column. More... | |
size_t | nonZeros () const |
Returns the total number of non-zero elements in the matrix. More... | |
size_t | nonZeros (size_t i) const |
Returns the number of non-zero elements in the specified row/column. More... | |
void | reset () |
Reset to the default initial values. More... | |
void | reset (size_t i) |
Reset the specified row/column to the default initial values. More... | |
void | clear () |
Clearing the ![]() | |
CustomMatrix & | transpose () |
In-place transpose of the matrix. More... | |
CustomMatrix & | ctranspose () |
In-place conjugate transpose of the matrix. More... | |
template<typename Other > | |
CustomMatrix & | scale (const Other &scalar) |
void | swap (CustomMatrix &m) |
Swapping the contents of two matrices. More... | |
Resource management functions | |
void | reset (Type *ptr, size_t m, size_t n) |
Resets the custom matrix and replaces the array of elements with the given array. More... | |
void | reset (Type *ptr, size_t m, size_t n, size_t nn) |
Resets the custom matrix and replaces the array of elements with the given array. More... | |
template<typename Deleter > | |
void | reset (Type *ptr, size_t m, size_t n, Deleter d) |
Resets the custom matrix and replaces the array of elements with the given array. More... | |
template<typename Deleter > | |
void | reset (Type *ptr, size_t m, size_t n, size_t nn, Deleter d) |
Resets the custom matrix and replaces the array of elements with the given array. More... | |
Expression template evaluation functions | |
template<typename Other > | |
bool | canAlias (const Other *alias) const |
Returns whether the matrix can alias with the given address alias. More... | |
template<typename Other > | |
bool | isAliased (const Other *alias) const |
Returns whether the matrix is aliased with the given address alias. More... | |
bool | isAligned () const |
Returns whether the matrix is properly aligned in memory. More... | |
bool | canSMPAssign () const |
Returns whether the matrix can be used in SMP assignments. More... | |
BLAZE_ALWAYS_INLINE IntrinsicType | load (size_t i, size_t j) const |
Load of an intrinsic element of the matrix. More... | |
BLAZE_ALWAYS_INLINE IntrinsicType | loada (size_t i, size_t j) const |
Aligned load of an intrinsic element of the matrix. More... | |
BLAZE_ALWAYS_INLINE IntrinsicType | loadu (size_t i, size_t j) const |
Unaligned load of an intrinsic element of the matrix. More... | |
BLAZE_ALWAYS_INLINE void | store (size_t i, size_t j, const IntrinsicType &value) |
Store of an intrinsic element of the matrix. More... | |
BLAZE_ALWAYS_INLINE void | storea (size_t i, size_t j, const IntrinsicType &value) |
Aligned store of an intrinsic element of the matrix. More... | |
BLAZE_ALWAYS_INLINE void | storeu (size_t i, size_t j, const IntrinsicType &value) |
Unaligned store of an intrinsic element of the matrix. More... | |
BLAZE_ALWAYS_INLINE void | stream (size_t i, size_t j, const IntrinsicType &value) |
Aligned, non-temporal store of an intrinsic element of the matrix. More... | |
template<typename MT > | |
DisableIf< VectorizedAssign< MT > >::Type | assign (const DenseMatrix< MT, SO > &rhs) |
template<typename MT > | |
EnableIf< VectorizedAssign< MT > >::Type | assign (const DenseMatrix< MT, SO > &rhs) |
template<typename MT > | |
void | assign (const DenseMatrix< MT,!SO > &rhs) |
Default implementation of the assignment of a column-major dense matrix. More... | |
template<typename MT > | |
void | assign (const SparseMatrix< MT, SO > &rhs) |
Default implementation of the assignment of a row-major sparse matrix. More... | |
template<typename MT > | |
void | assign (const SparseMatrix< MT,!SO > &rhs) |
Default implementation of the assignment of a column-major sparse matrix. More... | |
template<typename MT > | |
DisableIf< VectorizedAddAssign< MT > >::Type | addAssign (const DenseMatrix< MT, SO > &rhs) |
template<typename MT > | |
EnableIf< VectorizedAddAssign< MT > >::Type | addAssign (const DenseMatrix< MT, SO > &rhs) |
template<typename MT > | |
void | addAssign (const DenseMatrix< MT,!SO > &rhs) |
Default implementation of the addition assignment of a column-major dense matrix. More... | |
template<typename MT > | |
void | addAssign (const SparseMatrix< MT, SO > &rhs) |
Default implementation of the addition assignment of a row-major sparse matrix. More... | |
template<typename MT > | |
void | addAssign (const SparseMatrix< MT,!SO > &rhs) |
Default implementation of the addition assignment of a column-major sparse matrix. More... | |
template<typename MT > | |
DisableIf< VectorizedSubAssign< MT > >::Type | subAssign (const DenseMatrix< MT, SO > &rhs) |
template<typename MT > | |
EnableIf< VectorizedSubAssign< MT > >::Type | subAssign (const DenseMatrix< MT, SO > &rhs) |
template<typename MT > | |
void | subAssign (const DenseMatrix< MT,!SO > &rhs) |
Default implementation of the subtraction assignment of a column-major dense matrix. More... | |
template<typename MT > | |
void | subAssign (const SparseMatrix< MT, SO > &rhs) |
Default implementation of the subtraction assignment of a row-major sparse matrix. More... | |
template<typename MT > | |
void | subAssign (const SparseMatrix< MT,!SO > &rhs) |
Default implementation of the subtraction assignment of a column-major sparse matrix. More... | |
Private Types | |
typedef IntrinsicTrait< Type > | IT |
Intrinsic trait for the matrix element type. | |
Private Member Functions | |
Construction functions | |
template<typename Arg > | |
DisableIf< IsClass< Arg > >::Type | construct (Type *ptr, size_t m, size_t n, Arg arg) |
template<typename Arg > | |
EnableIf< IsClass< Arg > >::Type | construct (Type *ptr, size_t m, size_t n, Arg arg) |
Private Attributes | |
Member variables | |
size_t | m_ |
The current number of rows of the matrix. | |
size_t | n_ |
The current number of columns of the matrix. | |
size_t | nn_ |
The number of elements between two rows. | |
boost::shared_array< Type > | v_ |
The dynamically allocated matrix elements. More... | |
Efficient implementation of a customizable matrix.
The CustomMatrix class template provides the functionality to represent an external array of elements of arbitrary type and a fixed size as a native Blaze dense matrix data structure. Thus in contrast to all other dense matrix types a custom matrix does not perform any kind of memory allocation by itself, but it is provided with an existing array of element during construction. A custom matrix can therefore be considered an alias to the existing array.
The type of the elements, the properties of the given array of elements and the storage order of the matrix can be specified via the following four template parameters:
The following examples give an impression of several possible types of custom matrices:
In comparison with the remaining Blaze dense matrix types CustomMatrix has several special characteristics. All of these result from the fact that a custom matrix is not performing any kind of memory allocation, but instead is given an existing array of elements. The following sections discuss all of these characteristics:
The CustomMatrix class template acts as an adaptor for an existing array of elements. As such it provides everything that is required to use the array just like a native Blaze dense matrix data structure. However, this flexibility comes with the price that the user of a custom matrix is responsible for the resource management.
When constructing a custom matrix there are two choices: Either a user manually manages the array of elements outside the custom matrix, or alternatively passes the responsibility for the memory management to an instance of CustomMatrix. In the second case the CustomMatrix class employs shared ownership between all copies of the custom matrix, which reference the same array.
The following examples give an impression of several possible custom matrices:
It is possible to pass any type of deleter to the constructor. The deleter is only required to provide a function call operator that can be passed the pointer to the managed array. As an example the following code snipped shows the implementation of two native Blaze deleters blaze::ArrayDelete and blaze::Deallocate:
As with all dense matrices it is possible to copy construct a custom matrix:
It is important to note that a custom matrix acts as a reference to the specified array. Thus the result of the copy constructor is a new custom matrix that is referencing and representing the same array as the original custom matrix. In case a deleter has been provided to the first custom matrix, both matrices share the responsibility to destroy the array when the last matrix goes out of scope.
In contrast to copy construction, just as with references, copy assignment does not change which array is referenced by the custom matrices, but modifies the values of the array:
In case the custom matrix is specified as aligned the passed array must adhere to some alignment restrictions based on the alignment requirements of the used data type and the used instruction set (SSE, AVX, ...). The restriction applies to the first element of each row/column: In case of a row-major matrix the first element of each row must be properly aligned, in case of a column-major matrix the first element of each column must be properly aligned. For instance, if a row-major matrix is used and AVX is active the first element of each row must be 32-bit aligned:
In the example, the row-major matrix has six columns. However, since with AVX eight integer values are loaded together the matrix is padded with two additional elements. This guarantees that the first element of each row is 32-bit aligned. In case the alignment requirements are violated, a std::invalid_argument exception is thrown.
Adding padding elements to the end of an array can have a significant impact on performance. For instance, assuming that AVX is available, then two aligned, padded, 3x3 double precision matrices can be added via three intrinsic addition instruction:
In this example, maximum performance is possible. However, in case no padding elements are inserted a scalar addition has to be used:
Note that the construction of padded and unpadded aligned matrices looks identical. However, in case of padded matrices, Blaze will zero initialize the padding element and use them in all computations in order to achieve maximum performance. In case of an unpadded matrix Blaze will ignore the elements with the downside that it is not possible to load a complete row to an AVX register, which makes it necessary to fall back to a scalar addition.
The number of padding elements is required to be sufficient with respect to the available instruction set: In case of an aligned padded custom matrix the added padding elements must guarantee that the total number of elements in each row/column is a multiple of the intrinsic vector width. In case of an unaligned padded matrix the number of padding elements can be greater or equal the number of padding elements of an aligned padded custom matrix. In case the padding is insufficient with respect to the available instruction set, a std::invalid_argument exception is thrown.
The use of custom matrices in arithmetic operations is designed to be as natural and intuitive as possible. All operations (addition, subtraction, multiplication, scaling, ...) can be expressed similar to a text book representation. Also, custom matrices can be combined with all other dense and sparse vectors and matrices. The following example gives an impression of the use of CustomMatrix:
anonymous enum |
Compilation flag for intrinsic optimization.
The vectorizable compilation flag indicates whether expressions the matrix is involved in can be optimized via intrinsics. In case the element type of the matrix is a vectorizable data type, the vectorizable compilation flag is set to true, otherwise it is set to false.
anonymous enum |
Compilation flag for SMP assignments.
The smpAssignable compilation flag indicates whether the matrix can be used in SMP (shared memory parallel) assignments (both on the left-hand and right-hand side of the assignment).
|
inlineexplicit |
Constructor for a matrix of size .
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
std::invalid_argument | Invalid setup of custom matrix. |
This constructor creates an unpadded custom matrix of size . The construction fails if ...
In all failure cases a std::invalid_argument exception is thrown.
|
inlineexplicit |
Constructor for a matrix of size .
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
nn | The total number of elements between two rows/columns. |
std::invalid_argument | Invalid setup of custom matrix. |
This constructor creates a custom matrix of size . The construction fails if ...
In all failure cases a std::invalid_argument exception is thrown.
|
inlineexplicit |
Constructor for a matrix of size .
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
d | The deleter to destroy the array of elements. |
std::invalid_argument | Invalid setup of custom matrix. |
This constructor creates an unpadded custom matrix of size . The construction fails if ...
In all failure cases a std::invalid_argument exception is thrown.
|
inlineexplicit |
Constructor for a matrix of size .
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
nn | The total number of elements between two rows/columns. |
d | The deleter to destroy the array of elements. |
std::invalid_argument | Invalid setup of custom matrix. |
This constructor creates a custom matrix of size . The construction fails if ...
In all failure cases a std::invalid_argument exception is thrown.
|
inline |
The copy constructor for CustomMatrix.
m | Matrix to be copied. |
The copy constructor initializes the custom matrix as an exact copy of the given custom matrix.
|
inline |
Default implementation of the addition assignment of a column-major dense matrix.
rhs | The right-hand side dense matrix to be added. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the addition assignment of a row-major sparse matrix.
rhs | The right-hand side sparse matrix to be added. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the addition assignment of a column-major sparse matrix.
rhs | The right-hand side sparse matrix to be added. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the addition assignment of a row-major dense matrix.
rhs | The right-hand side dense matrix to be added. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Intrinsic optimized implementation of the addition assignment of a row-major dense matrix.
rhs | The right-hand side dense matrix to be added. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the assignment of a column-major dense matrix.
rhs | The right-hand side dense matrix to be assigned. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the assignment of a row-major sparse matrix.
rhs | The right-hand side sparse matrix to be assigned. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the assignment of a column-major sparse matrix.
rhs | The right-hand side sparse matrix to be assigned. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the assignment of a row-major dense matrix.
rhs | The right-hand side dense matrix to be assigned. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Intrinsic optimized implementation of the assignment of a row-major dense matrix.
rhs | The right-hand side dense matrix to be assigned. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Checked access to the matrix elements.
i | Access index for the row. The index has to be in the range ![]() |
j | Access index for the column. The index has to be in the range ![]() |
std::out_of_range | Invalid matrix access index. |
In contrast to the subscript operator this function always performs a check of the given access indices.
|
inline |
Checked access to the matrix elements.
i | Access index for the row. The index has to be in the range ![]() |
j | Access index for the column. The index has to be in the range ![]() |
std::out_of_range | Invalid matrix access index. |
In contrast to the subscript operator this function always performs a check of the given access indices.
|
inline |
Returns an iterator to the first element of row/column i.
i | The row/column index. |
This function returns a row/column iterator to the first element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first element of column i.
|
inline |
Returns an iterator to the first element of row/column i.
i | The row/column index. |
This function returns a row/column iterator to the first element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first element of column i.
|
inline |
Returns whether the matrix can alias with the given address alias.
alias | The alias to be checked. |
This function returns whether the given address can alias with the matrix. In contrast to the isAliased() function this function is allowed to use compile time expressions to optimize the evaluation.
|
inline |
Returns whether the matrix can be used in SMP assignments.
This function returns whether the matrix can be used in SMP assignments. In contrast to the smpAssignable member enumeration, which is based solely on compile time information, this function additionally provides runtime information (as for instance the current number of rows and/or columns of the matrix).
|
inline |
Returns the maximum capacity of the matrix.
|
inline |
Returns the current capacity of the specified row/column.
i | The index of the row/column. |
This function returns the current capacity of the specified row/column. In case the storage order is set to rowMajor the function returns the capacity of row i, in case the storage flag is set to columnMajor the function returns the capacity of column i.
|
inline |
Returns an iterator to the first element of row/column i.
i | The row/column index. |
This function returns a row/column iterator to the first element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first element of column i.
|
inline |
Returns an iterator just past the last element of row/column i.
i | The row/column index. |
This function returns an row/column iterator just past the last element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last element of column i.
|
inline |
|
inline |
Returns the current number of columns of the matrix.
|
inline |
Finalizing the construction of an unmanaged custom matrix.
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
arg | The total number of elements between two rows/columns. |
This function finalizes the construction of an unmanaged custom matrix.
|
inline |
Finalizing the construction of a managed custom matrix.
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
arg | The deleter to destroy the array of elements. |
|
inline |
In-place conjugate transpose of the matrix.
std::logic_error | Impossible transpose operation. |
In case the matrix is not a square matrix, a std::logic_error exception is thrown.
|
inline |
Low-level data access to the matrix elements.
This function returns a pointer to the internal storage of the dynamic matrix. Note that you can NOT assume that all matrix elements lie adjacent to each other! The dynamic matrix may use techniques such as padding to improve the alignment of the data. Whereas the number of elements within a row/column are given by the rows()
and columns()
member functions, respectively, the total number of elements including padding is given by the spacing()
member function.
|
inline |
Low-level data access to the matrix elements.
This function returns a pointer to the internal storage of the dynamic matrix. Note that you can NOT assume that all matrix elements lie adjacent to each other! The dynamic matrix may use techniques such as padding to improve the alignment of the data. Whereas the number of elements within a row/column are given by the rows()
and columns()
member functions, respectively, the total number of elements including padding is given by the spacing()
member function.
|
inline |
Low-level data access to the matrix elements of row/column i.
i | The row/column index. |
This function returns a pointer to the internal storage for the elements in row/column i.
|
inline |
Low-level data access to the matrix elements of row/column i.
i | The row/column index. |
This function returns a pointer to the internal storage for the elements in row/column i.
|
inline |
Returns an iterator just past the last element of row/column i.
i | The row/column index. |
This function returns an row/column iterator just past the last element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last element of column i.
|
inline |
Returns an iterator just past the last element of row/column i.
i | The row/column index. |
This function returns an row/column iterator just past the last element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last element of column i.
|
inline |
Returns whether the matrix is aliased with the given address alias.
alias | The alias to be checked. |
This function returns whether the given address is aliased with the matrix. In contrast to the canAlias() function this function is not allowed to use compile time expressions to optimize the evaluation.
|
inline |
Returns whether the matrix is properly aligned in memory.
This function returns whether the matrix is guaranteed to be properly aligned in memory, i.e. whether the beginning and the end of each row/column of the matrix are guaranteed to conform to the alignment restrictions of the element type Type.
BLAZE_ALWAYS_INLINE CustomMatrix< Type, AF, PF, SO >::IntrinsicType blaze::CustomMatrix< Type, AF, PF, SO >::load | ( | size_t | i, |
size_t | j | ||
) | const |
Load of an intrinsic element of the matrix.
i | Access index for the row. The index has to be in the range [0..M-1]. |
j | Access index for the column. The index has to be in the range [0..N-1]. |
This function performs a load of a specific intrinsic element of the dense matrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
BLAZE_ALWAYS_INLINE CustomMatrix< Type, AF, PF, SO >::IntrinsicType blaze::CustomMatrix< Type, AF, PF, SO >::loada | ( | size_t | i, |
size_t | j | ||
) | const |
Aligned load of an intrinsic element of the matrix.
i | Access index for the row. The index has to be in the range [0..M-1]. |
j | Access index for the column. The index has to be in the range [0..N-1]. |
This function performs an aligned load of a specific intrinsic element of the dense matrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
BLAZE_ALWAYS_INLINE CustomMatrix< Type, AF, PF, SO >::IntrinsicType blaze::CustomMatrix< Type, AF, PF, SO >::loadu | ( | size_t | i, |
size_t | j | ||
) | const |
Unaligned load of an intrinsic element of the matrix.
i | Access index for the row. The index has to be in the range [0..M-1]. |
j | Access index for the column. The index has to be in the range [0..N-1]. |
This function performs an unaligned load of a specific intrinsic element of the dense matrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
|
inline |
Returns the total number of non-zero elements in the matrix.
|
inline |
Returns the number of non-zero elements in the specified row/column.
i | The index of the row/column. |
This function returns the current number of non-zero elements in the specified row/column. In case the storage order is set to rowMajor the function returns the number of non-zero elements in row i, in case the storage flag is set to columnMajor the function returns the number of non-zero elements in column i.
|
inline |
2D-access to the matrix elements.
i | Access index for the row. The index has to be in the range ![]() |
j | Access index for the column. The index has to be in the range ![]() |
This function only performs an index check in case BLAZE_USER_ASSERT() is active. In contrast, the at() function is guaranteed to perform a check of the given access indices.
|
inline |
2D-access to the matrix elements.
i | Access index for the row. The index has to be in the range ![]() |
j | Access index for the column. The index has to be in the range ![]() |
This function only performs an index check in case BLAZE_USER_ASSERT() is active. In contrast, the at() function is guaranteed to perform a check of the given access indices.
|
inline |
Multiplication assignment operator for the multiplication of a matrix ( ).
rhs | The right-hand side matrix for the multiplication. |
std::invalid_argument | Matrix sizes do not match. |
In case the current sizes of the two given matrices don't match, a std::invalid_argument is thrown.
|
inline |
Multiplication assignment operator for the multiplication between a matrix and a scalar value ( ).
rhs | The right-hand side scalar value for the multiplication. |
|
inline |
Addition assignment operator for the addition of a matrix ( ).
rhs | The right-hand side matrix to be added to the matrix. |
std::invalid_argument | Matrix sizes do not match. |
In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown.
|
inline |
Subtraction assignment operator for the subtraction of a matrix ( ).
rhs | The right-hand side matrix to be subtracted from the matrix. |
std::invalid_argument | Matrix sizes do not match. |
In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown.
|
inline |
Division assignment operator for the division of a matrix by a scalar value ( ).
rhs | The right-hand side scalar value for the division. |
|
inline |
Homogenous assignment to all matrix elements.
rhs | Scalar value to be assigned to all matrix elements. |
|
inline |
Copy assignment operator for CustomMatrix.
rhs | Matrix to be copied. |
std::invalid_argument | Matrix sizes do not match. |
The matrix is initialized as a copy of the given matrix. In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown.
|
inline |
Array assignment to all matrix elements.
array | ![]() |
std::invalid_argument | Invalid array size. |
This assignment operator offers the option to directly set all elements of the matrix:
The matrix is assigned the values from the given array. Missing values are initialized with default values (as e.g. the value 6 in the example). Note that the size of the array must match the size of the custom matrix. Otherwise a std::invalid_argument exception is thrown. Also note that after the assignment array will have the same entries as init.
|
inline |
Assignment operator for different matrices.
rhs | Matrix to be copied. |
std::invalid_argument | Matrix sizes do not match. |
The matrix is initialized as a copy of the given matrix. In case the current sizes of the two matrices don't match, a std::invalid_argument exception is thrown.
|
inlineinherited |
Conversion operator for non-constant matrices.
|
inlineinherited |
Conversion operator for constant matrices.
|
inline |
Reset to the default initial values.
|
inline |
Reset the specified row/column to the default initial values.
i | The index of the row/column. |
This function resets the values in the specified row/column to their default value. In case the storage order is set to rowMajor the function resets the values in row i, in case the storage order is set to columnMajor the function resets the values in column i. Note that the capacity of the row/column remains unchanged.
|
inline |
Resets the custom matrix and replaces the array of elements with the given array.
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
std::invalid_argument | Invalid setup of custom matrix. |
This function resets the custom matrix to the given array of elements of size . The function fails if ...
In all failure cases a std::invalid_argument exception is thrown.
|
inline |
Resets the custom matrix and replaces the array of elements with the given array.
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
nn | The total number of elements between two rows/columns. |
std::invalid_argument | Invalid setup of custom matrix. |
This function resets the custom matrix to the given array of elements of size . The function fails if ...
In all failure cases a std::invalid_argument exception is thrown.
|
inline |
Resets the custom matrix and replaces the array of elements with the given array.
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
d | The deleter to destroy the array of elements. |
std::invalid_argument | Invalid setup of custom matrix. |
This function resets the custom matrix to the given array of elements of size . The function fails if ...
In all failure cases a std::invalid_argument exception is thrown.
|
inline |
Resets the custom matrix and replaces the array of elements with the given array.
ptr | The array of elements to be used by the matrix. |
m | The number of rows of the array of elements. |
n | The number of columns of the array of elements. |
nn | The total number of elements between two rows/columns. |
d | The deleter to destroy the array of elements. |
std::invalid_argument | Invalid setup of custom matrix. |
This function resets the custom matrix to the given array of elements of size . The function fails if ...
In all failure cases a std::invalid_argument exception is thrown.
|
inline |
Returns the current number of rows of the matrix.
|
inline |
Scaling of the matrix by the scalar value scalar ( ).
scalar | The scalar value for the matrix scaling. |
|
inline |
Returns the spacing between the beginning of two rows/columns.
This function returns the spacing between the beginning of two rows/columns, i.e. the total number of elements of a row/column. In case the storage order is set to rowMajor the function returns the spacing between two rows, in case the storage flag is set to columnMajor the function returns the spacing between two columns.
BLAZE_ALWAYS_INLINE void blaze::CustomMatrix< Type, AF, PF, SO >::store | ( | size_t | i, |
size_t | j, | ||
const IntrinsicType & | value | ||
) |
Store of an intrinsic element of the matrix.
i | Access index for the row. The index has to be in the range [0..M-1]. |
j | Access index for the column. The index has to be in the range [0..N-1]. |
value | The intrinsic element to be stored. |
This function performs a store of a specific intrinsic element of the dense matrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
BLAZE_ALWAYS_INLINE void blaze::CustomMatrix< Type, AF, PF, SO >::storea | ( | size_t | i, |
size_t | j, | ||
const IntrinsicType & | value | ||
) |
Aligned store of an intrinsic element of the matrix.
i | Access index for the row. The index has to be in the range [0..M-1]. |
j | Access index for the column. The index has to be in the range [0..N-1]. |
value | The intrinsic element to be stored. |
This function performs an aligned store of a specific intrinsic element of the dense matrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
BLAZE_ALWAYS_INLINE void blaze::CustomMatrix< Type, AF, PF, SO >::storeu | ( | size_t | i, |
size_t | j, | ||
const IntrinsicType & | value | ||
) |
Unaligned store of an intrinsic element of the matrix.
i | Access index for the row. The index has to be in the range [0..M-1]. |
j | Access index for the column. The index has to be in the range [0..N-1]. |
value | The intrinsic element to be stored. |
This function performs an unaligned store of a specific intrinsic element of the dense matrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
BLAZE_ALWAYS_INLINE void blaze::CustomMatrix< Type, AF, PF, SO >::stream | ( | size_t | i, |
size_t | j, | ||
const IntrinsicType & | value | ||
) |
Aligned, non-temporal store of an intrinsic element of the matrix.
i | Access index for the row. The index has to be in the range [0..M-1]. |
j | Access index for the column. The index has to be in the range [0..N-1]. |
value | The intrinsic element to be stored. |
This function performs an aligned, non-temporal store of a specific intrinsic element of the dense matrix. The row index must be smaller than the number of rows and the column index must be smaller than the number of columns. Additionally, the column index (in case of a row-major matrix) or the row index (in case of a column-major matrix) must be a multiple of the number of values inside the intrinsic element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
|
inline |
Default implementation of the subtraction assignment of a column-major dense matrix.
rhs | The right-hand side dense matrix to be subtracted. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the subtraction assignment of a row-major sparse matrix.
rhs | The right-hand side sparse matrix to be subtracted. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the subtraction assignment of a column-major sparse matrix.
rhs | The right-hand side sparse matrix to be subtracted. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the subtraction assignment of a row-major dense matrix.
rhs | The right-hand side dense matrix to be subtracted. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Intrinsic optimized implementation of the subtraction assignment of a row-major dense matrix.
rhs | The right-hand side dense matrix to be subtracted. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Swapping the contents of two matrices.
m | The matrix to be swapped. |
no-throw | guarantee. |
|
inline |
In-place transpose of the matrix.
std::logic_error | Impossible transpose operation. |
In case the matrix is not a square matrix, a std::logic_error exception is thrown.
|
private |
The dynamically allocated matrix elements.
Access to the matrix elements is gained via the function call operator. In case of row-major order the memory layout of the elements is
.