DASH  0.3.0
dash::CartesianSpace< NumDimensions, SizeType > Class Template Reference

Cartesian space defined by extents in n dimensions. More...

#include <Cartesian.h>

Public Types

typedef IndexType index_type
 
typedef SizeType size_type
 
typedef std::array< SizeType, NumDimensions > extents_type
 
typedef std::integral_constant< dim_t, NumDimensions > ndim
 The number of dimension in the cartesian space. More...
 

Public Member Functions

constexpr CartesianSpace ()
 Default constructor, creates a cartesian space of extent 0 in all dimensions. More...
 
template<typename... Args>
 CartesianSpace (SizeType arg, Args... args)
 Constructor, creates a cartesian index space of given extents in all dimensions. More...
 
 CartesianSpace (const extents_type &extents)
 Constructor, creates a cartesian space of given extents. More...
 
bool operator== (const self_t &other) const
 Equality comparison operator. More...
 
constexpr bool operator!= (const self_t &other) const
 Inequality comparison operator. More...
 
template<typename... Args>
void resize (SizeType arg, Args... args)
 Change the extent of the cartesian space in every dimension. More...
 
template<typename SizeType_ >
void resize (const std::array< SizeType_, NumDimensions > &extents)
 Change the extent of the cartesian space in every dimension. More...
 
void resize (dim_t dim, SizeType extent)
 Change the extent of the cartesian space in the given dimension. More...
 
constexpr dim_t rank () const noexcept
 The number of dimension in the cartesian space with extent greater than 1. More...
 
constexpr SizeType size () const noexcept
 The number of discrete elements within the space spanned by the coordinate. More...
 
constexpr const extents_type & extents () const noexcept
 Extents of the cartesian space, by dimension. More...
 
SizeType extent (dim_t dim) const
 The extent of the cartesian space in the given dimension. More...
 

Friends

template<dim_t NDim_, typename SizeType_ >
std::ostream & operator<< (std::ostream &os, const CartesianSpace< NDim_, SizeType_ > &cartesian_space)
 

Detailed Description

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
class dash::CartesianSpace< NumDimensions, SizeType >

Cartesian space defined by extents in n dimensions.

See also
DashCartesianSpaceConcept

Definition at line 26 of file Cartesian.h.

Member Typedef Documentation

◆ ndim

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
typedef std::integral_constant<dim_t, NumDimensions> dash::CartesianSpace< NumDimensions, SizeType >::ndim

The number of dimension in the cartesian space.

Definition at line 57 of file Cartesian.h.

Constructor & Destructor Documentation

◆ CartesianSpace() [1/3]

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
constexpr dash::CartesianSpace< NumDimensions, SizeType >::CartesianSpace ( )
inline

Default constructor, creates a cartesian space of extent 0 in all dimensions.

Definition at line 63 of file Cartesian.h.

64  : _size(0),
65  _rank(NumDimensions)
66  { }

◆ CartesianSpace() [2/3]

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
template<typename... Args>
dash::CartesianSpace< NumDimensions, SizeType >::CartesianSpace ( SizeType  arg,
Args...  args 
)
inline

Constructor, creates a cartesian index space of given extents in all dimensions.

Definition at line 73 of file Cartesian.h.

References dash::CartesianSpace< NumDimensions, SizeType >::resize().

74  : _size(0),
75  _rank(NumDimensions) {
76  resize(arg, args...);
77  }
void resize(SizeType arg, Args... args)
Change the extent of the cartesian space in every dimension.
Definition: Cartesian.h:116

◆ CartesianSpace() [3/3]

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
dash::CartesianSpace< NumDimensions, SizeType >::CartesianSpace ( const extents_type &  extents)
inline

Constructor, creates a cartesian space of given extents.

Definition at line 82 of file Cartesian.h.

References dash::CartesianSpace< NumDimensions, SizeType >::resize().

84  : _size(0),
85  _rank(NumDimensions) {
86  resize(extents);
87  }
void resize(SizeType arg, Args... args)
Change the extent of the cartesian space in every dimension.
Definition: Cartesian.h:116
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:171

Member Function Documentation

◆ extent()

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
SizeType dash::CartesianSpace< NumDimensions, SizeType >::extent ( dim_t  dim) const
inline

The extent of the cartesian space in the given dimension.

Parameters
dimThe dimension in the coordinate
Returns
The extent in the given dimension

Definition at line 181 of file Cartesian.h.

Referenced by dash::ShiftTilePattern< NumDimensions, Arrangement, IndexType >::ndim(), dash::SeqTilePattern< NumDimensions, Arrangement, IndexType >::ndim(), dash::CartesianSpace< NumDimensions, SizeType >::resize(), dash::CartesianIndexSpace< NumDimensions, ROW_MAJOR, dash::default_index_t >::resize(), dash::BlockPattern< 1, ROW_MAJOR, dash::default_index_t >::underfilled_blocksize(), and dash::TilePattern< NumDimensions, Arrangement, IndexType >::underfilled_blocksize().

