File indexing completed on 2025-01-18 09:54:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _DIAGMatrix_H_
0016 #define _DIAGMatrix_H_
0017
0018 #include <vector>
0019
0020 #include "CLHEP/Matrix/defs.h"
0021 #include "CLHEP/Matrix/GenMatrix.h"
0022
0023 namespace CLHEP {
0024
0025 class HepRandom;
0026
0027 class HepMatrix;
0028 class HepSymMatrix;
0029 class HepVector;
0030
0031
0032
0033
0034
0035 class HepDiagMatrix: public HepGenMatrix {
0036 public:
0037 inline HepDiagMatrix();
0038
0039
0040
0041 explicit HepDiagMatrix(int p);
0042 HepDiagMatrix(int p, int);
0043
0044
0045
0046
0047 HepDiagMatrix(int p, HepRandom &r);
0048
0049 HepDiagMatrix(const HepDiagMatrix &hm1);
0050
0051
0052 virtual ~HepDiagMatrix();
0053
0054
0055 inline int num_row() const;
0056 inline int num_col() const;
0057
0058
0059 double &operator()(int row, int col);
0060 const double &operator()(int row, int col) const;
0061
0062
0063
0064 double &fast(int row, int col);
0065 const double &fast(int row, int col) const;
0066
0067
0068
0069
0070 void assign(const HepMatrix &hm2);
0071
0072
0073 void assign(const HepSymMatrix &hm2);
0074
0075
0076 void assign(const HepDiagMatrix &hm2);
0077
0078
0079 HepDiagMatrix & operator*=(double t);
0080
0081
0082 HepDiagMatrix & operator/=(double t);
0083
0084
0085 HepDiagMatrix & operator+=( const HepDiagMatrix &hm2);
0086 HepDiagMatrix & operator-=( const HepDiagMatrix &hm2);
0087
0088
0089 HepDiagMatrix & operator=( const HepDiagMatrix &hm2);
0090
0091
0092 HepDiagMatrix operator- () const;
0093
0094
0095 HepDiagMatrix T() const;
0096
0097
0098 HepDiagMatrix apply(double (*f)(double,
0099 int, int)) const;
0100
0101
0102 HepSymMatrix similarity(const HepMatrix &hm1) const;
0103
0104 HepSymMatrix similarityT(const HepMatrix &hm1) const;
0105
0106
0107 double similarity(const HepVector &) const;
0108
0109
0110 HepDiagMatrix sub(int min_row, int max_row) const;
0111
0112 HepDiagMatrix sub(int min_row, int max_row);
0113
0114
0115
0116 void sub(int row, const HepDiagMatrix &hm1);
0117
0118
0119 HepDiagMatrix inverse(int&ierr) const;
0120
0121
0122
0123 void invert(int&ierr);
0124
0125
0126
0127
0128
0129 inline void invert();
0130
0131
0132 inline HepDiagMatrix inverse() const;
0133
0134
0135 double determinant() const;
0136
0137
0138 double trace() const;
0139
0140
0141 class HepDiagMatrix_row {
0142 public:
0143 inline HepDiagMatrix_row(HepDiagMatrix&,int);
0144 inline double & operator[](int);
0145 private:
0146 HepDiagMatrix& _a;
0147 int _r;
0148 };
0149 class HepDiagMatrix_row_const {
0150 public:
0151 inline HepDiagMatrix_row_const(const HepDiagMatrix&,int);
0152 inline const double & operator[](int) const;
0153 private:
0154 const HepDiagMatrix& _a;
0155 int _r;
0156 };
0157
0158
0159 inline HepDiagMatrix_row operator[] (int);
0160 inline HepDiagMatrix_row_const operator[] (int) const;
0161
0162
0163
0164
0165
0166 protected:
0167 inline int num_size() const;
0168
0169 private:
0170 friend class HepDiagMatrix_row;
0171 friend class HepDiagMatrix_row_const;
0172 friend class HepMatrix;
0173 friend class HepSymMatrix;
0174
0175 friend HepDiagMatrix operator*(const HepDiagMatrix &hm1,
0176 const HepDiagMatrix &hm2);
0177 friend HepDiagMatrix operator+(const HepDiagMatrix &hm1,
0178 const HepDiagMatrix &hm2);
0179 friend HepDiagMatrix operator-(const HepDiagMatrix &hm1,
0180 const HepDiagMatrix &hm2);
0181 friend HepMatrix operator*(const HepDiagMatrix &hm1, const HepMatrix &hm2);
0182 friend HepMatrix operator*(const HepMatrix &hm1, const HepDiagMatrix &hm2);
0183 friend HepVector operator*(const HepDiagMatrix &hm1, const HepVector &hm2);
0184
0185 #ifdef DISABLE_ALLOC
0186 std::vector<double > m;
0187 #else
0188 std::vector<double,Alloc<double,25> > m;
0189 #endif
0190 int nrow;
0191 #if defined(__sun) || !defined(__GNUG__)
0192
0193
0194
0195 static double zero;
0196 #else
0197 static const double zero;
0198 #endif
0199 };
0200
0201 std::ostream& operator<<(std::ostream &s, const HepDiagMatrix &q);
0202
0203
0204 HepMatrix operator*(const HepMatrix &hm1, const HepDiagMatrix &hm2);
0205 HepMatrix operator*(const HepDiagMatrix &hm1, const HepMatrix &hm2);
0206 HepDiagMatrix operator*(double t, const HepDiagMatrix &d1);
0207 HepDiagMatrix operator*(const HepDiagMatrix &d1, double t);
0208
0209
0210
0211 HepDiagMatrix operator/(const HepDiagMatrix &hm1, double t);
0212
0213
0214 HepMatrix operator+(const HepMatrix &hm1, const HepDiagMatrix &d2);
0215 HepMatrix operator+(const HepDiagMatrix &d1, const HepMatrix &hm2);
0216 HepDiagMatrix operator+(const HepDiagMatrix &hm1, const HepDiagMatrix &d2);
0217 HepSymMatrix operator+(const HepSymMatrix &s1, const HepDiagMatrix &d2);
0218 HepSymMatrix operator+(const HepDiagMatrix &d1, const HepSymMatrix &s2);
0219
0220
0221 HepMatrix operator-(const HepMatrix &hm1, const HepDiagMatrix &d2);
0222 HepMatrix operator-(const HepDiagMatrix &d1, const HepMatrix &hm2);
0223 HepDiagMatrix operator-(const HepDiagMatrix &d1, const HepDiagMatrix &d2);
0224 HepSymMatrix operator-(const HepSymMatrix &s1, const HepDiagMatrix &d2);
0225 HepSymMatrix operator-(const HepDiagMatrix &d1, const HepSymMatrix &s2);
0226
0227
0228 HepDiagMatrix dsum(const HepDiagMatrix &s1, const HepDiagMatrix &s2);
0229
0230
0231 }
0232
0233 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0234
0235 using namespace CLHEP;
0236 #endif
0237
0238 #ifndef HEP_DEBUG_INLINE
0239 #include "CLHEP/Matrix/DiagMatrix.icc"
0240 #endif
0241
0242 #endif