All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PFuncTest.cpp
Go to the documentation of this file.
1 // $Id: PFuncTest.cpp,v 1.5 2006/12/08 12:15:24 hmd Exp $
2 // ============================================================================
3 // Include files
4 // ============================================================================
5 // STD & STL
6 // ============================================================================
7 #include <math.h>
8 #include <stdio.h>
9 #include <vector>
10 // ============================================================================
11 // GaudiMath
12 // ============================================================================
13 #include "GaudiMath/GaudiMath.h"
14 #include "GaudiMath/Adapters.h"
15 // ============================================================================
16 
17 // ============================================================================
25 // ============================================================================
26 
27 double fun ( const std::vector<double>& x)
28 {
29  return 3 * x[0] * x[0] + 5 * x[1] * x[1] + 8;
30 }
31 
32 int main()
33 {
34  const GaudiMath::Function& myfun = GaudiMath::adapter( 2 , &fun ) ;
35  Genfun::Argument arg(myfun.dimensionality());
36 
37  std::string format( "x[0]=%6.5f x[1]=%6.5f myfun=%+.10f");
38  format +=" fun=%+.10f fun-myfun=%+.10f \n" ;
39  std::vector<double> x =
40  std::vector<double>(myfun.dimensionality());
41 
42  for ( double a = 0; a < 3; ++a)
43  {
44  for (double b = 0; b < 3; ++b)
45  {
46  arg[0] = x[0] = a;
47  arg[1] = x[1] = b;
48 
49  printf ( format.c_str() ,
50  x[0], x[1], myfun(arg), fun(x),
51  fun(x) - myfun(arg) );
52  }
53  }
54 
55  exit(0);
56 
57 }
58 
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:133
int main()
Definition: PFuncTest.cpp:32
Genfun::AbsFunction Function
Definition: GaudiMath.h:26
GAUDI_API AIDAFunction adapter(const AIDA::IFunction &function)
Definition: Adapters.cpp:28
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:27