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

Constant grid expression in which every cell equals the same scalar value. More...

#include <Grid.hpp>

+ Inheritance diagram for CDPL::Math::ScalarGrid< T >:

Public Types

typedef T ValueType
 The scalar value type. More...
 
typedef const T & Reference
 Reference type (always a const reference — cells are immutable). More...
 
typedef const T & ConstReference
 Constant reference type to a cell. More...
 
typedef std::size_t SizeType
 The unsigned size type. More...
 
typedef std::ptrdiff_t DifferenceType
 The signed difference type. More...
 
typedef GridReference< SelfTypeClosureType
 Closure type used when this grid appears inside another expression. More...
 
typedef const GridReference< const SelfTypeConstClosureType
 Constant closure type used when this grid appears inside another expression. More...
 
typedef Grid< T > GridTemporaryType
 Concrete temporary grid type used by expression-template machinery. More...
 
- Public Types inherited from CDPL::Math::GridContainer< ScalarGrid< T > >
typedef ScalarGrid< T > ContainerType
 The derived grid container type. More...
 
- Public Types inherited from CDPL::Math::GridExpression< E >
typedef E 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

 ScalarGrid ()
 Constructs an empty scalar grid. More...
 
 ScalarGrid (SizeType m, SizeType n, SizeType o, const ValueType &v=ValueType())
 Constructs a scalar grid of size \( m \times n \times o \) in which every cell equals v. More...
 
 ScalarGrid (const ScalarGrid &m)
 Constructs a copy of the scalar grid m. More...
 
ConstReference operator() (SizeType i) const
 Returns a const reference to the common cell value (linear-index form). More...
 
ConstReference operator() (SizeType i, SizeType j, SizeType k) const
 Returns a const reference to the common cell value (3D-index form). More...
 
bool isEmpty () const
 Tells whether the grid is empty (any axis has zero size). More...
 
SizeType getSize () const
 Returns the total cell count \( \mathrm{size}_1 \cdot \mathrm{size}_2 \cdot \mathrm{size}_3 \). More...
 
SizeType getSize1 () const
 Returns the first-axis size. More...
 
SizeType getSize2 () const
 Returns the second-axis size. More...
 
SizeType getSize3 () const
 Returns the third-axis size. More...
 
SizeType getMaxSize1 () const
 Returns the maximum representable first-axis size. More...
 
SizeType getMaxSize2 () const
 Returns the maximum representable second-axis size. More...
 
SizeType getMaxSize3 () const
 Returns the maximum representable third-axis size. More...
 
ScalarGridoperator= (const ScalarGrid &g)
 Copy-assigns the axis sizes and common value from g. More...
 
void swap (ScalarGrid &g)
 Swaps the axis sizes and common value with g. More...
 
void resize (SizeType m, SizeType n, SizeType o)
 Resizes the grid axes to (m, n, o). More...
 
- Public Member Functions inherited from CDPL::Math::GridContainer< ScalarGrid< T > >
const ContainerTypeoperator() () const
 Returns a const reference to the derived grid container. More...
 
ContainerTypeoperator() ()
 Returns a reference to the derived grid container. More...
 
- Public Member Functions inherited from CDPL::Math::GridExpression< E >
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 (ScalarGrid &g1, ScalarGrid &g2)
 ADL-enabled free-function form of swap(). More...
 

Additional Inherited Members

- Protected Member Functions inherited from CDPL::Math::GridContainer< ScalarGrid< T > >
 GridContainer ()
 
 ~GridContainer ()
 
- Protected Member Functions inherited from CDPL::Math::GridExpression< E >
 GridExpression ()
 
 ~GridExpression ()
 
- Protected Member Functions inherited from CDPL::Math::Expression< E >
 Expression ()
 
 ~Expression ()
 

Detailed Description

template<typename T>
class CDPL::Math::ScalarGrid< T >

Constant grid expression in which every cell equals the same scalar value.

Template Parameters
TThe scalar value type.

Member Typedef Documentation

◆ ValueType

template<typename T >
typedef T CDPL::Math::ScalarGrid< T >::ValueType

The scalar value type.

◆ Reference

template<typename T >
typedef const T& CDPL::Math::ScalarGrid< T >::Reference

Reference type (always a const reference — cells are immutable).

◆ ConstReference

template<typename T >
typedef const T& CDPL::Math::ScalarGrid< T >::ConstReference

Constant reference type to a cell.

◆ SizeType

template<typename T >
typedef std::size_t CDPL::Math::ScalarGrid< T >::SizeType

The unsigned size type.

◆ DifferenceType

template<typename T >
typedef std::ptrdiff_t CDPL::Math::ScalarGrid< T >::DifferenceType

The signed difference type.

◆ ClosureType

template<typename T >
typedef GridReference<SelfType> CDPL::Math::ScalarGrid< T >::ClosureType

