fastglc — quadrature with the fast Gauss-Legendre method of Ignace Bogaert.


#include <fastglc.h>
int (objective_t)( double x,
  void * context,
  double * fx);
extern int fastglc_eval( size_t n,
  objective_t * f,
  void * context,
  double * result);
extern const char * fastgcl_strerror ( int errorcode);


The fastglc_eval function evaluates the integral of the function f on the interval [-1, 1] using an n-point Gauss-Legendre quadrature.

The parameters, in detail, are:

size_t n

The number of nodes in the quadrature, must be positive.

objective_t * f

A function with prototype objective_t as in the synopsis above, for which the integral is sought.

The function should return zero for success and non-zero on error.

void * context

Context for the function f, which may be NULL provided that the function does not dereference it.

double * result

The result of the quadrature which will be assigned on success.


On success, returns zero (FASTGLC_OK) and assigns the results to result.

On error a nonzero value is returned, and the function fastglc_strerror can be used to obtain a description of the error.


J.J. Green.

This code is a C99 port of the C++ implementation by Ignace Bogaert.