File indexing completed on 2025-01-18 09:58:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef G4ErrorSymMatrix_hh
0036 #define G4ErrorSymMatrix_hh
0037
0038 #include <vector>
0039 #include "globals.hh"
0040
0041 class G4ErrorMatrix;
0042
0043 class G4ErrorSymMatrix
0044 {
0045 public:
0046 inline G4ErrorSymMatrix();
0047
0048
0049
0050 explicit G4ErrorSymMatrix(G4int p);
0051 G4ErrorSymMatrix(G4int p, G4int);
0052
0053
0054
0055
0056 G4ErrorSymMatrix(const G4ErrorSymMatrix& m1);
0057 G4ErrorSymMatrix(G4ErrorSymMatrix&&) = default;
0058
0059
0060
0061
0062 virtual ~G4ErrorSymMatrix();
0063
0064
0065 inline G4int num_row() const;
0066 inline G4int num_col() const;
0067
0068
0069 const G4double& operator()(G4int row, G4int col) const;
0070 G4double& operator()(G4int row, G4int col);
0071
0072
0073
0074 const G4double& fast(G4int row, G4int col) const;
0075 G4double& fast(G4int row, G4int col);
0076
0077
0078
0079
0080 void assign(const G4ErrorMatrix& m2);
0081
0082
0083 void assign(const G4ErrorSymMatrix& m2);
0084
0085
0086 G4ErrorSymMatrix& operator*=(G4double t);
0087
0088
0089 G4ErrorSymMatrix& operator/=(G4double t);
0090
0091
0092 G4ErrorSymMatrix& operator+=(const G4ErrorSymMatrix& m2);
0093 G4ErrorSymMatrix& operator-=(const G4ErrorSymMatrix& m2);
0094
0095
0096 G4ErrorSymMatrix& operator=(const G4ErrorSymMatrix& m2);
0097 G4ErrorSymMatrix& operator=(G4ErrorSymMatrix&&) = default;
0098
0099
0100
0101 G4ErrorSymMatrix operator-() const;
0102
0103
0104 G4ErrorSymMatrix T() const;
0105
0106
0107 G4ErrorSymMatrix apply(G4double (*f)(G4double, G4int, G4int)) const;
0108
0109
0110 G4ErrorSymMatrix similarity(const G4ErrorMatrix& m1) const;
0111 G4ErrorSymMatrix similarity(const G4ErrorSymMatrix& m1) const;
0112
0113
0114 G4ErrorSymMatrix similarityT(const G4ErrorMatrix& m1) const;
0115
0116
0117
0118 G4ErrorSymMatrix sub(G4int min_row, G4int max_row) const;
0119
0120
0121 void sub(G4int row, const G4ErrorSymMatrix& m1);
0122
0123
0124 G4ErrorSymMatrix sub(G4int min_row, G4int max_row);
0125
0126
0127
0128 inline G4ErrorSymMatrix inverse(G4int& ifail) const;
0129
0130
0131
0132 void invert(G4int& ifail);
0133
0134
0135
0136
0137
0138 G4double determinant() const;
0139
0140
0141 G4double trace() const;
0142
0143
0144 class G4ErrorSymMatrix_row
0145 {
0146 public:
0147 inline G4ErrorSymMatrix_row(G4ErrorSymMatrix&, G4int);
0148 inline G4double& operator[](G4int);
0149
0150 private:
0151 G4ErrorSymMatrix& _a;
0152 G4int _r;
0153 };
0154 class G4ErrorSymMatrix_row_const
0155 {
0156 public:
0157 inline G4ErrorSymMatrix_row_const(const G4ErrorSymMatrix&, G4int);
0158 inline const G4double& operator[](G4int) const;
0159
0160 private:
0161 const G4ErrorSymMatrix& _a;
0162 G4int _r;
0163 };
0164
0165
0166 inline G4ErrorSymMatrix_row operator[](G4int);
0167 inline G4ErrorSymMatrix_row_const operator[](G4int) const;
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 void invertCholesky5(G4int& ifail);
0178 void invertCholesky6(G4int& ifail);
0179
0180
0181
0182
0183 void invertHaywood4(G4int& ifail);
0184 void invertHaywood5(G4int& ifail);
0185 void invertHaywood6(G4int& ifail);
0186 void invertBunchKaufman(G4int& ifail);
0187
0188 protected:
0189 inline G4int num_size() const;
0190
0191 private:
0192 friend class G4ErrorSymMatrix_row;
0193 friend class G4ErrorSymMatrix_row_const;
0194 friend class G4ErrorMatrix;
0195
0196 friend void tridiagonal(G4ErrorSymMatrix* a, G4ErrorMatrix* hsm);
0197 friend G4double condition(const G4ErrorSymMatrix& m);
0198 friend void diag_step(G4ErrorSymMatrix* t, G4int begin, G4int end);
0199 friend void diag_step(G4ErrorSymMatrix* t, G4ErrorMatrix* u, G4int begin,
0200 G4int end);
0201 friend G4ErrorMatrix diagonalize(G4ErrorSymMatrix* s);
0202 friend void house_with_update2(G4ErrorSymMatrix* a, G4ErrorMatrix* v,
0203 G4int row, G4int col);
0204
0205 friend G4ErrorSymMatrix operator+(const G4ErrorSymMatrix& m1,
0206 const G4ErrorSymMatrix& m2);
0207 friend G4ErrorSymMatrix operator-(const G4ErrorSymMatrix& m1,
0208 const G4ErrorSymMatrix& m2);
0209 friend G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1,
0210 const G4ErrorSymMatrix& m2);
0211 friend G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1,
0212 const G4ErrorMatrix& m2);
0213 friend G4ErrorMatrix operator*(const G4ErrorMatrix& m1,
0214 const G4ErrorSymMatrix& m2);
0215
0216
0217
0218
0219 std::vector<G4double> m;
0220
0221 G4int nrow;
0222 G4int size;
0223
0224 static G4ThreadLocal G4double posDefFraction5x5;
0225 static G4ThreadLocal G4double adjustment5x5;
0226 static const G4double CHOLESKY_THRESHOLD_5x5;
0227 static const G4double CHOLESKY_CREEP_5x5;
0228
0229 static G4ThreadLocal G4double posDefFraction6x6;
0230 static G4ThreadLocal G4double adjustment6x6;
0231 static const G4double CHOLESKY_THRESHOLD_6x6;
0232 static const G4double CHOLESKY_CREEP_6x6;
0233
0234 void invert4(G4int& ifail);
0235 void invert5(G4int& ifail);
0236 void invert6(G4int& ifail);
0237 };
0238
0239
0240
0241
0242
0243
0244 std::ostream& operator<<(std::ostream& s, const G4ErrorSymMatrix& q);
0245
0246
0247 G4ErrorMatrix operator*(const G4ErrorMatrix& m1, const G4ErrorSymMatrix& m2);
0248 G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1, const G4ErrorMatrix& m2);
0249 G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1, const G4ErrorSymMatrix& m2);
0250 G4ErrorSymMatrix operator*(G4double t, const G4ErrorSymMatrix& s1);
0251 G4ErrorSymMatrix operator*(const G4ErrorSymMatrix& s1, G4double t);
0252
0253
0254
0255 G4ErrorSymMatrix operator/(const G4ErrorSymMatrix& m1, G4double t);
0256
0257
0258 G4ErrorMatrix operator+(const G4ErrorMatrix& m1, const G4ErrorSymMatrix& s2);
0259 G4ErrorMatrix operator+(const G4ErrorSymMatrix& s1, const G4ErrorMatrix& m2);
0260 G4ErrorSymMatrix operator+(const G4ErrorSymMatrix& s1,
0261 const G4ErrorSymMatrix& s2);
0262
0263
0264 G4ErrorMatrix operator-(const G4ErrorMatrix& m1, const G4ErrorSymMatrix& s2);
0265 G4ErrorMatrix operator-(const G4ErrorSymMatrix& m1, const G4ErrorMatrix& m2);
0266 G4ErrorSymMatrix operator-(const G4ErrorSymMatrix& s1,
0267 const G4ErrorSymMatrix& s2);
0268
0269
0270 G4ErrorSymMatrix dsum(const G4ErrorSymMatrix& s1, const G4ErrorSymMatrix& s2);
0271
0272
0273 G4double condition(const G4ErrorSymMatrix& m);
0274
0275
0276 void diag_step(G4ErrorSymMatrix* t, G4int begin, G4int end);
0277 void diag_step(G4ErrorSymMatrix* t, G4ErrorMatrix* u, G4int begin, G4int end);
0278
0279
0280 G4ErrorMatrix diagonalize(G4ErrorSymMatrix* s);
0281
0282
0283
0284 void house_with_update2(G4ErrorSymMatrix* a, G4ErrorMatrix* v, G4int row = 1,
0285 G4int col = 1);
0286
0287
0288 void tridiagonal(G4ErrorSymMatrix* a, G4ErrorMatrix* hsm);
0289 G4ErrorMatrix tridiagonal(G4ErrorSymMatrix* a);
0290
0291
0292 #include "G4ErrorSymMatrix.icc"
0293
0294 #endif