181  {
182  DASH_ASSERT_RANGE(
183  0, dim, NumDimensions-1,
184  "Dimension for CartesianSpace::extent(dim) is out of bounds");
185  return _extents[dim];
186  }

◆ extents()

◆ operator!=()

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
constexpr bool dash::CartesianSpace< NumDimensions, SizeType >::operator!= ( const self_t other) const
inline

Inequality comparison operator.

Definition at line 108 of file Cartesian.h.

108  {
109  return !(*this == other);
110  }

◆ operator==()

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
bool dash::CartesianSpace< NumDimensions, SizeType >::operator== ( const self_t other) const
inline

Equality comparison operator.

Definition at line 92 of file Cartesian.h.

92  {
93  if (this == &other) {
94  return true;
95  }
96  for(auto i = 0; i < NumDimensions; i++) {
97  if (_extents[i] != other._extents[i]) {
98  return false;
99  }
100  }
101  // No need to compare _size as it is derived from _extents.
102  return true;
103  }

◆ rank()

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
constexpr dim_t dash::CartesianSpace< NumDimensions, SizeType >::rank ( ) const
inlinenoexcept

The number of dimension in the cartesian space with extent greater than 1.

See also
ndim
Returns
The number of dimensions in the coordinate

Definition at line 154 of file Cartesian.h.

154  {
155  return _rank;
156  }

◆ resize() [1/3]

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
template<typename... Args>
void dash::CartesianSpace< NumDimensions, SizeType >::resize ( SizeType  arg,
Args...  args 
)
inline

Change the extent of the cartesian space in every dimension.

Definition at line 116 of file Cartesian.h.

References dash::CartesianSpace< NumDimensions, SizeType >::extents().

Referenced by dash::CartesianIndexSpace< NumDimensions, ROW_MAJOR, dash::default_index_t >::CartesianIndexSpace(), dash::CartesianSpace< NumDimensions, SizeType >::CartesianSpace(), dash::CartesianSpace< NumDimensions, SizeType >::resize(), dash::CartesianIndexSpace< NumDimensions, ROW_MAJOR, dash::default_index_t >::resize(), and dash::LocalMemoryLayout< NumDimensions, Arrangement, IndexType >::resize().

116  {
117  static_assert(
118  sizeof...(Args) == NumDimensions-1,
119  "Invalid number of arguments");
120  std::array<SizeType, NumDimensions> extents =
121  {{ arg, (SizeType)(args)... }};
122  resize(extents);
123  }
void resize(SizeType arg, Args... args)
Change the extent of the cartesian space in every dimension.
Definition: Cartesian.h:116
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:171

◆ resize() [2/3]

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
template<typename SizeType_ >
void dash::CartesianSpace< NumDimensions, SizeType >::resize ( const std::array< SizeType_, NumDimensions > &  extents)
inline

Change the extent of the cartesian space in every dimension.

Definition at line 129 of file Cartesian.h.

129  {
130  // Update size:
131  _size = 1;
132  for(auto i = 0; i < NumDimensions; i++ ) {
133  _extents[i] = static_cast<SizeType>(extents[i]);
134  _size *= _extents[i];
135  }
136  }
constexpr const extents_type & extents() const noexcept
Extents of the cartesian space, by dimension.
Definition: Cartesian.h:171

◆ resize() [3/3]

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
void dash::CartesianSpace< NumDimensions, SizeType >::resize ( dim_t  dim,
SizeType  extent 
)
inline

Change the extent of the cartesian space in the given dimension.

Definition at line 141 of file Cartesian.h.

References dash::CartesianSpace< NumDimensions, SizeType >::extent(), and dash::CartesianSpace< NumDimensions, SizeType >::resize().

141  {
142  _extents[dim] = extent;
143  resize(_extents);
144  }
SizeType extent(dim_t dim) const
The extent of the cartesian space in the given dimension.
Definition: Cartesian.h:181
void resize(SizeType arg, Args... args)
Change the extent of the cartesian space in every dimension.
Definition: Cartesian.h:116

◆ size()

template<dim_t NumDimensions, typename SizeType = dash::default_size_t>
constexpr SizeType dash::CartesianSpace< NumDimensions, SizeType >::size ( ) const
inlinenoexcept

The number of discrete elements within the space spanned by the coordinate.

Returns
The number of discrete elements in the coordinate's space

Definition at line 164 of file Cartesian.h.

Referenced by dash::CartesianIndexSpace< NumDimensions, ROW_MAJOR, dash::default_index_t >::coords(), and dash::TilePattern< NumDimensions, Arrangement, IndexType >::underfilled_blocksize().

164  {
165  return _size;
166  }

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