#include <iostream>
using namespace std;

#include <print.h>
#include <powerseries1D.h>
#include <powerseriesWD.h>

#include <powerseriestest.h>

void powerseriestest::test01()
{
  cout << "Power series test" << endl;

  double az[4] = {1.0,2.0,3.0,4.0};

  powerseries1D<double> f(az,4);

  double y;
  cout << "Expect 10" << endl;
  f(y,1.0);
  cout << SHOW(y) << endl;
  cout << "Expect 49" << endl;
  f(y,2.0);
  cout << SHOW(y) << endl;
  cout << endl;
  cout << "Testing the function another way." << endl;
  cout << SHOW(f(2.0)) << endl;
  f.differentiate();
  for (uint i=0; i<4; ++i)
  {
    cout << f.ai[i] << "*t^" << i << "+";
  }
  
}

void powerseriestest::test02()
{
  uintc N(4);
  uintc W(2);
  double az[W*N] = 
  { 
    1.0, 2.0, 3.0, 4.0,
    3.0, -7.0, 4.5, 0.0
  };

  powerseriesWD<double> f(az,W,N);

  double y;
  cout << "Expect 10" << endl;
  f.currentSet(0);
  f(y,1.0);
  cout << SHOW(y) << endl;

  f.currentSet(1);
  f(y,1.0);
  cout << SHOW(y) << endl;
}




