Skip to content

A routine that generates an arbitrarily-weighted quadrature scheme

License

Notifications You must be signed in to change notification settings

gjwilkie/genquad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

genquad

A routine that generates an arbitrarily-weighted quadrature scheme for Gaussian numerical integration. Written in Fortran 90 and requires the LAPACK linear algebra library.

You wish to approximate the integral:

alt text

where xi and wi are the grid points (a.k.a. "abscissae") and weights of the N-point quadrature scheme, respectively. Knowledge of the weighting function g(x) is contained in these arrays. This package generates these abscissae and weights for any given (relatively well-behaved) weighting function g.

An important feature of Gaussian quadrature is spectral accuracy. Instead of the error decreasing as a power of N, it decreases *exponentially with N.

If you wish to use N > 80, quadratic precision is necessary in calculating the quadrature rules (though not necessarily in the rules themselves). To do so, include the flag -freal-r-real-16 if compiling with gfortran. However, if you need this many grid points, you should consider using a different weighting function or an adaptive numerical integration scheme.

Using genquad

  1. Copy quadpack.f90 and genquad.f90 to your source directory and include the genquad module
use genquad, only: get_quadrature_rule
  1. When building your application, include your LAPACK library when linking. Also, include following in your Makefile:
FFLAGS = -freal-r-real-8

genquad.o : genquad.f90 quadpack.o
   gfortran -c $(FFLAGS) genquad.f90

quadpack.o : quadpack.f90
   gfortran -c $(FFLAGS) quadpack.f90
  1. Make sure the weighting function is defined as external in the calling routine.

Testing genquad

To ensure integrals are acurately estimated and specral accuracy is maintained, you may wish to run the test suite. To do so:

  1. Update Makefile with the location of your LAPACK library and, if necessary, your fortran compiler.
  2. Run make test

Reference

See Appendix C of thesis for more details.

About

A routine that generates an arbitrarily-weighted quadrature scheme

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published