![]() |
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 | |
typedef MT::ElementType | ElementType |
Type of the sparse matrix elements. | |
typedef MT::Reference | Reference |
Reference to a non-constant matrix value. | |
typedef MT::ConstReference | ConstReference |
Reference to a constant matrix value. | |
typedef MT::Iterator | Iterator |
Iterator over non-constant elements. | |
typedef MT::ConstIterator | ConstIterator |
Iterator over constant elements. | |
typedef PT | MatrixType |
Type of the matrix. | |
Public Member Functions | |
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... | |
Data access functions | |
Reference | operator() (size_t i, size_t j) const |
Function call operator for the direct access to 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... | |
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... | |
void | finalize (size_t i) const |
Finalizing the element insertion of a row/column. More... | |
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... | |
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... | |
void | transpose () const |
Transposing the represented matrix. More... | |
template<typename Other > | |
void | scale (const Other &scalar) const |
Scaling of the sparse matrix by the scalar value scalar ( ![]() | |
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... | |
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. |
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.
Note: Although append() does not allocate new memory, it still invalidates all iterators returned by the end() functions!
|
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 |
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 ![]() |
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. |
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. |
This function erases a range of element 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 |
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().
Note: Although finalize() does not allocate new memory, it still invalidates all iterators returned by the end() functions!
|
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 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 compressed 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 ![]() |
|
inlineinherited |
Conversion operator for non-constant matrices.
|
inlineinherited |
Conversion operator for constant matrices.
|
inline |
Setting the minimum capacity of the represented matrix.
n | The new minimum capacity of the matrix. |
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. |
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. |
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. |
|
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 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 |
Transposing the represented 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 sparse 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 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 compressed matrix iterator is subject to invalidation due to inserting operations via the function call operator or the insert() function!