Back to home page

EIC code displayed by LXR

 
 

    


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

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