Jpp
15.0.4
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
JMatrixND.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JLang/JException.hh
"
6
#include "
JMath/JMatrixND.hh
"
7
8
#include "
Jeep/JTimer.hh
"
9
#include "
Jeep/JParser.hh
"
10
#include "
Jeep/JMessage.hh
"
11
12
13
/**
14
* \file
15
*
16
* Example program to test matrix operations.
17
* \author mdejong
18
*/
19
int
main
(
int
argc,
char
**argv)
20
{
21
using namespace
std;
22
23
int
N
;
24
int
numberOfEvents;
25
int
debug
;
26
27
try
{
28
29
JParser<>
zap(
"Example program to test matrix operations."
);
30
31
zap[
'N'
] =
make_field
(
N
);
32
zap[
'n'
] =
make_field
(numberOfEvents);
33
zap[
'd'
] =
make_field
(
debug
) = 2;
34
35
zap(argc, argv);
36
}
37
catch
(
const
exception &error) {
38
FATAL
(error.what() << endl);
39
}
40
41
using namespace
JPP;
42
43
44
JMatrixND
A
(
N
);
45
46
const
double
u
= 2.0;
47
48
for
(
int
i = 0; i !=
N
; ++i) {
49
50
A
(i,i) =
u
;
51
52
for
(
int
j
= 0;
j
!= i; ++
j
) {
53
A
(
j
,i) =
A
(i,
j
) = 0.0;
54
}
55
}
56
57
{
58
JTimer t1(
"standard"
);
59
60
for
(
int
i = 0; i != numberOfEvents; ++i) {
61
62
t1.start();
63
64
JMatrixND B(
N
);
65
66
B.mul(A,A);
67
68
JMatrixND
C
(
N
);
69
70
C.mul(B,A);
71
72
JMatrixND
D
(
N
);
73
74
D.mul(C,A);
75
76
JMatrixND
E
(
N
);
77
78
E.mul(D,A);
79
80
t1.stop();
81
82
E.div(
u
*
u
*
u
*
u
*
u
);
83
84
if
(!E.isIdentity()) {
85
ERROR
(
"Matrix product error"
<< endl);
86
}
87
}
88
89
t1.print(cout);
90
}
91
{
92
JTimer t1(
"calculator"
);
93
94
JMatrixND B(
N
);
95
96
for
(
int
i = 0; i != numberOfEvents; ++i) {
97
98
t1.start();
99
100
B = A * A * A * A *
A
;
101
102
t1.stop();
103
104
B.div(
u
*
u
*
u
*
u
*
u
);
105
106
if
(!B.isIdentity()) {
107
ERROR
(
"Matrix product error"
<< endl);
108
}
109
}
110
111
t1.print(cout);
112
}
113
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
JException.hh
Exceptions.
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JTimer.hh
N
then JShowerPostfit f $INPUT_FILE o $OUTPUT_FILE N
Definition:
JShowerPostfit.sh:95
E
then usage E
Definition:
JMuonPostfit.sh:35
JPHYSICS::C
static const double C
Physics constants.
Definition:
JPhysics/JConstants.hh:25
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
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.
JTOOLS::j
int j
Definition:
JPolint.hh:666
JTOOLS::u
double u[N+1]
Definition:
JPolint.hh:739
D
do echo Generating $dir eval D
Definition:
JDrawLED.sh:53
JMatrixND.hh
A
source $JPP_DIR setenv csh $JPP_DIR eval JShellParser o a A
Definition:
JShellParser.csh:15
Generated by
1.8.5