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

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

#include <Grid.hpp>

+ Inheritance diagram for CDPL::Math::GridReference< G >:

Public Types

typedef G GridType
 The wrapped grid type. More...
 
typedef G::ValueType ValueType
 The element value type of the wrapped grid. More...
 
typedef std::conditional< std::is_const< G >::value, typename G::ConstReference, typename G::Reference >::type Reference
 Mutable reference type (degrades to ConstReference when the wrapped grid is const). More...
 
typedef G::ConstReference ConstReference
 Constant reference type to an element. More...
 
typedef G::SizeType SizeType
 The unsigned size type used by the wrapped grid. More...
 
typedef G::DifferenceType DifferenceType
 The signed difference type used by the wrapped grid. More...
 
typedef SelfType ClosureType
 Closure type used when this reference appears inside another expression. More...
 
typedef const SelfType ConstClosureType
 Constant closure type used when this reference appears inside another expression. More...
 
- Public Types inherited from CDPL::Math::GridExpression< GridReference< G > >
typedef GridReference< G > ExpressionType
 The derived grid 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

 GridReference (GridType &g)
 Constructs the reference wrapping the grid g. More...
 
Reference operator() (SizeType i)
 Returns a mutable reference to the element at the linear index i of the wrapped grid. More...
 
ConstReference operator() (SizeType i) const
 Returns a const reference to the element at the linear index i of the wrapped grid. More...
 
Reference operator() (SizeType i, SizeType j, SizeType k)
 Returns a mutable reference to the element at the (i, j, k) cell of the wrapped grid. More...
 
ConstReference operator() (SizeType i, SizeType j, SizeType k) const
 Returns a const reference to the element at the (i, j, k) cell of the wrapped grid. More...
 
SizeType getSize () const
 Returns the total number of cells of the wrapped grid. More...
 
SizeType getSize1 () const
 Returns the size of the wrapped grid along the first dimension. More...
 
SizeType getSize2 () const
 Returns the size of the wrapped grid along the second dimension. More...
 
SizeType getSize3 () const
 Returns the size of the wrapped grid along the third dimension. More...
 
SizeType getMaxSize () const
 Returns the maximum total number of cells the wrapped grid can hold. More...
 
SizeType getMaxSize1 () const
 Returns the maximum size of the wrapped grid along the first dimension. More...
 
SizeType getMaxSize2 () const
 Returns the maximum size of the wrapped grid along the second dimension. More...
 
SizeType getMaxSize3 () const
 Returns the maximum size of the wrapped grid along the third dimension. More...
 
bool isEmpty () const
 Tells whether the wrapped grid is empty (zero cells along any dimension). More...
 
const GridTypegetData () const
 Returns a const reference to the wrapped grid. More...
 
GridTypegetData ()
 Returns a mutable reference to the wrapped grid. More...
 
GridReferenceoperator= (const GridReference &r)
 Copies the cells of r into the wrapped grid. More...
 
template<typename E >
GridReferenceoperator= (const GridExpression< E > &e)
 Assigns the grid expression e to the wrapped grid. More...
 
template<typename E >
GridReferenceoperator+= (const GridExpression< E > &e)
 Adds the grid expression e cell-wise to the wrapped grid. More...
 
template<typename E >
GridReferenceoperator-= (const GridExpression< E > &e)
 Subtracts the grid expression e cell-wise from the wrapped grid. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, GridReference >::type & operator*= (const T &t)
 Multiplies every cell of the wrapped grid by the scalar t. More...
 
template<typename T >
std::enable_if< IsScalar< T >::value, GridReference >::type & operator/= (const T &t)
 Divides every cell of the wrapped grid by the scalar t. More...
 
template<typename E >
GridReferenceassign (const GridExpression< E > &e)
 Assigns the grid expression e to the wrapped grid without intermediate temporary (use only when e does not alias the wrapped grid). More...
 
template<typename E >
GridReferenceplusAssign (const GridExpression< E > &e)
 Adds the grid expression e to the wrapped grid without intermediate temporary. More...
 
template<typename E >
GridReferenceminusAssign (const GridExpression< E > &e)
 Subtracts the grid expression e from the wrapped grid without intermediate temporary. More...
 
