LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 64 of file TensorIndices.h.

Member Typedef Documentation

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

Definition at line 69 of file TensorIndices.h.

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

Definition at line 67 of file TensorIndices.h.

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

Definition at line 71 of file TensorIndices.h.

Constructor & Destructor Documentation

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

Definition at line 76 of file TensorIndices.h.

References fhicl::detail::atom::value().

76 : 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 83 of file TensorIndices.h.

83 : TensorIndices(*dimIter) {}
TensorIndices(DimSize_t dim)
Definition: TensorIndices.h:76

Member Function Documentation

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

Definition at line 93 of file TensorIndices.h.

93 { 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 98 of file TensorIndices.h.

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

Definition at line 137 of file TensorIndices.h.

References util::flags::to_string().

138  {
139  if (has(index)) return index; // good
140  throw std::out_of_range("Requested index " + std::to_string(index)
141  + " for a dimension of size " + std::to_string(size()));
142  }
bool has(Index_t index) const
DimSize_t size() const
std::string to_string(Flag_t< Storage > const flag)
Convert a flag into a stream (shows its index).
Definition: BitMask.h:187
template<unsigned int DIM>
DimSize_t util::TensorIndices< 1U >::dim ( ) const
inline

Definition at line 115 of file TensorIndices.h.

116  {
117  static_assert(DIM == 0, "Invalid dimension requested");
118  return dimSize;
119  } // 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 146 of file TensorIndices.h.

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

Definition at line 101 of file TensorIndices.h.

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

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

Definition at line 122 of file TensorIndices.h.

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

Definition at line 128 of file TensorIndices.h.

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

Definition at line 133 of file TensorIndices.h.

References size().

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

Definition at line 86 of file TensorIndices.h.

86 { 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 91 of file TensorIndices.h.

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

Definition at line 131 of file TensorIndices.h.

References size().

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

Definition at line 73 of file TensorIndices.h.

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

Definition at line 112 of file TensorIndices.h.

Referenced by operator!=(), util::TensorIndices< DIMS >::operator()(), and operator==().

112 { 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 155 of file TensorIndices.h.

155 { 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 150 of file TensorIndices.h.

Member Data Documentation

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

size of the largest dimension

Definition at line 152 of file TensorIndices.h.


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