NAG - Numerical Algorithms Group library
The NAG Fortran library is an extensive and robust library of numerical
algorithms that has been tested over many years. It is reliable and
comprehensive.
NAG's own on-line documentation :
There are also 8 volumes of manuals in book form (for Version 14)
(somewhere). We seem to have Version 17 at the time of writing, but do
ls -l /opt/lib/libnag.a to get an up-to-date view. Source code
not available. Not currently on Linux.
Examples (in Fortran) of how to use each routine can also be found in
somewhere like here.
Calling NAG Fortran routines from C/C++:
Here is a simple example in C++ for
the NAG complex division function A02ACF. The source code is:
#include
extern "C" {
void a02acf_(double &XR, double &XI, double &YR, double &YI, double &ZR, double &ZI);
}
int main() {
double XR=1.0, XI=1.0, YR=0.0, YI=1.0, ZR, ZI;
a02acf_(XR,XI,YR,YI,ZR,ZI);
cout << "z = (" << ZR << "," << ZI << ")\n";
}
Notes:
- the NAG function must be renamed:
A02ACF has become a02acf_
- a suitable function declaration is needed for each function (wrapped in
extern "C" { } if using C++)
- all arguments are passed in by reference (C programmers use pointers)
- 2D array indices in Fortran are the opposite way round from C/C++
- strings: my impression is that they are stored like they are in C (i.e. with trailing null). Any more information would be welcome.
- more complex arguments - try Jonathan Deane
Linking under Solaris:
- using QMake, add
nag to the USESLIBs variable
- using
ld, add -lnag to the library path
NAG with SGI:
On SGI there are 2 libraries: nag3000 and nag4000,
corresponding to two different cpu models (neither compatible with AMMA). I'm
not sure we have it installed correctly.
Acknowledgements:
Thanks to Jonathan Deane, who supplied most of the information on this page.
Bill Christmas
Last modified: Mon Oct 27 14:27:25 GMT 2003