public class TriDiagonalSolver
extends java.lang.Object
Constructor and Description |
---|
TriDiagonalSolver() |
Modifier and Type | Method and Description |
---|---|
static Vector3d[] |
solve(VectorNd a,
VectorNd b,
VectorNd c,
Vector3d[] rvals)
Vectorized version of
solve() that
accepts a right hand side rvals consisting of an array of n
3-vectors, where nis the matrix size, and creates and returns an array of
n 3-vectors containing the corresponding solution. |
static boolean |
solve(VectorNd x,
VectorNd a,
VectorNd b,
VectorNd c,
VectorNd r)
Solves a tridiagonal matrix whose lower, diagonal and upper bands are
given by
a , b and c , respectively. |
static Vector3d[] |
solveCyclical(VectorNd a,
VectorNd b,
VectorNd c,
Vector3d[] rvals)
Vectorized version of
solveCyclical() that accepts a right hand side rvals consisting
of an array of n 3-vectors, where n is the matrix size, and creates and
returns an array of n 3-vectors containing the corresponding solution. |
static boolean |
solveCyclical(VectorNd x,
VectorNd a,
VectorNd b,
VectorNd c,
VectorNd r)
Solves a cyclical tridiagonal matrix whose lower, diagonal and upper
bands are given by
a , b and c , respectively. |
public static boolean solve(VectorNd x, VectorNd a, VectorNd b, VectorNd c, VectorNd r)
a
, b
and c
, respectively. The size of
the matrix n is given by the size of b
, and the matrix structure
looks like
[ b0 c0 ] [ a0 b1 c1 ] [ a1 b2 c2 ] [ ] [ .... ] [ ] [ a(n-3) b(n-2) c(n-2) ] [ a(n-2) b(n-1) ]
a
and b
must have sizes >=
n-1; extra values are
ignored. The right hand side is given by r
, and the result is
placed in x
, which is resized if necessary.x
- returns the solved resulta
- lower band; size must be >=
n-1b
- diagonal band; size determines the matrix size nc
- upper band; size must be >=
n-1r
- right hand side; size must be ntrue
if the matrix was successfully solved or false
if a zero divide was encounteredpublic static Vector3d[] solve(VectorNd a, VectorNd b, VectorNd c, Vector3d[] rvals)
solve()
that
accepts a right hand side rvals
consisting of an array of n
3-vectors, where nis the matrix size, and creates and returns an array of
n 3-vectors containing the corresponding solution. In effect, the method
applies the scalar solve to each of the x
, y
, z
fields of rvals
.a
- lower band; size must be >=
n-1b
- diagonal band; size determines the matrix size nc
- upper band; size must be >=
n-1rvals
- right hand side; length must be nnull
if
a zero divide was encounteredpublic static boolean solveCyclical(VectorNd x, VectorNd a, VectorNd b, VectorNd c, VectorNd r)
a
, b
and c
, respectively. The
size of the matrix n is given by the size of b
. Cyclical
tridiagonal matrices arise in the analysis of periodic systems, and have
the same structure as standard tridiagonal matrices, with addition of two
terms in upper right and lower left corners:
[ b0 c0 a(n-1) ] [ a0 b1 c1 ] [ a1 b2 c2 ] [ ] [ .... ] [ ] [ a(n-3) b(n-2) c(n-2) ] [ c(n-1) a(n-2) b(n-1) ]
a
and b
must have sizes >=
n, with a(n-1)
and c(n-1)
supplying the upper right and lower left terms,
respectively. The right hand side is given by r
, and the result
is placed in x
, which is resized if necessary.x
- returns the solved resulta
- lower band; size must be >=
nb
- diagonal band; size determines the matrix size nc
- upper band; size must be >=
nr
- right hand side; size must be ntrue
if the matrix was successfully solved or false
if a zero divide was encounteredpublic static Vector3d[] solveCyclical(VectorNd a, VectorNd b, VectorNd c, Vector3d[] rvals)
solveCyclical()
that accepts a right hand side rvals
consisting
of an array of n 3-vectors, where n is the matrix size, and creates and
returns an array of n 3-vectors containing the corresponding solution. In
effect, the method applies the scalar cyclical solve to each of the
x
, y
, z
fields of rvals
.a
- lower band; size must be >=
nb
- diagonal band; size determines the matrix size nc
- upper band; size must be >=
nrvals
- right hand side; length must be nnull
if
a zero divide was encountered