The Gaudi Framework  v29r0 (ff2e7097)
InterpTest.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD& STL
5 // ============================================================================
7 #include "GaudiMath/GaudiMath.h"
8 #include <cmath>
9 #include <cstdio>
10 #include <iostream>
11 
12 // ============================================================================
20 // ============================================================================
21 
22 int main()
23 {
24 
25  const GaudiMath::Function& mysin = GaudiMath::SimpleFun( sin );
26  const GaudiMath::Function& mycos = GaudiMath::SimpleFun( cos );
27 
30 
31  for ( int i = 0; i <= 20; ++i ) {
32  double x = i * 3.141592 / 20.0;
33  double y = mysin( x );
34  vctx.push_back( x );
35  vcty.push_back( y );
36  }
37 
39 
40  const GaudiMath::Constant minusOne( -1.0, 1 );
41  const GaudiMath::Constant plusOne( 1.0, 1 );
42 
44  const GaudiMath::Spline i1( vctx, vcty, Cspline_Periodic );
45 
47  const GaudiMath::SplineDeriv i2( vctx, vcty, Cspline_Periodic );
48 
50  const GaudiMath::Function& i3 = GaudiMath::SplineDeriv2( vctx, vcty, Cspline_Periodic ) * minusOne;
51 
53  const GaudiMath::Function& i4 = plusOne + GaudiMath::SplineInteg( vctx, vcty, Cspline_Periodic, 0.0 ) * minusOne;
54 
55  for ( int i = 0; i < 30; ++i ) {
56  double x = i * 3.141592 / 30.0;
57  printf( "x=%+7.1f; Sin-i1=%+14.9f; Cos-i2=%+14.9f; Sin-i3=%+14.9f; Cos-i4=%+14.9f;\n", x / Gaudi::Units::degree,
58  mysin( x ) - i1( x ), mycos( x ) - i2( x ), mysin( x ) - i3( x ), mycos( x ) - i4( x ) );
59  }
60 }
Genfun::GaudiMathImplementation::GSLSplineDeriv2 SplineDeriv2
Definition: GaudiMath.h:35
constexpr double degree
Genfun::GaudiMathImplementation::SimpleFunction SimpleFun
Definition: GaudiMath.h:28
Fixed constant function.
Definition: Constant.h:31
int main()
Definition: InterpTest.cpp:22
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
T push_back(T...args)
Genfun::GaudiMathImplementation::GSLSplineInteg SplineInteg
Definition: GaudiMath.h:36