//Set up the nodes (x) and weights (w) of Gaussian quadrature, using the Golub Welsch algorithm
//coeffs and vectors are allocated arrays which are required only for solving the tridiagonal matrix equation
void gauss_integration_setup(int datapoints, double *weights, double *x)
{  int idx; double *coeffs, *vectors;

  coeffs=(double*)malloc((datapoints-1)*sizeof(double));	
  vectors=(double*)malloc(datapoints*datapoints*sizeof(double));

   x[0]=0.0;
   for (idx=1;idx<datapoints;idx++)
	{
	x[idx]=0.0;
	coeffs[idx-1]=0.5/sqrt(1.0-1.0/(4.0*idx*idx));
	}	

   //dstev finds the eigenvalues and vectors of a symmetric matrix
   LAPACKE_dstev(LAPACK_ROW_MAJOR,'v', datapoints, x, coeffs, vectors, datapoints);

   for (idx=0;idx<datapoints;idx++)
	{
	x[idx]=0.5*(x[idx]+1.0);	//This leads to nodes in the range (0,1)
	weights[idx]=vectors[idx]*vectors[idx];
	}

  free(coeffs);
  free(vectors);
}
Exemple #2
0
template <> inline
int stev(const char order, const char job, const int N, double *D, double *E, double *Z, const int LDZ)
{
	return LAPACKE_dstev(order, job, N, D, E, Z, LDZ);
}