Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:22

0001 // @(#)root/mathcore:$Id: IFunction.h 24537 2008-06-25 11:01:23Z moneta $
0002 // Authors: C. Gumpert    09/2011
0003 /**********************************************************************
0004  *                                                                    *
0005  * Copyright (c) 2011 , LCG ROOT MathLib Team                         *
0006  *                                                                    *
0007  *                                                                    *
0008  **********************************************************************/
0009 //
0010 // implementation of template functions for TDataPointN class
0011 //
0012 
0013 #ifndef TDataPointN_ICC
0014 #define TDataPointN_ICC
0015 
0016 namespace ROOT
0017 {
0018 namespace Math
0019 {
0020 
0021 
0022 //////////////////////////////////////////////////////////////////////
0023 //
0024 // template<unsigned int _k,typename val_type> class TDataPointN
0025 //
0026 //////////////////////////////////////////////////////////////////////
0027 
0028 //______________________________________________________________________________
0029 template<typename _val_type>
0030 TDataPointN<_val_type>::TDataPointN():
0031    m_vCoordinates(nullptr),
0032    m_fWeight(1)
0033 {
0034    m_vCoordinates = new _val_type[kDimension];
0035    for(UInt_t k = 0; k < kDimension; ++k)
0036       m_vCoordinates[k] = 0;
0037 }
0038 
0039 //______________________________________________________________________________
0040 #ifndef __MAKECINT__
0041 template<typename _val_type>
0042 template<typename _coord_type>
0043 TDataPointN<_val_type>::TDataPointN(const _coord_type* pData,_val_type fWeight):
0044    m_vCoordinates(0),
0045    m_fWeight(fWeight)
0046 {
0047    // fill coordinates
0048    m_vCoordinates = new _val_type[kDimension];
0049    for(unsigned int i = 0; i < kDimension; ++i)
0050       m_vCoordinates[i] = pData[i];
0051 }
0052 #endif
0053 
0054 //______________________________________________________________________________
0055 template<typename _val_type>
0056 TDataPointN<_val_type>::~TDataPointN()
0057 {
0058    delete [] m_vCoordinates;
0059 }
0060 
0061 //______________________________________________________________________________
0062 #ifndef __MAKECINT__
0063 template<typename _val_type>
0064 template<typename _val>
0065 _val_type TDataPointN<_val_type>::Distance(const TDataPointN<_val>& rPoint) const
0066 {
0067    _val_type fDist2 = 0;
0068    for(unsigned int i = 0; i < kDimension; ++i)
0069       fDist2 += pow(GetCoordinate(i) - rPoint.GetCoordinate(i),2);
0070 
0071    return sqrt(fDist2);
0072 }
0073 #endif
0074 
0075 //______________________________________________________________________________
0076 template<typename _val_type>
0077 inline _val_type TDataPointN<_val_type>::GetCoordinate(unsigned int iAxis) const
0078 {
0079    assert(iAxis < kDimension);
0080    return m_vCoordinates[iAxis];
0081 }
0082 
0083 //______________________________________________________________________________
0084 template<typename _val_type>
0085 inline void TDataPointN<_val_type>::SetCoordinate(unsigned int iAxis,_val_type fValue)
0086 {
0087    assert(iAxis < kDimension);
0088    m_vCoordinates[iAxis] = fValue;
0089 }
0090 
0091 //______________________________________________________________________________
0092 template<typename _val_type>
0093 inline bool TDataPointN<_val_type>::Less(TDataPointN<_val_type>& rPoint,unsigned int iAxis) const
0094 {
0095    assert(iAxis < kDimension);
0096    return (m_vCoordinates[iAxis] < rPoint.GetCoordinate(iAxis));
0097 }
0098 
0099 }//namespace Math
0100 }//namespace ROOT
0101 
0102 #endif //TDataPointN_ICC