/// Initialise the weights w and abscissas x.
void GaussLaguerre::initialise()
{
  int i;
  // Create Laguerre polynomial L_n of order n+1 using recurrence relation - L_{n+1} is required to calculate weights below
  Array<complex<double>,1> one(2);
  one = 1.0, -1.0;
  Polynomial currL(one); // 1-x
  Polynomial prevL;      // 1
  // 2n+1-x:
  Polynomial two_n_plus_one_minus_x(one);
  for (i=2;i<=n+1;i++) {
    two_n_plus_one_minus_x += 2.0;
    Polynomial tmp(currL);
    tmp   *= two_n_plus_one_minus_x;
	prevL *= -(i-1.0);
	tmp   += prevL;
	tmp   *= 1.0/double(i);
	prevL  = currL;
	currL  = tmp; }
  // Abscissas x are the roots of the Laguerre polynomial
  const Array<complex<double>,1>& roots = prevL.roots();
  for (i=1;i<=n;i++) x(i) = roots(i-1).real(); // note that indexing starts from 1, not 0 in this particular implementation
  // Calculate weights w - using eq. 14 at http://mathworld.wolfram.com/Laguerre-GaussQuadrature.html
  for (i=1;i<=n;i++) {
    double tmp = (n+1)*currL(x(i)).real();
	w(i) = x(i) / (tmp*tmp); }
}
void func2()
{
  /* Thread 2 */
  auto valsGivingZero = p.roots();
}
void func1()
{
  /* Thread 1 */
  auto rootsOfP = p.roots();
}