Closure type used when this grid appears inside another expression.

◆ ConstClosureType

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

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

◆ GridTemporaryType

template<typename T >
typedef Grid<T> CDPL::Math::ScalarGrid< T >::GridTemporaryType

Concrete temporary grid type used by expression-template machinery.

Constructor & Destructor Documentation

◆ ScalarGrid() [1/3]

template<typename T >
CDPL::Math::ScalarGrid< T >::ScalarGrid ( )
inline

Constructs an empty scalar grid.

◆ ScalarGrid() [2/3]

template<typename T >
CDPL::Math::ScalarGrid< T >::ScalarGrid ( SizeType  m,
SizeType  n,
SizeType  o,
const ValueType v = ValueType() 
)
inline

Constructs a scalar grid of size \( m \times n \times o \) in which every cell equals v.

Parameters
mThe first-axis size.
nThe second-axis size.
oThe third-axis size.
vThe common cell value.

◆ ScalarGrid() [3/3]

template<typename T >
CDPL::Math::ScalarGrid< T >::ScalarGrid ( const ScalarGrid< T > &  m)
inline

Constructs a copy of the scalar grid m.

Parameters
mThe scalar grid to copy.

Member Function Documentation

◆ operator()() [1/2]

template<typename T >
ConstReference CDPL::Math::ScalarGrid< T >::operator() ( SizeType  i) const
inline

Returns a const reference to the common cell value (linear-index form).

Parameters
iThe zero-based linear index.
Returns
A const reference to the common cell value.
Exceptions
Base::IndexErrorif i is out of range.

◆ operator()() [2/2]

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

Returns a const reference to the common cell value (3D-index form).

Parameters
iThe zero-based first-axis index.
jThe zero-based second-axis index.
kThe zero-based third-axis index.
Returns
A const reference to the common cell value.
Exceptions
Base::IndexErrorif any of the indices is out of range.

◆ isEmpty()

template<typename T >
bool CDPL::Math::ScalarGrid< T >::isEmpty ( ) const
inline

Tells whether the grid is empty (any axis has zero size).

Returns
true if any axis is zero, and false otherwise.

◆ getSize()

template<typename T >
SizeType CDPL::Math::ScalarGrid< T >::getSize ( ) const
inline

Returns the total cell count \( \mathrm{size}_1 \cdot \mathrm{size}_2 \cdot \mathrm{size}_3 \).

Returns
The total number of cells.

◆ getSize1()

template<typename T >
SizeType CDPL::Math::ScalarGrid< T >::getSize1 ( ) const
inline

Returns the first-axis size.

Returns
The size along the first axis.

◆ getSize2()

template<typename T >
SizeType CDPL::Math::ScalarGrid< T >::getSize2 ( ) const
inline

Returns the second-axis size.

Returns
The size along the second axis.

◆ getSize3()

template<typename T >
SizeType CDPL::Math::ScalarGrid< T >::getSize3 ( ) const
inline

Returns the third-axis size.

Returns
The size along the third axis.

◆ getMaxSize1()

template<typename T >
SizeType CDPL::Math::ScalarGrid< T >::getMaxSize1 ( ) const
inline

Returns the maximum representable first-axis size.

Returns
The maximum first-axis size.

◆ getMaxSize2()

template<typename T >
SizeType CDPL::Math::ScalarGrid< T >::getMaxSize2 ( ) const
inline

Returns the maximum representable second-axis size.

Returns
The maximum second-axis size.

◆ getMaxSize3()

template<typename T >
SizeType CDPL::Math::ScalarGrid< T >::getMaxSize3 ( ) const
inline

Returns the maximum representable third-axis size.

Returns
The maximum third-axis size.

◆ operator=()

template<typename T >
ScalarGrid& CDPL::Math::ScalarGrid< T >::operator= ( const ScalarGrid< T > &  g)
inline

Copy-assigns the axis sizes and common value from g.

Parameters
gThe source scalar grid.
Returns
A reference to itself.

◆ swap()

template<typename T >
void CDPL::Math::ScalarGrid< T >::swap ( ScalarGrid< T > &  g)
inline

Swaps the axis sizes and common value with g.

Parameters
gThe scalar grid to swap with.

◆ resize()

template<typename T >
void CDPL::Math::ScalarGrid< T >::resize ( SizeType  m,
SizeType  n,
SizeType  o 
)
inline

Resizes the grid axes to (m, n, o).

Parameters
mThe new first-axis size.
nThe new second-axis size.
oThe new third-axis size.

Friends And Related Function Documentation

◆ swap

template<typename T >
void swap ( ScalarGrid< T > &  g1,
ScalarGrid< T > &  g2 
)
friend

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

Parameters
g1The first scalar grid.
g2The second scalar grid.

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