void swap (GridReference &r)
 Swaps the contents of the wrapped grid with those of the grid wrapped by r. More...
 
- Public Member Functions inherited from CDPL::Math::GridExpression< GridReference< G > >
const ExpressionTypeoperator() () const
 Returns a const reference to the derived grid expression. More...
 
ExpressionTypeoperator() ()
 Returns a reference to the derived grid expression. More...
 

Friends

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

Additional Inherited Members

- Protected Member Functions inherited from CDPL::Math::GridExpression< GridReference< G > >
 GridExpression ()
 
 ~GridExpression ()
 
- Protected Member Functions inherited from CDPL::Math::Expression< E >
 Expression ()
 
 ~Expression ()
 

Detailed Description

template<typename G>
class CDPL::Math::GridReference< G >

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

Template Parameters
GThe wrapped grid type.

Member Typedef Documentation

◆ GridType

template<typename G >
typedef G CDPL::Math::GridReference< G >::GridType

The wrapped grid type.

◆ ValueType

template<typename G >
typedef G::ValueType CDPL::Math::GridReference< G >::ValueType

The element value type of the wrapped grid.

◆ Reference

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

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

◆ ConstReference

template<typename G >
typedef G::ConstReference CDPL::Math::GridReference< G >::ConstReference

Constant reference type to an element.

◆ SizeType

template<typename G >
typedef G::SizeType CDPL::Math::GridReference< G >::SizeType

The unsigned size type used by the wrapped grid.

◆ DifferenceType

template<typename G >
typedef G::DifferenceType CDPL::Math::GridReference< G >::DifferenceType

The signed difference type used by the wrapped grid.

◆ ClosureType

template<typename G >
typedef SelfType CDPL::Math::GridReference< G >::ClosureType

Closure type used when this reference appears inside another expression.

◆ ConstClosureType

template<typename G >
typedef const SelfType CDPL::Math::GridReference< G >::ConstClosureType

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

Constructor & Destructor Documentation

◆ GridReference()

template<typename G >
CDPL::Math::GridReference< G >::GridReference ( GridType g)
inlineexplicit

Constructs the reference wrapping the grid g.

Parameters
gThe grid to wrap.

Member Function Documentation

◆ operator()() [1/4]

template<typename G >
Reference CDPL::Math::GridReference< G >::operator() ( SizeType  i)
inline

Returns a mutable reference to the element at the linear index i of the wrapped grid.

Parameters
iThe zero-based linear index.
Returns
A mutable reference to the element.

◆ operator()() [2/4]

template<typename G >
ConstReference CDPL::Math::GridReference< G >::operator() ( SizeType  i) const
inline

Returns a const reference to the element at the linear index i of the wrapped grid.

Parameters
iThe zero-based linear index.
Returns
A const reference to the element.

◆ operator()() [3/4]

template<typename G >
Reference CDPL::Math::GridReference< G >::operator() ( SizeType  i,
SizeType  j,
SizeType  k 
)
inline

Returns a mutable reference to the element at the (i, j, k) cell of the wrapped grid.

Parameters
iThe zero-based first-dimension index.
jThe zero-based second-dimension index.
kThe zero-based third-dimension index.
Returns
A mutable reference to the element.

◆ operator()() [4/4]

template<typename G >
ConstReference CDPL::Math::GridReference< G >::operator() ( SizeType  i,
SizeType  j,
SizeType  k 
) const
inline

Returns a const reference to the element at the (i, j, k) cell of the wrapped grid.

Parameters
iThe zero-based first-dimension index.
jThe zero-based second-dimension index.
kThe zero-based third-dimension index.
Returns
A const reference to the element.

◆ getSize()

template<typename G >
SizeType CDPL::Math::GridReference< G >::getSize ( ) const
inline

Returns the total number of cells of the wrapped grid.

Returns
The wrapped grid's total cell count.

◆ getSize1()

template<typename G >
SizeType CDPL::Math::GridReference< G >::getSize1 ( ) const
inline

Returns the size of the wrapped grid along the first dimension.

Returns
The wrapped grid's first-dimension size.

◆ getSize2()

template<typename G >
SizeType CDPL::Math::GridReference< G >::getSize2 ( ) const
inline

Returns the size of the wrapped grid along the second dimension.

