#include <cmath>
using namespace std;

#include <bernstein.h>
#include <mathlib.h>




void bernsteinPoly::construct
( 
  uintc n_, 
  uintc i_
)
{
  n = n_;
  i = i_;
  construct();
}

bernsteinPoly::bernsteinPoly
( 
  uintc n_, 
  uintc i_
)
  : n(n_), i(i_)
{
  construct();
}

void bernsteinPoly::construct()
{
  mathcombination(coeff,n,i);
}

void bernsteinPoly::eval
(
  double & res,
  doublec t
) const
{
  doublec a1(1.0-t);
  res = coeff * pow(t,(double)i) * pow(a1,(double)(n-i));
}


void bernsteinPolyProd::construct()
{
  b0.construct();
  b1.construct();
}

void bernsteinPolyProd::eval
(
  double & res, 
  doublec u, 
  doublec v
) const
{
  res = b0.eval(u)*b1.eval(v);
}

bernsteinPolyProd::bernsteinPolyProd
( 
  uintc n0_, 
  uintc i0_,
  uintc n1_, 
  uintc i1_
)
  : b0(n0_,i0_), b1(n1_,i1_)
{
  construct();
}






