Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JMatrix2S.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/JMatrix2S.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 */
21int 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 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}
Exceptions.
int main(int argc, char **argv)
Definition JMatrix2S.cc:21
General purpose messaging.
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define ERROR(A)
Definition JMessage.hh:66
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define NOTICE(A)
Definition JMessage.hh:64
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
General exception.
Definition JException.hh:24
2 x 2 symmetric matrix
Definition JMatrix2S.hh:28
Utility class to parse command line options.
Definition JParser.hh:1698
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).