#ifndef PROBPARAB_H
#define PROBPARAB_H

#include <dumbarray.h>

#include <print.h>

/*!
  \brief Test Problem of a 3D parabola.

  The state xi needs to be initialized.

*/
class probparab
{
public:

  double * xi;

  void operator () ( double & fval )
  {
    double a = xi[0]-1.0;
    double b = xi[1]-2.0;
    double c = xi[2]-5.0;
    fval = a*a+b*b+c*c;
  }
};
/*!
  \brief Test Problem of a 3D parabola.

  The minimizer uses the state in the function.
*/
class probparab2
{
public:

  uint counter;

  double *xi;

  /** Allocate memory for xi.*/
  probparab2();

  /** Free memory. */
  ~probparab2();

  void operator () ( double & fval )
  {
    ++counter;

//cout << "probparab2: xi=" << printvecfunc(xi,3) << endl;

    double a = xi[0]-1.0;
    double b = xi[1]-2.0;
    double c = xi[2]-5.0;
    fval = a*a+b*b+c*c;
  }
};

/*!
  \brief Test Problem of a 3D parabola.
*/
class probparab3
{
public:

  // For demo purposes.
  double a0;
  double a1;
  double a2;

  dumbarray<double> xi;

  /** Initialize memory for xi.*/
  probparab3();

  void operator () ( double & fval )
  {
    double a = xi[0]-1.0;
    double b = xi[1]-2.0;
    double c = xi[2]-5.0;
    fval = a*a+b*b+c*c;
  }
};

#endif



