#include "CLHEP/GenericFunctions/GenericFunctions.hh"
#include "CLHEP/GenericFunctions/Sin.hh"
#include "CLHEP/GenericFunctions/Cos.hh"
#include "CLHEP/GenericFunctions/defs.h"
#include <float.h>
#include <cassert>
#include <cmath>
#include <iostream>
Go to the source code of this file.
◆ main()
int main |
( |
int |
, |
|
|
char ** |
|
|
) |
| |
Definition at line 11 of file testGenericFunctions.cc.
11 {
12
14
17
18 for (double x = 0; x < 100; x++) {
19
20
21 assert (fabs((
f*g) (x) - (sin(x)*cos(x))) <= FLT_EPSILON);
22 assert (fabs((
f+g) (x) - (sin(x)+cos(x))) <= FLT_EPSILON);
23 assert (fabs((
f-g) (x) - (sin(x)-cos(x))) <= FLT_EPSILON);
24 assert (fabs((
f/g) (x) - (sin(x)/cos(x))) <= FLT_EPSILON);
25
26
27
28 assert (fabs((p*
f)(x)- 4.0*sin(x)) <= FLT_EPSILON);
29 assert (fabs((
f*p)(x)- 4.0*sin(x)) <= FLT_EPSILON);
30
31
32
33 assert (fabs((
f*4.0)(x)- 4.0*sin(x)) <= FLT_EPSILON);
34 assert (fabs((4.0*
f)(x)- 4.0*sin(x)) <= FLT_EPSILON);
35
36
37 assert (fabs(((
f(g))(x)) - sin(cos(x))) <= FLT_EPSILON);
38
39 }
40
41
42
43 assert (fabs((p*p).getValue()- 4.0*4.0) <= FLT_EPSILON);
44
45
46 assert (fabs((4*p).getValue()- 4.0*4.0) <= FLT_EPSILON);
47 assert (fabs((p*4).getValue()- 4.0*4.0) <= FLT_EPSILON);
48
49
50 std::cout << "GenericFunctions autotest has passed" << std::endl;
51 return 0;
52}