Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
util::TensorIndices< 1U > Class Template Reference

#include <TensorIndices.h>

Public Types

using Index_t = TensorIndicesBasicTypes::Index_t
 
using DimSize_t = TensorIndicesBasicTypes::DimSize_t
 
using LinIndex_t = TensorIndicesBasicTypes::LinIndex_t
 

Public Member Functions

 TensorIndices (DimSize_t dim)
 
template<typename ITER , typename = std::enable_if_t <std::is_convertible<decltype(*(ITER())), DimSize_t>::value, void>>
 TensorIndices (ITER dimIter)
 
LinIndex_t operator() (Index_t index) const
 
template<typename ITER >
std::enable_if_t< std::is_convertible< decltype(*(ITER())), DimSize_t >::value, LinIndex_toperator() (ITER indexIter) const
 
LinIndex_t at (Index_t index) const
 
template<typename ITER >
std::enable_if_t< std::is_convertible< decltype(*(ITER())), DimSize_t >::value, LinIndex_tat (ITER indexIter) const
 
bool has (Index_t index) const
 
template<typename ITER >
std::enable_if_t< std::is_convertible< decltype(*(ITER())), DimSize_t >::value, boolhas (ITER indexIter) const
 
template<unsigned int DIM = 0>
DimSize_t size () const
 
template<unsigned int DIM>
DimSize_t dim () const
 
template<unsigned int DIM>
bool hasIndex (Index_t index) const
 
bool hasLinIndex (LinIndex_t linIndex) const
 
bool operator== (TensorIndices< 1U > const &t) const
 
bool operator!= (TensorIndices< 1U > const &t) const
 

Static Public Member Functions

static constexpr unsigned int rank ()
 

Protected Member Functions

Index_t checkOuterIndex (Index_t index) const
 
DimSize_t dim0 () const
 Returns the size of the outer dimension. More...
 

Private Member Functions

DimSize_t totalSize () const
 Returns the total size of this tensor. More...
 

Private Attributes

DimSize_t dimSize
 size of the largest dimension More...
 

Friends

template<unsigned int R, unsigned int D>
struct details::ExtractTensorDimension
 

Detailed Description

template<>
class util::TensorIndices< 1U >

Specialisation for vector index (rank 1).

Documentation is in the general template. No public methods are added respect to it (but the minor() method is removed).

Definition at line 63 of file TensorIndices.h.

Member Typedef Documentation

using util::TensorIndices< 1U >::DimSize_t = TensorIndicesBasicTypes::DimSize_t

Definition at line 68 of file TensorIndices.h.

using util::TensorIndices< 1U >::Index_t = TensorIndicesBasicTypes::Index_t

Definition at line 66 of file TensorIndices.h.

using util::TensorIndices< 1U >::LinIndex_t = TensorIndicesBasicTypes::LinIndex_t

Definition at line 70 of file TensorIndices.h.

Constructor & Destructor Documentation

util::TensorIndices< 1U >::TensorIndices ( DimSize_t  dim)
inline

Definition at line 75 of file TensorIndices.h.

75 : dimSize(dim) {}
DimSize_t dim() const
DimSize_t dimSize
size of the largest dimension
template<typename ITER , typename = std::enable_if_t <std::is_convertible<decltype(*(ITER())), DimSize_t>::value, void>>
util::TensorIndices< 1U >::TensorIndices ( ITER  dimIter)
inline

Definition at line 82 of file TensorIndices.h.

82 : TensorIndices(*dimIter) {}
TensorIndices(DimSize_t dim)
Definition: TensorIndices.h:75

Member Function Documentation

LinIndex_t util::TensorIndices< 1U >::at ( Index_t  index) const
inline

Definition at line 92 of file TensorIndices.h.

92 { return checkOuterIndex(index); }
Index_t checkOuterIndex(Index_t index) const
template<typename ITER >
std::enable_if_t<std::is_convertible<decltype(*(ITER())), DimSize_t>::value, LinIndex_t> util::TensorIndices< 1U >::at ( ITER  indexIter) const
inline

Definition at line 97 of file TensorIndices.h.

98  { return checkOuterIndex(*indexIter); }
Index_t checkOuterIndex(Index_t index) const
Index_t util::TensorIndices< 1U >::checkOuterIndex ( Index_t  index) const
inlineprotected

