Public Types | Public Member Functions | Private Types | List of all members
blaze::MatrixAccessProxy< MT > Class Template Reference

Access proxy for sparse, $ M \times N $ 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>

Inherits blaze::Proxy< MatrixAccessProxy< MT >, ElementType_< MT > >.

Public Types

typedef ElementType_< MT > RepresentedType
 Type of the represented sparse matrix element.
 
typedef RepresentedTypeRawReference
 Raw reference to the represented element.
 

Public Member Functions

template<typename T >
const MatrixAccessProxy< VT > & operator= (initializer_list< T > list) const
 Initializer list assignment to the accessed sparse matrix element. More...
 
template<typename T >
const MatrixAccessProxy< VT > & operator= (initializer_list< initializer_list< T > > list) const
 Initializer list assignment to the accessed sparse matrix element. More...
 
template<typename T >
const MatrixAccessProxy< MT > & operator= (const T &value) const
 Assignment to the accessed sparse matrix element. More...
 
template<typename T >
const MatrixAccessProxy< MT > & operator+= (const T &value) const
 Addition assignment to the accessed sparse matrix element. More...
 
template<typename T >
const MatrixAccessProxy< MT > & operator-= (const T &value) const
 Subtraction assignment to the accessed sparse matrix element. More...
 
template<typename T >
const MatrixAccessProxy< MT > & operator*= (const T &value) const
 Multiplication assignment to the accessed sparse matrix element. More...
 
template<typename T >
const MatrixAccessProxy< MT > & operator/= (const T &value) const
 Division assignment to the accessed sparse matrix element. More...
 
Constructors
 MatrixAccessProxy (MT &sm, size_t i, size_t j)
 Initialization constructor for a MatrixAccessProxy. More...
 
 MatrixAccessProxy (const MatrixAccessProxy &map)
 The copy constructor for MatrixAccessProxy. More...
 
Destructor
 ~MatrixAccessProxy ()
 The destructor for MatrixAccessProxy.
 
Operators
const MatrixAccessProxyoperator= (const MatrixAccessProxy &map) const
 Copy assignment operator for MatrixAccessProxy. More...
 
template<typename T >
const MatrixAccessProxyoperator= (initializer_list< T > list) const
 
template<typename T >
const MatrixAccessProxyoperator= (initializer_list< initializer_list< T > > list) const
 
template<typename T >
const MatrixAccessProxyoperator= (const T &value) const
 
template<typename T >
const MatrixAccessProxyoperator+= (const T &value) const
 
template<typename T >
const MatrixAccessProxyoperator-= (const T &value) const
 
template<typename T >
const MatrixAccessProxyoperator*= (const T &value) const
 
template<typename T >
const MatrixAccessProxyoperator/= (const T &value) const
 
Utility functions
RawReference get () const noexcept
 Returning the value of the accessed sparse matrix element. More...
 
bool isRestricted () const noexcept
 Returns whether the proxy represents a restricted sparse matrix element.. More...
 
Conversion operator
 operator RawReference () const noexcept
 Conversion to the accessed sparse matrix element. More...
 

Private Types

enum  : bool { rmm = IsRowMajorMatrix<MT>::value }
 Compile time flag indicating whether the given matrix type is a row-major matrix.
 

Private Member Functions

Forbidden operations
void * operator& () const
 Address operator (private & undefined)
 

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.
 

Detailed Description

template<typename MT>
class blaze::MatrixAccessProxy< MT >

Access proxy for sparse, $ M \times N $ 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:

// Standard usage of the function call operator to initialize a matrix element.
// Only a single sparse matrix element is accessed!
A(0,1) = 1.0;
// Initialization of a matrix element via another matrix element.
// Two sparse matrix accesses in one statement!
A(1,2) = A(0,1);
// Multiple accesses to elements of the sparse matrix in one statement!
const double result = A(0,2) + A(1,2) + A(2,2);

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.

Constructor & Destructor Documentation

template<typename MT >
blaze::MatrixAccessProxy< MT >::MatrixAccessProxy ( MT &  sm,
size_t  i,
size_t  j 
)
inlineexplicit

