Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ErrorSymMatrix.cc File Reference
#include "globals.hh"
#include <iostream>
#include <cmath>
#include "G4ErrorSymMatrix.hh"
#include "G4ErrorMatrix.hh"

Go to the source code of this file.

Macros

#define SIMPLE_UOP(OPER)
 
#define SIMPLE_BOP(OPER)
 
#define SIMPLE_TOP(OPER)
 
#define CHK_DIM_2(r1, r2, c1, c2, fun)
 
#define CHK_DIM_1(c1, r2, fun)
 
#define A00   0
 
#define A01   1
 
#define A02   3
 
#define A03   6
 
#define A04   10
 
#define A05   15
 
#define A10   1
 
#define A11   2
 
#define A12   4
 
#define A13   7
 
#define A14   11
 
#define A15   16
 
#define A20   3
 
#define A21   4
 
#define A22   5
 
#define A23   8
 
#define A24   12
 
#define A25   17
 
#define A30   6
 
#define A31   7
 
#define A32   8
 
#define A33   9
 
#define A34   13
 
#define A35   18
 
#define A40   10
 
#define A41   11
 
#define A42   12
 
#define A43   13
 
#define A44   14
 
#define A45   19
 
#define A50   15
 
#define A51   16
 
#define A52   17
 
#define A53   18
 
#define A54   19
 
#define A55   20
 

Functions

G4ErrorSymMatrix dsum (const G4ErrorSymMatrix &mat1, const G4ErrorSymMatrix &mat2)
 
G4ErrorMatrix operator+ (const G4ErrorMatrix &mat1, const G4ErrorSymMatrix &mat2)
 
G4ErrorMatrix operator+ (const G4ErrorSymMatrix &mat1, const G4ErrorMatrix &mat2)
 
G4ErrorSymMatrix operator+ (const G4ErrorSymMatrix &mat1, const G4ErrorSymMatrix &mat2)
 
G4ErrorMatrix operator- (const G4ErrorMatrix &mat1, const G4ErrorSymMatrix &mat2)
 
G4ErrorMatrix operator- (const G4ErrorSymMatrix &mat1, const G4ErrorMatrix &mat2)
 
G4ErrorSymMatrix operator- (const G4ErrorSymMatrix &mat1, const G4ErrorSymMatrix &mat2)
 
G4ErrorSymMatrix operator/ (const G4ErrorSymMatrix &mat1, G4double t)
 
G4ErrorSymMatrix operator* (const G4ErrorSymMatrix &mat1, G4double t)
 
G4ErrorSymMatrix operator* (G4double t, const G4ErrorSymMatrix &mat1)
 
G4ErrorMatrix operator* (const G4ErrorMatrix &mat1, const G4ErrorSymMatrix &mat2)
 
G4ErrorMatrix operator* (const G4ErrorSymMatrix &mat1, const G4ErrorMatrix &mat2)
 
G4ErrorMatrix operator* (const G4ErrorSymMatrix &mat1, const G4ErrorSymMatrix &mat2)
 
std::ostream & operator<< (std::ostream &os, const G4ErrorSymMatrix &q)
 

Macro Definition Documentation

◆ A00

#define A00   0

Definition at line 1348 of file G4ErrorSymMatrix.cc.

◆ A01

#define A01   1

Definition at line 1349 of file G4ErrorSymMatrix.cc.

◆ A02

#define A02   3

Definition at line 1350 of file G4ErrorSymMatrix.cc.

◆ A03

#define A03   6

Definition at line 1351 of file G4ErrorSymMatrix.cc.

◆ A04

#define A04   10

Definition at line 1352 of file G4ErrorSymMatrix.cc.

◆ A05

#define A05   15

Definition at line 1353 of file G4ErrorSymMatrix.cc.

◆ A10

#define A10   1

Definition at line 1355 of file G4ErrorSymMatrix.cc.

◆ A11

#define A11   2

Definition at line 1356 of file G4ErrorSymMatrix.cc.

◆ A12

#define A12   4

Definition at line 1357 of file G4ErrorSymMatrix.cc.

◆ A13

#define A13   7

Definition at line 1358 of file G4ErrorSymMatrix.cc.

◆ A14

#define A14   11

Definition at line 1359 of file G4ErrorSymMatrix.cc.

◆ A15

