![]() |
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 >.
Public Types | |
enum | { smpAssignable = !IsSMPAssignable<Type>::value } |
Compilation flag for SMP assignments. More... | |
typedef CompressedMatrix< Type, SO > | This |
Type of this CompressedMatrix instance. | |
typedef This | ResultType |
Result type for expression template evaluations. | |
typedef CompressedMatrix< Type,!SO > | OppositeType |
Result type with opposite storage order for expression template evaluations. | |
typedef CompressedMatrix< Type,!SO > | TransposeType |
Transpose type for expression template evaluations. | |
typedef Type | ElementType |
Type of the sparse matrix elements. | |
typedef const Type & | ReturnType |
Return type for expression template evaluations. | |
typedef const This & | CompositeType |
Data type for composite expression templates. | |
typedef MatrixAccessProxy< This > | Reference |
Reference to a sparse matrix value. | |
typedef const Type & | ConstReference |
Reference to a constant sparse matrix value. | |
typedef Element * | Iterator |
Iterator over non-constant elements. | |
typedef const Element * | ConstIterator |
Iterator over constant elements. | |
typedef MT | MatrixType |
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 Matrix< MT, SO2 > &rhs) |
Multiplication assignment operator for the multiplication of a matrix ( ![]() | |
template<typename Other > | |
EnableIf< IsNumeric< Other > , CompressedMatrix< Type, SO > >::Type & | operator*= (Other rhs) |
Multiplication assignment operator for the multiplication between a sparse matrix and a scalar value ( ![]() | |
template<typename Other > | |
EnableIf< IsNumeric< Other > , CompressedMatrix< Type, SO > >::Type & | operator/= (Other rhs) |
Division assignment operator for the division of a sparse matrix by a scalar value ( ![]() | |
template<typename Other > | |
CompressedMatrix< Type, SO > & | scale (Other scalar) |
Scaling of the sparse matrix by the scalar value scalar ( ![]() | |
template<typename Other > | |
CompressedMatrix< Type, SO > & | scaleDiagonal (Other scalar) |
Scaling the diagonal of the sparse matrix by the scalar value scalar. More... | |
MatrixType & | operator~ () |
Conversion operator for non-constant matrices. More... | |
const MatrixType & | operator~ () const |
Conversion operator for constant matrices. More... | |
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 (const CompressedMatrix &sm) | |
The copy 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... | |
Destructor | |
~CompressedMatrix () | |
The destructor for CompressedMatrix. | |
Data access functions | |
Reference | operator() (size_t i, size_t j) |
2D-access to the sparse matrix elements. More... | |
ConstReference | operator() (size_t i, size_t j) const |
2D-access to the sparse matrix elements. More... | |
Iterator | begin (size_t i) |
Returns an iterator to the first non-zero element of row/column i. More... | |
ConstIterator | begin (size_t i) const |
Returns an iterator to the first non-zero element of row/column i. More... | |
ConstIterator | cbegin (size_t i) const |
Returns an iterator to the first non-zero element of row/column i. More... | |
Iterator | end (size_t i) |
Returns an iterator just past the last non-zero element of row/column i. More... | |
ConstIterator | end (size_t i) const |
Returns an iterator just past the last non-zero element of row/column i. More... | |
ConstIterator | cend (size_t i) const |
Returns an iterator just past the last non-zero element of row/column i. More... | |
Assignment operators | |
CompressedMatrix & | operator= (const CompressedMatrix &rhs) |
Copy 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 Matrix< MT, SO2 > &rhs) |
template<typename Other > | |
EnableIf< IsNumeric< Other > , CompressedMatrix >::Type & | operator*= (Other rhs) |
template<typename Other > | |
EnableIf< IsNumeric< Other > , CompressedMatrix >::Type & | operator/= (Other rhs) |
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 then the given index. More... | |
ConstIterator | 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) |
Returns an iterator to the first index greater then the given index. More... | |
ConstIterator | upperBound (size_t i, size_t j) const |
Returns an iterator to the first index greater then the given index. More... | |
Low-level utility functions | |
void | append (size_t i, size_t j, const Type &value, bool check=false) |
Appending an element to the specified row/column of the sparse matrix. More... | |
void | finalize (size_t i) |
Finalizing the element insertion of a row/column. 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 | canSMPAssign () const |
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 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 , 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 sparse 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 sparse matrix. More... | |
Private Types | |
typedef ValueIndexPair< Type > | ElementBase |
Base class for the sparse matrix element. | |
Utility functions | |
size_t | rows () const |
Returns the current number of rows of the sparse matrix. More... | |
size_t | columns () const |
Returns the current number of columns of the sparse matrix. More... | |
size_t | capacity () const |
Returns the maximum capacity of the sparse 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 number of non-zero elements in the sparse 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 sparse matrix. More... | |
Iterator | insert (size_t i, size_t j, const Type &value) |
Inserting an element into the sparse matrix. More... | |
void | erase (size_t i, size_t j) |
Erasing an element from the sparse matrix. More... | |
Iterator | erase (size_t i, Iterator pos) |
Erasing an element from the sparse matrix. More... | |
Iterator | erase (size_t i, Iterator first, Iterator last) |
Erasing a range of elements from the sparse matrix. More... | |
void | resize (size_t m, size_t n, bool preserve=true) |
Changing the size of the sparse matrix. More... | |
void | reserve (size_t nonzeros) |
Setting the minimum capacity of the sparse matrix. More... | |
void | reserve (size_t i, size_t nonzeros) |
Setting the minimum capacity of a specific row/column of the sparse 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 sparse matrix. More... | |
CompressedMatrix & | transpose () |
Transposing the matrix. More... | |
template<typename Other > | |
CompressedMatrix & | scale (Other scalar) |
template<typename Other > | |
CompressedMatrix & | scaleDiagonal (Other scalar) |
void | swap (CompressedMatrix &sm) |
Swapping the contents of two sparse matrices. More... | |
size_t | extendCapacity () const |
Calculating a new matrix capacity. More... | |
void | reserveElements (size_t nonzeros) |
Reserving the specified number of sparse matrix elements. More... | |
Member variables | |
size_t | m_ |
The current number of rows of the sparse matrix. | |
size_t | n_ |
The current number of columns of the sparse 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_ = Type() |
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 combination 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:
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 .
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. |
The matrix is initialized to the zero matrix.
|
inline |
The copy constructor for CompressedMatrix.
sm | Sparse matrix to be copied. |
|
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. |
|
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 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 |
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.
In combination with the reserve() and the finalize() function, append() provides the most efficient way to add new elements to a (newly created) sparse matrix:
Note: Although append() does not allocate new memory, it still invalidates all iterators returned by the end() functions!
|
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 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 |
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.
|
inline |
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.
|
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 sparse 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 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.
|
inline |
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 sparse matrix.
After the clear() function, the size of the sparse matrix is 0.
|
inline |
Returns the current number of columns of the sparse matrix.
|
inline |
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 |
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 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.
|
inlineprivate |
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().
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 |
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!
CompressedMatrix< Type, SO >::Iterator blaze::CompressedMatrix< Type, SO >::insert | ( | size_t | i, |
size_t | j, | ||
const Type & | value | ||
) |
Inserting an element into 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 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 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 conAlias() 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 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 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 sparse 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 sparse 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 ![]() |
|
inline |
2D-access to the sparse 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 ![]() |
|
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 sparse 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 sparse matrix by a scalar value ( ).
rhs | The right-hand side scalar value for the division. |
|
inline |
Copy assignment operator for CompressedMatrix.
rhs | Sparse matrix to be copied. |
The sparse matrix is resized according to the given sparse matrix and initialized as a copy of this matrix.
|
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.
|
inlineinherited |
Conversion operator for non-constant matrices.
|
inlineinherited |
Conversion operator for constant matrices.
|
inline |
Setting the minimum capacity of the sparse matrix.
nonzeros | The new minimum capacity of the sparse 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.
void blaze::CompressedMatrix< Type, SO >::reserve | ( | size_t | i, |
size_t | nonzeros | ||
) |
Setting the minimum capacity of a specific row/column of the sparse matrix.
i | The row/column index of the new element ![]() ![]() |
nonzeros | 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
.
|
private |
Reserving the specified number of sparse 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 sparse matrix.
m | The new number of rows of the sparse matrix. |
n | The new number of columns of the sparse 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.
|
inline |
Returns the current number of rows of the sparse matrix.
|
inline |
Scaling of the sparse matrix by the scalar value scalar ( ).
scalar | The scalar value for the matrix scaling. |
|
inline |
Scaling the diagonal of the sparse matrix by the scalar value scalar.
scalar | The scalar value for the diagonal scaling. |
|
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 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 |
Swapping the contents of two sparse matrices.
sm | The sparse matrix to be swapped. |
no-throw | guarantee. |
|
inline |
Transposing 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 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!
|
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!