00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef _DIAGMatrix_H_
00048 #define _DIAGMatrix_H_
00049
00050 #ifdef GNUPRAGMA
00051 #pragma interface
00052 #endif
00053
00054 #include "CLHEP/Matrix/GenMatrix.h"
00055 #ifdef HEP_USE_RANDOM
00056 class HepRandom;
00057 #endif
00058
00059 #ifdef HEP_NO_INLINE_IN_DECLARATION
00060 #define inline
00061 #endif
00062
00063 class HepMatrix;
00064 class HepSymMatrix;
00065 class HepVector;
00066
00071 class HepDiagMatrix: public HepGenMatrix {
00072 public:
00073 inline HepDiagMatrix();
00074
00075
00076
00077 explicit HepDiagMatrix(int p);
00078 HepDiagMatrix(int p, int);
00079
00080
00081
00082
00083 #ifdef HEP_USE_RANDOM
00084 HepDiagMatrix(int p, HepRandom &r);
00085 #endif
00086
00087 HepDiagMatrix(const HepDiagMatrix &m1);
00088
00089
00090 virtual ~HepDiagMatrix();
00091
00092
00093 inline int num_row() const;
00094 inline int num_col() const;
00095
00096
00097 double &operator()(int row, int col);
00098 const double &operator()(int row, int col) const;
00099
00100
00101
00102 double &fast(int row, int col);
00103 const double &fast(int row, int col) const;
00104
00105
00106
00107
00108 void assign(const HepMatrix &m2);
00109
00110
00111 void assign(const HepSymMatrix &m2);
00112
00113
00114 void assign(const HepDiagMatrix &m2);
00115
00116
00117 HepDiagMatrix & operator*=(double t);
00118
00119
00120 HepDiagMatrix & operator/=(double t);
00121
00122
00123 HepDiagMatrix & operator+=( const HepDiagMatrix &m2);
00124 HepDiagMatrix & operator-=( const HepDiagMatrix &m2);
00125
00126
00127 HepDiagMatrix & operator=( const HepDiagMatrix &m2);
00128
00129
00130 HepDiagMatrix operator- () const;
00131
00132
00133 HepDiagMatrix T() const;
00134
00135
00136 HepDiagMatrix apply(double (*f)(double,
00137 int, int)) const;
00138
00139
00140 HepSymMatrix similarity(const HepMatrix &m1) const;
00141
00142 HepSymMatrix similarityT(const HepMatrix &m1) const;
00143
00144
00145 double similarity(const HepVector &) const;
00146
00147
00148 HepDiagMatrix sub(int min_row, int max_row) const;
00149
00150 #ifdef HEP_CC_NEED_SUB_WITHOUT_CONST
00151 HepDiagMatrix sub(int min_row, int max_row);
00152
00153
00154 #endif
00155
00156 void sub(int row, const HepDiagMatrix &m1);
00157
00158
00159 HepDiagMatrix inverse(int&ierr) const;
00160
00161
00162
00163 void invert(int&ierr);
00164
00165
00166
00167
00168
00169 double determinant() const;
00170
00171
00172 double trace() const;
00173
00174
00175 class HepDiagMatrix_row {
00176 public:
00177 inline HepDiagMatrix_row(HepDiagMatrix&,int);
00178 inline double & operator[](int);
00179 private:
00180 HepDiagMatrix& _a;
00181 int _r;
00182 };
00183 class HepDiagMatrix_row_const {
00184 public:
00185 inline HepDiagMatrix_row_const(const HepDiagMatrix&,int);
00186 inline const double & operator[](int) const;
00187 private:
00188 const HepDiagMatrix& _a;
00189 int _r;
00190 };
00191
00192
00193 inline HepDiagMatrix_row operator[] (int);
00194 inline HepDiagMatrix_row_const operator[] (int) const;
00195
00196
00197
00198
00199
00200 protected:
00201 inline int num_size() const;
00202
00203 private:
00204 friend class HepDiagMatrix_row;
00205 friend class HepDiagMatrix_row_const;
00206 friend class HepMatrix;
00207 friend class HepSymMatrix;
00208
00209 friend HepDiagMatrix operator*(const HepDiagMatrix &m1,
00210 const HepDiagMatrix &m2);
00211 friend HepDiagMatrix operator+(const HepDiagMatrix &m1,
00212 const HepDiagMatrix &m2);
00213 friend HepDiagMatrix operator-(const HepDiagMatrix &m1,
00214 const HepDiagMatrix &m2);
00215 friend HepMatrix operator*(const HepDiagMatrix &m1, const HepMatrix &m2);
00216 friend HepMatrix operator*(const HepMatrix &m1, const HepDiagMatrix &m2);
00217 friend HepVector operator*(const HepDiagMatrix &m1, const HepVector &m2);
00218
00219 double *m;
00220 int nrow;
00221 #if defined(__sun) || !defined(__GNUG__)
00222
00223
00224
00225 static double zero;
00226 #else
00227 static const double zero;
00228 #endif
00229 };
00230
00231 HepStd::ostream& operator<<(HepStd::ostream &s, const HepDiagMatrix &q);
00232
00233
00234 HepMatrix operator*(const HepMatrix &m1, const HepDiagMatrix &m2);
00235 HepMatrix operator*(const HepDiagMatrix &m1, const HepMatrix &m2);
00236 HepDiagMatrix operator*(double t, const HepDiagMatrix &d1);
00237 HepDiagMatrix operator*(const HepDiagMatrix &d1, double t);
00238
00239
00240
00241 HepDiagMatrix operator/(const HepDiagMatrix &m1, double t);
00242
00243
00244 HepMatrix operator+(const HepMatrix &m1, const HepDiagMatrix &d2);
00245 HepMatrix operator+(const HepDiagMatrix &d1, const HepMatrix &m2);
00246 HepDiagMatrix operator+(const HepDiagMatrix &m1, const HepDiagMatrix &d2);
00247 HepSymMatrix operator+(const HepSymMatrix &s1, const HepDiagMatrix &d2);
00248 HepSymMatrix operator+(const HepDiagMatrix &d1, const HepSymMatrix &s2);
00249
00250
00251 HepMatrix operator-(const HepMatrix &m1, const HepDiagMatrix &d2);
00252 HepMatrix operator-(const HepDiagMatrix &d1, const HepMatrix &m2);
00253 HepDiagMatrix operator-(const HepDiagMatrix &d1, const HepDiagMatrix &d2);
00254 HepSymMatrix operator-(const HepSymMatrix &s1, const HepDiagMatrix &d2);
00255 HepSymMatrix operator-(const HepDiagMatrix &d1, const HepSymMatrix &s2);
00256
00257
00258 HepDiagMatrix dsum(const HepDiagMatrix &s1, const HepDiagMatrix &s2);
00259
00260
00261 #ifdef HEP_NO_INLINE_IN_DECLARATION
00262 #undef inline
00263 #endif
00264
00265 #if defined(HEP_SHORT_NAMES)
00266 typedef HepDiagMatrix DiagMatrix;
00267 #endif
00268
00269 #ifndef HEP_DEBUG_INLINE
00270 #include "CLHEP/Matrix/DiagMatrix.icc"
00271 #endif
00272
00273 #endif