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

Matrix-expression proxy that views a contiguous rectangular subrange of an underlying matrix. More...

#include <MatrixProxy.hpp>

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

Public Types

typedef M MatrixType
 The wrapped matrix type. More...
 
typedef M::SizeType SizeType
 The size type used by the wrapped matrix. More...
 
typedef M::DifferenceType DifferenceType
 The signed difference type used by the wrapped matrix. More...
 
typedef M::ValueType ValueType
 The element value type of the wrapped matrix. More...
 
typedef M::ConstReference ConstReference
 Constant reference type to an element. 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 std::conditional< std::is_const< M >::value, typename M::ConstClosureType, typename M::ClosureType >::type MatrixClosureType
 Closure type used to store the wrapped matrix internally. More...
 
typedef const SelfType ConstClosureType
 Constant closure type used when this proxy appears inside another expression. More...
 
typedef SelfType ClosureType
 Closure type used when this proxy appears inside another expression. More...
 
typedef Range< SizeTypeRangeType
 Range type used to specify the row and column index ranges. More...
 
- Public Types inherited from CDPL::Math::MatrixExpression< MatrixRange< M > >
typedef MatrixRange< 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

 MatrixRange (MatrixType &m, const RangeType &r1, const RangeType &r2)
 Constructs the matrix range proxy viewing rows in r1 and columns in r2 of m. More...
 
Reference operator() (SizeType i, SizeType j)
 Returns a mutable reference to the element at proxy index (i, j). More...
 
ConstReference operator() (SizeType i, SizeType j) const
 Returns a const reference to the element at proxy index (i, j). More...
 
SizeType getStart1 () const
 Returns the row index range's start index in the wrapped matrix. More...
 
SizeType getStart2 () const
 Returns the column index range's start index in the wrapped matrix. More...
 
SizeType getSize1 () const
 Returns the number of rows in the proxy (size of the row range). More...
 
SizeType getSize2 () const
 Returns the number of columns in the proxy (size of the column range). More...
 
bool isEmpty () const
 Tells whether the proxy is empty (either range has size zero). More...
 
MatrixClosureTypegetData ()
 Returns a reference to the wrapped matrix (via its stored closure). More...
 
const MatrixClosureTypegetData () const
 Returns a const reference to the wrapped matrix (via its stored closure). More...
 
MatrixRangeoperator= (const MatrixRange &r)
 Copy-assigns the contents of r to this matrix range (via a temporary to handle aliasing). More...
 
template<typename E >
MatrixRangeoperator= (const MatrixExpression< E > &e)
 Assigns the elements of the matrix expression e to this matrix range (via a temporary to handle aliasing). More...
 
template<typename E >
MatrixRangeoperator+= (const MatrixExpression< E > &e)
 Adds the elements of the matrix expression e to this matrix range (via a temporary to handle aliasing). More...
 
template<typename E >
MatrixRangeoperator-= (const MatrixExpression< E > &e)
 Subtracts the elements of the matrix expression e from this matrix range (via a temporary to handle aliasing). More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, MatrixRange >::type & operator*= (const T &t)
 Multiplies every element of this matrix range by the scalar t. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, MatrixRange >::type & operator/= (const T &t)
 Divides every element of this matrix range by the scalar t. More...
 
template<typename E >
MatrixRangeassign (const MatrixExpression< E > &e)
 Assigns the elements of the matrix expression e to this matrix range without intermediate temporary. More...
 
template<typename E >
MatrixRangeplusAssign (const MatrixExpression< E > &e)
 Adds the elements of the matrix expression e to this matrix range without intermediate temporary. More...
 
template<typename E >
MatrixRangeminusAssign (const MatrixExpression< E > &e)
 Subtracts the elements of the matrix expression e from this matrix range without intermediate temporary. More...
 
void swap (MatrixRange &r)
 Swaps the contents of this matrix range with those of r (via element-wise swap of the underlying matrix elements). More...
 
- Public Member Functions inherited from CDPL::Math::MatrixExpression< MatrixRange< 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 (MatrixRange &r1, MatrixRange &r2)
 ADL-enabled free-function form of swap(). More...
 

Additional Inherited Members

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

Detailed Description

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

Matrix-expression proxy that views a contiguous rectangular subrange of an underlying matrix.

Template Parameters
MThe wrapped matrix type.

Member Typedef Documentation

◆ MatrixType

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

The wrapped matrix type.

◆ SizeType

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

The size type used by the wrapped matrix.

◆ DifferenceType

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

The signed difference type used by the wrapped matrix.

◆ ValueType

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

