Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:37

0001 // -*- C++ -*-
0002 // ---------------------------------------------------------------------------
0003 //
0004 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
0005 //
0006 // This is the definitions of the inline member functions of the
0007 // HepSymMatrix class
0008 //
0009 #include <stdexcept>
0010 namespace CLHEP {
0011 
0012 inline HepSymMatrix::HepSymMatrix() 
0013   : m(0), nrow(0), size_(0)
0014 {}
0015 
0016 inline int HepSymMatrix::num_row() const { return nrow;}
0017 inline int HepSymMatrix::num_col() const  { return nrow;}
0018 inline int HepSymMatrix::num_size() const  { return size_;}
0019 
0020 inline double & HepSymMatrix::fast(int row,int col)
0021 {
0022 #ifdef MATRIX_BOUND_CHECK
0023   if(row<1||row>num_row() || col<1||col>num_col())
0024     error("Range error in HepSymMatrix::fast()");
0025 #endif
0026   return *(m.begin()+(row*(row-1))/2+(col-1));
0027 }
0028 inline const double & HepSymMatrix::fast(int row,int col) const
0029 {
0030 #ifdef MATRIX_BOUND_CHECK
0031   if(row<1||row>num_row() || col<1||col>num_col())
0032     error("Range error in HepSymMatrix::fast()");
0033 #endif
0034   return *(m.begin()+(row*(row-1))/2+(col-1));
0035 }
0036 
0037 inline double & HepSymMatrix::operator()(int row, int col)
0038     {return (row>=col? fast(row,col) : fast(col,row));}
0039 inline const double & HepSymMatrix::operator()(int row, int col) const 
0040     {return (row>=col? fast(row,col) : fast(col,row));}
0041 
0042 inline void HepSymMatrix::assign(const HepSymMatrix &hm2) 
0043   {(*this)=hm2;}
0044 
0045 inline HepSymMatrix HepSymMatrix::T() const {return HepSymMatrix(*this);}
0046 
0047 inline HepSymMatrix::HepSymMatrix_row HepSymMatrix::operator[] (int r)
0048 #ifdef HEP_GNU_OPTIMIZED_RETURN
0049   return b(*this,r);
0050 {
0051 #else
0052 {
0053   HepSymMatrix_row b(*this,r);
0054 #endif
0055   return b;
0056 }
0057 
0058 inline HepSymMatrix::HepSymMatrix_row_const HepSymMatrix::operator[] (int r) const
0059 #ifdef HEP_GNU_OPTIMIZED_RETURN
0060   return b(*this,r);
0061 {
0062 #else
0063 {
0064   const HepSymMatrix_row_const b(*this,r);
0065 #endif
0066   return b;
0067 }
0068 
0069 inline double &HepSymMatrix::HepSymMatrix_row::operator[](int c)
0070 {
0071 #ifdef MATRIX_BOUND_CHECK
0072    if(_r<0||_r>=_a.nrow || c<0||c>=_a.nrow)
0073       error("Range error in HepSymMatrix::operator[][]");
0074 #endif
0075    if (_r >= c ) {
0076       return *(_a.m.begin() + (_r+1)*_r/2 + c);
0077    } else {
0078       return *(_a.m.begin() + (c+1)*c/2 + _r);
0079    }
0080 }
0081 
0082 inline const double &
0083 HepSymMatrix::HepSymMatrix_row_const::operator[](int c) const 
0084 {
0085 #ifdef MATRIX_BOUND_CHECK
0086    if(_r<0||_r>=_a.nrow || c<0||c>=_a.nrow)
0087       error("Range error in HepSymMatrix::operator[][]");
0088 #endif
0089    if (_r >= c ) {
0090       return *(_a.m.begin() + (_r+1)*_r/2 + c);
0091    } else {
0092       return *(_a.m.begin() + (c+1)*c/2 + _r);
0093    }
0094 }
0095 
0096 inline HepSymMatrix::HepSymMatrix_row::HepSymMatrix_row(HepSymMatrix &a,
0097                                int r) 
0098    : _a(a), _r(r)
0099 {}
0100 
0101 inline HepSymMatrix::HepSymMatrix_row_const::HepSymMatrix_row_const
0102 (const HepSymMatrix&a,int r) 
0103    : _a(a), _r(r)
0104 {}
0105 
0106 inline HepSymMatrix HepSymMatrix::inverse(int &ifail) const
0107 #ifdef HEP_GNU_OPTIMIZED_RETURN
0108      return mTmp(*this);
0109 {
0110 #else
0111 {
0112   HepSymMatrix mTmp(*this);
0113 #endif
0114   mTmp.invert(ifail);
0115   return mTmp;
0116 }
0117 
0118 inline HepSymMatrix HepSymMatrix::inverse() const {
0119   int ierr;
0120   HepSymMatrix mt=inverse(ierr);
0121   if (ierr) throw std::runtime_error("Error in HepSymMatrix inversion");
0122   return mt;
0123 }
0124 
0125 inline void HepSymMatrix::invert() {
0126   int ierr;
0127   invert(ierr);
0128   if (ierr) throw std::runtime_error("Error in HepSymMatrix inversion");
0129 }
0130 
0131 }  // namespace CLHEP
0132 
0133