ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
TrigVSI::KDPoint< T, D > Class Template Reference

Class for k-dimensional point. More...

#include <KDPoint.h>

Collaboration diagram for TrigVSI::KDPoint< T, D >:

Public Member Functions

 KDPoint ()
 
 KDPoint (std::array< T, D > &arr)
 
 KDPoint (std::array< T, D > &&arr)
 
 KDPoint (const std::vector< T > &v)
 
 KDPoint (std::initializer_list< T > list)
 
const KDPoint< T, D > operator+ (const KDPoint< T, D > &other) const
 Add each elements except weights. More...
 
const KDPoint< T, D > operator- (const KDPoint< T, D > &other) const
 Subtract each elements except weights. More...
 
KDPoint< T, D > & operator+= (const KDPoint< T, D > &other)
 
KDPoint< T, D > & operator-= (const KDPoint< T, D > &other)
 
template<typename I >
const KDPoint< T, D > operator* (const I &other) const
 Multiply each elements except weights. More...
 
template<typename I >
const KDPoint< T, D > operator/ (const I &other) const
 Divide each elements except weights. More...
 
T & operator[] (size_t i)
 Return i-th element. More...
 
const T & operator[] (size_t i) const
 Return i-th element. More...
 
KDPoint< T, D > average (const KDPoint< T, D > &p)
 Return average point of this point and given point. More...
 
Member Accessors

Return position of the point.

const std::array< T, D > & getPos () const
 
at (size_t i) const
 Return i-th element. If given i exceeds the size, return NaN. More...
 
double getWeight () const
 Return the weight of the point. More...
 
void setWeight (double w)
 Set the weight to given value. More...
 

Static Public Member Functions

static KDPoint< T, D > average (const std::vector< KDPoint< T, D >> &)
 

Private Attributes

std::array< T, D > m_point
 
double m_weight
 

Detailed Description

template<typename T, size_t D>
class TrigVSI::KDPoint< T, D >

Class for k-dimensional point.

Template parameters

Definition at line 29 of file KDPoint.h.

Constructor & Destructor Documentation

◆ KDPoint() [1/5]

template<typename T , size_t D>
TrigVSI::KDPoint< T, D >::KDPoint ( )
inline

Definition at line 36 of file KDPoint.h.

36 : m_point( std::array<T,D>() ), m_weight(1.){};

◆ KDPoint() [2/5]

template<typename T , size_t D>
TrigVSI::KDPoint< T, D >::KDPoint ( std::array< T, D > &  arr)
inline

Definition at line 37 of file KDPoint.h.

37 : m_point(arr), m_weight(1.){};

◆ KDPoint() [3/5]

template<typename T , size_t D>
TrigVSI::KDPoint< T, D >::KDPoint ( std::array< T, D > &&  arr)
inline

Definition at line 38 of file KDPoint.h.

38 : m_point(std::move(arr)), m_weight(1.){};

◆ KDPoint() [4/5]

template<typename T , size_t D>
TrigVSI::KDPoint< T, D >::KDPoint ( const std::vector< T > &  v)
inline

Definition at line 40 of file KDPoint.h.

40  : m_weight(1.) {
41  for (size_t i = 0; i < D; i++) { if (i < v.size()) m_point[i] = v[i]; }
42  };

◆ KDPoint() [5/5]

template<typename T , size_t D>
TrigVSI::KDPoint< T, D >::KDPoint ( std::initializer_list< T >  list)
inline

Definition at line 44 of file KDPoint.h.

44  : m_weight(1.) {
45  auto bg = list.begin();
46  for (auto itr = bg; itr != bg + D; ++itr) {
47  size_t i = std::distance(bg, itr);
48  m_point[i] = *itr;
49  }
50  };

Member Function Documentation

◆ at()

template<typename T , size_t D>
T TrigVSI::KDPoint< T, D >::at ( size_t  i) const
inline

Return i-th element. If given i exceeds the size, return NaN.

Definition at line 128 of file KDPoint.h.

128 { return (i < D)? m_point[i] : TMath::QuietNaN(); };

◆ average() [1/2]

template<typename T , size_t D>
KDPoint<T,D> TrigVSI::KDPoint< T, D >::average ( const KDPoint< T, D > &  p)
inline

Return average point of this point and given point.

Definition at line 137 of file KDPoint.h.

138  {
139  KDPoint<T,D> tmp;
140  tmp = ( *this * this->m_weight + p * p.m_weight ) / ( this->m_weight + p.m_weight );
141  return tmp;
142  };

◆ average() [2/2]

template<typename T , size_t D>
static KDPoint<T, D> TrigVSI::KDPoint< T, D >::average ( const std::vector< KDPoint< T, D >> &  )
inlinestatic

◆ getPos()