#define A15   16

Definition at line 1360 of file G4ErrorSymMatrix.cc.

◆ A20

#define A20   3

Definition at line 1362 of file G4ErrorSymMatrix.cc.

◆ A21

#define A21   4

Definition at line 1363 of file G4ErrorSymMatrix.cc.

◆ A22

#define A22   5

Definition at line 1364 of file G4ErrorSymMatrix.cc.

◆ A23

#define A23   8

Definition at line 1365 of file G4ErrorSymMatrix.cc.

◆ A24

#define A24   12

Definition at line 1366 of file G4ErrorSymMatrix.cc.

◆ A25

#define A25   17

Definition at line 1367 of file G4ErrorSymMatrix.cc.

◆ A30

#define A30   6

Definition at line 1369 of file G4ErrorSymMatrix.cc.

◆ A31

#define A31   7

Definition at line 1370 of file G4ErrorSymMatrix.cc.

◆ A32

#define A32   8

Definition at line 1371 of file G4ErrorSymMatrix.cc.

◆ A33

#define A33   9

Definition at line 1372 of file G4ErrorSymMatrix.cc.

◆ A34

#define A34   13

Definition at line 1373 of file G4ErrorSymMatrix.cc.

◆ A35

#define A35   18

Definition at line 1374 of file G4ErrorSymMatrix.cc.

◆ A40

#define A40   10

Definition at line 1376 of file G4ErrorSymMatrix.cc.

◆ A41

#define A41   11

Definition at line 1377 of file G4ErrorSymMatrix.cc.

◆ A42

#define A42   12

Definition at line 1378 of file G4ErrorSymMatrix.cc.

◆ A43

#define A43   13

Definition at line 1379 of file G4ErrorSymMatrix.cc.

◆ A44

#define A44   14

Definition at line 1380 of file G4ErrorSymMatrix.cc.

◆ A45

#define A45   19

Definition at line 1381 of file G4ErrorSymMatrix.cc.

◆ A50

#define A50   15

Definition at line 1383 of file G4ErrorSymMatrix.cc.

◆ A51

#define A51   16

Definition at line 1384 of file G4ErrorSymMatrix.cc.

◆ A52

#define A52   17

Definition at line 1385 of file G4ErrorSymMatrix.cc.

◆ A53

#define A53   18

Definition at line 1386 of file G4ErrorSymMatrix.cc.

◆ A54

#define A54   19

Definition at line 1387 of file G4ErrorSymMatrix.cc.

◆ A55

#define A55   20

Definition at line 1388 of file G4ErrorSymMatrix.cc.

◆ CHK_DIM_1

