All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
InterpTest.cpp
Go to the documentation of this file.
1 // $Id: Interp.cpp,v 1.3 2006/12/08 12:15:24 hmd Exp $
2 // ============================================================================
3 // Include files
4 // ============================================================================
5 // STD& STL
6 // ============================================================================
7 #include <cmath>
8 #include <iostream>
9 #include <cstdio>
11 #include "GaudiMath/GaudiMath.h"
12 
13 // ============================================================================
21 // ============================================================================
22 
23 int main()
24 {
25 
26  const GaudiMath::Function& mysin = GaudiMath::SimpleFun( sin );
27  const GaudiMath::Function& mycos = GaudiMath::SimpleFun( cos );
28 
29  std::vector<double> vctx ;
30  std::vector<double> vcty ;
31 
32  for ( int i = 0 ; i < 20 ; ++i )
33  {
34  double x = i * 3.141592/20.0 ;
35  double y = mysin ( x ) ;
36  vctx.push_back ( x ) ;
37  vcty.push_back ( y ) ;
38  }
39 
41 
42  const GaudiMath::Constant minusOne (-1.0, 1);
43  const GaudiMath::Constant plusOne (1.0, 1);
44 
46  const GaudiMath::Spline i1(vctx, vcty, Cspline_Periodic);
47 
49  const GaudiMath::SplineDeriv i2(vctx, vcty, Cspline_Periodic);
50 
52  const GaudiMath::Function& i3 =
53  GaudiMath::SplineDeriv2(vctx, vcty, Cspline_Periodic) * minusOne;
54 
56  const GaudiMath::Function& i4 = plusOne +
57  GaudiMath::SplineInteg(vctx, vcty, Cspline_Periodic, 0.0) * minusOne;
58 
59  for ( int i = -10 ; i < 30 ; ++i ) {
60  double x = i * 3.141592/30.0 ;
61  printf( "x=%+7.1f; Sin-i1=%+14.9f; Cos-i2=%+14.9f; Sin-i3=%+14.9f; Cos-i4=%+14.9f;\n",
62  x / Gaudi::Units::degree,
63  mysin ( x ) - i1( x ),
64  mycos ( x ) - i2( x ),
65  mysin ( x ) - i3( x ),
66  mycos ( x ) - i4( x ));
67  }
68 
69  exit(0);
70 
71 }
72 
Genfun::GaudiMathImplementation::GSLSplineDeriv2 SplineDeriv2
Definition: GaudiMath.h:46
Genfun::GaudiMathImplementation::SimpleFunction SimpleFun
Definition: GaudiMath.h:33
Fixed constant function.
Definition: Constant.h:25
int main()
Definition: InterpTest.cpp:23
Genfun::AbsFunction Function
Definition: GaudiMath.h:26
Genfun::GaudiMathImplementation::GSLSplineInteg SplineInteg
Definition: GaudiMath.h:48
list i
Definition: ana.py:128