Jpp  15.0.3
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMatrix3S.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 
5 #include "TRandom3.h"
6 
7 #include "JLang/JException.hh"
8 #include "JMath/JMatrix3S.hh"
9 #include "JMath/JMathTestkit.hh"
10 
11 #include "Jeep/JParser.hh"
12 #include "Jeep/JMessage.hh"
13 
14 
15 /**
16  * \file
17  *
18  * Example program to test inversion of symmetric matrix.
19  * \author mdejong
20  */
21 int main(int argc, char**argv)
22 {
23  using namespace std;
24  using namespace JPP;
25 
26  double precision;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Example program to test inversion of symmetric matrix.");
32 
33  zap['e'] = make_field(precision) = 1.0e-6;
34  zap['d'] = make_field(debug) = 3;
35 
36  zap(argc, argv);
37  }
38  catch(const exception &error) {
39  FATAL(error.what() << endl);
40  }
41 
42 
43  gRandom->SetSeed(0);
44 
45 
46  JMatrix3S A = getRandom<JMatrix3S>();
47 
48  DEBUG("Matrix A" << endl);
49  DEBUG(A << endl);
50 
51  NOTICE("Determinant A " << A.getDeterminant() << endl);
52 
53  try {
54 
55  JMatrix3S B(A);
56 
57  B.invert();
58 
59  DEBUG("Matrix A^-1" << endl);
60  DEBUG(B << endl);
61 
62  NOTICE("Determinant A^-1 = " << B.getDeterminant() << endl);
63 
64  JMatrix3D C(A * B);
65 
66  DEBUG("Matrix A x A^-1" << endl);
67  DEBUG(C << endl);
68 
69  NOTICE("Determinant (A x A^-1) = " << C.getDeterminant() << endl);
70  NOTICE("Determinant A x Determinant A^-1 = " << A.getDeterminant() * B.getDeterminant() << endl);
71  NOTICE("A x A^-1 = I ? " << C.isIdentity(precision) << endl);
72 
73  if (!C.isIdentity(precision)) {
74  ERROR("Matrix A x A^-1 /= I" << endl);
75  }
76 
77  JMatrix3D D = C - JMatrix3D::getIdentity();
78 
79  DEBUG("Matrix D = C - I" << endl);
80  DEBUG(D << endl);
81 
82  ASSERT(C.isIdentity(precision));
83  }
84  catch (const JException& error) {
85  FATAL(error << endl);
86  }
87 
88  return 0;
89 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Exceptions.
int main(int argc, char *argv[])
Definition: Main.cc:15
static const double C
Physics constants.
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
#define NOTICE(A)
Definition: JMessage.hh:64
#define ERROR(A)
Definition: JMessage.hh:66
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
source $JPP_DIR setenv csh $JPP_DIR &dev null eval JShellParser o a A
do echo Generating $dir eval D
Definition: JDrawLED.sh:53