Returns
The wrapped grid's second-dimension size.

◆ getSize3()

template<typename G >
SizeType CDPL::Math::GridReference< G >::getSize3 ( ) const
inline

Returns the size of the wrapped grid along the third dimension.

Returns
The wrapped grid's third-dimension size.

◆ getMaxSize()

template<typename G >
SizeType CDPL::Math::GridReference< G >::getMaxSize ( ) const
inline

Returns the maximum total number of cells the wrapped grid can hold.

Returns
The wrapped grid's maximum total cell capacity.

◆ getMaxSize1()

template<typename G >
SizeType CDPL::Math::GridReference< G >::getMaxSize1 ( ) const
inline

Returns the maximum size of the wrapped grid along the first dimension.

Returns
The wrapped grid's maximum first-dimension size.

◆ getMaxSize2()

template<typename G >
SizeType CDPL::Math::GridReference< G >::getMaxSize2 ( ) const
inline

Returns the maximum size of the wrapped grid along the second dimension.

Returns
The wrapped grid's maximum second-dimension size.

◆ getMaxSize3()

template<typename G >
SizeType CDPL::Math::GridReference< G >::getMaxSize3 ( ) const
inline

Returns the maximum size of the wrapped grid along the third dimension.

Returns
The wrapped grid's maximum third-dimension size.

◆ isEmpty()

template<typename G >
bool CDPL::Math::GridReference< G >::isEmpty ( ) const
inline

Tells whether the wrapped grid is empty (zero cells along any dimension).

Returns
true if the wrapped grid is empty, and false otherwise.

◆ getData() [1/2]

template<typename G >
const GridType& CDPL::Math::GridReference< G >::getData ( ) const
inline

Returns a const reference to the wrapped grid.

Returns
A const reference to the wrapped grid.

◆ getData() [2/2]

template<typename G >
GridType& CDPL::Math::GridReference< G >::getData ( )
inline

Returns a mutable reference to the wrapped grid.

Returns
A mutable reference to the wrapped grid.

◆ operator=() [1/2]

template<typename G >
GridReference& CDPL::Math::GridReference< G >::operator= ( const GridReference< G > &  r)
inline

Copies the cells of r into the wrapped grid.

Parameters
rThe source reference.
Returns
A reference to itself.

◆ operator=() [2/2]

template<typename G >
template<typename E >
GridReference& CDPL::Math::GridReference< G >::operator= ( const GridExpression< E > &  e)
inline

Assigns the grid expression e to the wrapped grid.

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

◆ operator+=()

template<typename G >
template<typename E >
GridReference& CDPL::Math::GridReference< G >::operator+= ( const GridExpression< E > &  e)
inline

Adds the grid expression e cell-wise to the wrapped grid.

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

◆ operator-=()

template<typename G >
template<typename E >
GridReference& CDPL::Math::GridReference< G >::operator-= ( const GridExpression< E > &  e)
inline

Subtracts the grid expression e cell-wise from the wrapped grid.

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

◆ operator*=()

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

Multiplies every cell of the wrapped grid by the scalar t.

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

◆ operator/=()

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

Divides every cell of the wrapped grid by the scalar t.

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

◆ assign()

template<typename G >
template<typename E >
GridReference& CDPL::Math::GridReference< G >::assign ( const GridExpression< E > &  e)
inline

Assigns the grid expression e to the wrapped grid without intermediate temporary (use only when e does not alias the wrapped grid).

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

◆ plusAssign()

template<typename G >
template<typename E >
GridReference& CDPL::Math::GridReference< G >::plusAssign ( const GridExpression< E > &  e)
inline

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

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

◆ minusAssign()

template<typename G >
template<typename E >
GridReference& CDPL::Math::GridReference< G >::minusAssign ( const GridExpression< E > &  e)
inline

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

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

◆ swap()

template<typename G >
void CDPL::Math::GridReference< G >::swap ( GridReference< G > &  r)
inline

Swaps the contents of the wrapped grid with those of the grid wrapped by r.

Parameters
rThe reference to swap with.

Friends And Related Function Documentation

◆ swap

template<typename G >
void swap ( GridReference< G > &  r1,
GridReference< G > &  r2 
)
friend

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

Parameters
r1The first reference.
r2The second reference.

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