#include <iostream>
using namespace std;


#include <print.h>
#include <vec.h>
#include <vectest.h>


void vectest::test01()
{
  cout << "Testing vec" << endl;
  uintc n=3;
  double a1[] = { 0.0, 0.0, 0.10 };
  double a2[n] = { 1.0, -3.0, 2.0 };
  double a3[n] = { 0.0, 0.0, 0.0 };

  cout << "a1=" << print(a1,a1+n) << endl;
  cout << "a2=" << print(a2,a2+n) << endl;
  
  cout << "v1 is a1" << endl;
  vec<double*,double> v1(&a1[0],n);
  cout << "v1 += a2" << endl;
  v1 += a2;
  cout << "v1=" << print(a1,a1+n) << endl;

  cout << "v1 += 3" << endl;
  v1 += 3.0;
  cout << "v1=" << print(a1,a1+n) << endl;

  cout << SHOW2(v1[1]=2.4) << endl;
  cout << "v1=" << print(a1,a1+n) << endl;

  vec<double*,double> x0(&a1[0],n);
  vec<double*,double> x1(&a2[0],n);
  vec<double*,double> x2(&a3[0],n);

  cout << "Calculating an equation" << endl;
  cout << "x2 = x0 + 2(x1-x0)" << endl;
  cout << "x0=" << (string)x0 << endl;
  cout << "x1=" << (string)x1 << endl;
  cout << SHOW2(x2 = x1) << endl;
  cout << "x2=" << (string)x2 << endl;
  cout << SHOW2(x2 -= x0) << endl;
  cout << "x2=" << (string)x2 << endl;
  cout << SHOW2(x2 *= 2.0) << endl;
  cout << "x2=" << (string)x2 << endl;
  cout << SHOW2(x2 += x0) << endl;
  cout << "x2=" << (string)x2 << endl;
}

void vectest::test02()
{
  cout << "Using vec to generate binomial coefficients" << endl;
  cout << "For D[X[n]] backward difference operator." << endl;
  uintc n=5;
  double ci[n] = { 1.0, 0.0, 0.0, 0.0, 0.0 };
  vec<double*,double> x(&ci[0],n);

  cout << (string)x << endl;
  x.difference();
  cout << (string)x << endl;
  x.difference();
  cout << (string)x << endl;
  x.difference();
  cout << (string)x << endl;
  x.difference();
  cout << (string)x << endl;

  cout << endl << endl;
  cout << "Generating the binomial coefficients." << endl;
  cout << "For case N=12" << endl;
  uintc N(13);
  double di[N];
  vec<double*,double> y(&di[0],N);
  y.binomial(12);

  cout << (string)y << endl;
}