#define CHK_DIM_1 ( c1,
r2,
fun )
Value:
if(c1 != r2) \
{ \
G4ErrorMatrix::error("Range error in Matrix function " #fun "(2)."); \
}

Definition at line 67 of file G4ErrorSymMatrix.cc.

67#define CHK_DIM_1(c1, r2, fun) \
68 if(c1 != r2) \
69 { \
70 G4ErrorMatrix::error("Range error in Matrix function " #fun "(2)."); \
71 }

◆ CHK_DIM_2

#define CHK_DIM_2 ( r1,
r2,
c1,
c2,
fun )
Value:
if(r1 != r2 || c1 != c2) \
{ \
G4ErrorMatrix::error("Range error in Matrix function " #fun "(1)."); \
}

Definition at line 61 of file G4ErrorSymMatrix.cc.

61#define CHK_DIM_2(r1, r2, c1, c2, fun) \
62 if(r1 != r2 || c1 != c2) \
63 { \
64 G4ErrorMatrix::error("Range error in Matrix function " #fun "(1)."); \
65 }

Referenced by operator+(), operator+(), operator-(), and operator-().

◆ SIMPLE_BOP

#define SIMPLE_BOP ( OPER)
Value:
G4ErrorMatrixIter a = m.begin(); \
G4ErrorMatrixConstIter b = mat2.m.begin(); \
G4ErrorMatrixConstIter e = m.begin() + num_size(); \
for(; a < e; a++, b++) \
(*a) OPER(*b);
std::vector< G4double >::iterator G4ErrorMatrixIter
std::vector< G4double >::const_iterator G4ErrorMatrixConstIter

Definition at line 46 of file G4ErrorSymMatrix.cc.

46#define SIMPLE_BOP(OPER) \
47 G4ErrorMatrixIter a = m.begin(); \
48 G4ErrorMatrixConstIter b = mat2.m.begin(); \
49 G4ErrorMatrixConstIter e = m.begin() + num_size(); \
50 for(; a < e; a++, b++) \
51 (*a) OPER(*b);

◆ SIMPLE_TOP

#define SIMPLE_TOP ( OPER)
Value:
G4ErrorMatrixConstIter a = mat1.m.begin(); \
G4ErrorMatrixConstIter b = mat2.m.begin(); \
G4ErrorMatrixIter t = mret.m.begin(); \
G4ErrorMatrixConstIter e = mat1.m.begin() + mat1.num_size(); \
for(; a < e; a++, b++, t++) \
(*t) = (*a) OPER(*b);

Definition at line 53 of file G4ErrorSymMatrix.cc.

53#define SIMPLE_TOP(OPER) \
54 G4ErrorMatrixConstIter a = mat1.m.begin(); \
55 G4ErrorMatrixConstIter b = mat2.m.begin(); \
56 G4ErrorMatrixIter t = mret.m.begin(); \
57 G4ErrorMatrixConstIter e = mat1.m.begin() + mat1.num_size(); \
58 for(; a < e; a++, b++, t++) \
59 (*t) = (*a) OPER(*b);

◆ SIMPLE_UOP

#define SIMPLE_UOP ( OPER)
Value:
G4ErrorMatrixIter a = m.begin(); \
G4ErrorMatrixIter e = m.begin() + num_size(); \
for(; a < e; a++) \
(*a) OPER t;

Definition at line 40 of file G4ErrorSymMatrix.cc.

40#define SIMPLE_UOP(OPER) \
41 G4ErrorMatrixIter a = m.begin(); \
42 G4ErrorMatrixIter e = m.begin() + num_size(); \
43 for(; a < e; a++) \
44 (*a) OPER t;

Function Documentation

◆ dsum()

G4ErrorSymMatrix dsum ( const G4ErrorSymMatrix & mat1,
const G4ErrorSymMatrix & mat2 )

Definition at line 195 of file G4ErrorSymMatrix.cc.

197{
198 G4ErrorSymMatrix mret(mat1.num_row() + mat2.num_row(), 0);
199 mret.sub(1, mat1);
200 mret.sub(mat1.num_row() + 1, mat2);
201 return mret;
202}
G4int num_row() const

◆ operator*() [1/5]

G4ErrorMatrix operator* ( const G4ErrorMatrix & mat1,
const G4ErrorSymMatrix & mat2 )

Definition at line 302 of file G4ErrorSymMatrix.cc.

303{
304 G4ErrorMatrix mret(mat1.num_row(), mat2.num_col());
305 CHK_DIM_1(mat1.num_col(), mat2.num_row(), *);
306 G4ErrorMatrixConstIter mit1, mit2, sp, snp; // mit2=0
307 G4double temp;
308 G4ErrorMatrixIter mir = mret.m.begin();
309 for(mit1 = mat1.m.begin();
310 mit1 < mat1.m.begin() + mat1.num_row() * mat1.num_col(); mit1 = mit2)
311 {
312 snp = mat2.m.begin();
313 for(int step = 1; step <= mat2.num_row(); ++step)
314 {
315 mit2 = mit1;
316 sp = snp;
317 snp += step;
318 temp = 0;
319 while(sp < snp) // Loop checking, 06.08.2015, G.Cosmo
320 {
321 temp += *(sp++) * (*(mit2++));
322 }
323 if(step < mat2.num_row())
324 { // only if we aren't on the last row
325 sp += step - 1;
326 for(int stept = step + 1; stept <= mat2.num_row(); stept++)
327 {
328 temp += *sp * (*(mit2++));
329 if(stept < mat2.num_row())
330 sp += stept;
331 }
332 } // if(step
333 *(mir++) = temp;
334 } // for(step
335 } // for(mit1
336 return mret;
337}
#define CHK_DIM_1(c1, r2, fun)
double G4double
Definition G4Types.hh:83
virtual G4int num_col() const
virtual G4int num_row() const
G4int num_col() const

◆ operator*() [2/5]

G4ErrorMatrix operator* ( const G4ErrorSymMatrix & mat1,
const G4ErrorMatrix & mat2 )

Definition at line 339 of file G4ErrorSymMatrix.cc.

340{
341 G4ErrorMatrix mret(mat1.num_row(), mat2.num_col());
342 CHK_DIM_1(mat1.num_col(), mat2.num_row(), *);
343 G4int step, stept;
344 G4ErrorMatrixConstIter mit1, mit2, sp, snp;
345 G4double temp;
346 G4ErrorMatrixIter mir = mret.m.begin();
347 for(step = 1, snp = mat1.m.begin(); step <= mat1.num_row(); snp += step++)
348 {
349 for(mit1 = mat2.m.begin(); mit1 < mat2.m.begin() + mat2.num_col(); mit1++)
350 {
351 mit2 = mit1;
352 sp = snp;
353 temp = 0;
354 while(sp < snp + step) // Loop checking, 06.08.2015, G.Cosmo
355 {
356 temp += *mit2 * (*(sp++));
357 mit2 += mat2.num_col();
358 }
359 sp += step - 1;
360 for(stept = step + 1; stept <= mat1.num_row(); stept++)
361 {
362 temp += *mit2 * (*sp);
363 mit2 += mat2.num_col();
364 sp += stept;
365 }
366 *(mir++) = temp;
367 }
368 }
369 return mret;
370}
int G4int
Definition G4Types.hh:85

◆ operator*() [3/5]

G4ErrorMatrix operator* ( const G4ErrorSymMatrix & mat1,
const G4ErrorSymMatrix & mat2 )

Definition at line 372 of file G4ErrorSymMatrix.cc.

374{
375 G4ErrorMatrix mret(mat1.num_row(), mat1.num_row());
376 CHK_DIM_1(mat1.num_col(), mat2.num_row(), *);
377 G4int step1, stept1, step2, stept2;
378 G4ErrorMatrixConstIter snp1, sp1, snp2, sp2;
379 G4double temp;
380 G4ErrorMatrixIter mr = mret.m.begin();
381 for(step1 = 1, snp1 = mat1.m.begin(); step1 <= mat1.num_row();
382 snp1 += step1++)
383 {
384 for(step2 = 1, snp2 = mat2.m.begin(); step2 <= mat2.num_row();)
385 {
386 sp1 = snp1;
387 sp2 = snp2;
388 snp2 += step2;
389 temp = 0;
390 if(step1 < step2)
391 {
392 while(sp1 < snp1 + step1) // Loop checking, 06.08.2015, G.Cosmo
393 {
394 temp += (*(sp1++)) * (*(sp2++));
395 }
396 sp1 += step1 - 1;
397 for(stept1 = step1 + 1; stept1 != step2 + 1; sp1 += stept1++)
398 {
399 temp += (*sp1) * (*(sp2++));
400 }
401 sp2 += step2 - 1;
402 for(stept2 = ++step2; stept2 <= mat2.num_row();
403 sp1 += stept1++, sp2 += stept2++)
404 {
405 temp += (*sp1) * (*sp2);
406 }
407 }
408 else
409 {
410 while(sp2 < snp2) // Loop checking, 06.08.2015, G.Cosmo
411 {
412 temp += (*(sp1++)) * (*(sp2++));
413 }
414 sp2 += step2 - 1;
415 for(stept2 = ++step2; stept2 != step1 + 1; sp2 += stept2++)
416 {
417 temp += (*(sp1++)) * (*sp2);
418 }
419 sp1 += step1 - 1;
420 for(stept1 = step1 + 1; stept1 <= mat1.num_row();
421 sp1 += stept1++, sp2 += stept2++)
422 {
423 temp += (*sp1) * (*sp2);
424 }
425 }
426 *(mr++) = temp;
427 }
428 }
429 return mret;
430}

◆ operator*() [4/5]

G4ErrorSymMatrix operator* ( const G4ErrorSymMatrix & mat1,
G4double t )

Definition at line 288 of file G4ErrorSymMatrix.cc.

289{
290 G4ErrorSymMatrix mret(mat1);
291 mret *= t;
292 return mret;
293}

◆ operator*() [5/5]

G4ErrorSymMatrix operator* ( G4double t,
const G4ErrorSymMatrix & mat1 )

Definition at line 295 of file G4ErrorSymMatrix.cc.

296{
297 G4ErrorSymMatrix mret(mat1);
298 mret *= t;
299 return mret;
300}

◆ operator+() [1/3]

G4ErrorMatrix operator+ ( const G4ErrorMatrix & mat1,
const G4ErrorSymMatrix & mat2 )

Definition at line 222 of file G4ErrorSymMatrix.cc.

223{
224 G4ErrorMatrix mret(mat1);
225 CHK_DIM_2(mat1.num_row(), mat2.num_row(), mat1.num_col(), mat2.num_col(), +);
226 mret += mat2;
227 return mret;
228}
#define CHK_DIM_2(r1, r2, c1, c2, fun)

◆ operator+() [2/3]

G4ErrorMatrix operator+ ( const G4ErrorSymMatrix & mat1,
const G4ErrorMatrix & mat2 )

Definition at line 230 of file G4ErrorSymMatrix.cc.

231{
232 G4ErrorMatrix mret(mat2);
233 CHK_DIM_2(mat1.num_row(), mat2.num_row(), mat1.num_col(), mat2.num_col(), +);
234 mret += mat1;
235 return mret;
236}

◆ operator+() [3/3]

G4ErrorSymMatrix operator+ ( const G4ErrorSymMatrix & mat1,
const G4ErrorSymMatrix & mat2 )

Definition at line 238 of file G4ErrorSymMatrix.cc.

240{
241 G4ErrorSymMatrix mret(mat1.nrow);
242 CHK_DIM_1(mat1.nrow, mat2.nrow, +);
243 SIMPLE_TOP(+)
244 return mret;
245}
#define SIMPLE_TOP(OPER)

◆ operator-() [1/3]

G4ErrorMatrix operator- ( const G4ErrorMatrix & mat1,
const G4ErrorSymMatrix & mat2 )

Definition at line 251 of file G4ErrorSymMatrix.cc.

252{
253 G4ErrorMatrix mret(mat1);
254 CHK_DIM_2(mat1.num_row(), mat2.num_row(), mat1.num_col(), mat2.num_col(), -);
255 mret -= mat2;
256 return mret;
257}

◆ operator-() [2/3]

G4ErrorMatrix operator- ( const G4ErrorSymMatrix & mat1,
const G4ErrorMatrix & mat2 )

Definition at line 259 of file G4ErrorSymMatrix.cc.

260{
261 G4ErrorMatrix mret(mat1);
262 CHK_DIM_2(mat1.num_row(), mat2.num_row(), mat1.num_col(), mat2.num_col(), -);
263 mret -= mat2;
264 return mret;
265}

◆ operator-() [3/3]

G4ErrorSymMatrix operator- ( const G4ErrorSymMatrix & mat1,
const G4ErrorSymMatrix & mat2 )

Definition at line 267 of file G4ErrorSymMatrix.cc.

269{
270 G4ErrorSymMatrix mret(mat1.num_row());
271 CHK_DIM_1(mat1.num_row(), mat2.num_row(), -);
272 SIMPLE_TOP(-)
273 return mret;
274}

◆ operator/()

G4ErrorSymMatrix operator/ ( const G4ErrorSymMatrix & mat1,
G4double t )

Definition at line 281 of file G4ErrorSymMatrix.cc.

282{
283 G4ErrorSymMatrix mret(mat1);
284 mret /= t;
285 return mret;
286}

◆ operator<<()

std::ostream & operator<< ( std::ostream & os,
const G4ErrorSymMatrix & q )

Definition at line 564 of file G4ErrorSymMatrix.cc.

565{
566 os << G4endl;
567
568 // Fixed format needs 3 extra characters for field,
569 // while scientific needs 7
570
571 std::size_t width;
572 if(os.flags() & std::ios::fixed)
573 {
574 width = os.precision() + 3;
575 }
576 else
577 {
578 width = os.precision() + 7;
579 }
580 for(G4int irow = 1; irow <= q.num_row(); ++irow)
581 {
582 for(G4int icol = 1; icol <= q.num_col(); ++icol)
583 {
584 os.width(width);
585 os << q(irow, icol) << " ";
586 }
587 os << G4endl;
588 }
589 return os;
590}
#define G4endl
Definition G4ios.hh:67