Definition at line 136 of file TensorIndices.h.

137  {
138  if (has(index)) return index; // good
139  throw std::out_of_range("Requested index " + std::to_string(index)
140  + " for a dimension of size " + std::to_string(size()));
141  }
bool has(Index_t index) const
DimSize_t size() const
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
template<unsigned int DIM>
DimSize_t util::TensorIndices< 1U >::dim ( ) const
inline

Definition at line 114 of file TensorIndices.h.

115  {
116  static_assert(DIM == 0, "Invalid dimension requested");
117  return dimSize;
118  } // dim()
DimSize_t dimSize
size of the largest dimension
DimSize_t util::TensorIndices< 1U >::dim0 ( ) const
inlineprotected

Returns the size of the outer dimension.

Definition at line 145 of file TensorIndices.h.

145 { return dimSize; }
DimSize_t dimSize
size of the largest dimension
bool util::TensorIndices< 1U >::has ( Index_t  index) const
inline

Definition at line 100 of file TensorIndices.h.

101  { return (index >= 0) && ((DimSize_t) index < size()); }
DimSize_t size() const
TensorIndicesBasicTypes::DimSize_t DimSize_t
Definition: TensorIndices.h:68
template<typename ITER >
std::enable_if_t<std::is_convertible<decltype(*(ITER())), DimSize_t>::value, bool> util::TensorIndices< 1U >::has ( ITER  indexIter) const
inline

Definition at line 106 of file TensorIndices.h.

107  { return (*indexIter >= 0) && ((DimSize_t) *indexIter < size()); }
DimSize_t size() const
TensorIndicesBasicTypes::DimSize_t DimSize_t
Definition: TensorIndices.h:68
template<unsigned int DIM>
bool util::TensorIndices< 1U >::hasIndex ( Index_t  index) const
inline

Definition at line 121 of file TensorIndices.h.

122  {
123  static_assert(DIM == 0, "Invalid dimension requested");
124  return has(index);
125  }
bool has(Index_t index) const
bool util::TensorIndices< 1U >::hasLinIndex ( LinIndex_t  linIndex) const
inline

Definition at line 127 of file TensorIndices.h.

128  { return has((Index_t) linIndex); }
bool has(Index_t index) const
TensorIndicesBasicTypes::Index_t Index_t
Definition: TensorIndices.h:66
bool util::TensorIndices< 1U >::operator!= ( TensorIndices< 1U > const &  t) const
inline

Definition at line 132 of file TensorIndices.h.

133  { return t.size() != size(); }
DimSize_t size() const
LinIndex_t util::TensorIndices< 1U >::operator() ( Index_t  index) const
inline

Definition at line 85 of file TensorIndices.h.

85 { return index; }
template<typename ITER >
std::enable_if_t<std::is_convertible<decltype(*(ITER())), DimSize_t>::value, LinIndex_t> util::TensorIndices< 1U >::operator() ( ITER  indexIter) const
inline

Definition at line 90 of file TensorIndices.h.

90 { return *indexIter; }
bool util::TensorIndices< 1U >::operator== ( TensorIndices< 1U > const &  t) const
inline

Definition at line 130 of file TensorIndices.h.

131  { return t.size() == size(); }
DimSize_t size() const
static constexpr unsigned int util::TensorIndices< 1U >::rank ( )
inlinestatic

Definition at line 72 of file TensorIndices.h.

72 { return 1U; }
template<unsigned int DIM = 0>
DimSize_t util::TensorIndices< 1U >::size ( void  ) const
inline

Definition at line 111 of file TensorIndices.h.

111 { return (DIM == 0)? totalSize(): dim<DIM>(); }
DimSize_t dim() const
DimSize_t totalSize() const
Returns the total size of this tensor.
DimSize_t util::TensorIndices< 1U >::totalSize ( ) const
inlineprivate

Returns the total size of this tensor.

Definition at line 154 of file TensorIndices.h.

154 { return dim0(); }
DimSize_t dim0() const
Returns the size of the outer dimension.

Friends And Related Function Documentation

template<unsigned int R, unsigned int D>
friend struct details::ExtractTensorDimension
friend

Definition at line 149 of file TensorIndices.h.

Member Data Documentation

DimSize_t util::TensorIndices< 1U >::dimSize
private

size of the largest dimension

Definition at line 151 of file TensorIndices.h.


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