Jpp
Functions
JMatrix3S.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include "TRandom3.h"
#include "JLang/JException.hh"
#include "JMath/JMatrix3S.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test inversion of symmetric matrix.

Author
mdejong

Definition in file JMatrix3S.cc.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 20 of file JMatrix3S.cc.

21 {
22  using namespace std;
23 
24  double precision;
25  int debug;
26 
27  try {
28 
29  JParser<> zap("Example program to test inversion of symmetric matrix.");
30 
31  zap['e'] = make_field(precision) = 1.0e-6;
32  zap['d'] = make_field(debug) = 3;
33 
34  zap(argc, argv);
35  }
36  catch(const exception &error) {
37  FATAL(error.what() << endl);
38  }
39 
40  using namespace JPP;
41 
42 
43  gRandom->SetSeed(0);
44 
45  const Double_t xmin = -1.0;
46  const Double_t xmax = +1.0;
47 
48 
49  JMatrix3D A(gRandom->Uniform(xmin,xmax), 0.0, 0.0,
50  gRandom->Uniform(xmin,xmax), gRandom->Uniform(xmin,xmax), 0.0,
51  gRandom->Uniform(xmin,xmax), gRandom->Uniform(xmin,xmax), gRandom->Uniform(xmin,xmax));
52 
53  A.a01 = A.a10;
54  A.a02 = A.a20;
55  A.a12 = A.a21;
56 
57 
58  DEBUG("Matrix A" << endl);
59  DEBUG(A << endl);
60 
61  NOTICE("Determinant A " << A.getDeterminant() << endl);
62 
63  try {
64 
65  JMatrix3S B(A);
66 
67  B.invert();
68 
69  DEBUG("Matrix A^-1" << endl);
70  DEBUG(B << endl);
71 
72  NOTICE("Determinant A^-1 = " << B.getDeterminant() << endl);
73 
74  JMatrix3D C(A * B);
75 
76  DEBUG("Matrix A x A^-1" << endl);
77  DEBUG(C << endl);
78 
79  NOTICE("Determinant (A x A^-1) = " << C.getDeterminant() << endl);
80  NOTICE("Determinant A x Determinant A^-1 = " << A.getDeterminant() * B.getDeterminant() << endl);
81  NOTICE("A x A^-1 = I ? " << C.isIdentity(precision) << endl);
82 
83  if (!C.isIdentity(precision)) {
84  ERROR("Matrix A x A^-1 /= I" << endl);
85  }
86 
87  JMatrix3D D = C - JMatrix3D::getIdentity();
88 
89  DEBUG("Matrix D = C - I" << endl);
90  DEBUG(D << endl);
91 
92  ASSERT(C.isIdentity(precision));
93  }
94  catch (const JException& error) {
95  FATAL(error << endl);
96  }
97 
98  return 0;
99 }
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
JPARSER::JParser
Utility class to parse command line options.
Definition: JParser.hh:1493
NOTICE
#define NOTICE(A)
Definition: JMessage.hh:64
JTOOLS::C
static const double C
Speed of light in vacuum [m/ns].
Definition: JConstants.hh:22
JPP
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JAAnetToolkit.hh:37
ERROR
#define ERROR(A)
Definition: JMessage.hh:66
debug
int debug
debug level
Definition: JSirene.cc:59
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1954
DEBUG
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
std
Definition: jaanetDictionary.h:36
FATAL
#define FATAL(A)
Definition: JMessage.hh:67