ROOT   6.10/09 Reference Guide
TDataPointN.icc
Go to the documentation of this file.
1 // @(#)root/mathcore:$Id: IFunction.h 24537 2008-06-25 11:01:23Z moneta$
2 // Authors: C. Gumpert 09/2011
3 /**********************************************************************
4  * *
5  * Copyright (c) 2011 , LCG ROOT MathLib Team *
6  * *
7  * *
8  **********************************************************************/
9 //
10 // impelmentation of template functions for TDataPointN class
11 //
12
13 #ifndef TDataPointN_ICC
14 #define TDataPointN_ICC
15
16 namespace ROOT
17 {
18 namespace Math
19 {
20
21
22 //////////////////////////////////////////////////////////////////////
23 //
24 // template<unsigned int _k,typename val_type> class TDataPointN
25 //
26 //////////////////////////////////////////////////////////////////////
27
28 //______________________________________________________________________________
29 template<typename _val_type>
31  m_vCoordinates(0),
32  m_fWeight(1)
33 {
34  m_vCoordinates = new _val_type[kDimension];
35  for(UInt_t k = 0; k < kDimension; ++k)
36  m_vCoordinates[k] = 0;
37 }
38
39 //______________________________________________________________________________
40 #ifndef __MAKECINT__
41 template<typename _val_type>
42 template<typename _coord_type>
43 TDataPointN<_val_type>::TDataPointN(const _coord_type* pData,_val_type fWeight):
44  m_vCoordinates(0),
45  m_fWeight(fWeight)
46 {
47  // fill coordinates
48  m_vCoordinates = new _val_type[kDimension];
49  for(unsigned int i = 0; i < kDimension; ++i)
50  m_vCoordinates[i] = pData[i];
51 }
52 #endif
53
54 //______________________________________________________________________________
55 template<typename _val_type>
57 {
58  delete [] m_vCoordinates;
59 }
60
61 //______________________________________________________________________________
62 #ifndef __MAKECINT__
63 template<typename _val_type>
64 template<typename _val>
66 {
67  _val_type fDist2 = 0;
68  for(unsigned int i = 0; i < kDimension; ++i)
69  fDist2 += pow(GetCoordinate(i) - rPoint.GetCoordinate(i),2);
70
71  return sqrt(fDist2);
72 }
73 #endif
74
75 //______________________________________________________________________________
76 template<typename _val_type>
77 inline _val_type TDataPointN<_val_type>::GetCoordinate(unsigned int iAxis) const
78 {
79  assert(iAxis < kDimension);
80  return m_vCoordinates[iAxis];
81 }
82
83 //______________________________________________________________________________
84 template<typename _val_type>
85 inline void TDataPointN<_val_type>::SetCoordinate(unsigned int iAxis,_val_type fValue)
86 {
87  assert(iAxis < kDimension);
88  m_vCoordinates[iAxis] = fValue;
89 }
90
91 //______________________________________________________________________________
92 template<typename _val_type>
93 inline bool TDataPointN<_val_type>::Less(TDataPointN<_val_type>& rPoint,unsigned int iAxis) const
94 {
95  assert(iAxis < kDimension);
96  return (m_vCoordinates[iAxis] < rPoint.GetCoordinate(iAxis));
97 }
98
99 }//namespace Math
100 }//namespace ROOT
101
102 #endif //TDataPointN_ICC
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
_val_type Distance(const TDataPointN< _val > &rPoint) const
Definition: TDataPointN.icc:65
_val_type GetCoordinate(unsigned int iAxis) const
Definition: TDataPointN.icc:77
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
bool Less(TDataPointN &rPoint, unsigned int iAxis) const
Definition: TDataPointN.icc:93
double pow(double, double)
PyObject * fValue
unsigned int UInt_t
Definition: RtypesCore.h:42
void SetCoordinate(unsigned int iAxis, value_type fValue)
Definition: TDataPointN.icc:85
Namespace for new Math classes and functions.
value_type * m_vCoordinates
Definition: TDataPointN.h:61