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