Jpp - the software that should make you happy
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
#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
JMatrix1S
A
= getRandom<JMatrix1S>();
47
48
DEBUG
(
"Matrix A"
<< endl);
49
DEBUG
(
A
<< endl);
50
51
NOTICE
(
"Determinant A "
<<
A
.getDeterminant() << endl);
52
53
try
{
54
55
JMatrix1S 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
JMatrix1D
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
JMatrix1D
D
= C - JMatrix1D::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
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
JException.hh
Exceptions.
D
do echo Generating $dir eval D
Definition:
JDrawLED.sh:50
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JMatrix1S.hh
JMathTestkit.hh
JPHYSICS::C
static const double C
Physics constants.
Definition:
JPhysics/JConstants.hh:25
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
NOTICE
#define NOTICE(A)
Definition:
JMessage.hh:64
ERROR
#define ERROR(A)
Definition:
JMessage.hh:66
debug
int debug
debug level
Definition:
JSirene.cc:63
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
A
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
Definition:
JShellParser.csh:15
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
Generated by
1.8.5