12#include "CLHEP/Matrix/defs.h"
13#include "CLHEP/Matrix/SymMatrix.h"
17double CLHEP_THREAD_LOCAL HepSymMatrix::posDefFraction5x5 = 1.0;
18double CLHEP_THREAD_LOCAL HepSymMatrix::posDefFraction6x6 = 1.0;
19double CLHEP_THREAD_LOCAL HepSymMatrix::adjustment5x5 = 0.0;
20double CLHEP_THREAD_LOCAL HepSymMatrix::adjustment6x6 = 0.0;
21const double HepSymMatrix::CHOLESKY_THRESHOLD_5x5 = .5;
22const double HepSymMatrix::CHOLESKY_THRESHOLD_6x6 = .2;
23const double HepSymMatrix::CHOLESKY_CREEP_5x5 = .005;
24const double HepSymMatrix::CHOLESKY_CREEP_6x6 = .002;
73void HepSymMatrix::invert5(
int & ifail) {
74 if (posDefFraction5x5 >= CHOLESKY_THRESHOLD_5x5) {
76 posDefFraction5x5 = .9*posDefFraction5x5 + .1*(1-ifail);
81 if (posDefFraction5x5 + adjustment5x5 >= CHOLESKY_THRESHOLD_5x5) {
83 posDefFraction5x5 = .9*posDefFraction5x5 + .1*(1-ifail);
90 adjustment5x5 += CHOLESKY_CREEP_5x5;
96void HepSymMatrix::invert6(
int & ifail) {
97 if (posDefFraction6x6 >= CHOLESKY_THRESHOLD_6x6) {
99 posDefFraction6x6 = .9*posDefFraction6x6 + .1*(1-ifail);
104 if (posDefFraction6x6 + adjustment6x6 >= CHOLESKY_THRESHOLD_6x6) {
106 posDefFraction6x6 = .9*posDefFraction6x6 + .1*(1-ifail);
113 adjustment6x6 += CHOLESKY_CREEP_6x6;
154 double Det3_123_012 = m[
A10]*Det2_23_12 - m[
A11]*Det2_23_02
156 double Det3_123_013 = m[
A10]*Det2_23_13 - m[
A11]*Det2_23_03
158 double Det3_123_023 = m[
A10]*Det2_23_23 - m[
A12]*Det2_23_03
160 double Det3_123_123 = m[
A11]*Det2_23_23 - m[
A12]*Det2_23_13
162 double Det3_124_012 = m[
A10]*Det2_24_12 - m[
A11]*Det2_24_02
164 double Det3_124_013 = m[
A10]*Det2_24_13 - m[
A11]*Det2_24_03
166 double Det3_124_014 = m[
A10]*Det2_24_14 - m[
A11]*Det2_24_04
168 double Det3_124_023 = m[
A10]*Det2_24_23 - m[
A12]*Det2_24_03
170 double Det3_124_024 = m[
A10]*Det2_24_24 - m[
A12]*Det2_24_04
172 double Det3_124_123 = m[
A11]*Det2_24_23 - m[
A12]*Det2_24_13
174 double Det3_124_124 = m[
A11]*Det2_24_24 - m[
A12]*Det2_24_14
176 double Det3_134_012 = m[
A10]*Det2_34_12 - m[
A11]*Det2_34_02
178 double Det3_134_013 = m[
A10]*Det2_34_13 - m[
A11]*Det2_34_03
180 double Det3_134_014 = m[
A10]*Det2_34_14 - m[
A11]*Det2_34_04
182 double Det3_134_023 = m[
A10]*Det2_34_23 - m[
A12]*Det2_34_03
184 double Det3_134_024 = m[
A10]*Det2_34_24 - m[
A12]*Det2_34_04
186 double Det3_134_034 = m[
A10]*Det2_34_34 - m[
A13]*Det2_34_04
188 double Det3_134_123 = m[
A11]*Det2_34_23 - m[
A12]*Det2_34_13
190 double Det3_134_124 = m[
A11]*Det2_34_24 - m[
A12]*Det2_34_14
192 double Det3_134_134 = m[
A11]*Det2_34_34 - m[
A13]*Det2_34_14
194 double Det3_234_012 = m[
A20]*Det2_34_12 - m[
A21]*Det2_34_02
196 double Det3_234_013 = m[
A20]*Det2_34_13 - m[
A21]*Det2_34_03
198 double Det3_234_014 = m[
A20]*Det2_34_14 - m[
A21]*Det2_34_04
200 double Det3_234_023 = m[
A20]*Det2_34_23 - m[
A22]*Det2_34_03
202 double Det3_234_024 = m[
A20]*Det2_34_24 - m[
A22]*Det2_34_04
204 double Det3_234_034 = m[
A20]*Det2_34_34 - m[
A23]*Det2_34_04
206 double Det3_234_123 = m[
A21]*Det2_34_23 - m[
A22]*Det2_34_13
208 double Det3_234_124 = m[
A21]*Det2_34_24 - m[
A22]*Det2_34_14
210 double Det3_234_134 = m[
A21]*Det2_34_34 - m[
A23]*Det2_34_14
212 double Det3_234_234 = m[
A22]*Det2_34_34 - m[
A23]*Det2_34_24
217 double Det4_0123_0123 = m[
A00]*Det3_123_123 - m[
A01]*Det3_123_023
218 + m[
A02]*Det3_123_013 - m[
A03]*Det3_123_012;
219 double Det4_0124_0123 = m[
A00]*Det3_124_123 - m[
A01]*Det3_124_023
220 + m[
A02]*Det3_124_013 - m[
A03]*Det3_124_012;
221 double Det4_0124_0124 = m[
A00]*Det3_124_124 - m[
A01]*Det3_124_024
222 + m[
A02]*Det3_124_014 - m[
A04]*Det3_124_012;
223 double Det4_0134_0123 = m[
A00]*Det3_134_123 - m[
A01]*Det3_134_023
224 + m[
A02]*Det3_134_013 - m[
A03]*Det3_134_012;
225 double Det4_0134_0124 = m[
A00]*Det3_134_124 - m[
A01]*Det3_134_024
226 + m[
A02]*Det3_134_014 - m[
A04]*Det3_134_012;
227 double Det4_0134_0134 = m[
A00]*Det3_134_134 - m[
A01]*Det3_134_034
228 + m[
A03]*Det3_134_014 - m[
A04]*Det3_134_013;
229 double Det4_0234_0123 = m[
A00]*Det3_234_123 - m[
A01]*Det3_234_023
230 + m[
A02]*Det3_234_013 - m[
A03]*Det3_234_012;
231 double Det4_0234_0124 = m[
A00]*Det3_234_124 - m[
A01]*Det3_234_024
232 + m[
A02]*Det3_234_014 - m[
A04]*Det3_234_012;
233 double Det4_0234_0134 = m[
A00]*Det3_234_134 - m[
A01]*Det3_234_034
234 + m[
A03]*Det3_234_014 - m[
A04]*Det3_234_013;
235 double Det4_0234_0234 = m[
A00]*Det3_234_234 - m[
A02]*Det3_234_034
236 + m[
A03]*Det3_234_024 - m[
A04]*Det3_234_023;
237 double Det4_1234_0123 = m[
A10]*Det3_234_123 - m[
A11]*Det3_234_023
238 + m[
A12]*Det3_234_013 - m[
A13]*Det3_234_012;
239 double Det4_1234_0124 = m[
A10]*Det3_234_124 - m[
A11]*Det3_234_024
240 + m[
A12]*Det3_234_014 - m[
A14]*Det3_234_012;
241 double Det4_1234_0134 = m[
A10]*Det3_234_134 - m[
A11]*Det3_234_034
242 + m[
A13]*Det3_234_014 - m[
A14]*Det3_234_013;
243 double Det4_1234_0234 = m[
A10]*Det3_234_234 - m[
A12]*Det3_234_034
244 + m[
A13]*Det3_234_024 - m[
A14]*Det3_234_023;
245 double Det4_1234_1234 = m[
A11]*Det3_234_234 - m[
A12]*Det3_234_134
246 + m[
A13]*Det3_234_124 - m[
A14]*Det3_234_123;
250 double det = m[
A00]*Det4_1234_1234
251 - m[
A01]*Det4_1234_0234
252 + m[
A02]*Det4_1234_0134
253 - m[
A03]*Det4_1234_0124
254 + m[
A04]*Det4_1234_0123;
257#ifdef SINGULAR_DIAGNOSTICS
258 std::cerr <<
"Kramer's rule inversion of a singular 5x5 matrix: "
265 double oneOverDet = 1.0/det;
266 double mn1OverDet = - oneOverDet;
268 m[
A00] = Det4_1234_1234 * oneOverDet;
269 m[
A01] = Det4_1234_0234 * mn1OverDet;
270 m[
A02] = Det4_1234_0134 * oneOverDet;
271 m[
A03] = Det4_1234_0124 * mn1OverDet;
272 m[
A04] = Det4_1234_0123 * oneOverDet;
274 m[
A11] = Det4_0234_0234 * oneOverDet;
275 m[
A12] = Det4_0234_0134 * mn1OverDet;
276 m[
A13] = Det4_0234_0124 * oneOverDet;
277 m[
A14] = Det4_0234_0123 * mn1OverDet;
279 m[
A22] = Det4_0134_0134 * oneOverDet;
280 m[
A23] = Det4_0134_0124 * mn1OverDet;
281 m[
A24] = Det4_0134_0123 * oneOverDet;
283 m[
A33] = Det4_0124_0124 * oneOverDet;
284 m[
A34] = Det4_0124_0123 * mn1OverDet;
286 m[
A44] = Det4_0123_0123 * oneOverDet;
339 double Det3_234_012 = m[
A20]*Det2_34_12 - m[
A21]*Det2_34_02
341 double Det3_234_013 = m[
A20]*Det2_34_13 - m[
A21]*Det2_34_03
343 double Det3_234_014 = m[
A20]*Det2_34_14 - m[
A21]*Det2_34_04
345 double Det3_234_023 = m[
A20]*Det2_34_23 - m[
A22]*Det2_34_03
347 double Det3_234_024 = m[
A20]*Det2_34_24 - m[
A22]*Det2_34_04
349 double Det3_234_034 = m[
A20]*Det2_34_34 - m[
A23]*Det2_34_04
351 double Det3_234_123 = m[
A21]*Det2_34_23 - m[
A22]*Det2_34_13
353 double Det3_234_124 = m[
A21]*Det2_34_24 - m[
A22]*Det2_34_14
355 double Det3_234_134 = m[
A21]*Det2_34_34 - m[
A23]*Det2_34_14
357 double Det3_234_234 = m[
A22]*Det2_34_34 - m[
A23]*Det2_34_24
359 double Det3_235_012 = m[
A20]*Det2_35_12 - m[
A21]*Det2_35_02
361 double Det3_235_013 = m[
A20]*Det2_35_13 - m[
A21]*Det2_35_03
363 double Det3_235_014 = m[
A20]*Det2_35_14 - m[
A21]*Det2_35_04
365 double Det3_235_015 = m[
A20]*Det2_35_15 - m[
A21]*Det2_35_05
367 double Det3_235_023 = m[
A20]*Det2_35_23 - m[
A22]*Det2_35_03
369 double Det3_235_024 = m[
A20]*Det2_35_24 - m[
A22]*Det2_35_04
371 double Det3_235_025 = m[
A20]*Det2_35_25 - m[
A22]*Det2_35_05
373 double Det3_235_034 = m[
A20]*Det2_35_34 - m[
A23]*Det2_35_04
375 double Det3_235_035 = m[
A20]*Det2_35_35 - m[
A23]*Det2_35_05
377 double Det3_235_123 = m[
A21]*Det2_35_23 - m[
A22]*Det2_35_13
379 double Det3_235_124 = m[
A21]*Det2_35_24 - m[
A22]*Det2_35_14
381 double Det3_235_125 = m[
A21]*Det2_35_25 - m[
A22]*Det2_35_15
383 double Det3_235_134 = m[
A21]*Det2_35_34 - m[
A23]*Det2_35_14
385 double Det3_235_135 = m[
A21]*Det2_35_35 - m[
A23]*Det2_35_15
387 double Det3_235_234 = m[
A22]*Det2_35_34 - m[
A23]*Det2_35_24
389 double Det3_235_235 = m[
A22]*Det2_35_35 - m[
A23]*Det2_35_25
391 double Det3_245_012 = m[
A20]*Det2_45_12 - m[
A21]*Det2_45_02
393 double Det3_245_013 = m[
A20]*Det2_45_13 - m[
A21]*Det2_45_03
395 double Det3_245_014 = m[
A20]*Det2_45_14 - m[
A21]*Det2_45_04
397 double Det3_245_015 = m[
A20]*Det2_45_15 - m[
A21]*Det2_45_05
399 double Det3_245_023 = m[
A20]*Det2_45_23 - m[
A22]*Det2_45_03
401 double Det3_245_024 = m[
A20]*Det2_45_24 - m[
A22]*Det2_45_04
403 double Det3_245_025 = m[
A20]*Det2_45_25 - m[
A22]*Det2_45_05
405 double Det3_245_034 = m[
A20]*Det2_45_34 - m[
A23]*Det2_45_04
407 double Det3_245_035 = m[
A20]*Det2_45_35 - m[
A23]*Det2_45_05
409 double Det3_245_045 = m[
A20]*Det2_45_45 - m[
A24]*Det2_45_05
411 double Det3_245_123 = m[
A21]*Det2_45_23 - m[
A22]*Det2_45_13
413 double Det3_245_124 = m[
A21]*Det2_45_24 - m[
A22]*Det2_45_14
415 double Det3_245_125 = m[
A21]*Det2_45_25 - m[
A22]*Det2_45_15
417 double Det3_245_134 = m[
A21]*Det2_45_34 - m[
A23]*Det2_45_14
419 double Det3_245_135 = m[
A21]*Det2_45_35 - m[
A23]*Det2_45_15
421 double Det3_245_145 = m[
A21]*Det2_45_45 - m[
A24]*Det2_45_15
423 double Det3_245_234 = m[
A22]*Det2_45_34 - m[
A23]*Det2_45_24
425 double Det3_245_235 = m[
A22]*Det2_45_35 - m[
A23]*Det2_45_25
427 double Det3_245_245 = m[
A22]*Det2_45_45 - m[
A24]*Det2_45_25
429 double Det3_345_012 = m[
A30]*Det2_45_12 - m[
A31]*Det2_45_02
431 double Det3_345_013 = m[
A30]*Det2_45_13 - m[
A31]*Det2_45_03
433 double Det3_345_014 = m[
A30]*Det2_45_14 - m[
A31]*Det2_45_04
435 double Det3_345_015 = m[
A30]*Det2_45_15 - m[
A31]*Det2_45_05
437 double Det3_345_023 = m[
A30]*Det2_45_23 - m[
A32]*Det2_45_03
439 double Det3_345_024 = m[
A30]*Det2_45_24 - m[
A32]*Det2_45_04
441 double Det3_345_025 = m[
A30]*Det2_45_25 - m[
A32]*Det2_45_05
443 double Det3_345_034 = m[
A30]*Det2_45_34 - m[
A33]*Det2_45_04
445 double Det3_345_035 = m[
A30]*Det2_45_35 - m[
A33]*Det2_45_05
447 double Det3_345_045 = m[
A30]*Det2_45_45 - m[
A34]*Det2_45_05
449 double Det3_345_123 = m[
A31]*Det2_45_23 - m[
A32]*Det2_45_13
451 double Det3_345_124 = m[
A31]*Det2_45_24 - m[
A32]*Det2_45_14
453 double Det3_345_125 = m[
A31]*Det2_45_25 - m[
A32]*Det2_45_15
455 double Det3_345_134 = m[
A31]*Det2_45_34 - m[
A33]*Det2_45_14
457 double Det3_345_135 = m[
A31]*Det2_45_35 - m[
A33]*Det2_45_15
459 double Det3_345_145 = m[
A31]*Det2_45_45 - m[
A34]*Det2_45_15
461 double Det3_345_234 = m[
A32]*Det2_45_34 - m[
A33]*Det2_45_24
463 double Det3_345_235 = m[
A32]*Det2_45_35 - m[
A33]*Det2_45_25
465 double Det3_345_245 = m[
A32]*Det2_45_45 - m[
A34]*Det2_45_25
467 double Det3_345_345 = m[
A33]*Det2_45_45 - m[
A34]*Det2_45_35
472 double Det4_1234_0123 = m[
A10]*Det3_234_123 - m[
A11]*Det3_234_023
473 + m[
A12]*Det3_234_013 - m[
A13]*Det3_234_012;
474 double Det4_1234_0124 = m[
A10]*Det3_234_124 - m[
A11]*Det3_234_024
475 + m[
A12]*Det3_234_014 - m[
A14]*Det3_234_012;
476 double Det4_1234_0134 = m[
A10]*Det3_234_134 - m[
A11]*Det3_234_034
477 + m[
A13]*Det3_234_014 - m[
A14]*Det3_234_013;
478 double Det4_1234_0234 = m[
A10]*Det3_234_234 - m[
A12]*Det3_234_034
479 + m[
A13]*Det3_234_024 - m[
A14]*Det3_234_023;
480 double Det4_1234_1234 = m[
A11]*Det3_234_234 - m[
A12]*Det3_234_134
481 + m[
A13]*Det3_234_124 - m[
A14]*Det3_234_123;
482 double Det4_1235_0123 = m[
A10]*Det3_235_123 - m[
A11]*Det3_235_023
483 + m[
A12]*Det3_235_013 - m[
A13]*Det3_235_012;
484 double Det4_1235_0124 = m[
A10]*Det3_235_124 - m[
A11]*Det3_235_024
485 + m[
A12]*Det3_235_014 - m[
A14]*Det3_235_012;
486 double Det4_1235_0125 = m[
A10]*Det3_235_125 - m[
A11]*Det3_235_025
487 + m[
A12]*Det3_235_015 - m[
A15]*Det3_235_012;
488 double Det4_1235_0134 = m[
A10]*Det3_235_134 - m[
A11]*Det3_235_034
489 + m[
A13]*Det3_235_014 - m[
A14]*Det3_235_013;
490 double Det4_1235_0135 = m[
A10]*Det3_235_135 - m[
A11]*Det3_235_035
491 + m[
A13]*Det3_235_015 - m[
A15]*Det3_235_013;
492 double Det4_1235_0234 = m[
A10]*Det3_235_234 - m[
A12]*Det3_235_034
493 + m[
A13]*Det3_235_024 - m[
A14]*Det3_235_023;
494 double Det4_1235_0235 = m[
A10]*Det3_235_235 - m[
A12]*Det3_235_035
495 + m[
A13]*Det3_235_025 - m[
A15]*Det3_235_023;
496 double Det4_1235_1234 = m[
A11]*Det3_235_234 - m[
A12]*Det3_235_134
497 + m[
A13]*Det3_235_124 - m[
A14]*Det3_235_123;
498 double Det4_1235_1235 = m[
A11]*Det3_235_235 - m[
A12]*Det3_235_135
499 + m[
A13]*Det3_235_125 - m[
A15]*Det3_235_123;
500 double Det4_1245_0123 = m[
A10]*Det3_245_123 - m[
A11]*Det3_245_023
501 + m[
A12]*Det3_245_013 - m[
A13]*Det3_245_012;
502 double Det4_1245_0124 = m[
A10]*Det3_245_124 - m[
A11]*Det3_245_024
503 + m[
A12]*Det3_245_014 - m[
A14]*Det3_245_012;
504 double Det4_1245_0125 = m[
A10]*Det3_245_125 - m[
A11]*Det3_245_025
505 + m[
A12]*Det3_245_015 - m[
A15]*Det3_245_012;
506 double Det4_1245_0134 = m[
A10]*Det3_245_134 - m[
A11]*Det3_245_034
507 + m[
A13]*Det3_245_014 - m[
A14]*Det3_245_013;
508 double Det4_1245_0135 = m[
A10]*Det3_245_135 - m[
A11]*Det3_245_035
509 + m[
A13]*Det3_245_015 - m[
A15]*Det3_245_013;
510 double Det4_1245_0145 = m[
A10]*Det3_245_145 - m[
A11]*Det3_245_045
511 + m[
A14]*Det3_245_015 - m[
A15]*Det3_245_014;
512 double Det4_1245_0234 = m[
A10]*Det3_245_234 - m[
A12]*Det3_245_034
513 + m[
A13]*Det3_245_024 - m[
A14]*Det3_245_023;
514 double Det4_1245_0235 = m[
A10]*Det3_245_235 - m[
A12]*Det3_245_035
515 + m[
A13]*Det3_245_025 - m[
A15]*Det3_245_023;
516 double Det4_1245_0245 = m[
A10]*Det3_245_245 - m[
A12]*Det3_245_045
517 + m[
A14]*Det3_245_025 - m[
A15]*Det3_245_024;
518 double Det4_1245_1234 = m[
A11]*Det3_245_234 - m[
A12]*Det3_245_134
519 + m[
A13]*Det3_245_124 - m[
A14]*Det3_245_123;
520 double Det4_1245_1235 = m[
A11]*Det3_245_235 - m[
A12]*Det3_245_135
521 + m[
A13]*Det3_245_125 - m[
A15]*Det3_245_123;
522 double Det4_1245_1245 = m[
A11]*Det3_245_245 - m[
A12]*Det3_245_145
523 + m[
A14]*Det3_245_125 - m[
A15]*Det3_245_124;
524 double Det4_1345_0123 = m[
A10]*Det3_345_123 - m[
A11]*Det3_345_023
525 + m[
A12]*Det3_345_013 - m[
A13]*Det3_345_012;
526 double Det4_1345_0124 = m[
A10]*Det3_345_124 - m[
A11]*Det3_345_024
527 + m[
A12]*Det3_345_014 - m[
A14]*Det3_345_012;
528 double Det4_1345_0125 = m[
A10]*Det3_345_125 - m[
A11]*Det3_345_025
529 + m[
A12]*Det3_345_015 - m[
A15]*Det3_345_012;
530 double Det4_1345_0134 = m[
A10]*Det3_345_134 - m[
A11]*Det3_345_034
531 + m[
A13]*Det3_345_014 - m[
A14]*Det3_345_013;
532 double Det4_1345_0135 = m[
A10]*Det3_345_135 - m[
A11]*Det3_345_035
533 + m[
A13]*Det3_345_015 - m[
A15]*Det3_345_013;
534 double Det4_1345_0145 = m[
A10]*Det3_345_145 - m[
A11]*Det3_345_045
535 + m[
A14]*Det3_345_015 - m[
A15]*Det3_345_014;
536 double Det4_1345_0234 = m[
A10]*Det3_345_234 - m[
A12]*Det3_345_034
537 + m[
A13]*Det3_345_024 - m[
A14]*Det3_345_023;
538 double Det4_1345_0235 = m[
A10]*Det3_345_235 - m[
A12]*Det3_345_035
539 + m[
A13]*Det3_345_025 - m[
A15]*Det3_345_023;
540 double Det4_1345_0245 = m[
A10]*Det3_345_245 - m[
A12]*Det3_345_045
541 + m[
A14]*Det3_345_025 - m[
A15]*Det3_345_024;
542 double Det4_1345_0345 = m[
A10]*Det3_345_345 - m[
A13]*Det3_345_045
543 + m[
A14]*Det3_345_035 - m[
A15]*Det3_345_034;
544 double Det4_1345_1234 = m[
A11]*Det3_345_234 - m[
A12]*Det3_345_134
545 + m[
A13]*Det3_345_124 - m[
A14]*Det3_345_123;
546 double Det4_1345_1235 = m[
A11]*Det3_345_235 - m[
A12]*Det3_345_135
547 + m[
A13]*Det3_345_125 - m[
A15]*Det3_345_123;
548 double Det4_1345_1245 = m[
A11]*Det3_345_245 - m[
A12]*Det3_345_145
549 + m[
A14]*Det3_345_125 - m[
A15]*Det3_345_124;
550 double Det4_1345_1345 = m[
A11]*Det3_345_345 - m[
A13]*Det3_345_145
551 + m[
A14]*Det3_345_135 - m[
A15]*Det3_345_134;
552 double Det4_2345_0123 = m[
A20]*Det3_345_123 - m[
A21]*Det3_345_023
553 + m[
A22]*Det3_345_013 - m[
A23]*Det3_345_012;
554 double Det4_2345_0124 = m[
A20]*Det3_345_124 - m[
A21]*Det3_345_024
555 + m[
A22]*Det3_345_014 - m[
A24]*Det3_345_012;
556 double Det4_2345_0125 = m[
A20]*Det3_345_125 - m[
A21]*Det3_345_025
557 + m[
A22]*Det3_345_015 - m[
A25]*Det3_345_012;
558 double Det4_2345_0134 = m[
A20]*Det3_345_134 - m[
A21]*Det3_345_034
559 + m[
A23]*Det3_345_014 - m[
A24]*Det3_345_013;
560 double Det4_2345_0135 = m[
A20]*Det3_345_135 - m[
A21]*Det3_345_035
561 + m[
A23]*Det3_345_015 - m[
A25]*Det3_345_013;
562 double Det4_2345_0145 = m[
A20]*Det3_345_145 - m[
A21]*Det3_345_045
563 + m[
A24]*Det3_345_015 - m[
A25]*Det3_345_014;
564 double Det4_2345_0234 = m[
A20]*Det3_345_234 - m[
A22]*Det3_345_034
565 + m[
A23]*Det3_345_024 - m[
A24]*Det3_345_023;
566 double Det4_2345_0235 = m[
A20]*Det3_345_235 - m[
A22]*Det3_345_035
567 + m[
A23]*Det3_345_025 - m[
A25]*Det3_345_023;
568 double Det4_2345_0245 = m[
A20]*Det3_345_245 - m[
A22]*Det3_345_045
569 + m[
A24]*Det3_345_025 - m[
A25]*Det3_345_024;
570 double Det4_2345_0345 = m[
A20]*Det3_345_345 - m[
A23]*Det3_345_045
571 + m[
A24]*Det3_345_035 - m[
A25]*Det3_345_034;
572 double Det4_2345_1234 = m[
A21]*Det3_345_234 - m[
A22]*Det3_345_134
573 + m[
A23]*Det3_345_124 - m[
A24]*Det3_345_123;
574 double Det4_2345_1235 = m[
A21]*Det3_345_235 - m[
A22]*Det3_345_135
575 + m[
A23]*Det3_345_125 - m[
A25]*Det3_345_123;
576 double Det4_2345_1245 = m[
A21]*Det3_345_245 - m[
A22]*Det3_345_145
577 + m[
A24]*Det3_345_125 - m[
A25]*Det3_345_124;
578 double Det4_2345_1345 = m[
A21]*Det3_345_345 - m[
A23]*Det3_345_145
579 + m[
A24]*Det3_345_135 - m[
A25]*Det3_345_134;
580 double Det4_2345_2345 = m[
A22]*Det3_345_345 - m[
A23]*Det3_345_245
581 + m[
A24]*Det3_345_235 - m[
A25]*Det3_345_234;
585 double Det5_01234_01234 = m[
A00]*Det4_1234_1234 - m[
A01]*Det4_1234_0234
586 + m[
A02]*Det4_1234_0134 - m[
A03]*Det4_1234_0124 + m[
A04]*Det4_1234_0123;
587 double Det5_01235_01234 = m[
A00]*Det4_1235_1234 - m[
A01]*Det4_1235_0234
588 + m[
A02]*Det4_1235_0134 - m[
A03]*Det4_1235_0124 + m[
A04]*Det4_1235_0123;
589 double Det5_01235_01235 = m[
A00]*Det4_1235_1235 - m[
A01]*Det4_1235_0235
590 + m[
A02]*Det4_1235_0135 - m[
A03]*Det4_1235_0125 + m[
A05]*Det4_1235_0123;
591 double Det5_01245_01234 = m[
A00]*Det4_1245_1234 - m[
A01]*Det4_1245_0234
592 + m[
A02]*Det4_1245_0134 - m[
A03]*Det4_1245_0124 + m[
A04]*Det4_1245_0123;
593 double Det5_01245_01235 = m[
A00]*Det4_1245_1235 - m[
A01]*Det4_1245_0235
594 + m[
A02]*Det4_1245_0135 - m[
A03]*Det4_1245_0125 + m[
A05]*Det4_1245_0123;
595 double Det5_01245_01245 = m[
A00]*Det4_1245_1245 - m[
A01]*Det4_1245_0245
596 + m[
A02]*Det4_1245_0145 - m[
A04]*Det4_1245_0125 + m[
A05]*Det4_1245_0124;
597 double Det5_01345_01234 = m[
A00]*Det4_1345_1234 - m[
A01]*Det4_1345_0234
598 + m[
A02]*Det4_1345_0134 - m[
A03]*Det4_1345_0124 + m[
A04]*Det4_1345_0123;
599 double Det5_01345_01235 = m[
A00]*Det4_1345_1235 - m[
A01]*Det4_1345_0235
600 + m[
A02]*Det4_1345_0135 - m[
A03]*Det4_1345_0125 + m[
A05]*Det4_1345_0123;
601 double Det5_01345_01245 = m[
A00]*Det4_1345_1245 - m[
A01]*Det4_1345_0245
602 + m[
A02]*Det4_1345_0145 - m[
A04]*Det4_1345_0125 + m[
A05]*Det4_1345_0124;
603 double Det5_01345_01345 = m[
A00]*Det4_1345_1345 - m[
A01]*Det4_1345_0345
604 + m[
A03]*Det4_1345_0145 - m[
A04]*Det4_1345_0135 + m[
A05]*Det4_1345_0134;
605 double Det5_02345_01234 = m[
A00]*Det4_2345_1234 - m[
A01]*Det4_2345_0234
606 + m[
A02]*Det4_2345_0134 - m[
A03]*Det4_2345_0124 + m[
A04]*Det4_2345_0123;
607 double Det5_02345_01235 = m[
A00]*Det4_2345_1235 - m[
A01]*Det4_2345_0235
608 + m[
A02]*Det4_2345_0135 - m[
A03]*Det4_2345_0125 + m[
A05]*Det4_2345_0123;
609 double Det5_02345_01245 = m[
A00]*Det4_2345_1245 - m[
A01]*Det4_2345_0245
610 + m[
A02]*Det4_2345_0145 - m[
A04]*Det4_2345_0125 + m[
A05]*Det4_2345_0124;
611 double Det5_02345_01345 = m[
A00]*Det4_2345_1345 - m[
A01]*Det4_2345_0345
612 + m[
A03]*Det4_2345_0145 - m[
A04]*Det4_2345_0135 + m[
A05]*Det4_2345_0134;
613 double Det5_02345_02345 = m[
A00]*Det4_2345_2345 - m[
A02]*Det4_2345_0345
614 + m[
A03]*Det4_2345_0245 - m[
A04]*Det4_2345_0235 + m[
A05]*Det4_2345_0234;
615 double Det5_12345_01234 = m[
A10]*Det4_2345_1234 - m[
A11]*Det4_2345_0234
616 + m[
A12]*Det4_2345_0134 - m[
A13]*Det4_2345_0124 + m[
A14]*Det4_2345_0123;
617 double Det5_12345_01235 = m[
A10]*Det4_2345_1235 - m[
A11]*Det4_2345_0235
618 + m[
A12]*Det4_2345_0135 - m[
A13]*Det4_2345_0125 + m[
A15]*Det4_2345_0123;
619 double Det5_12345_01245 = m[
A10]*Det4_2345_1245 - m[
A11]*Det4_2345_0245
620 + m[
A12]*Det4_2345_0145 - m[
A14]*Det4_2345_0125 + m[
A15]*Det4_2345_0124;
621 double Det5_12345_01345 = m[
A10]*Det4_2345_1345 - m[
A11]*Det4_2345_0345
622 + m[
A13]*Det4_2345_0145 - m[
A14]*Det4_2345_0135 + m[
A15]*Det4_2345_0134;
623 double Det5_12345_02345 = m[
A10]*Det4_2345_2345 - m[
A12]*Det4_2345_0345
624 + m[
A13]*Det4_2345_0245 - m[
A14]*Det4_2345_0235 + m[
A15]*Det4_2345_0234;
625 double Det5_12345_12345 = m[
A11]*Det4_2345_2345 - m[
A12]*Det4_2345_1345
626 + m[
A13]*Det4_2345_1245 - m[
A14]*Det4_2345_1235 + m[
A15]*Det4_2345_1234;
630 double det = m[
A00]*Det5_12345_12345
631 - m[
A01]*Det5_12345_02345
632 + m[
A02]*Det5_12345_01345
633 - m[
A03]*Det5_12345_01245
634 + m[
A04]*Det5_12345_01235
635 - m[
A05]*Det5_12345_01234;
638#ifdef SINGULAR_DIAGNOSTICS
639 std::cerr <<
"Kramer's rule inversion of a singular 6x6 matrix: "
646 double oneOverDet = 1.0/det;
647 double mn1OverDet = - oneOverDet;
649 m[
A00] = Det5_12345_12345*oneOverDet;
650 m[
A01] = Det5_12345_02345*mn1OverDet;
651 m[
A02] = Det5_12345_01345*oneOverDet;
652 m[
A03] = Det5_12345_01245*mn1OverDet;
653 m[
A04] = Det5_12345_01235*oneOverDet;
654 m[
A05] = Det5_12345_01234*mn1OverDet;
656 m[
A11] = Det5_02345_02345*oneOverDet;
657 m[
A12] = Det5_02345_01345*mn1OverDet;
658 m[
A13] = Det5_02345_01245*oneOverDet;
659 m[
A14] = Det5_02345_01235*mn1OverDet;
660 m[
A15] = Det5_02345_01234*oneOverDet;
662 m[
A22] = Det5_01345_01345*oneOverDet;
663 m[
A23] = Det5_01345_01245*mn1OverDet;
664 m[
A24] = Det5_01345_01235*oneOverDet;
665 m[
A25] = Det5_01345_01234*mn1OverDet;
667 m[
A33] = Det5_01245_01245*oneOverDet;
668 m[
A34] = Det5_01245_01235*mn1OverDet;
669 m[
A35] = Det5_01245_01234*oneOverDet;
671 m[
A44] = Det5_01235_01235*oneOverDet;
672 m[
A45] = Det5_01235_01234*mn1OverDet;
674 m[
A55] = Det5_01234_01234*oneOverDet;
693 double h30, h31, h32;
694 double h40, h41, h42, h43;
696 double h00, h11, h22, h33, h44;
701 double g30, g31, g32;
702 double g40, g41, g42, g43;
712 if (h00 <= 0)
return;
713 h00 = 1.0 / sqrt(h00);
722 h11 = m[
A11] - (g10 * g10);
723 if (h11 <= 0)
return;
724 h11 = 1.0 / sqrt(h11);
729 g21 = (m[
A21] - (g10 * g20)) * h11;
730 g31 = (m[
A31] - (g10 * g30)) * h11;
731 g41 = (m[
A41] - (g10 * g40)) * h11;
735 h22 = m[
A22] - (g20 * g20) - (g21 * g21);
736 if (h22 <= 0)
return;
737 h22 = 1.0 / sqrt(h22);
742 g32 = (m[
A32] - (g20 * g30) - (g21 * g31)) * h22;
743 g42 = (m[
A42] - (g20 * g40) - (g21 * g41)) * h22;
747 h33 = m[
A33] - (g30 * g30) - (g31 * g31) - (g32 * g32);
748 if (h33 <= 0)
return;
749 h33 = 1.0 / sqrt(h33);
753 g43 = (m[
A43] - (g30 * g40) - (g31 * g41) - (g32 * g42)) * h33;
757 h44 = m[
A44] - (g40 * g40) - (g41 * g41) - (g42 * g42) - (g43 * g43);
758 if (h44 <= 0)
return;
759 h44 = 1.0 / sqrt(h44);
766 h43 = -h33 * g43 * h44;
767 h32 = -h22 * g32 * h33;
768 h42 = -h22 * (g32 * h43 + g42 * h44);
769 h21 = -h11 * g21 * h22;
770 h31 = -h11 * (g21 * h32 + g31 * h33);
771 h41 = -h11 * (g21 * h42 + g31 * h43 + g41 * h44);
772 h10 = -h00 * g10 * h11;
773 h20 = -h00 * (g10 * h21 + g20 * h22);
774 h30 = -h00 * (g10 * h31 + g20 * h32 + g30 * h33);
775 h40 = -h00 * (g10 * h41 + g20 * h42 + g30 * h43 + g40 * h44);
780 m[
A00] = h00 * h00 + h10 * h10 + h20 * h20 + h30 * h30 + h40 * h40;
781 m[
A01] = h10 * h11 + h20 * h21 + h30 * h31 + h40 * h41;
782 m[
A11] = h11 * h11 + h21 * h21 + h31 * h31 + h41 * h41;
783 m[
A02] = h20 * h22 + h30 * h32 + h40 * h42;
784 m[
A12] = h21 * h22 + h31 * h32 + h41 * h42;
785 m[
A22] = h22 * h22 + h32 * h32 + h42 * h42;
786 m[
A03] = h30 * h33 + h40 * h43;
787 m[
A13] = h31 * h33 + h41 * h43;
788 m[
A23] = h32 * h33 + h42 * h43;
789 m[
A33] = h33 * h33 + h43 * h43;
816 double h30, h31, h32;
817 double h40, h41, h42, h43;
818 double h50, h51, h52, h53, h54;
820 double h00, h11, h22, h33, h44, h55;
825 double g30, g31, g32;
826 double g40, g41, g42, g43;
827 double g50, g51, g52, g53, g54;
837 if (h00 <= 0)
return;
838 h00 = 1.0 / sqrt(h00);
848 h11 = m[
A11] - (g10 * g10);
849 if (h11 <= 0)
return;
850 h11 = 1.0 / sqrt(h11);
855 g21 = (m[
A21] - (g10 * g20)) * h11;
856 g31 = (m[
A31] - (g10 * g30)) * h11;
857 g41 = (m[
A41] - (g10 * g40)) * h11;
858 g51 = (m[
A51] - (g10 * g50)) * h11;
862 h22 = m[
A22] - (g20 * g20) - (g21 * g21);
863 if (h22 <= 0)
return;
864 h22 = 1.0 / sqrt(h22);
869 g32 = (m[
A32] - (g20 * g30) - (g21 * g31)) * h22;
870 g42 = (m[
A42] - (g20 * g40) - (g21 * g41)) * h22;
871 g52 = (m[
A52] - (g20 * g50) - (g21 * g51)) * h22;
875 h33 = m[
A33] - (g30 * g30) - (g31 * g31) - (g32 * g32);
876 if (h33 <= 0)
return;
877 h33 = 1.0 / sqrt(h33);
882 g43 = (m[
A43] - (g30 * g40) - (g31 * g41) - (g32 * g42)) * h33;
883 g53 = (m[
A53] - (g30 * g50) - (g31 * g51) - (g32 * g52)) * h33;
887 h44 = m[
A44] - (g40 * g40) - (g41 * g41) - (g42 * g42) - (g43 * g43);
888 if (h44 <= 0)
return;
889 h44 = 1.0 / sqrt(h44);
893 g54 = (m[
A54] - (g40 * g50) - (g41 * g51) - (g42 * g52) - (g43 * g53)) * h44;
897 h55 = m[
A55] - (g50*g50) - (g51*g51) - (g52*g52) - (g53*g53) - (g54*g54);
898 if (h55 <= 0)
return;
899 h55 = 1.0 / sqrt(h55);
906 h54 = -h44 * g54 * h55;
907 h43 = -h33 * g43 * h44;
908 h53 = -h33 * (g43 * h54 + g53 * h55);
909 h32 = -h22 * g32 * h33;
910 h42 = -h22 * (g32 * h43 + g42 * h44);
911 h52 = -h22 * (g32 * h53 + g42 * h54 + g52 * h55);
912 h21 = -h11 * g21 * h22;
913 h31 = -h11 * (g21 * h32 + g31 * h33);
914 h41 = -h11 * (g21 * h42 + g31 * h43 + g41 * h44);
915 h51 = -h11 * (g21 * h52 + g31 * h53 + g41 * h54 + g51 * h55);
916 h10 = -h00 * g10 * h11;
917 h20 = -h00 * (g10 * h21 + g20 * h22);
918 h30 = -h00 * (g10 * h31 + g20 * h32 + g30 * h33);
919 h40 = -h00 * (g10 * h41 + g20 * h42 + g30 * h43 + g40 * h44);
920 h50 = -h00 * (g10 * h51 + g20 * h52 + g30 * h53 + g40 * h54 + g50 * h55);
925 m[
A00] = h00 * h00 + h10 * h10 + h20 * h20 + h30 * h30 + h40 * h40 + h50*h50;
926 m[
A01] = h10 * h11 + h20 * h21 + h30 * h31 + h40 * h41 + h50 * h51;
927 m[
A11] = h11 * h11 + h21 * h21 + h31 * h31 + h41 * h41 + h51 * h51;
928 m[
A02] = h20 * h22 + h30 * h32 + h40 * h42 + h50 * h52;
929 m[
A12] = h21 * h22 + h31 * h32 + h41 * h42 + h51 * h52;
930 m[
A22] = h22 * h22 + h32 * h32 + h42 * h42 + h52 * h52;
931 m[
A03] = h30 * h33 + h40 * h43 + h50 * h53;
932 m[
A13] = h31 * h33 + h41 * h43 + h51 * h53;
933 m[
A23] = h32 * h33 + h42 * h43 + h52 * h53;
934 m[
A33] = h33 * h33 + h43 * h43 + h53 * h53;
935 m[
A04] = h40 * h44 + h50 * h54;
936 m[
A14] = h41 * h44 + h51 * h54;
937 m[
A24] = h42 * h44 + h52 * h54;
938 m[
A34] = h43 * h44 + h53 * h54;
939 m[
A44] = h44 * h44 + h54 * h54;
953void HepSymMatrix::invert4 (
int & ifail) {
976 double Det3_012_012 = m[
A00]*Det2_12_12 - m[
A01]*Det2_12_02
978 double Det3_013_012 = m[
A00]*Det2_13_12 - m[
A01]*Det2_13_02
980 double Det3_013_013 = m[
A00]*Det2_13_13 - m[
A01]*Det2_13_03
982 double Det3_023_012 = m[
A00]*Det2_23_12 - m[
A01]*Det2_23_02
984 double Det3_023_013 = m[
A00]*Det2_23_13 - m[
A01]*Det2_23_03
986 double Det3_023_023 = m[
A00]*Det2_23_23 - m[
A02]*Det2_23_03
988 double Det3_123_012 = m[
A10]*Det2_23_12 - m[
A11]*Det2_23_02
990 double Det3_123_013 = m[
A10]*Det2_23_13 - m[
A11]*Det2_23_03
992 double Det3_123_023 = m[
A10]*Det2_23_23 - m[
A12]*Det2_23_03
994 double Det3_123_123 = m[
A11]*Det2_23_23 - m[
A12]*Det2_23_13
999 double det = m[
A00]*Det3_123_123
1000 - m[
A01]*Det3_123_023
1001 + m[
A02]*Det3_123_013
1002 - m[
A03]*Det3_123_012;
1005#ifdef SINGULAR_DIAGNOSTICS
1006 std::cerr <<
"Kramer's rule inversion of a singular 4x4 matrix: "
1013 double oneOverDet = 1.0/det;
1014 double mn1OverDet = - oneOverDet;
1016 m[
A00] = Det3_123_123 * oneOverDet;
1017 m[
A01] = Det3_123_023 * mn1OverDet;
1018 m[
A02] = Det3_123_013 * oneOverDet;
1019 m[
A03] = Det3_123_012 * mn1OverDet;
1022 m[
A11] = Det3_023_023 * oneOverDet;
1023 m[
A12] = Det3_023_013 * mn1OverDet;
1024 m[
A13] = Det3_023_012 * oneOverDet;
1026 m[
A22] = Det3_013_013 * oneOverDet;
1027 m[
A23] = Det3_013_012 * mn1OverDet;
1029 m[
A33] = Det3_012_012 * oneOverDet;
void invertHaywood5(int &ifail)
void invertCholesky6(int &ifail)
void invertHaywood4(int &ifail)
void invertCholesky5(int &ifail)
void invertHaywood6(int &ifail)