Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JMath
JMatrix1S.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/JMatrix1S.hh
"
9
10
#include "
Jeep/JParser.hh
"
11
#include "
Jeep/JMessage.hh
"
12
13
14
/**
15
* \file
16
*
17
* Example program to test inversion of symmetric matrix.
18
* \author mdejong
19
*/
20
int
main
(
int
argc,
char
**argv)
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
JMatrix1D A(gRandom->Uniform(xmin,xmax));
50
51
52
DEBUG
(
"Matrix A"
<< endl);
53
DEBUG
(A << endl);
54
55
NOTICE
(
"Determinant A "
<< A.getDeterminant() << endl);
56
57
try
{
58
59
JMatrix1S B(A);
60
61
B.invert();
62
63
DEBUG
(
"Matrix A^-1"
<< endl);
64
DEBUG
(B << endl);
65
66
NOTICE
(
"Determinant A^-1 = "
<< B.getDeterminant() << endl);
67
68
JMatrix1D
C
(A * B);
69
70
DEBUG
(
"Matrix A x A^-1"
<< endl);
71
DEBUG
(C << endl);
72
73
NOTICE
(
"Determinant (A x A^-1) = "
<< C.getDeterminant() << endl);
74
NOTICE
(
"Determinant A x Determinant A^-1 = "
<< A.getDeterminant() * B.getDeterminant() << endl);
75
NOTICE
(
"A x A^-1 = I ? "
<< C.isIdentity(precision) << endl);
76
77
if
(!C.isIdentity(precision)) {
78
ERROR
(
"Matrix A x A^-1 /= I"
<< endl);
79
}
80
81
JMatrix1D D = C - JMatrix1D::getIdentity();
82
83
DEBUG
(
"Matrix D = C - I"
<< endl);
84
DEBUG
(D << endl);
85
86
ASSERT
(C.isIdentity(precision));
87
}
88
catch
(
const
JException& error) {
89
FATAL
(error << endl);
90
}
91
92
return
0;
93
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1410
JException.hh
Exceptions.
JMatrix1S.hh
ASSERT
#define ASSERT(A)
Assert macro.
Definition:
JMessage.hh:72
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1836
NOTICE
#define NOTICE(A)
Definition:
JMessage.hh:62
ERROR
#define ERROR(A)
Definition:
JMessage.hh:64
debug
int debug
debug level
Definition:
JSirene.cc:59
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:65
JParser.hh
Utility class to parse command line options.
JTOOLS::C
static const double C
Speed of light in vacuum [m/ns].
Definition:
JConstants.hh:22
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:60
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5