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 software written by Nobu Katayama and Mike Smyth, Cornell University.
0007 //
0008 // This is the definitions of the inline member functions of the
0009 // HepMatrix class
0010 //
0011 #include <stdexcept>
0012 namespace CLHEP {
0013 
0014 inline HepMatrix::HepMatrix()
0015   : m(0), nrow(0), ncol(0), size_(0) {}
0016 
0017 inline HepMatrix::HepMatrix_row HepMatrix::operator[] (int r)
0018 #ifdef HEP_GNU_OPTIMIZED_RETURN
0019   return b(*this,r);
0020 {
0021 #else
0022 {
0023   HepMatrix_row b(*this,r);
0024 #endif
0025   return b;
0026 }
0027 
0028 inline const HepMatrix::HepMatrix_row_const HepMatrix::operator[] (int r) const
0029 #ifdef HEP_GNU_OPTIMIZED_RETURN
0030   return b(*this,r);
0031 {
0032 #else
0033 {
0034   HepMatrix_row_const b(*this,r);
0035 #endif
0036   return b;
0037 }
0038 
0039 inline double &HepMatrix::HepMatrix_row::operator[](int c) {
0040 #ifdef MATRIX_BOUND_CHECK
0041   if (_r<0 || _r>=_a.num_row() || c<0 || c>=_a.num_col())
0042     HepGenMatrix::error("Range error in HepMatrix::operator[][]");
0043 #endif
0044   return *(_a.m.begin()+_r*_a.ncol+c);
0045 }
0046 
0047 inline const double &HepMatrix::HepMatrix_row_const::operator[](int c) const
0048 {
0049 #ifdef MATRIX_BOUND_CHECK
0050   if (_r<0 || _r>=_a.num_row() || c<0 || c>=_a.num_col())
0051     HepGenMatrix::error("Range error in HepMatrix::operator[][]");
0052 #endif
0053   return *(_a.m.begin()+_r*_a.ncol+c);
0054 }
0055 
0056 inline HepMatrix::HepMatrix_row::HepMatrix_row(HepMatrix&a,int r) 
0057 : _a(a) {
0058   _r = r;
0059 }
0060 
0061 inline HepMatrix::HepMatrix_row_const::HepMatrix_row_const 
0062 (const HepMatrix&a, int r) 
0063    : _a(a) 
0064 {
0065   _r = r;
0066 }
0067 
0068 // This function swaps two Matrices without doing a full copy.
0069 inline void swap(HepMatrix &hm1,HepMatrix &hm2) {
0070   HepGenMatrix::swap(hm1.m,hm2.m);
0071 /*** commented
0072   HepGenMatrix::swap(hm1.nrow,hm2.nrow);
0073   HepGenMatrix::swap(hm1.ncol,hm2.ncol);
0074   HepGenMatrix::swap(hm1.size_,hm2.size_);
0075 */
0076 }
0077 
0078   /*-ap inline */ HepMatrix HepMatrix::inverse(int &ierr) const
0079 #ifdef HEP_GNU_OPTIMIZED_RETURN
0080   return mTmp(*this);
0081 {
0082 #else
0083 {
0084   HepMatrix mTmp(*this);
0085 #endif
0086   mTmp.invert(ierr);
0087   return mTmp;
0088 }
0089 
0090 inline HepMatrix HepMatrix::inverse() const {
0091   int ierr;
0092   HepMatrix mt=inverse(ierr);
0093   if (ierr) throw std::runtime_error("Error in HepMatrix inversion");
0094   return mt;
0095 }
0096 
0097 inline void HepMatrix::invert() {
0098   int ierr;
0099   invert(ierr);
0100   if (ierr) throw std::runtime_error("Error in HepMatrix inversion");
0101 }
0102 
0103 }  // namespace CLHEP
0104