template<typename T , size_t D>
const std::array<T,D>& TrigVSI::KDPoint< T, D >::getPos ( ) const
inline

Definition at line 125 of file KDPoint.h.

125 { return m_point; };

◆ getWeight()

template<typename T , size_t D>
double TrigVSI::KDPoint< T, D >::getWeight ( ) const
inline

Return the weight of the point.

Definition at line 131 of file KDPoint.h.

131 { return m_weight; };

◆ operator*()

template<typename T , size_t D>
template<typename I >
const KDPoint<T,D> TrigVSI::KDPoint< T, D >::operator* ( const I &  other) const
inline

Multiply each elements except weights.

Definition at line 90 of file KDPoint.h.

91  {
92  std::array<T,D> tmp;
93  for ( size_t i = 0; i < D; i++ ) {
94  tmp[i] = this->m_point[i] * other;
95  }
96  return KDPoint<T,D>(tmp);
97  }

◆ operator+()

template<typename T , size_t D>
const KDPoint<T,D> TrigVSI::KDPoint< T, D >::operator+ ( const KDPoint< T, D > &  other) const
inline

Add each elements except weights.

Definition at line 53 of file KDPoint.h.

54  {
55  std::array<T,D> tmp;
56  for ( size_t i = 0; i < D; i++ ) {
57  tmp[i] = this->m_point[i] + other.m_point[i];
58  }
59  return KDPoint<T,D>(tmp);
60  };

◆ operator+=()

template<typename T , size_t D>
KDPoint<T,D>& TrigVSI::KDPoint< T, D >::operator+= ( const KDPoint< T, D > &  other)
inline

Definition at line 72 of file KDPoint.h.

73  {
74  for ( size_t i = 0; i < D; i++ ) {
75  this->m_point[i] += other.m_point.at(i);
76  }
77  return *this;
78  };

◆ operator-()

template<typename T , size_t D>
const KDPoint<T,D> TrigVSI::KDPoint< T, D >::operator- ( const KDPoint< T, D > &  other) const
inline

Subtract each elements except weights.

Definition at line 63 of file KDPoint.h.

64  {
65  std::array<T,D> tmp;
66  for ( size_t i = 0; i < D; i++ ) {
67  tmp[i] = this->m_point[i] - other.m_point[i];
68  }
69  return KDPoint<T,D>(tmp);
70  };

◆ operator-=()

template<typename T , size_t D>
KDPoint<T,D>& TrigVSI::KDPoint< T, D >::operator-= ( const KDPoint< T, D > &  other)
inline

Definition at line 80 of file KDPoint.h.

81  {
82  for ( size_t i = 0; i < D; i++ ) {
83  this->m_point[i] -= other.m_point.at(i);
84  }
85  return *this;
86  };

◆ operator/()

template<typename T , size_t D>
template<typename I >
const KDPoint<T,D> TrigVSI::KDPoint< T, D >::operator/ ( const I &  other) const
inline

Divide each elements except weights.

Definition at line 101 of file KDPoint.h.

102  {
103  std::array<T,D> tmp;
104  for ( size_t i = 0; i < D; i++ ) {
105  tmp[i] = this->m_point[i] / other;
106  }
107  return KDPoint<T,D>(tmp);
108  }

◆ operator[]() [1/2]

template<typename T , size_t D>
T& TrigVSI::KDPoint< T, D >::operator[] ( size_t  i)
inline

Return i-th element.

Definition at line 111 of file KDPoint.h.

112  {
113  return m_point[i];
114  };

◆ operator[]() [2/2]

template<typename T , size_t D>
const T& TrigVSI::KDPoint< T, D >::operator[] ( size_t  i) const
inline

Return i-th element.

Definition at line 117 of file KDPoint.h.

118  {
119  return m_point[i];
120  };

◆ setWeight()

template<typename T , size_t D>
void TrigVSI::KDPoint< T, D >::setWeight ( double  w)
inline

Set the weight to given value.

Definition at line 133 of file KDPoint.h.

133 { m_weight = w; };

Member Data Documentation

◆ m_point

template<typename T , size_t D>
std::array<T,D> TrigVSI::KDPoint< T, D >::m_point
private

Definition at line 31 of file KDPoint.h.

◆ m_weight

template<typename T , size_t D>
double TrigVSI::KDPoint< T, D >::m_weight
private

Definition at line 32 of file KDPoint.h.


The documentation for this class was generated from the following file:
StandaloneBunchgroupHandler.bg
bg
Definition: StandaloneBunchgroupHandler.py:243
TrigVSI::KDPoint::m_point
std::array< T, D > m_point
Definition: KDPoint.h:31
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
python.PyAthena.v
v
Definition: PyAthena.py:154
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
TrigVSI::KDPoint::m_weight
double m_weight
Definition: KDPoint.h:32
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54