JavaView® v2.00.008

jvx.numeric
Class PnMatrix

java.lang.Object
  |
  +--jvx.numeric.PnMatrix

public class PnMatrix
extends java.lang.Object

Numerical routines for bigger matrix linear algebra problems. Methods are taken from Numerical Recipes and adapted such that all array indices start with 0 rather than the standard fortran 1.

Version:
20.07.99, 1.00 revised (kp) All array indices start at 0.
20.07.99, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
PdMatrix

Constructor Summary
PnMatrix()
           
 
Method Summary
static double determinant(double[][] aIn, int n)
          Compute determinant of a given NxN matrix A.
static boolean invert(double[][] y, double[][] aIn, int n)
          Invert a given NxN matrix A and return its invers.
static void lubksb(double[][] a, int n, int[] indx, double[] b)
          Solves the set of N linear equations AX=B.
static double ludcmp(double[][] a, int n, int[] indx)
          Given an NxN matrix A this routine replaces it by the LU decomposition of a rowwise permutation of itself.
static void main(java.lang.String[] args)
          Test routine for matrix inversion.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PnMatrix

public PnMatrix()
Method Detail

main

public static void main(java.lang.String[] args)
Test routine for matrix inversion.

invert

public static boolean invert(double[][] y,
                             double[][] aIn,
                             int n)
Invert a given NxN matrix A and return its invers. Apply LU decomposition. A and N are input. Y is output containing the invers of matrix A. Input matrix is not modified since copied to a temporary matrix. All array indices start with 0 rather than the standard fortran 1.
Returns:
false if A was singular and therefore LU failed.
See Also:
ludcmp(double[][], int, int[]), lubksb(double[][], int, int[], double[])

determinant

public static double determinant(double[][] aIn,
                                 int n)
Compute determinant of a given NxN matrix A. Apply LU decomposition. A and N are input. Y is output containing the invers of matrix A. Input matrix is not modified since copied to a temporary matrix. All array indices start with 0 rather than the standard fortran 1.
Returns:
determinant, or 0. if matrix is singular.
See Also:
ludcmp(double[][], int, int[]), lubksb(double[][], int, int[], double[])

ludcmp

public static double ludcmp(double[][] a,
                            int n,
                            int[] indx)
                     throws java.lang.ArithmeticException
Given an NxN matrix A this routine replaces it by the LU decomposition of a rowwise permutation of itself. A and N are input. A is output, arranged as in equation (2.3.14) described in Numerical Recipes; INDX is an output vector which record the row permutation effected by the partial pivoting; the return value is +/-1 depending on whether the number of row interchanges was even (1.) or odd (-1.). This routine is used in combination with LUBKSB to solve linear equations or invert a matrix.

This version is taken from Numerical Recipes and adapted such that all array indices start with 0 rather than the standard fortran 1.

Throws:
java.lang.ArithmeticException - if A was singular.
See Also:
lubksb(double[][], int, int[], double[])

lubksb

public static void lubksb(double[][] a,
                          int n,
                          int[] indx,
                          double[] b)
Solves the set of N linear equations AX=B. Here A is input, not as the matrix A but rather as its LU decomposition, determined by the routine LUDCMP. INDX 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, N, NP and INDX are not modified by the 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 the use in matrix inversion.

This version is taken from Numerical Recipes and adapted such that all array indices start with 0 rather than the standard fortran 1.

See Also:
ludcmp(double[][], int, int[])

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.