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

Matrix-expression proxy that views a strided rectangular slice of an underlying matrix. More...

#include <MatrixProxy.hpp>

+ Inheritance diagram for CDPL::Math::MatrixSlice< 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 Slice< SizeType, DifferenceTypeSliceType
 Slice type used to specify the row and column slices (start, stride, size). More...
 
- Public Types inherited from CDPL::Math::MatrixExpression< MatrixSlice< M > >
typedef MatrixSlice< 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

 MatrixSlice (MatrixType &m, const SliceType &s1, const SliceType &s2)
 Constructs the matrix slice proxy viewing rows in s1 and columns in s2 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 slice's start index in the wrapped matrix. More...
 
SizeType getStart2 () const
 Returns the column slice's start index in the wrapped matrix. More...
 
DifferenceType getStride1 () const
 Returns the row slice's stride in the wrapped matrix. More...
 
DifferenceType getStride2 () const
 Returns the column slice's stride in the wrapped matrix. More...
 
SizeType getSize1 () const
 Returns the number of rows in the proxy (size of the row slice). More...
 
SizeType getSize2 () const
 Returns the number of columns in the proxy (size of the column slice). More...
 
bool isEmpty () const
 Tells whether the proxy is empty (either slice 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...
 
MatrixSliceoperator= (const MatrixSlice &s)
 Copy-assigns the contents of s to this matrix slice (via a temporary to handle aliasing). More...
 
template<typename E >
MatrixSliceoperator= (const MatrixExpression< E > &e)
 Assigns the elements of the matrix expression e to this matrix slice (via a temporary to handle aliasing). More...
 
template<typename E >
MatrixSliceoperator+= (const MatrixExpression< E > &e)
 Adds the elements of the matrix expression e to this matrix slice (via a temporary to handle aliasing). More...
 
template<typename E >
MatrixSliceoperator-= (const MatrixExpression< E > &e)
 Subtracts the elements of the matrix expression e from this matrix slice (via a temporary to handle aliasing). More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, MatrixSlice >::type & operator*= (const T &t)
 Multiplies every element of this matrix slice by the scalar t. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, MatrixSlice >::type & operator/= (const T &t)
 Divides every element of this matrix slice by the scalar t. More...
 
template<typename E >
MatrixSliceassign (const MatrixExpression< E > &e)
 Assigns the elements of the matrix expression e to this matrix slice without intermediate temporary. More...
 
template<typename E >
MatrixSliceplusAssign (const MatrixExpression< E > &e)
 Adds the elements of the matrix expression e to this matrix slice without intermediate temporary. More...
 
template<typename E >
MatrixSliceminusAssign (const MatrixExpression< E > &e)
 Subtracts the elements of the matrix expression e from this matrix slice without intermediate temporary. More...
 
void swap (MatrixSlice &s)
 Swaps the contents of this matrix slice with those of s (via element-wise swap of the underlying matrix elements). More...
 
- Public Member Functions inherited from CDPL::Math::MatrixExpression< MatrixSlice< 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 (MatrixSlice &s1, MatrixSlice &s2)
 ADL-enabled free-function form of swap(). More...
 

Additional Inherited Members

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

Detailed Description

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

Matrix-expression proxy that views a strided rectangular slice of an underlying matrix.

Template Parameters
MThe wrapped matrix type.

Member Typedef Documentation

◆ MatrixType

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

The wrapped matrix type.

◆ SizeType

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

The size type used by the wrapped matrix.

◆ DifferenceType

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

The signed difference type used by the wrapped matrix.

◆ ValueType

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

The element value type of the wrapped matrix.

◆ ConstReference

template<typename M >
typedef M::ConstReference CDPL::Math::MatrixSlice< 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::MatrixSlice< 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::MatrixSlice< M >::MatrixClosureType

Closure type used to store the wrapped matrix internally.

◆ ConstClosureType

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

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

◆ ClosureType

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

Closure type used when this proxy appears inside another expression.

◆ SliceType

template<typename M >
typedef Slice<SizeType, DifferenceType> CDPL::Math::MatrixSlice< M >::SliceType

Slice type used to specify the row and column slices (start, stride, size).

Constructor & Destructor Documentation

◆ MatrixSlice()

template<typename M >
CDPL::Math::MatrixSlice< M >::MatrixSlice ( MatrixType m,
const SliceType s1,
const SliceType s2 
)
inline

Constructs the matrix slice proxy viewing rows in s1 and columns in s2 of m.

Parameters
mThe wrapped matrix.
s1The row slice (start, stride, size).
s2The column slice (start, stride, size).

Member Function Documentation

◆ operator()() [1/2]

template<typename M >
Reference CDPL::Math::MatrixSlice< 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(s1(i), s2(j)).

◆ operator()() [2/2]

template<typename M >
ConstReference CDPL::Math::MatrixSlice< 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(s1(i), s2(j)).

◆ getStart1()

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

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

Returns
The start row index.

◆ getStart2()

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

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

Returns
The start column index.

◆ getStride1()

template<typename M >
DifferenceType CDPL::Math::MatrixSlice< M >::getStride1 ( ) const
inline

Returns the row slice's stride in the wrapped matrix.

Returns
The row stride.

◆ getStride2()

template<typename M >
DifferenceType CDPL::Math::MatrixSlice< M >::getStride2 ( ) const
inline

Returns the column slice's stride in the wrapped matrix.

Returns
The column stride.

◆ getSize1()

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

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

Returns
The number of rows.

◆ getSize2()

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

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

Returns
The number of columns.

◆ isEmpty()

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

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

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

◆ getData() [1/2]

template<typename M >
MatrixClosureType& CDPL::Math::MatrixSlice< 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::MatrixSlice< 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 >
MatrixSlice& CDPL::Math::MatrixSlice< M >::operator= ( const MatrixSlice< M > &  s)
inline

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

Parameters
sThe source matrix slice.
Returns
A reference to itself.

◆ operator=() [2/2]

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

Assigns the elements of the matrix expression e to this matrix slice (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 >
MatrixSlice& CDPL::Math::MatrixSlice< M >::operator+= ( const MatrixExpression< E > &  e)
inline

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

Subtracts the elements of the matrix expression e from this matrix slice (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, MatrixSlice>::type& CDPL::Math::MatrixSlice< M >::operator*= ( const T &  t)
inline

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

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

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

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

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

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

Parameters
sThe matrix slice to swap with.

Friends And Related Function Documentation

◆ swap

template<typename M >
void swap ( MatrixSlice< M > &  s1,
MatrixSlice< M > &  s2 
)
friend

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

Parameters
s1The first matrix slice.
s2The second matrix slice.

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