Initialization constructor for a MatrixAccessProxy.

Parameters
smReference to the accessed sparse matrix.
iThe row-index of the accessed sparse matrix element.
jThe column-index of the accessed sparse matrix element.
template<typename MT >
blaze::MatrixAccessProxy< MT >::MatrixAccessProxy ( const MatrixAccessProxy< MT > &  map)
inline

The copy constructor for MatrixAccessProxy.

Parameters
mapSparse matrix access proxy to be copied.

Member Function Documentation

template<typename MT >
MatrixAccessProxy< MT >::RawReference blaze::MatrixAccessProxy< MT >::get ( ) const
inlinenoexcept

Returning the value of the accessed sparse matrix element.

Returns
Direct/raw reference to the accessed sparse matrix element.
template<typename MT >
bool blaze::MatrixAccessProxy< MT >::isRestricted ( ) const
inlinenoexcept

Returns whether the proxy represents a restricted sparse matrix element..

Returns
true in case access to the sparse matrix element is restricted, false if not.
template<typename MT >
blaze::MatrixAccessProxy< MT >::operator RawReference ( ) const
inlinenoexcept

Conversion to the accessed sparse matrix element.

Returns
Direct/raw reference to the accessed sparse matrix element.
template<typename MT>
template<typename T >
const MatrixAccessProxy<MT>& blaze::MatrixAccessProxy< MT >::operator*= ( const T &  value) const
inline

Multiplication assignment to the accessed sparse matrix element.

Parameters
valueThe right-hand side value for the multiplication.
Returns
Reference to the assigned access proxy.
template<typename MT>
template<typename T >
const MatrixAccessProxy<MT>& blaze::MatrixAccessProxy< MT >::operator+= ( const T &  value) const
inline

Addition assignment to the accessed sparse matrix element.

Parameters
valueThe right-hand side value to be added to the sparse matrix element.
Returns
Reference to the assigned access proxy.
template<typename MT>
template<typename T >
const MatrixAccessProxy<MT>& blaze::MatrixAccessProxy< MT >::operator-= ( const T &  value) const
inline

Subtraction assignment to the accessed sparse matrix element.

Parameters
valueThe right-hand side value to be subtracted from the sparse matrix element.
Returns
Reference to the assigned access proxy.
template<typename MT>
template<typename T >
const MatrixAccessProxy<MT>& blaze::MatrixAccessProxy< MT >::operator/= ( const T &  value) const
inline

Division assignment to the accessed sparse matrix element.

Parameters
valueThe right-hand side value for the division.
Returns
Reference to the assigned access proxy.
template<typename MT >
const MatrixAccessProxy< MT > & blaze::MatrixAccessProxy< MT >::operator= ( const MatrixAccessProxy< MT > &  map) const
inline

Copy assignment operator for MatrixAccessProxy.

Parameters
mapSparse matrix access proxy to be copied.
Returns
Reference to the assigned access proxy.
template<typename MT>
template<typename T >
const MatrixAccessProxy<VT>& blaze::MatrixAccessProxy< MT >::operator= ( initializer_list< T >  list) const
inline

Initializer list assignment to the accessed sparse matrix element.

Parameters
listThe list to be assigned to the sparse matrix element.
Returns
Reference to the assigned access proxy.
template<typename MT>
template<typename T >
const MatrixAccessProxy<VT>& blaze::MatrixAccessProxy< MT >::operator= ( initializer_list< initializer_list< T > >  list) const
inline

Initializer list assignment to the accessed sparse matrix element.

Parameters
listThe list to be assigned to the sparse matrix element.
Returns
Reference to the assigned access proxy.
template<typename MT>
template<typename T >
const MatrixAccessProxy<MT>& blaze::MatrixAccessProxy< MT >::operator= ( const T &  value) const
inline

Assignment to the accessed sparse matrix element.

Parameters
valueThe new value of the sparse matrix element.
Returns
Reference to the assigned access proxy.

The documentation for this class was generated from the following file: