Chemical Data Processing Library C++ API - Version 1.4.0
Public Types | Public Member Functions | Friends | List of all members
CDPL::Math::MatrixReference< M > Class Template Reference

Lightweight matrix expression that proxies a reference to an underlying matrix container. More...

#include <Matrix.hpp>

+ Inheritance diagram for CDPL::Math::MatrixReference< M >:

Public Types

typedef M MatrixType
 The wrapped matrix type. More...
 
typedef M::ValueType ValueType
 The element value type of the wrapped matrix. More...
 
typedef std::conditional< std::is_const< M >::value, typename M::ConstReference, typename M::Reference >::type Reference
 Mutable reference type (degrades to ConstReference when the wrapped matrix is const). More...
 
typedef M::ConstReference ConstReference
 Constant reference type to an element. More...
 
typedef M::SizeType SizeType
 The unsigned size type of the wrapped matrix. More...
 
typedef M::DifferenceType DifferenceType
 The signed difference type of the wrapped matrix. More...
 
typedef SelfType ClosureType
 Closure type used when this proxy appears inside another expression. More...
 
typedef const SelfType ConstClosureType
 Constant closure type used when this proxy appears inside another expression. More...
 
- Public Types inherited from CDPL::Math::MatrixExpression< MatrixReference< M > >
typedef MatrixReference< M > ExpressionType
 The derived matrix expression type. More...
 
- Public Types inherited from CDPL::Math::Expression< E >
typedef E ExpressionType
 The derived expression type (made available to expression-template machinery). More...
 

Public Member Functions

 MatrixReference (MatrixType &m)
 Constructs the reference proxy referring to m. More...
 
Reference operator() (SizeType i, SizeType j)
 Returns a mutable reference to the element at (i, j). More...
 
ConstReference operator() (SizeType i, SizeType j) const
 Returns a const reference to the element at (i, j). More...
 
SizeType getSize1 () const
 Returns the wrapped matrix's number of rows. More...
 
SizeType getSize2 () const
 Returns the wrapped matrix's number of columns. More...
 
SizeType getMaxSize () const
 Returns the wrapped matrix's maximum total element count. More...
 
SizeType getMaxSize1 () const
 Returns the wrapped matrix's maximum number of rows. More...
 
SizeType getMaxSize2 () const
 Returns the wrapped matrix's maximum number of columns. More...
 
bool isEmpty () const
 Tells whether the wrapped matrix is empty. More...
 
const MatrixTypegetData () const
 Returns a const reference to the wrapped matrix. More...
 
MatrixTypegetData ()
 Returns a reference to the wrapped matrix. More...
 
MatrixReferenceoperator= (const MatrixReference &r)
 Copy-assigns the wrapped matrix from the matrix referenced by r. More...
 
template<typename E >
MatrixReferenceoperator= (const MatrixExpression< E > &e)
 Assigns the matrix expression e to the wrapped matrix. More...
 
template<typename E >
MatrixReferenceoperator+= (const MatrixExpression< E > &e)
 Adds the matrix expression e element-wise to the wrapped matrix. More...
 
template<typename E >
MatrixReferenceoperator-= (const MatrixExpression< E > &e)
 Subtracts the matrix expression e element-wise from the wrapped matrix. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, MatrixReference >::type & operator*= (const T &t)
 Multiplies every element of the wrapped matrix by the scalar t. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, MatrixReference >::type & operator/= (const T &t)
 Divides every element of the wrapped matrix by the scalar t. More...
 
template<typename E >
MatrixReferenceassign (const MatrixExpression< E > &e)
 Assigns the matrix expression e to the wrapped matrix without intermediate temporary. More...
 
template<typename E >
MatrixReferenceplusAssign (const MatrixExpression< E > &e)
 Adds the matrix expression e to the wrapped matrix without intermediate temporary. More...
 
template<typename E >
MatrixReferenceminusAssign (const MatrixExpression< E > &e)
 Subtracts the matrix expression e from the wrapped matrix without intermediate temporary. More...
 
void swap (MatrixReference &r)
 Swaps the contents of the two wrapped matrices. More...
 
- Public Member Functions inherited from CDPL::Math::MatrixExpression< MatrixReference< M > >
const ExpressionTypeoperator() () const
 Returns a const reference to the derived matrix expression. More...
 
ExpressionTypeoperator() ()
 Returns a reference to the derived matrix expression. More...
 

Friends

void swap (MatrixReference &r1, MatrixReference &r2)
 ADL-enabled free-function form of swap(). More...
 

Additional Inherited Members

- Protected Member Functions inherited from CDPL::Math::MatrixExpression< MatrixReference< M > >
 MatrixExpression ()
 
 ~MatrixExpression ()
 
- Protected Member Functions inherited from CDPL::Math::Expression< E >
 Expression ()
 
 ~Expression ()
 

Detailed Description

template<typename M>
class CDPL::Math::MatrixReference< M >

Lightweight matrix expression that proxies a reference to an underlying matrix container.

Template Parameters
MThe wrapped matrix type.

Member Typedef Documentation

◆ MatrixType

template<typename M >
typedef M CDPL::Math::MatrixReference< M >::MatrixType

The wrapped matrix type.

◆ ValueType

template<typename M >
typedef M::ValueType CDPL::Math::MatrixReference< M >::ValueType

The element value type of the wrapped matrix.

◆ Reference

template<typename M >
typedef std::conditional<std::is_const<M>::value, typename M::ConstReference, typename M::Reference>::type CDPL::Math::MatrixReference< M >::Reference

Mutable reference type (degrades to ConstReference when the wrapped matrix is const).

◆ ConstReference

template<typename M >
typedef M::ConstReference CDPL::Math::MatrixReference< M >::ConstReference

Constant reference type to an element.

◆ SizeType

template<typename M >
typedef M::SizeType CDPL::Math::MatrixReference< M >::SizeType

The unsigned size type of the wrapped matrix.

◆ DifferenceType

template<typename M >
typedef M::DifferenceType CDPL::Math::MatrixReference< M >::DifferenceType

The signed difference type of the wrapped matrix.

◆ ClosureType

template<typename M >
typedef SelfType CDPL::Math::MatrixReference< M >::ClosureType

Closure type used when this proxy appears inside another expression.

◆ ConstClosureType

template<typename M >
typedef const SelfType CDPL::Math::MatrixReference< M >::ConstClosureType

Constant closure type used when this proxy appears inside another expression.

Constructor & Destructor Documentation

◆ MatrixReference()

template<typename M >
CDPL::Math::MatrixReference< M >::MatrixReference ( MatrixType m)
inlineexplicit

Constructs the reference proxy referring to m.

Parameters
mThe wrapped matrix to proxy.

Member Function Documentation

◆ operator()() [1/2]

template<typename M >
Reference CDPL::Math::MatrixReference< M >::operator() ( SizeType  i,
SizeType  j 
)
inline

Returns a mutable reference to the element at (i, j).

Parameters
iThe zero-based row index.
jThe zero-based column index.
Returns
A mutable reference to the element.

◆ operator()() [2/2]

template<typename M >
ConstReference CDPL::Math::MatrixReference< M >::operator() ( SizeType  i,
SizeType  j 
) const
inline

Returns a const reference to the element at (i, j).

Parameters
iThe zero-based row index.
jThe zero-based column index.
Returns
A const reference to the element.

◆ getSize1()

template<typename M >
SizeType CDPL::Math::MatrixReference< M >::getSize1 ( ) const
inline

Returns the wrapped matrix's number of rows.

Returns
The number of rows.

◆ getSize2()

template<typename M >
SizeType CDPL::Math::MatrixReference< M >::getSize2 ( ) const
inline

Returns the wrapped matrix's number of columns.

Returns
The number of columns.

◆ getMaxSize()

template<typename M >
SizeType CDPL::Math::MatrixReference< M >::getMaxSize ( ) const
inline

Returns the wrapped matrix's maximum total element count.

Returns
The maximum total element count.

◆ getMaxSize1()

template<typename M >
SizeType CDPL::Math::MatrixReference< M >::getMaxSize1 ( ) const
inline

Returns the wrapped matrix's maximum number of rows.

Returns
The maximum number of rows.

◆ getMaxSize2()

template<typename M >
SizeType CDPL::Math::MatrixReference< M >::getMaxSize2 ( ) const
inline

Returns the wrapped matrix's maximum number of columns.

Returns
The maximum number of columns.

◆ isEmpty()

template<typename M >
bool CDPL::Math::MatrixReference< M >::isEmpty ( ) const
inline

Tells whether the wrapped matrix is empty.

Returns
true if the wrapped matrix has zero rows or zero columns, and false otherwise.

◆ getData() [1/2]

template<typename M >
const MatrixType& CDPL::Math::MatrixReference< M >::getData ( ) const
inline

Returns a const reference to the wrapped matrix.

Returns
A const reference to the wrapped matrix.

◆ getData() [2/2]

template<typename M >
MatrixType& CDPL::Math::MatrixReference< M >::getData ( )
inline

Returns a reference to the wrapped matrix.

Returns
A reference to the wrapped matrix.

◆ operator=() [1/2]

template<typename M >
MatrixReference& CDPL::Math::MatrixReference< M >::operator= ( const MatrixReference< M > &  r)
inline

Copy-assigns the wrapped matrix from the matrix referenced by r.

Parameters
rThe source reference proxy.
Returns
A reference to itself.

◆ operator=() [2/2]

template<typename M >
template<typename E >
MatrixReference& CDPL::Math::MatrixReference< M >::operator= ( const MatrixExpression< E > &  e)
inline

Assigns the matrix expression e to the wrapped matrix.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ operator+=()

template<typename M >
template<typename E >
MatrixReference& CDPL::Math::MatrixReference< M >::operator+= ( const MatrixExpression< E > &  e)
inline

Adds the matrix expression e element-wise to the wrapped matrix.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ operator-=()

template<typename M >
template<typename E >
MatrixReference& CDPL::Math::MatrixReference< M >::operator-= ( const MatrixExpression< E > &  e)
inline

Subtracts the matrix expression e element-wise from the wrapped matrix.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ operator*=()

template<typename M >
template<typename T >
std::enable_if<IsScalar<T>::value, MatrixReference>::type& CDPL::Math::MatrixReference< M >::operator*= ( const T &  t)
inline

Multiplies every element of the wrapped matrix by the scalar t.

Template Parameters
TThe scalar type.
Parameters
tThe scalar multiplier.
Returns
A reference to itself.

◆ operator/=()

template<typename M >
template<typename T >
std::enable_if<IsScalar<T>::value, MatrixReference>::type& CDPL::Math::MatrixReference< M >::operator/= ( const T &  t)
inline

Divides every element of the wrapped matrix by the scalar t.

Template Parameters
TThe scalar type.
Parameters
tThe scalar divisor.
Returns
A reference to itself.

◆ assign()

template<typename M >
template<typename E >
MatrixReference& CDPL::Math::MatrixReference< M >::assign ( const MatrixExpression< E > &  e)
inline

Assigns the matrix expression e to the wrapped matrix without intermediate temporary.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ plusAssign()

template<typename M >
template<typename E >
MatrixReference& CDPL::Math::MatrixReference< M >::plusAssign ( const MatrixExpression< E > &  e)
inline

Adds the matrix expression e to the wrapped matrix without intermediate temporary.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ minusAssign()

template<typename M >
template<typename E >
MatrixReference& CDPL::Math::MatrixReference< M >::minusAssign ( const MatrixExpression< E > &  e)
inline

Subtracts the matrix expression e from the wrapped matrix without intermediate temporary.

Template Parameters
EThe source matrix expression type.
Parameters
eThe source matrix expression.
Returns
A reference to itself.

◆ swap()

template<typename M >
void CDPL::Math::MatrixReference< M >::swap ( MatrixReference< M > &  r)
inline

Swaps the contents of the two wrapped matrices.

Parameters
rThe reference proxy to swap with.

Friends And Related Function Documentation

◆ swap

template<typename M >
void swap ( MatrixReference< M > &  r1,
MatrixReference< M > &  r2 
)
friend

ADL-enabled free-function form of swap().

Parameters
r1The first reference proxy.
r2The second reference proxy.

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