public class SymmetricTridiagonalFilter
extends java.lang.Object
When applied to an input array x of length n, the filter computes elements of an output y as follows:
y[i] = af*x[i] + b*x[i+1] ; for i = 0
y[i] = b*x[i-1] + ai*x[i] + b*x[i+1] ; for i = 1, 2, ..., n-2
y[i] = b*x[i-1] + al*x[i] ; for i = n-1
To facilitate different assumptions about values off the ends of arrays
(boundary conditions), the coefficients af
and al
for the first and last equations may differ from the coefficient
ai
used in the interior equations. In a tridiagonal matrix
representation of this filter, the coefficient af
is in the
upper left corner, and the coefficient al
is in the lower
right corner.
For example, the choice af = al = ai
is equivalent to assuming
zero values off the ends of input arrays. Likewise, the choice af =
al = ai+b
is equivalent to assuming zero-slope.
This filter and its inverse (if that exists) may be applied in place. For
all methods, the input array x
and output array y
can be the same array.
When applying an inverse filter, only a few simple checks are performed to
ensure that the inverse exists, that the tridiagonal matrix is not
singular. For example |a|≥2|b|
is required, so that the
matrix is diagonally dominant.
This software is an adaptation of Algorithm 4.1 in Boisvert, R.F., 1991, Algorithms for special tridiagonal systems: SIAM J. Sci. Stat. Comput., v. 12, no. 2, pp. 423-442.
Constructor and Description |
---|
SymmetricTridiagonalFilter(double af,
double ai,
double al,
double b)
Constructs a symmetric tridiagonal filter.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(float[] x,
float[] y)
Applies this filter.
|
void |
apply1(float[][][] x,
float[][][] y)
Applies this filter along the 1st dimension of a 3D array.
|
void |
apply1(float[][] x,
float[][] y)
Applies this filter along the 1st dimension of a 2D array.
|
void |
apply2(float[][][] x,
float[][][] y)
Applies this filter along the 2nd dimension of a 3D array.
|
void |
apply2(float[][] x,
float[][] y)
Applies this filter along the 2nd dimension of a 2D array.
|
void |
apply3(float[][][] x,
float[][][] y)
Applies this filter along the 3rd dimension of a 3D array.
|
void |
applyInverse(float[] x,
float[] y)
Applies the inverse of this filter.
|
void |
applyInverse1(float[][][] x,
float[][][] y)
Applies the inverse of this filter along the 1st dimension of a 3D array.
|
void |
applyInverse1(float[][] x,
float[][] y)
Applies the inverse of this filter along the 1st dimension of a 2D array.
|
void |
applyInverse2(float[][][] x,
float[][][] y)
Applies the inverse of this filter along the 2nd dimension of a 3D array.
|
void |
applyInverse2(float[][] x,
float[][] y)
Applies the inverse of this filter along the 2nd dimension of a 2D array.
|
void |
applyInverse3(float[][][] x,
float[][][] y)
Applies the inverse of this filter along the 3rd dimension of a 3D array.
|
static void |
main(java.lang.String[] args) |
static void |
test1Random() |
static void |
test1Simple() |
static void |
test2Random() |
static void |
test2Simple() |
static void |
test3Random() |
static void |
test3Simple() |
public SymmetricTridiagonalFilter(double af, double ai, double al, double b)
af
- the diagonal coefficient a for the first sample.ai
- the diagonal coefficient a for interior samples.al
- the diagonal coefficient a for the last sample.b
- the off-diagonal coefficient b.public void apply(float[] x, float[] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void apply1(float[][] x, float[][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void apply2(float[][] x, float[][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void apply1(float[][][] x, float[][][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void apply2(float[][][] x, float[][][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void apply3(float[][][] x, float[][][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void applyInverse(float[] x, float[] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void applyInverse1(float[][] x, float[][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void applyInverse2(float[][] x, float[][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void applyInverse1(float[][][] x, float[][][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void applyInverse2(float[][][] x, float[][][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public void applyInverse3(float[][][] x, float[][][] y)
x
- input array x; may be the same as the output array y.y
- output array y; may be the same as the input array x.public static void test1Simple()
public static void test2Simple()
public static void test3Simple()
public static void test1Random()
public static void test2Random()
public static void test3Random()
public static void main(java.lang.String[] args)