LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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, bool > has (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 58 of file TensorIndices.h.

Member Typedef Documentation

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

Definition at line 62 of file TensorIndices.h.

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

Definition at line 60 of file TensorIndices.h.

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

Definition at line 64 of file TensorIndices.h.

Constructor & Destructor Documentation

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

Definition at line 68 of file TensorIndices.h.

References value.

68 : 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 73 of file TensorIndices.h.

73  : TensorIndices(*dimIter)
74  {}
TensorIndices(DimSize_t dim)
Definition: TensorIndices.h:68

Member Function Documentation

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

Definition at line 85 of file TensorIndices.h.

85 { 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 88 of file TensorIndices.h.

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

Definition at line 129 of file TensorIndices.h.

References util::size(), and util::to_string().

130  {
131  if (has(index)) return index; // good
132  throw std::out_of_range("Requested index " + std::to_string(index) +
133  " for a dimension of size " + std::to_string(size()));
134  }
bool has(Index_t index) const
Definition: TensorIndices.h:94
DimSize_t size() const
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
template<unsigned int DIM>
DimSize_t util::TensorIndices< 1U >::dim ( ) const
inline

Definition at line 110 of file TensorIndices.h.

111  {
112  static_assert(DIM == 0, "Invalid dimension requested");
113  return dimSize;
114  } // 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 138 of file TensorIndices.h.

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

Definition at line 94 of file TensorIndices.h.

References util::size().

94 { return (index >= 0) && ((DimSize_t)index < size()); }
DimSize_t size() const
TensorIndicesBasicTypes::DimSize_t DimSize_t
Definition: TensorIndices.h:62
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 97 of file TensorIndices.h.

References util::size().

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

Definition at line 117 of file TensorIndices.h.

118  {
119  static_assert(DIM == 0, "Invalid dimension requested");
120  return has(index);
121  }
bool has(Index_t index) const
Definition: TensorIndices.h:94
bool util::TensorIndices< 1U >::hasLinIndex ( LinIndex_t  linIndex) const
inline

Definition at line 123 of file TensorIndices.h.

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

Definition at line 126 of file TensorIndices.h.

References util::size(), and size().

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

Definition at line 76 of file TensorIndices.h.

References value.

76 { 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 80 of file TensorIndices.h.

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

Definition at line 125 of file TensorIndices.h.

References util::size(), and size().

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

Definition at line 66 of file TensorIndices.h.

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

Definition at line 104 of file TensorIndices.h.

Referenced by operator!=(), and operator==().

105  {
106  return (DIM == 0) ? totalSize() : dim<DIM>();
107  }
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 147 of file TensorIndices.h.

147 { 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 142 of file TensorIndices.h.

Member Data Documentation

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

size of the largest dimension

Definition at line 144 of file TensorIndices.h.


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