Package nr

Numerical algorithms inspired by Numerical Recipes.


Interface Summary
Extrapolator implements an extrapolation calculation routine for a vector function.
Mat based on the Matrix template from Numerical Recipes.
MatDecomposition represents a decomposition of a matrix so that it can be used to solve linear equations.
Vec based on the vector template of Numerical Recipes.

Class Summary
Function A functionoid designed to implement a scalar function of a scalar
LUDecomposition LU Decomposition.
Mat_array Implements a simple Mat based on a fixed array
Mat_wrapper Implements a simple Mat based on a based on an external array.
MatMath basic functions for vector and matrix math not particularly efficient--they allocate a lot of objects that are promptly deallocated
Polynomial Polynomial evaluations, from CERN
PolynomialExtrapolator Extrapolator based on pzextr in Numberical Recipes section 16.4
ScalarFunction A functionoid designed to implement a scalar function of a vector
SingularValueDecomposition Singular Value Decomposition.
SpecialFunctions Some useful functions
Vec_array Implements a simple Vec based on a fixed array
Vec_wrapper Implements a simple Vec based on an external array.
VecFunction A functionoid designed to implement a vector function of a vector

Exception Summary
DidNotConvergeException thrown when an algorithm in package nr does not converge on a solution.

Package nr Description

Numerical algorithms inspired by Numerical Recipes. These use the classes Vec for vectors and Mat for matrices that are simply interfaces that provide get/set methods for individual elements. Use the Vec_array and Mat_array for simple implementations that use double[] and double[][].

Many of the algorithms (mostly the ODE solvers and extrapolation) are from Numerical Recipes, but implemented by me, and I believe that none of these violate their copyright. These routines are released under the Sun Public License, but please acknowledge me.

The matrix decompositions are from the jama package from the National Institute of Standards and Technology. Those are written in Java and are in the public domain, so no concern about violating NR's overly restrictive licensing.

The statistical and random functions are from the CERN COLT package. This is probably the best collection of JAVA numerical algorithms, and I should use them more.

On a personal note, I think NR is great, and have been using since the first C version, but agree with the comments on Amazon. It's still written in FORTRAN, despite nominally being translated to C++. This is obvious from the 6-letter routine names and the use of i-n initial letters for integers, but even more so in the algorithms. They are all written as procedural code, with no use of object-oriented language features even where they would be ideal. They use global variables and hard-coded function names to pass things "behind the back" of their routines, where they should be using instance variables and methods. Actually using their routines (especially in a different language like Java) requires a fair amount of translation. The algorithms themselves, and the text, are very good.

I did not use the jama.Matrix class directly, because I wanted the vectors and matrices to be interfaces rather than classes. This gives me more flexibility in using other data structures especially sub-vectors and sub-matrices. It does, however, sacrifice performance, since the CERN and NIST data structures are finely tuned for performance.

Daniel Wachsstock 28 July 2004