CLHEP 2.4.7.1
C++ Class Library for High Energy Physics
DiagMatrix.icc
Go to the documentation of this file.
1// -*- C++ -*-
2// ---------------------------------------------------------------------------
3//
4// This file is a part of the CLHEP - a Class Library for High Energy Physics.
5//
6// This software written by Nobu Katayama and Mike Smyth, Cornell University.
7//
8#include <stdexcept>
9namespace CLHEP {
10
12 : m(0), nrow(0)
13{}
14
15inline int HepDiagMatrix::num_row() const { return nrow;}
16inline int HepDiagMatrix::num_col() const { return nrow;}
17inline int HepDiagMatrix::num_size() const { return nrow;}
18
19inline double & HepDiagMatrix::fast(int row,int col)
20{
21#ifdef MATRIX_BOUND_CHECK
22 if (row<1 || row>nrow || col<1 || col>nrow)
23 error("Range error in HepDiagMatrix::fast()");
24#endif
25 if (row != col)
26 error("Index error in HepDiagMatrix::fast(i,j): i != j");
27
28 return *(m.begin()+(col-1));
29}
30
31inline const double & HepDiagMatrix::fast(int row,int col) const
32{
33#ifdef MATRIX_BOUND_CHECK
34 if (row<1 || row>nrow || col<1 || col>nrow)
35 error("Range error in HepDiagMatrix::fast()");
36#endif
37 if (row == col) {
38 return *(m.begin()+(col-1));
39 } else {
40#if defined(__sun) || !defined(__GNUG__)
41//
42// Sun CC 4.0.1 has this bug.
43//
44 zero = 0;
45#endif
46 return zero;
47 }
48}
49
50inline double & HepDiagMatrix::operator()(int row, int col)
51{
52 return fast(col,row);
53}
54
55inline const double & HepDiagMatrix::operator()(int row, int col) const
56{
57 return fast(col,row);
58}
59
60inline void HepDiagMatrix::assign(const HepDiagMatrix &hm2) {(*this)=hm2;}
61
62inline HepDiagMatrix HepDiagMatrix::T() const {return HepDiagMatrix(*this);}
63
65#ifdef HEP_GNU_OPTIMIZED_RETURN
66 return b(*this,r);
67{
68#else
69{
70 HepDiagMatrix_row b(*this,r);
71#endif
72 return b;
73}
74
76#ifdef HEP_GNU_OPTIMIZED_RETURN
77 return b(*this,r);
78{
79#else
80{
81 const HepDiagMatrix_row_const b(*this,r);
82#endif
83 return b;
84}
85
87{
88 return _a.fast(_r+1, c+1);
89}
90
91inline const double&
93{
94 return _a.fast(_r+1,c+1);
95}
96
98(HepDiagMatrix& a, int r)
99 : _a(a), _r(r)
100{}
101
103(const HepDiagMatrix& a, int r)
104 : _a(a), _r(r)
105{}
106
108#ifdef HEP_GNU_OPTIMIZED_RETURN
109 return mTmp(*this);
110{
111#else
112{
113 HepDiagMatrix mTmp(*this);
114#endif
115 mTmp.invert(ierr);
116 return mTmp;
117}
118
120 int ierr;
121 HepDiagMatrix mt=inverse(ierr);
122 if (ierr) throw std::runtime_error("Error in HepDiagMatrix inversion");
123 return mt;
124}
125
127 int ierr;
128 invert(ierr);
129 if (ierr) throw std::runtime_error("Error in HepDiagMatrix inversion");
130}
131
132} // namespace CLHEP
HepDiagMatrix_row_const(const HepDiagMatrix &, int)
HepDiagMatrix_row(HepDiagMatrix &, int)
HepDiagMatrix T() const
double & fast(int row, int col)
HepDiagMatrix_row operator[](int)
void assign(const HepMatrix &hm2)
double & operator()(int row, int col)
HepDiagMatrix inverse() const
static void error(const char *s)