Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JTools
JSphere3D.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JTools/JMapList.hh
"
6
#include "
JTools/JFunction1D_t.hh
"
7
#include "
JTools/JFunctionalMap_t.hh
"
8
#include "
JTools/JMultiFunction.hh
"
9
#include "
JTools/JToolsToolkit.hh
"
10
#include "
JTools/JFunctionalMap.hh
"
11
12
#include "
Jeep/JPrint.hh
"
13
#include "
Jeep/JParser.hh
"
14
#include "
Jeep/JMessage.hh
"
15
16
17
/**
18
* \file
19
*
20
* Example program to test 3D integration of sphere.
21
* \author mdejong
22
*/
23
int
main
(
int
argc,
char
**argv)
24
{
25
using namespace
std;
26
27
unsigned
int
numberOfBins;
28
int
debug
;
29
30
try
{
31
32
JParser<>
zap(
"Example program to test 3D integration of sphere."
);
33
34
zap[
'N'
] =
make_field
(numberOfBins) = 101;
35
zap[
'd'
] =
make_field
(
debug
) = 3;
36
37
zap(argc, argv);
38
}
39
catch
(
const
exception &error) {
40
FATAL
(error.what() << endl);
41
}
42
43
44
using namespace
JPP;
45
46
47
const
double
R = 1.0;
48
49
typedef
JGridPolint3Function1D_t JFunction1D_t;
50
typedef
JMapList<JPolint3FunctionalGridMap> JMaplist_t;
51
typedef
JMultiFunction<JFunction1D_t, JMaplist_t> JMultiFunction_t;
52
53
54
JMultiFunction_t ga;
55
JMultiFunction_t gb;
56
57
const
double
xmin = -R * 1.05;
58
const
double
xmax = +R * 1.05;
59
const
double
dx = (xmax - xmin) / (numberOfBins - 1);
60
61
for
(
double
x = xmin; x < xmax + 0.5*dx; x += dx) {
62
for
(
double
y = xmin; y < xmax + 0.5*dx; y += dx) {
63
64
const
double
z = R*R - x*x - y*y;
65
66
if
(z > 0.0) {
67
ga[x][y] = -sqrt(z);
68
gb[x][y] = +sqrt(z);
69
}
else
{
70
ga[x][y] = 0.0;
71
gb[x][y] = 0.0;
72
}
73
}
74
}
75
76
ga.compile();
77
gb.compile();
78
79
cout <<
"Volume (real) "
<<
SCIENTIFIC
(12,4) << 4.0*
PI
*R*R*R/3.0 << endl;
80
cout <<
"Volume (calc) "
<<
SCIENTIFIC
(12,4) <<
getIntegral
(gb) -
getIntegral
(ga) << endl;
81
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1410
JTOOLS::PI
static const double PI
Constants.
Definition:
JConstants.hh:20
JFunctionalMap_t.hh
Various implementations of functional maps.
JFunction1D_t.hh
JPrint.hh
I/O formatting auxiliaries.
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1836
JToolsToolkit.hh
This include file contains various recursive methods to operate on multi-dimensional collections...
debug
int debug
debug level
Definition:
JSirene.cc:59
JFunctionalMap.hh
JMessage.hh
General purpose messaging.
JMapList.hh
FATAL
#define FATAL(A)
Definition:
JMessage.hh:65
JParser.hh
Utility class to parse command line options.
SCIENTIFIC
Auxiliary data structure for floating point format specification.
Definition:
JPrint.hh:498
JMultiFunction.hh
JTOOLS::getIntegral
JContainer_t::ordinate_type getIntegral(const JContainer_t &input)
Get integral of input data points.
Definition:
JToolsToolkit.hh:133
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5