
#include <print.h>


#include <partialderivativetest.h>

#include <exploreh.h>
#include <probsysequ01.h>
#include <partialderivative.h>


void partialderivativetest01()
{
  cout << "This test is to solve a non-linear system of equations" << endl;
  cout << " numerically and terminate the approximation when the" << endl;
  cout << " parital derivatives become small." << endl;
  exploreh<probsysequ01,double*,double> g(2,0.2,50000);

  double x0[2] = { 0.5, 0.5 };

  g.reset(x0);

  g.print(cout);

  double zero = 1e-5;
  cout << "Iterate until the partial derivative are less than" << endl;
  cout << " " << zero << " in magnitude." << endl;
  bool valid=true;

  partialderivative< exploreh<probsysequ01,double*,double> > partiald(g);

  uintc kmax=30;
  for (uint i=0; valid; ++i)
  {
    for (uint k=0; k<kmax; ++k)
      ++g;

    partiald();
    if (zero > partiald.absvalue() )
      valid=false;

cout << SHOW(i) << endl;
    //++g;

  }

  g.print(cout);
  cout << SHOW(g.fn.counter) << endl;

}




