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