The element value type of the wrapped matrix.

◆ ConstReference

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

Constant reference type to an element.

◆ Reference

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

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

◆ MatrixClosureType

template<typename M >
typedef std::conditional<std::is_const<M>::value, typename M::ConstClosureType, typename M::ClosureType>::type CDPL::Math::MatrixRange< M >::MatrixClosureType

Closure type used to store the wrapped matrix internally.

◆ ConstClosureType

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

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

◆ ClosureType

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

Closure type used when this proxy appears inside another expression.

◆ RangeType

template<typename M >
typedef Range<SizeType> CDPL::Math::MatrixRange< M >::RangeType

Range type used to specify the row and column index ranges.

Constructor & Destructor Documentation

◆ MatrixRange()

template<typename M >
CDPL::Math::MatrixRange< M >::MatrixRange ( MatrixType m,
const RangeType r1,
const RangeType r2 
)
inline

Constructs the matrix range proxy viewing rows in r1 and columns in r2 of m.

Parameters
mThe wrapped matrix.
r1The row index range.
r2The column index range.

Member Function Documentation

◆ operator()() [1/2]

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

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

Parameters
iThe zero-based proxy row index.
jThe zero-based proxy column index.
Returns
A mutable reference to the underlying element m(r1(i), r2(j)).

◆ operator()() [2/2]

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

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

Parameters
iThe zero-based proxy row index.
jThe zero-based proxy column index.
Returns
A const reference to the underlying element m(r1(i), r2(j)).

◆ getStart1()

template<typename M >
SizeType CDPL::Math::MatrixRange< M >::getStart1 ( ) const
inline

Returns the row index range's start index in the wrapped matrix.

Returns
The start row index.

◆ getStart2()

template<typename M >
SizeType CDPL::Math::MatrixRange< M >::getStart2 ( ) const
inline

Returns the column index range's start index in the wrapped matrix.

Returns
The start column index.

◆ getSize1()

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

Returns the number of rows in the proxy (size of the row range).

Returns
The number of rows.

◆ getSize2()

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

Returns the number of columns in the proxy (size of the column range).

Returns
The number of columns.

◆ isEmpty()

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

Tells whether the proxy is empty (either range has size zero).

Returns
true if either range has zero size, and false otherwise.

◆ getData() [1/2]

template<typename M >
MatrixClosureType& CDPL::Math::MatrixRange< M >::getData ( )
inline

Returns a reference to the wrapped matrix (via its stored closure).

Returns
A reference to the wrapped matrix closure.

◆ getData() [2/2]

template<typename M >
const MatrixClosureType& CDPL::Math::MatrixRange< M >::getData ( ) const
inline

Returns a const reference to the wrapped matrix (via its stored closure).

Returns
A const reference to the wrapped matrix closure.

◆ operator=() [1/2]

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

Copy-assigns the contents of r to this matrix range (via a temporary to handle aliasing).

Parameters
rThe source matrix range.
Returns
A reference to itself.

◆ operator=() [2/2]

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

Assigns the elements of the matrix expression e to this matrix range (via a temporary to handle aliasing).

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

◆ operator+=()

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

Adds the elements of the matrix expression e to this matrix range (via a temporary to handle aliasing).

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

◆ operator-=()

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

Subtracts the elements of the matrix expression e from this matrix range (via a temporary to handle aliasing).

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, MatrixRange>::type& CDPL::Math::MatrixRange< M >::operator*= ( const T &  t)
inline

Multiplies every element of this matrix range 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, MatrixRange>::type& CDPL::Math::MatrixRange< M >::operator/= ( const T &  t)
inline

Divides every element of this matrix range 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 >
MatrixRange& CDPL::Math::MatrixRange< M >::assign ( const MatrixExpression< E > &  e)
inline

Assigns the elements of the matrix expression e to this matrix range 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 >
MatrixRange& CDPL::Math::MatrixRange< M >::plusAssign ( const MatrixExpression< E > &  e)
inline

Adds the elements of the matrix expression e to this matrix range 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 >
MatrixRange& CDPL::Math::MatrixRange< M >::minusAssign ( const MatrixExpression< E > &  e)
inline

Subtracts the elements of the matrix expression e from this matrix range 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::MatrixRange< M >::swap ( MatrixRange< M > &  r)
inline

Swaps the contents of this matrix range with those of r (via element-wise swap of the underlying matrix elements).

Parameters
rThe matrix range to swap with.

Friends And Related Function Documentation

◆ swap

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

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

Parameters
r1The first matrix range.
r2The second matrix range.

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