All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DerivativeTest.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <math.h>
7 #include <stdio.h>
8 #include <iostream>
9 // ============================================================================
10 // Gaudi
11 // ============================================================================
12 #include "GaudiMath/GaudiMath.h"
14 // ============================================================================
15 // CLHEP
16 // ============================================================================
17 #include "CLHEP/GenericFunctions/Sin.hh"
18 // ============================================================================
19 // Handle CLHEP 2.0.x move to CLHEP namespace
20 namespace CLHEP { }
21 using namespace CLHEP;
22 
23 // ============================================================================
31 // ============================================================================
32 
33 int main()
34 {
35 
36  std::cout <<
37  " Test for numerical differentiation of Genfun::Sin(x) " << std::endl ;
38 
39  const GaudiMath::Function& mysin = Genfun::Sin();
40  const GaudiMath::Derivative& prim1 = GaudiMath::Derivative( mysin , 0 );
41  const GaudiMath::Function& prim = prim1 ;
42 
43  for( double x = -90 * Gaudi::Units::degree ;
44  x <= 180 * Gaudi::Units::degree ;
45  x += 10 * Gaudi::Units::degree ) {
46  double value = prim(x) ;
47  double error = prim1.error() ;
48  printf
49  ( " x=%8.3f deg; Sin'=%+.19f; ActualErr=%+.19f; EstimatedErr=%+.19f\n",
51  value ,
52  value - cos(x) ,
53  error );
54  }
55 
56  exit(0);
57 
58 }
59 
60 // ============================================================================
61 // The END
62 // ============================================================================
constexpr double degree
double error() const
the absolute error estimate for the last call
T endl(T...args)
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:29
int main()
Numerical derivative (using GSL adaptive numerical differentiation)