All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PFuncTest.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 <vector>
9 // ============================================================================
10 // GaudiMath
11 // ============================================================================
12 #include "GaudiMath/GaudiMath.h"
13 #include "GaudiMath/Adapters.h"
14 // ============================================================================
15 
16 // ============================================================================
24 // ============================================================================
25 
26 double fun ( const std::vector<double>& x)
27 {
28  return 3 * x[0] * x[0] + 5 * x[1] * x[1] + 8;
29 }
30 
31 int main()
32 {
33  const GaudiMath::Function& myfun = GaudiMath::adapter( 2 , &fun ) ;
34  Genfun::Argument arg(myfun.dimensionality());
35 
36  std::string format( "x[0]=%6.5f x[1]=%6.5f myfun=%+.10f");
37  format +=" fun=%+.10f fun-myfun=%+.10f \n" ;
39  std::vector<double>(myfun.dimensionality());
40 
41  for ( double a = 0; a < 3; ++a)
42  {
43  for (double b = 0; b < 3; ++b)
44  {
45  arg[0] = x[0] = a;
46  arg[1] = x[1] = b;
47 
48  printf ( format.c_str() ,
49  x[0], x[1], myfun(arg), fun(x),
50  fun(x) - myfun(arg) );
51  }
52  }
53 
54  exit(0);
55 
56 }
57 
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
int main()
Definition: PFuncTest.cpp:31
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
STL class.
GAUDI_API AIDAFunction adapter(const AIDA::IFunction &function)
Definition: Adapters.cpp:27
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26