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.
  See Also:
    `PdMatrix`
  Author:
    Konrad Polthier
  Version:
    21.02.05, 1.30 revised (ep) New method `tridag`.
    11.01.05, 1.20 revised (ep) New methods for solving symmetric pentadiagonal systems.
    20.07.99, 1.00 revised (kp) All array indices start at 0.
    20.07.99, 1.00 created (kp)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PnMatrix()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `cyclic(double[] a, double[] b, double[] c, double[] r, double[] x, double[] bb, double[] u, double[] z, double[] tmp, int n, double eps)` Solves the equation `Au=r`, where `A` is a cyclic tridiagonal matrix with diagonal `b`, lower offdiagonal `a` and upper offdiagonal `c`.
    `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.
    `static boolean` | `penpes(int n, double[] a, double[] b, double[] c, double[] f, double[] d, double[] e, double[] h, double eps)` Solves a linear system of equations with penta-diagonal, symmetric coefficient matrix with additional perodicity coefficients (1,n-1),(1,n) and (2,n).
    `static boolean` | `pentas(int n, double[] a, double[] b, double[] c, double[] f, double eps)` Solves a linear system of equations with penta-diagonal, symmetric coefficient matrix.
    `static boolean` | `tridag(double[] a, double[] b, double[] c, double[] r, double[] u, double[] tmp, int n, double eps)` Solves the equation `Au=r`, where `A` is a tridiagonal matrix with diagonal `b`, lower offdiagonal `a` and upper offdiagonal `c`.

    - ### Methods inherited from class java.lang.Object

      `equals, 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[])`
      Author:
        Konrad Polthier
      Version:
        08.09.99, 1.20 revised (kp) Keep input matrix untouched.
        07.09.99, 1.10 revised (kp) Return false instead of throwing ArithmeticException.
        20.07.99, 1.00 created (kp)

    - #### 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[])`
      Author:
        Konrad Polthier
      Version:
        15.04.06, 1.20 revised (kp) Singular matrix just returns 0, but issues no warning.
        08.09.99, 1.10 revised (kp) Keep input matrix untouched.
        20.07.99, 1.00 created (kp)

    - #### 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[])`
      Author:
        Numerical Recipes, changed to Java and adapted by Konrad Polthier
      Version:
        20.07.99, 1.00 revised (kp) All array indices start at 0.
        20.07.99, 1.00 created (kp)

    - #### 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[])`
      Author:
        Numerical Recipes, changed to Java and adapted by Konrad Polthier
      Version:
        20.07.99, 1.00 revised (kp) All array indices start at 0.
        20.07.99, 1.00 created (kp)

    - #### pentas

          public static final boolean pentas(int n,
                                             double[] a,
                                             double[] b,
                                             double[] c,
                                             double[] f,
                                             double eps)

      Solves a linear system of equations with penta-diagonal, symmetric coefficient matrix. The arrays a, b, c and f are modified by the routine.
      Parameters:
        `n` - dimension of matrix; must be greater or equal to 3
        `a` - diagonal of length n
        `b` - 1st side diagonal of length n-1 (but array must be of length n)
        `c` - 2nd side diagonal of length n-2 (but array must be of length n)
        `f` - input: right hand side; output: solution
        `eps` - precision; recommended is 10^(-t+2) where t is machine precision
      Returns:
        true at success; false if matrix is (numerically) singular
      Author:
        From 'Eindimensionale Spline-Interpolations-Algorithmen, H. Späth', ported to Java by Eike Preuss

    - #### penpes

          public static final boolean penpes(int n,
                                             double[] a,
                                             double[] b,
                                             double[] c,
                                             double[] f,
                                             double[] d,
                                             double[] e,
                                             double[] h,
                                             double eps)

      Solves a linear system of equations with penta-diagonal, symmetric coefficient matrix with additional perodicity coefficients (1,n-1),(1,n) and (2,n). The arrays a, b, c and f are modified by the routine.
      Parameters:
        `n` - dimension of matrix; must be greater or equal to 5
        `a` - diagonal of length n
        `b` - 1st side diagonal of length n-1; and b[n-1] must contain matrix element (1,n)
        `c` - 2nd side diagonal of length n-2; and b[n-2],b[n-1] must contain matrix elements (1,n-1),(2,n)
        `f` - input: right hand side; output: solution
        `d` - helper array of length n
        `e` - helper array of length n
        `h` - helper array of length n
        `eps` - precision; recommended is 10^(-t+2) where t is machine precision
      Returns:
        true at success; false if matrix is (numerically) singular
      Author:
        From 'Eindimensionale Spline-Interpolations-Algorithmen, H. Späth', ported to Java by Eike Preuss

    - #### tridag

          public static boolean tridag(double[] a,
                                       double[] b,
                                       double[] c,
                                       double[] r,
                                       double[] u,
                                       double[] tmp,
                                       int n,
                                       double eps)

      Solves the equation `Au=r`, where `A` is a tridiagonal matrix with diagonal `b`, lower offdiagonal `a` and upper offdiagonal `c`.

      Input vectors `a`, `b`, `c` and `r` are not modified. The method only succeeds if no pivoting is required!

      Parameters:
        `a` - lower offdiagonal; only the entries 1,...,n-1 are used
        `b` - diagonal
        `c` - upper offdiagonal; only the entries 0,...,n-2 are used
        `r` - right hand side
        `u` - output: solution
        `tmp` - temporary vector of size `n`; may be null
        `n` - dimension of matrix/vectors
        `eps` - precision
      Returns:
        true at success
      Version:
        21.02.05, 1.00 created (ep) Created and adapted from numerical recipes (2.4).

    - #### cyclic

          public static boolean cyclic(double[] a,
                                       double[] b,
                                       double[] c,
                                       double[] r,
                                       double[] x,
                                       double[] bb,
                                       double[] u,
                                       double[] z,
                                       double[] tmp,
                                       int n,
                                       double eps)

      Solves the equation `Au=r`, where `A` is a cyclic tridiagonal matrix with diagonal `b`, lower offdiagonal `a` and upper offdiagonal `c`.

      Input vectors `a`, `b`, `c` and `r` are not modified. The method only succeeds if no pivoting is required!

      Parameters:
        `a` - lower offdiagonal; contains the element in upper right corner as `a[0]`
        `b` - diagonal
        `c` - upper offdiagonal; contains the element in lower left corner as `c[n-1]`
        `r` - right hand side
        `x` - output: solution
        `bb` - temporary vector of size `n`; may be null
        `u` - temporary vector of size `n`; may be null
        `z` - temporary vector of size `n`; may be null
        `tmp` - temporary vector of size `n`; may be null
        `n` - dimension of matrix/vectors
        `eps` - precision
      Returns:
        true at success
      Version:
        22.02.05, 1.00 created (ep) Created and adapted from numerical recipes (2.7).

"

The software JavaView? is copyright protected. All Rights Reserved.
"