![]() |
Proxy backend for sparse matrix types.The SparseMatrixProxy class serves as a backend for the Proxy class. It is used in case the data type represented by the proxy is a sparse matrix and augments the Proxy interface by the complete interface required of sparse matrices. More...
#include <SparseMatrixProxy.h>
Inherits blaze::SparseMatrix< PT, IsColumnMajorMatrix< MT >::value >.
Public Types | |
enum | : bool { smpAssignable = MT::smpAssignable } |
Compilation flag for SMP assignments. | |
using | ResultType = ResultType_< MT > |
Result type for expression template evaluations. | |
using | OppositeType = OppositeType_< MT > |
Result type with opposite storage order for expression template evaluations. | |
using | TransposeType = TransposeType_< MT > |
Transpose type for expression template evaluations. | |
using | ElementType = ElementType_< MT > |
Type of the sparse matrix elements. | |
using | ReturnType = ReturnType_< MT > |
Return type for expression template evaluations. | |
using | CompositeType = CompositeType_< MT > |
Data type for composite expression templates. | |
using | Reference = Reference_< MT > |
Reference to a non-constant matrix value. | |
using | ConstReference = ConstReference_< MT > |
Reference to a constant matrix value. | |
using | Iterator = Iterator_< MT > |
Iterator over non-constant elements. | |
using | ConstIterator = ConstIterator_< MT > |
Iterator over constant elements. | |
using | MatrixType = PT |
Type of the matrix. | |
Public Member Functions | |
BLAZE_ALWAYS_INLINE MatrixType & | operator~ () noexcept |
Conversion operator for non-constant matrices. More... | |
BLAZE_ALWAYS_INLINE const MatrixType & | operator~ () const noexcept |
Conversion operator for constant matrices. More... | |
Data access functions | |
Reference | operator() (size_t i, size_t j) const |
Function call operator for the direct access to matrix elements. More... | |
Reference | at (size_t i, size_t j) const |
Checked access to the matrix elements. More... | |
Iterator | begin (size_t i) const |
Returns an iterator to the first element of row/column i of the represented matrix. More... | |
ConstIterator | cbegin (size_t i) const |
Returns an iterator to the first element of row/column i of the represented matrix. More... | |
Iterator | end (size_t i) const |
Returns an iterator just past the last element of row/column i of the represented matrix. More... | |
ConstIterator | cend (size_t i) const |
Returns an iterator just past the last element of row/column i of the represented matrix. More... | |
Utility functions | |
size_t | rows () const |
Returns the current number of rows of the represented matrix. More... | |
size_t | columns () const |
Returns the current number of columns of the represented matrix. More... | |
size_t | capacity () const |
Returns the maximum capacity of the represented matrix. More... | |
size_t | capacity (size_t i) const |
Returns the current capacity of the specified row/column of the represented matrix. More... | |
size_t | nonZeros () const |
Returns the number of non-zero elements in the represented matrix. More... | |
size_t | nonZeros (size_t i) const |
Returns the number of non-zero elements in the specified row/column of the represented matrix. More... | |
void | reset () const |
Reset to the default initial value. More... | |
void | reset (size_t i) const |
Reset the specified row/column to the default initial values. More... | |
void | clear () const |
Clearing the represented vector. More... | |
void | finalize (size_t i) const |
Finalizing the element insertion of a row/column. More... | |
void | resize (size_t m, size_t n, bool preserve=true) const |
Changing the size of the represented matrix. More... | |
void | reserve (size_t n) const |
Setting the minimum capacity of the represented matrix. More... | |
void | reserve (size_t i, size_t n) const |
Setting the minimum capacity of a specific row/column of the sparse matrix. More... | |
void | trim () const |
Removing all excessive capacity from all rows/columns. More... | |
void | trim (size_t i) const |
Removing all excessive capacity of a specific row/column of the sparse matrix. More... | |
Insertion functions | |
Iterator | set (size_t i, size_t j, const ElementType &value) const |
Setting an element of the represented sparse matrix. More... | |
Iterator | insert (size_t i, size_t j, const ElementType &value) const |
Inserting an element into the represented sparse matrix. More... | |
void | append (size_t i, size_t j, const ElementType &value, bool check=false) const |
Appending an element to the specified row/column of the sparse matrix. More... | |
Erase functions | |
void | erase (size_t i, size_t j) const |
Erasing an element from the sparse matrix. More... | |
Iterator | erase (size_t i, Iterator pos) const |
Erasing an element from the sparse matrix. More... | |
Iterator | erase (size_t i, Iterator first, Iterator last) const |
Erasing a range of elements from the sparse matrix. More... | |
template<typename Pred > | |
void | erase (Pred predicate) |
Erasing specific elements from the sparse matrix. More... | |
template<typename Pred > | |
void | erase (size_t i, Iterator first, Iterator last, Pred predicate) |
Erasing specific elements from a range of the sparse matrix. More... | |
Lookup functions | |
Iterator | find (size_t i, size_t j) const |
Searches for a specific matrix element. More... | |
Iterator | lowerBound (size_t i, size_t j) const |
Returns an iterator to the first index not less then the given index. More... | |
Iterator | upperBound (size_t i, size_t j) const |
Returns an iterator to the first index greater then the given index. More... | |
Numeric functions | |
void | transpose () const |
In-place transpose of the represented matrix. More... | |
void | ctranspose () const |
In-place conjugate transpose of the represented matrix. More... | |
template<typename Other > | |
void | scale (const Other &scalar) const |
Scaling of the sparse matrix by the scalar value scalar ( ![]() | |
Proxy backend for sparse matrix types.
The SparseMatrixProxy class serves as a backend for the Proxy class. It is used in case the data type represented by the proxy is a sparse matrix and augments the Proxy interface by the complete interface required of sparse matrices.
|
inline |
Appending an element to the specified row/column of the sparse 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. |
std::invalid_argument | Invalid access to restricted element. |
This function provides a very efficient way to fill a sparse 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.
|
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::invalid_argument | Invalid access to restricted element. |
std::out_of_range | Invalid matrix access index. |
This function returns a reference to the accessed value at position (i,j). In case the sparse matrix does not yet store an element at position (i,j) , a new element is inserted into the sparse matrix. 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 of the represented matrix.
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.
|
inline |
Returns the maximum capacity of the represented matrix.
|
inline |
Returns the current capacity of the specified row/column of the represented matrix.
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 of the represented matrix.
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.
|
inline |
Returns an iterator just past the last element of row/column i of the represented matrix.
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 represented vector.
This function clears the matrix to its default initial state.
|
inline |
Returns the current number of columns of the represented matrix.
|
inline |
In-place conjugate transpose of the represented matrix.
std::invalid_argument | Invalid access to restricted element. |
|
inline |
Returns an iterator just past the last element of row/column i of the represented matrix.
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 sparse 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 ![]() |
std::invalid_argument | Invalid access to restricted element. |
This function erases an element from the sparse matrix.
|
inline |
Erasing an element from the sparse 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. |
std::invalid_argument | Invalid access to restricted element. |
This function erases an element from the sparse 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 sparse matrix.
i | The row/column index of the element 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. |
std::invalid_argument | Invalid access to restricted element. |
This function erases a range of elements from the sparse 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 sparse matrix.
predicate | The unary predicate for the element selection. |
This function erases specific elements from the sparse 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.
|
inline |
Erasing specific elements from a range of the sparse 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 sparse 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.
|
inline |
Finalizing the element insertion of a row/column.
i | The index of the row/column to be finalized ![]() |
std::invalid_argument | Invalid access to restricted element. |
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 sparse matrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!
|
inline |
Inserting an element into the represented sparse 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 access to restricted element. |
std::invalid_argument | Invalid sparse matrix access index. |
This function inserts a new element into the sparse matrix. However, duplicate elements are not allowed. In case the sparse matrix already contains an element with row index i and column index j, a std::invalid_argument exception is thrown.
|
inline |
Returns an iterator to the first index not less then 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 then 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 then 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 sparse matrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!
|
inline |
Returns the number of non-zero elements in the represented matrix.
|
inline |
Returns the number of non-zero elements in the specified row/column of the represented matrix.
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 |
Function call operator for the direct access to 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::invalid_argument | Invalid access to restricted element. |
This function returns a reference to the accessed value at position (i,j). In case the sparse matrix does not yet store an element at position (i,j) , a new element is inserted into the sparse 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.
|
inlinenoexceptinherited |
Conversion operator for non-constant matrices.
|
inlinenoexceptinherited |
Conversion operator for constant matrices.
|
inline |
Setting the minimum capacity of the represented matrix.
n | The new minimum capacity of the matrix. |
std::invalid_argument | Invalid access to restricted element. |
This function increases the capacity of the sparse matrix to at least nonzeros elements. The current values of the matrix elements and the individual capacities of the matrix rows are preserved.
|
inline |
Setting the minimum capacity of a specific row/column of the sparse matrix.
i | The row/column index of the new element ![]() ![]() |
n | The new minimum capacity of the specified row/column. |
std::invalid_argument | Invalid access to restricted element. |
This function increases the capacity of row/column i of the sparse matrix to at least nonzeros elements. The current values of the sparse 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
.
|
inline |
Reset to the default initial value.
This function resets all elements of the matrix 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 |
Changing the size of the represented matrix.
m | The new number of rows of the matrix. |
n | The new number of columns of the matrix. |
preserve | true if the old values of the matrix should be preserved, false if not. |
std::invalid_argument | Invalid access to restricted element. |
This function resizes the matrix using the given size to . Depending on the type of the matrix, 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.
|
inline |
Returns the current number of rows of the represented matrix.
|
inline |
Scaling of the sparse matrix by the scalar value scalar ( ).
scalar | The scalar value for the matrix scaling. |
std::invalid_argument | Invalid access to restricted element. |
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 |
Setting an element of the represented sparse 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. |
std::invalid_argument | Invalid access to restricted element. |
std::invalid_argument | Invalid sparse matrix access index. |
This function sets the value of an element of the sparse matrix. In case the sparse 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 |
In-place transpose of the represented matrix.
std::invalid_argument | Invalid access to restricted element. |
|
inline |
Removing all excessive capacity from all rows/columns.
std::invalid_argument | Invalid access to restricted element. |
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 sparse matrix.
i | The index of the row/column to be trimmed ( ![]() ![]() |
std::invalid_argument | Invalid access to restricted element. |
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 then 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 then 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 then 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 sparse matrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!