public class PnMatrix
extends java.lang.Object
PdMatrix
Constructor and Description |
---|
PnMatrix() |
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 . |
public static void main(java.lang.String[] args)
public static boolean invert(double[][] y, double[][] aIn, int n)
ludcmp(double[][], int, int[])
,
lubksb(double[][], int, int[], double[])
public static double determinant(double[][] aIn, int n)
All array indices start with 0 rather than the standard fortran 1.
ludcmp(double[][], int, int[])
,
lubksb(double[][], int, int[], double[])
public static double ludcmp(double[][] a, int n, int[] indx) throws java.lang.ArithmeticException
This version is taken from Numerical Recipes and adapted such that all array indices start with 0 rather than the standard fortran 1.
java.lang.ArithmeticException
- if A was singular.lubksb(double[][], int, int[], double[])
public static void lubksb(double[][] a, int n, int[] indx, double[] b)
This version is taken from Numerical Recipes and adapted such that all array indices start with 0 rather than the standard fortran 1.
ludcmp(double[][], int, int[])
public static final boolean pentas(int n, double[] a, double[] b, double[] c, double[] f, double eps)
n
- dimension of matrix; must be greater or equal to 3a
- diagonal of length nb
- 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: solutioneps
- precision; recommended is 10^(-t+2) where t is machine precisionpublic static final boolean penpes(int n, double[] a, double[] b, double[] c, double[] f, double[] d, double[] e, double[] h, double eps)
n
- dimension of matrix; must be greater or equal to 5a
- diagonal of length nb
- 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: solutiond
- helper array of length ne
- helper array of length nh
- helper array of length neps
- precision; recommended is 10^(-t+2) where t is machine precisionpublic static boolean tridag(double[] a, double[] b, double[] c, double[] r, double[] u, double[] tmp, int n, double eps)
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!
a
- lower offdiagonal; only the entries 1,...,n-1 are usedb
- diagonalc
- upper offdiagonal; only the entries 0,...,n-2 are usedr
- right hand sideu
- output: solutiontmp
- temporary vector of size n
; may be nulln
- dimension of matrix/vectorseps
- precisionpublic 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)
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!
a
- lower offdiagonal; contains the element in upper right corner as a[0]
b
- diagonalc
- upper offdiagonal; contains the element in lower left corner as c[n-1]
r
- right hand sidex
- output: solutionbb
- temporary vector of size n
; may be nullu
- temporary vector of size n
; may be nullz
- temporary vector of size n
; may be nulltmp
- temporary vector of size n
; may be nulln
- dimension of matrix/vectorseps
- precision"