The Gaudi Framework  v30r3 (a5ef0a68)
PFuncTest.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <cmath>
7 #include <cstdio>
8 #include <vector>
9 // ============================================================================
10 // GaudiMath
11 // ============================================================================
12 #include "GaudiMath/Adapters.h"
13 #include "GaudiMath/GaudiMath.h"
14 // ============================================================================
15 
16 // ============================================================================
24 // ============================================================================
25 
26 double fun( const std::vector<double>& x ) { return 3 * x[0] * x[0] + 5 * x[1] * x[1] + 8; }
27 
28 int main()
29 {
30  const GaudiMath::Function& myfun = GaudiMath::adapter( 2, &fun );
31  Genfun::Argument arg( myfun.dimensionality() );
32 
33  std::string format( "x[0]=%6.5f x[1]=%6.5f myfun=%+.10f" );
34  format += " fun=%+.10f fun-myfun=%+.10f \n";
35  std::vector<double> x( myfun.dimensionality() );
36 
37  for ( double a = 0; a < 3; ++a ) {
38  for ( double b = 0; b < 3; ++b ) {
39  arg[0] = x[0] = a;
40  arg[1] = x[1] = b;
41 
42  printf( format.c_str(), x[0], x[1], myfun( arg ), fun( x ), fun( x ) - myfun( arg ) );
43  }
44  }
45 }
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:120
int main()
Definition: PFuncTest.cpp:28
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
STL class.
GAUDI_API AIDAFunction adapter(const AIDA::IFunction &function)
Definition: Adapters.cpp:25
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26