home *** CD-ROM | disk | FTP | other *** search
- *** BASIC V Maths Library Functions ***
-
- Andy Pole
-
-
- The library contains functions to perform the following fundamental
- matrix algebraic operations: transposition; identity matrix;
- solution to linear equations determinant; inverse; decomposition;
- (operations related to eigenstructure are expected in the not too distant
- future!). Also included are routines for cubic spline fitting and interpolation
- for one and two (bicubic) dimensions. Many of the routines are based on FORTRAN
- functions contained in "Numerical Recipes. The Art of Scientific
- Computing," by W.H. Press, B.P. Flannery, S.A. Teukolsky, and W.T.
- Vetterling (CUP). Finally there are a group of utilities for displaying numeric
- arrays.
-
- All routines have been tested under a variety of conditions and have
- given correct results. However, all usual disclaimers apply!
-
-
- NOTE Error checking for things such as a square matrix
- for determinant calculation is *NOT* performed---anyone who wants
- this can easily make the required alterations.
-
- === Matrix Algebra ===
-
- Function DET(X()): returns the determinant of the n by n
- matrix X. This will work for any square matrix by using the LU decomposition.
-
- Function}CDET(X()): similar to DET but specifically for symmetric
- positive definite matrices. Here Cholesky decomposition is used which
- is, of course, much faster than LU.
-
- Procedure IDMAT(RETURN I()): sets up the identity matrix. Note
- that dimension checking is not performed which means that an array
- comprising more columns than rows will be accepted. In this case the
- `additional' columns will be ignored. This is a useful feature in some
- applications where certain kinds of augmented structure are required.
-
- Procedure IMAT(M(), RETURN IM()): The inverse of the n by n
- matrix M is computed and returned in IM.
-
- Procedure LUDCMP(RETURN A(), N\%, RETURN INDX\%(), RETURN D\%):
- Given an N% by N% matrix A, this routine replaces it by the LU
- decomposition of a rowwise permutation of itself. U is the upper
- triangular part of this, L the strict lower part together with the unit
- diagonal. INDEX% is an output
- N%-vector which records the row permutation effected by the partial
- pivoting. D% is output as +/- 1 depending on whether the number of
- row interchanges was even or odd respectively. This routine is used in
- combination with LUBKSB to solve linear equations or invert a matrix.
-
- Procedure LUBKSB(A(), N%, INDEX%(), B()): Solves the set of
- linear equations A.X=B. Here A is input, not as the matrix A but rather
- its LU decomposition, determined by the routine LUDCMP. INDEX% is
- input as the permutation vector returned by LUDCMP. B is input as the
- right-hand side vector B, and returns with the solution vector X. A and
- INDEX% are not modified by this routine and can be left in place for
- successive calls with different right-hand sides B. This routine takes
- into account the possibility that B will begin with many zero elements,
- so it is efficient for use in matrix inversion.
-
- Procedure CHOLESKY(X(), RETURN U()): The Cholesky decomposition of
- the symmetric positive definite matrix X is returned in U. (The
- algorithm is not in Numerical Recipes but can be found in good algebra
- or statistics texts. One example is G.A.F. Seber, "An Introduction
- to Linear Regression Analysis.")
-
- Procedure ISPDMAT(X(), RETURN IX()): The inverse of the spd matrix
- X is returned in IX. Inversion is performed via the Cholesky
- decomposition which is considerably faster than LU decomposition in this
- special case.
-
- Procedure TRANSPOSE(X(), RETURN XT()): Returns the transpose of X
- in XT. (Once again, no error checking is performed on argument dimensions.)
- _______________________________________________________________________________
-
- === Spline Fitting and Interpolation ===
-
- Procedure C_SPLINE(X(), Y(), RETURN Y2()): Given arrays X and Y
- containing a tabulated function, Y(i)=f[X(i)], with X(1)<X(2)<...<X(n),
- this routine returns an array of the second derivatives of the
- interpolating function at the tabulated points X. The local variables
- YP1 and YPN are set to use the so-called `not-a-knot' end conditions.
-
- Procedure C_SPLINT(X(), Y(), Y2(), x, RETURN y): Given arrays X
- and Y as in C_SPLINE and Y2 as returned from C_SPLINE, and given a value
- of x, this function returns a cubic spline interpolated value y.
-
- Procedure C2_SPLINE(X1(), X2(), Y(), RETURN Y2()): Given tabulated
- independent variables X1 (dimension m) and X2 (dimension n)
- and corresponding function values Y (dimension m by n), this
- routine constructs one-dimensional cubic splines of the rows of Y and
- returns the second derivatives in the (m by n) array Y2.
-
- Procedure C2_SPLINT(X1(), X2(), Y(), Y2(), x1, x2, RETURN y):
- given X1, X2 and Y as in C2_SPLINE and Y2 as produced by that routine,
- and given a desired interpolating point (x1, x2), this routine returns
- an interpolated function value y by bicubic spline interpolation.
- _______________________________________________________________________________
-
- === Array Display Routines ===
-
- Procedure PRINTVEC(V()) prints a REAL vector.
-
- Procedure PRINTVECI(V%()) prints an INTEGER vector.
-
- Procedure PRINTMAT(M()) prints a REAL matrix.
-
- Prodcedure PRINTMATI(M%()) prints an INTEGER matrix.
- _______________________________________________________________________________
-
- Comments/bugs/queries to:
-
- Dr. Andy Pole
- 48 Thorney Road
- Coventry
- CV2 3PH
-
-
- 15 October 1988.
-