![]() |
Efficient implementation of a compressed matrix.The CompressedMatrix class template is the representation of an arbitrary sized sparse matrix with
dynamically allocated elements of arbitrary type. The type of the elements and the storage order of the matrix can be specified via the two template parameters:
More...
#include <CompressedMatrix.h>
Inherits blaze::SparseMatrix< CompressedMatrix< Type, SO >, SO >.
Classes | |
struct | Rebind |
Rebind mechanism to obtain a CompressedMatrix with different data/element type. More... | |
struct | Resize |
Resize mechanism to obtain a CompressedMatrix with different fixed dimensions. More... | |
Public Types | |
using | This = CompressedMatrix< Type, SO > |
Type of this CompressedMatrix instance. | |
using | BaseType = SparseMatrix< This, SO > |
Base type of this CompressedMatrix instance. | |
using | ResultType = This |
Result type for expression template evaluations. | |
using | OppositeType = CompressedMatrix< Type,!SO > |
Result type with opposite storage order for expression template evaluations. | |
using | TransposeType = CompressedMatrix< Type,!SO > |
Transpose type for expression template evaluations. | |
using | ElementType = Type |
Type of the compressed matrix elements. | |
using | ReturnType = const Type & |
Return type for expression template evaluations. | |
using | CompositeType = const This & |
Data type for composite expression templates. | |
using | Reference = MatrixAccessProxy< This > |
Reference to a compressed matrix value. | |
using | ConstReference = const Type & |
Reference to a constant compressed matrix value. | |
using | Iterator = Element * |
Iterator over non-constant elements. | |
using | ConstIterator = const Element * |
Iterator over constant elements. | |
using | MatrixType = CompressedMatrix< Type, SO > |
Type of the matrix. | |
Public Member Functions | |
template<typename MT , bool SO2> | |
CompressedMatrix< Type, SO > & | operator= (const DenseMatrix< MT, SO2 > &rhs) |
Assignment operator for dense matrices. More... | |
template<typename MT , bool SO2> | |
CompressedMatrix< Type, SO > & | operator= (const SparseMatrix< MT, SO2 > &rhs) |
Assignment operator for different sparse matrices. More... | |
template<typename MT , bool SO2> | |
CompressedMatrix< Type, SO > & | operator+= (const Matrix< MT, SO2 > &rhs) |
Addition assignment operator for the addition of a matrix ( ![]() | |
template<typename MT , bool SO2> | |
CompressedMatrix< Type, SO > & | operator-= (const Matrix< MT, SO2 > &rhs) |
Subtraction assignment operator for the subtraction of a matrix ( ![]() | |
template<typename MT , bool SO2> | |
CompressedMatrix< Type, SO > & | operator%= (const DenseMatrix< MT, SO2 > &rhs) |
Schur product assignment operator for the multiplication of a dense matrix ( ![]() | |
template<typename MT , bool SO2> | |
CompressedMatrix< Type, SO > & | operator%= (const SparseMatrix< MT, SO2 > &rhs) |
Schur product assignment operator for the multiplication of a sparse matrix ( ![]() | |
template<typename Other > | |
CompressedMatrix< Type, SO > & | scale (const Other &scalar) |
Scaling of the compressed matrix by the scalar value scalar ( ![]() | |
BLAZE_ALWAYS_INLINE constexpr MatrixType & | operator~ () noexcept |
Conversion operator for non-constant matrices. More... | |
BLAZE_ALWAYS_INLINE constexpr const MatrixType & | operator~ () const noexcept |
Conversion operator for constant matrices. More... | |
Destructor | |
~CompressedMatrix () | |
The destructor for CompressedMatrix. | |
Data access functions | |
Reference | operator() (size_t i, size_t j) noexcept |
2D-access to the compressed matrix elements. More... | |
ConstReference | operator() (size_t i, size_t j) const noexcept |
2D-access to the compressed 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... | |
Iterator | begin (size_t i) noexcept |
Returns an iterator to the first non-zero element of row/column i. More... | |
ConstIterator | begin (size_t i) const noexcept |
Returns an iterator to the first non-zero element of row/column i. More... | |
ConstIterator | cbegin (size_t i) const noexcept |
Returns an iterator to the first non-zero element of row/column i. More... | |
Iterator | end (size_t i) noexcept |
Returns an iterator just past the last non-zero element of row/column i. More... | |
ConstIterator | end (size_t i) const noexcept |
Returns an iterator just past the last non-zero element of row/column i. More... | |
ConstIterator | cend (size_t i) const noexcept |
Returns an iterator just past the last non-zero element of row/column i. More... | |
Assignment operators | |
CompressedMatrix & | operator= (initializer_list< initializer_list< Type > > list) |
List assignment to all matrix elements. More... | |
CompressedMatrix & | operator= (const CompressedMatrix &rhs) |
Copy assignment operator for CompressedMatrix. More... | |
CompressedMatrix & | operator= (CompressedMatrix &&rhs) noexcept |
Move assignment operator for CompressedMatrix. More... | |
template<typename MT , bool SO2> | |
CompressedMatrix & | operator= (const DenseMatrix< MT, SO2 > &rhs) |
template<typename MT , bool SO2> | |
CompressedMatrix & | operator= (const SparseMatrix< MT, SO2 > &rhs) |
template<typename MT , bool SO2> | |
CompressedMatrix & | operator+= (const Matrix< MT, SO2 > &rhs) |
template<typename MT , bool SO2> | |
CompressedMatrix & | operator-= (const Matrix< MT, SO2 > &rhs) |
template<typename MT , bool SO2> | |
CompressedMatrix & | operator%= (const DenseMatrix< MT, SO2 > &rhs) |
template<typename MT , bool SO2> | |
CompressedMatrix & | operator%= (const SparseMatrix< MT, SO2 > &rhs) |
Erase functions | |
void | erase (size_t i, size_t j) |
Erasing an element from the compressed matrix. More... | |
Iterator | erase (size_t i, Iterator pos) |
Erasing an element from the compressed matrix. More... | |
Iterator | erase (size_t i, Iterator first, Iterator last) |
Erasing a range of elements from the compressed matrix. More... | |
template<typename Pred > | |
void | erase (Pred predicate) |
Erasing specific elements from the compressed matrix. More... | |
template<typename Pred > | |
void | erase (size_t i, Iterator first, Iterator last, Pred predicate) |
Erasing specific elements from a range of the compressed matrix. More... | |
Lookup functions | |
Iterator | find (size_t i, size_t j) |
Searches for a specific matrix element. More... | |
ConstIterator | find (size_t i, size_t j) const |
Searches for a specific matrix element. More... | |
Iterator | lowerBound (size_t i, size_t j) |
Returns an iterator to the first index not less than the given index. More... | |
ConstIterator | lowerBound (size_t i, size_t j) const |
Returns an iterator to the first index not less than the given index. More... | |
Iterator | upperBound (size_t i, size_t j) |
Returns an iterator to the first index greater than the given index. More... | |
ConstIterator | upperBound (size_t i, size_t j) const |
Returns an iterator to the first index greater than the given index. More... | |
Numeric functions | |
CompressedMatrix & | transpose () |
In-place transpose of the matrix. More... | |
CompressedMatrix & | ctranspose () |
In-place conjugate transpose of the matrix. More... | |
template<typename Other > | |
CompressedMatrix & | scale (const Other &scalar) |
Expression template evaluation functions | |
template<typename Other > | |
bool | canAlias (const Other *alias) const noexcept |
Returns whether the matrix can alias with the given address alias. More... | |
template<typename Other > | |
bool | isAliased (const Other *alias) const noexcept |
Returns whether the matrix is aliased with the given address alias. More... | |
bool | canSMPAssign () const noexcept |
Returns whether the matrix can be used in SMP assignments. More... | |
template<typename MT , bool SO2> | |
void | assign (const DenseMatrix< MT, SO2 > &rhs) |
Default implementation of the assignment of a row-major dense matrix. More... | |
template<typename MT > | |
void | assign (const SparseMatrix< MT, SO > &rhs) |
Default implementation of the assignment of a row-major compressed matrix. More... | |
template<typename MT > | |
void | assign (const SparseMatrix< MT,!SO > &rhs) |
Default implementation of the assignment of a column-major compressed matrix. More... | |
template<typename MT , bool SO2> | |
void | addAssign (const DenseMatrix< MT, SO2 > &rhs) |
Default implementation of the addition assignment of a dense matrix. More... | |
template<typename MT , bool SO2> | |
void | addAssign (const SparseMatrix< MT, SO2 > &rhs) |
Default implementation of the addition assignment of a compressed matrix. More... | |
template<typename MT , bool SO2> | |
void | subAssign (const DenseMatrix< MT, SO2 > &rhs) |
Default implementation of the subtraction assignment of a dense matrix. More... | |
template<typename MT , bool SO2> | |
void | subAssign (const SparseMatrix< MT, SO2 > &rhs) |
Default implementation of the subtraction assignment of a compressed matrix. More... | |
template<typename MT , bool SO2> | |
void | schurAssign (const DenseMatrix< MT, SO2 > &rhs) |
Default implementation of the Schur product assignment of a dense matrix. More... | |
Static Public Attributes | |
static constexpr bool | smpAssignable = !IsSMPAssignable_v<Type> |
Compilation flag for SMP assignments. More... | |
static constexpr bool | storageOrder |
Storage order of the matrix. | |
Private Types | |
using | ElementBase = ValueIndexPair< Type > |
Base class for the compressed matrix element. | |
using | IteratorBase = ElementBase * |
Iterator over non-constant base elements. | |
Constructors | |
CompressedMatrix () | |
The default constructor for CompressedMatrix. | |
CompressedMatrix (size_t m, size_t n) | |
Constructor for a matrix of size ![]() | |
CompressedMatrix (size_t m, size_t n, size_t nonzeros) | |
Constructor for a matrix of size ![]() | |
CompressedMatrix (size_t m, size_t n, const std::vector< size_t > &nonzeros) | |
Constructor for a matrix of size ![]() | |
CompressedMatrix (initializer_list< initializer_list< Type > > list) | |
List initialization of all matrix elements. More... | |
CompressedMatrix (const CompressedMatrix &sm) | |
The copy constructor for CompressedMatrix. More... | |
CompressedMatrix (CompressedMatrix &&sm) noexcept | |
The move constructor for CompressedMatrix. More... | |
template<typename MT , bool SO2> | |
CompressedMatrix (const DenseMatrix< MT, SO2 > &dm) | |
Conversion constructor from dense matrices. More... | |
template<typename MT , bool SO2> | |
CompressedMatrix (const SparseMatrix< MT, SO2 > &sm) | |
Conversion constructor from different sparse matrices. More... | |
CompressedMatrix (size_t m, size_t n, Uninitialized) | |
Constructor for an uninitialized matrix of size ![]() | |
Utility functions | |
size_t | rows () const noexcept |
Returns the current number of rows of the compressed matrix. More... | |
size_t | columns () const noexcept |
Returns the current number of columns of the compressed matrix. More... | |
size_t | capacity () const noexcept |
Returns the maximum capacity of the compressed matrix. More... | |
size_t | capacity (size_t i) const noexcept |
Returns the current capacity of the specified row/column. More... | |
size_t | nonZeros () const |
Returns the number of non-zero elements in the compressed 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 compressed matrix. More... | |
void | resize (size_t m, size_t n, bool preserve=true) |
Changing the size of the compressed matrix. More... | |
void | reserve (size_t nonzeros) |
Setting the minimum capacity of the compressed matrix. More... | |
void | reserve (size_t i, size_t nonzeros) |
Setting the minimum capacity of a specific row/column of the compressed matrix. More... | |
void | trim () |
Removing all excessive capacity from all rows/columns. More... | |
void | trim (size_t i) |
Removing all excessive capacity of a specific row/column of the compressed matrix. More... | |
void | shrinkToFit () |
Requesting the removal of unused capacity. More... | |
void | swap (CompressedMatrix &sm) noexcept |
Swapping the contents of two sparse matrices. More... | |
size_t | extendCapacity () const noexcept |
Calculating a new matrix capacity. More... | |
void | reserveElements (size_t nonzeros) |
Reserving the specified number of compressed matrix elements. More... | |
Iterator | castDown (IteratorBase it) const noexcept |
Performs a down-cast of the given iterator. More... | |
IteratorBase | castUp (Iterator it) const noexcept |
Performs an up-cast of the given iterator. More... | |
Insertion functions | |
Iterator | set (size_t i, size_t j, const Type &value) |
Setting an element of the compressed matrix. More... | |
Iterator | insert (size_t i, size_t j, const Type &value) |
Inserting an element into the compressed matrix. More... | |
void | append (size_t i, size_t j, const Type &value, bool check=false) |
Appending an element to the specified row/column of the compressed matrix. More... | |
void | finalize (size_t i) |
Finalizing the element insertion of a row/column. More... | |
Iterator | insert (Iterator pos, size_t i, size_t j, const Type &value) |
Inserting an element into the compressed matrix. More... | |
Member variables | |
size_t | m_ |
The current number of rows of the compressed matrix. | |
size_t | n_ |
The current number of columns of the compressed matrix. | |
size_t | capacity_ |
The current capacity of the pointer array. | |
Iterator * | begin_ |
Pointers to the first non-zero element of each row. | |
Iterator * | end_ |
Pointers one past the last non-zero element of each row. | |
static const Type | zero_ {} |
Neutral element for accesses to zero elements. | |
Efficient implementation of a compressed matrix.
The CompressedMatrix class template is the representation of an arbitrary sized sparse matrix with dynamically allocated elements of arbitrary type. The type of the elements and the storage order of the matrix can be specified via the two template parameters:
Inserting/accessing elements in a compressed matrix can be done by several alternative functions. The following example demonstrates all options:
The use of CompressedMatrix is very natural and intuitive. All operations (addition, subtraction, multiplication, scaling, ...) can be performed on all possible combinations of row-major and column-major dense and sparse matrices with fitting element types. The following example gives an impression of the use of CompressedMatrix:
|
inlineexplicit |
Constructor for a matrix of size .
m | The number of rows of the matrix. |
n | The number of columns of the matrix. |
The matrix is initialized to the zero matrix and has no free capacity.
|
inlineexplicit |
Constructor for a matrix of size .
m | The number of rows of the matrix. |
n | The number of columns of the matrix. |
nonzeros | The number of expected non-zero elements. |
The matrix is initialized to the zero matrix.
|
explicit |
Constructor for a matrix of size .
m | The number of rows of the matrix. |
n | The number of columns of the matrix. |
nonzeros | The expected number of non-zero elements in each row/column. |
The matrix is initialized to the zero matrix and will have the specified capacity in each row/column. Note that in case of a row-major matrix the given vector must have at least m elements, in case of a column-major matrix at least n elements.
|
inlineexplicit |
List initialization of all matrix elements.
list | The initializer list. |
This constructor provides the option to explicitly initialize the elements of the matrix by means of an initializer list:
The matrix is sized according to the size of the initializer list and all its elements are initialized by the values of the given initializer list. Missing values are considered to be default values.
|
inline |
The copy constructor for CompressedMatrix.
sm | Sparse matrix to be copied. |
|
inlinenoexcept |
The move constructor for CompressedMatrix.
sm | The compressed matrix to be moved into this instance. |
|
inline |
Conversion constructor from dense matrices.
dm | Dense matrix to be copied. |
|
inline |
Conversion constructor from different sparse matrices.
sm | Sparse matrix to be copied. |
|
inlineexplicitprivate |
Constructor for an uninitialized matrix of size .
m | The number of rows of the matrix. |
n | The number of columns of the matrix. |
|
inline |
Default implementation of the addition assignment of a 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 compressed matrix.
rhs | The right-hand side compressed 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 |
Appending an element to the specified row/column of the compressed matrix.
i | The row index of the new element. The index has to be in the range ![]() |
j | The column index of the new element. The index has to be in the range ![]() |
value | The value of the element to be appended. |
check | true if the new value should be checked for default values, false if not. |
This function provides a very efficient way to fill a compressed matrix with elements. It appends a new element to the end of the specified row/column without any additional memory allocation. Therefore it is strictly necessary to keep the following preconditions in mind:
Ignoring these preconditions might result in undefined behavior! The optional check parameter specifies whether the new value should be tested for a default value. If the new value is a default value (for instance 0 in case of an integral element type) the value is not appended. Per default the values are not tested.
In combination with the reserve() and the finalize() function, append() provides the most efficient way to add new elements to a (newly created) compressed matrix:
finalize()
function has to be explicitly called for each row/column, even for empty ones!
|
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 |
Default implementation of the assignment of a row-major compressed matrix.
rhs | The right-hand side compressed 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 compressed matrix.
rhs | The right-hand side compressed 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. |
This function returns a reference to the accessed value at position (i,j). In case the compressed matrix does not yet store an element at position (i,j) , a new element is inserted into the compressed matrix. In contrast to the function call 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 function call operator this function always performs a check of the given access indices.
|
inlinenoexcept |
Returns an iterator to the first non-zero element of row/column i.
i | The row/column index. |
This function returns a row/column iterator to the first non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first non-zero element of column i.
|
inlinenoexcept |
Returns an iterator to the first non-zero element of row/column i.
i | The row/column index. |
This function returns a row/column iterator to the first non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first non-zero element of column i.
|
inlinenoexcept |
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.
|
inlinenoexcept |
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).
|
inlinenoexcept |
Returns the maximum capacity of the compressed matrix.
|
inlinenoexcept |
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.
|
inlineprivatenoexcept |
Performs a down-cast of the given iterator.
This function performs a down-cast of the given iterator to base elements to an iterator to derived elements.
|
inlineprivatenoexcept |
Performs an up-cast of the given iterator.
This function performs an up-cast of the given iterator to derived elements to an iterator to base elements.
|
inlinenoexcept |
Returns an iterator to the first non-zero element of row/column i.
i | The row/column index. |
This function returns a row/column iterator to the first non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator to the first non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator to the first non-zero element of column i.
|
inlinenoexcept |
Returns an iterator just past the last non-zero element of row/column i.
i | The row/column index. |
This function returns an row/column iterator just past the last non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last non-zero element of column i.
|
inline |
Clearing the compressed matrix.
After the clear() function, the size of the compressed matrix is 0.
|
inlinenoexcept |
Returns the current number of columns of the compressed matrix.
|
inline |
In-place conjugate transpose of the matrix.
|
inlinenoexcept |
Returns an iterator just past the last non-zero element of row/column i.
i | The row/column index. |
This function returns an row/column iterator just past the last non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last non-zero element of column i.
|
inlinenoexcept |
Returns an iterator just past the last non-zero element of row/column i.
i | The row/column index. |
This function returns an row/column iterator just past the last non-zero element of row/column i. In case the storage order is set to rowMajor the function returns an iterator just past the last non-zero element of row i, in case the storage flag is set to columnMajor the function returns an iterator just past the last non-zero element of column i.
|
inline |
Erasing an element from the compressed matrix.
i | The row index of the element to be erased. The index has to be in the range ![]() |
j | The column index of the element to be erased. The index has to be in the range ![]() |
This function erases an element from the compressed matrix.
|
inline |
Erasing an element from the compressed matrix.
i | The row/column index of the element to be erased. The index has to be in the range ![]() |
pos | Iterator to the element to be erased. |
This function erases an element from the compressed matrix. In case the storage order is set to rowMajor the function erases an element from row i, in case the storage flag is set to columnMajor the function erases an element from column i.
|
inline |
Erasing a range of elements from the compressed matrix.
i | The row/column index of the elements to be erased. The index has to be in the range ![]() |
first | Iterator to first element to be erased. |
last | Iterator just past the last element to be erased. |
This function erases a range of elements from the compressed matrix. In case the storage order is set to rowMajor the function erases a range of elements from row i, in case the storage flag is set to columnMajor the function erases a range of elements from column i.
|
inline |
Erasing specific elements from the compressed matrix.
predicate | The unary predicate for the element selection. |
This function erases specific elements from the compressed matrix. The elements are selected by the given unary predicate predicate, which is expected to accept a single argument of the type of the elements and to be pure. The following example demonstrates how to remove all elements that are smaller than a certain threshold value:
|
inline |
Erasing specific elements from a range of the compressed matrix.
i | The row/column index of the elements to be erased. The index has to be in the range ![]() |
first | Iterator to first element of the range. |
last | Iterator just past the last element of the range. |
predicate | The unary predicate for the element selection. |
This function erases specific elements from a range of elements of the compressed matrix. The elements are selected by the given unary predicate predicate, which is expected to accept a single argument of the type of the elements and to be pure. In case the storage order is set to rowMajor the function erases a range of elements from row i, in case the storage flag is set to columnMajor the function erases a range of elements from column i. The following example demonstrates how to remove all elements that are smaller than a certain threshold value:
|
inlineprivatenoexcept |
Calculating a new matrix capacity.
This function calculates a new matrix capacity based on the current capacity of the sparse matrix. Note that the new capacity is restricted to the interval .
|
inline |
Finalizing the element insertion of a row/column.
i | The index of the row/column to be finalized ![]() |
This function is part of the low-level interface to efficiently fill a matrix with elements. After completion of row/column i via the append() function, this function can be called to finalize row/column i and prepare the next row/column for insertion process via append().
|
inline |
Searches for a specific matrix element.
i | The row index of the search element. The index has to be in the range ![]() |
j | The column index of the search element. The index has to be in the range ![]() |
This function can be used to check whether a specific element is contained in the sparse matrix. It specifically searches for the element with row index i and column index j. In case the element is found, the function returns an row/column iterator to the element. Otherwise an iterator just past the last non-zero element of row i or column j (the end() iterator) is returned. Note that the returned compressed matrix iterator is subject to invalidation due to inserting operations via the function call operator, the set() function or the insert() function!
|
inline |
Searches for a specific matrix element.
i | The row index of the search element. The index has to be in the range ![]() |
j | The column index of the search element. The index has to be in the range ![]() |
This function can be used to check whether a specific element is contained in the sparse matrix. It specifically searches for the element with row index i and column index j. In case the element is found, the function returns an row/column iterator to the element. Otherwise an iterator just past the last non-zero element of row i or column j (the end() iterator) is returned. Note that the returned compressed matrix iterator is subject to invalidation due to inserting operations via the function call operator, the set() function or the insert() function!
|
inline |
Inserting an element into the compressed matrix.
i | The row index of the new element. The index has to be in the range ![]() |
j | The column index of the new element. The index has to be in the range ![]() |
value | The value of the element to be inserted. |
std::invalid_argument | Invalid compressed matrix access index. |
This function inserts a new element into the compressed matrix. However, duplicate elements are not allowed. In case the compressed matrix already contains an element with row index i and column index j, a std::invalid_argument exception is thrown.
|
private |
Inserting an element into the compressed matrix.
pos | The position of the new element. |
i | The row index of the new element. The index has to be in the range ![]() |
j | The column index of the new element. The index has to be in the range ![]() |
value | The value of the element to be inserted. |
std::invalid_argument | Invalid compressed matrix access index. |
|
inlinenoexcept |
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 an iterator to the first index not less than the given index.
i | The row index of the search element. The index has to be in the range ![]() |
j | The column index of the search element. The index has to be in the range ![]() |
In case of a row-major matrix, this function returns a row iterator to the first element with an index not less than the given column index. In case of a column-major matrix, the function returns a column iterator to the first element with an index not less than the given row index. In combination with the upperBound() function this function can be used to create a pair of iterators specifying a range of indices. Note that the returned compressed matrix iterator is subject to invalidation due to inserting operations via the function call operator, the set() function or the insert() function!
|
inline |
Returns an iterator to the first index not less than the given index.
i | The row index of the search element. The index has to be in the range ![]() |
j | The column index of the search element. The index has to be in the range ![]() |
In case of a row-major matrix, this function returns a row iterator to the first element with an index not less than the given column index. In case of a column-major matrix, the function returns a column iterator to the first element with an index not less than the given row index. In combination with the upperBound() function this function can be used to create a pair of iterators specifying a range of indices. Note that the returned compressed matrix iterator is subject to invalidation due to inserting operations via the function call operator, the set() function or the insert() function!
|
inline |
Returns the number of non-zero elements in the compressed 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 |
Schur product assignment operator for the multiplication of a dense matrix ( ).
rhs | The right-hand side dense matrix for the Schur product. |
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 |
Schur product assignment operator for the multiplication of a sparse matrix ( ).
rhs | The right-hand side sparse matrix for the Schur product. |
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.
|
inlinenoexcept |
2D-access to the compressed 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 returns a reference to the accessed value at position (i,j). In case the compressed matrix does not yet store an element at position (i,j) , a new element is inserted into the compressed matrix. Note that 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.
|
inlinenoexcept |
2D-access to the compressed 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 |
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 |
List assignment to all matrix elements.
list | The initializer list. |
This assignment operator offers the option to directly assign to all elements of the matrix by means of an initializer list:
The matrix is resized according to the given initializer list and all its elements are assigned the values from the given initializer list. Missing values are considered to be default values.
|
inline |
Copy assignment operator for CompressedMatrix.
rhs | Sparse matrix to be copied. |
The compressed matrix is resized according to the given compressed matrix and initialized as a copy of this matrix.
|
inlinenoexcept |
Move assignment operator for CompressedMatrix.
rhs | The compressed matrix to be moved into this instance. |
|
inline |
Assignment operator for dense matrices.
rhs | Dense matrix to be copied. |
The matrix is resized according to the given matrix and initialized as a copy of this matrix.
|
inline |
Assignment operator for different sparse matrices.
rhs | Sparse matrix to be copied. |
The matrix is resized according to the given matrix and initialized as a copy of this matrix.
|
inlinenoexceptinherited |
Conversion operator for non-constant matrices.
|
inlinenoexceptinherited |
Conversion operator for constant matrices.
|
inline |
Setting the minimum capacity of the compressed matrix.
nonzeros | The new minimum capacity of the compressed matrix. |
This function increases the capacity of the compressed matrix to at least nonzeros elements. The current values of the matrix elements and the individual capacities of the matrix rows are preserved.
void blaze::CompressedMatrix< Type, SO >::reserve | ( | size_t | i, |
size_t | nonzeros | ||
) |
Setting the minimum capacity of a specific row/column of the compressed matrix.
i | The row/column index ![]() ![]() |
nonzeros | The new minimum capacity of the specified row/column. |
This function increases the capacity of row/column i of the compressed matrix to at least nonzeros elements. The current values of the compressed matrix and all other individual row/column capacities are preserved. In case the storage order is set to rowMajor, the function reserves capacity for row i and the index has to be in the range . In case the storage order is set to columnMajor, the function reserves capacity for column i and the index has to be in the range
.
|
private |
Reserving the specified number of compressed matrix elements.
nonzeros | The number of matrix elements to be reserved. |
|
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.
void blaze::CompressedMatrix< Type, SO >::resize | ( | size_t | m, |
size_t | n, | ||
bool | preserve = true |
||
) |
Changing the size of the compressed matrix.
m | The new number of rows of the compressed matrix. |
n | The new number of columns of the compressed matrix. |
preserve | true if the old values of the matrix should be preserved, false if not. |
This function resizes the matrix using the given size to . During this operation, new dynamic memory may be allocated in case the capacity of the matrix is too small. Note that this function may invalidate all existing views (submatrices, rows, columns, ...) on the matrix if it is used to shrink the matrix. Additionally, the resize operation potentially changes all matrix elements. In order to preserve the old matrix values, the preserve flag can be set to true.
|
inlinenoexcept |
Returns the current number of rows of the compressed matrix.
|
inline |
Scaling of the compressed matrix by the scalar value scalar ( ).
scalar | The scalar value for the matrix scaling. |
This function scales the matrix by applying the given scalar value scalar to each element of the matrix. For built-in and complex
data types it has the same effect as using the multiplication assignment operator:
|
inline |
Default implementation of the Schur product assignment of a dense matrix.
rhs | The right-hand side dense matrix for the Schur product. |
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 |
Setting an element of the compressed matrix.
i | The row index of the new element. The index has to be in the range ![]() |
j | The column index of the new element. The index has to be in the range ![]() |
value | The value of the element to be set. |
This function sets the value of an element of the compressed matrix. In case the compressed matrix already contains an element with row index i and column index j its value is modified, else a new element with the given value is inserted.
|
inline |
Requesting the removal of unused capacity.
This function minimizes the capacity of the matrix by removing unused capacity. Please note that in case a reallocation occurs, all iterators (including end() iterators), all pointers and references to elements of this matrix are invalidated.
|
inline |
Default implementation of the subtraction assignment of a 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 compressed matrix.
rhs | The right-hand side compressed 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.
|
inlinenoexcept |
Swapping the contents of two sparse matrices.
sm | The compressed matrix to be swapped. |
|
inline |
In-place transpose of the matrix.
|
inline |
Removing all excessive capacity from all rows/columns.
The trim() function can be used to reverse the effect of all row/column-specific reserve() calls. The function removes all excessive capacity from all rows (in case of a rowMajor matrix) or columns (in case of a columnMajor matrix). Note that this function does not remove the overall capacity but only reduces the capacity per row/column.
|
inline |
Removing all excessive capacity of a specific row/column of the compressed matrix.
i | The index of the row/column to be trimmed ( ![]() ![]() |
This function can be used to reverse the effect of a row/column-specific reserve() call. It removes all excessive capacity from the specified row (in case of a rowMajor matrix) or column (in case of a columnMajor matrix). The excessive capacity is assigned to the subsequent row/column.
|
inline |
Returns an iterator to the first index greater than the given index.
i | The row index of the search element. The index has to be in the range ![]() |
j | The column index of the search element. The index has to be in the range ![]() |
In case of a row-major matrix, this function returns a row iterator to the first element with an index greater than the given column index. In case of a column-major matrix, the function returns a column iterator to the first element with an index greater than the given row index. In combination with the lowerBound() function this function can be used to create a pair of iterators specifying a range of indices. Note that the returned compressed matrix iterator is subject to invalidation due to inserting operations via the function call operator, the set() function or or the insert() function!
|
inline |
Returns an iterator to the first index greater than the given index.
i | The row index of the search element. The index has to be in the range ![]() |
j | The column index of the search element. The index has to be in the range ![]() |
In case of a row-major matrix, this function returns a row iterator to the first element with an index greater than the given column index. In case of a column-major matrix, the function returns a column iterator to the first element with an index greater than the given row index. In combination with the lowerBound() function this function can be used to create a pair of iterators specifying a range of indices. Note that the returned compressed matrix iterator is subject to invalidation due to inserting operations via the function call operator, the set() function or the insert() function!
|
static |
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).