![]() |
Access proxy for sparse, matrices.The MatrixAccessProxy provides safe access to the elements of a non-const sparse matrices.
The proxied access to the elements of a sparse matrix is necessary since it may be possible that several insertion operations happen in the same statement. The following code illustrates this with two examples by means of the CompressedMatrix class:
More...
#include <MatrixAccessProxy.h>
Public Types | |
typedef MT | MatrixType |
Type of the accessed sparse matrix. | |
typedef MT::ElementType | ElementType |
Type of the accessed sparse matrix element. | |
typedef ElementType & | Reference |
Reference type of the accessed element. | |
typedef const ElementType & | ConstReference |
Reference type of the accessed constant element. | |
typedef MT::Iterator | Iterator |
Iterator type of the accessed sparse matrix. | |
Public Member Functions | |
Constructors | |
MatrixAccessProxy (MT &sv, size_t i, size_t j) | |
Initialization constructor for a MatrixAccessProxy. | |
MatrixAccessProxy (const MatrixAccessProxy &vap) | |
The copy constructor for MatrixAccessProxy. | |
Operators | |
MatrixAccessProxy & | operator= (const MatrixAccessProxy &vap) |
Copy assignment operator for MatrixAccessProxy. | |
template<typename T > | |
MatrixAccessProxy & | operator= (const T &value) |
Assignment to the accessed sparse matrix element. | |
template<typename T > | |
MatrixAccessProxy & | operator+= (const T &value) |
Addition assignment to the accessed sparse matrix element. | |
template<typename T > | |
MatrixAccessProxy & | operator-= (const T &value) |
Subtraction assignment to the accessed sparse matrix element. | |
template<typename T > | |
MatrixAccessProxy & | operator*= (const T &value) |
Multiplication assignment to the accessed sparse matrix element. | |
template<typename T > | |
MatrixAccessProxy & | operator/= (const T &value) |
Division assignment to the accessed sparse matrix element. | |
Conversion operator | |
operator Reference () const | |
Conversion to the accessed sparse matrix element. | |
Private Types | |
enum | { rmm = IsRowMajorMatrix<MT>::value } |
Compile time flag indicating whether the given matrix type is a row-major matrix. | |
Private Member Functions | |
Utility functions | |
Reference | get () const |
Returning the value of the accessed sparse matrix element. | |
void | set (ConstReference value) const |
Setting the value of the accessed sparse matrix element. | |
Private Attributes | |
Member variables | |
MT & | sm_ |
Reference to the accessed sparse matrix. | |
size_t | i_ |
Row-index of the accessed sparse matrix element. | |
size_t | j_ |
Column-index of the accessed sparse matrix element. | |
Access proxy for sparse, matrices.
The MatrixAccessProxy provides safe access to the elements of a non-const sparse matrices.
The proxied access to the elements of a sparse matrix is necessary since it may be possible that several insertion operations happen in the same statement. The following code illustrates this with two examples by means of the CompressedMatrix class:
The problem (especially with the last statement) is that several insertion operations might take place due to the access via the function call operator. If the function call operator would return a direct reference to one of the accessed elements, this reference might be invalidated during the evaluation of a subsequent function call operator, which results in undefined behavior. This class provides the necessary functionality to guarantee a safe access to the sparse matrix elements while preserving the intuitive use of the function call operator.
|
inlineexplicit |
Initialization constructor for a MatrixAccessProxy.
sv | Reference to the accessed sparse matrix. |
i | The row-index of the accessed sparse matrix element. |
j | The column-index of the accessed sparse matrix element. |
|
inline |
The copy constructor for MatrixAccessProxy.
map | Sparse matrix access proxy to be copied. |
|
inlineprivate |
Returning the value of the accessed sparse matrix element.
|
inline |
Conversion to the accessed sparse matrix element.
|
inline |
Multiplication assignment to the accessed sparse matrix element.
value | The right-hand side value for the multiplication. |
|
inline |
Addition assignment to the accessed sparse matrix element.
value | The right-hand side value to be added to the sparse matrix element. |
|
inline |
Subtraction assignment to the accessed sparse matrix element.
value | The right-hand side value to be subtracted from the sparse matrix element. |
|
inline |
Division assignment to the accessed sparse matrix element.
value | The right-hand side value for the division. |
|
inline |
Copy assignment operator for MatrixAccessProxy.
map | Sparse matrix access proxy to be copied. |
|
inline |
Assignment to the accessed sparse matrix element.
value | The new value of the sparse matrix element. |
|
inlineprivate |
Setting the value of the accessed sparse matrix element.
value | Reference to the new value of the sparse matrix element. |