Jpp  15.0.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JMatrix2S.cc File Reference

Example program to test inversion of symmetric matrix. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "TRandom3.h"
#include "JLang/JException.hh"
#include "JMath/JMatrix2S.hh"
#include "JMath/JMathTestkit.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 JMatrix2S.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 21 of file JMatrix2S.cc.

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  JMatrix2S A = getRandom<JMatrix2S>();
47 
48  DEBUG("Matrix A" << endl);
49  DEBUG(A << endl);
50 
51  NOTICE("Determinant A " << A.getDeterminant() << endl);
52 
53  try {
54 
55  JMatrix2S 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  JMatrix2D 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  JMatrix2D D = C - JMatrix2D::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
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
#define FATAL(A)
Definition: JMessage.hh:67
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
do echo Generating $dir eval D
Definition: JDrawLED.sh:53
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A