public class FloatBandMatrix extends SMatrix
In numerical analysis, matrices from finite element or finite difference problems are often banded. Such matrices can be viewed as descriptions of the coupling between the problem variables; the bandedness corresponds to the fact that variables are not coupled over arbitrarily large distances. Such matrices can be further divided - for instance, banded matrices exist where every element in the band is nonzero. These often arise when discretizing one-dimensional problems. Problems in higher dimensions also lead to banded matrices, in which case the band itself also tends to be sparse. For instance, a partial differential equation on a square domain (using central differences) will yield a matrix with a half-bandwidth equal to the square root of the matrix dimension, but inside the band only 5 diagonals are nonzero. Unfortunately, applying Gaussian elimination (or equivalently an LU decomposition) to such a matrix results in the band being filled in by many non-zero elements. As sparse matrices lend themselves to more efficient computation than dense matrices, there has been much research focused on finding ways to minimize the bandwidth (or directly minimize the fill in) by applying permutations to the matrix, or other such equivalence or similarity transformations.
From a computational point of view, working with band matrices is always preferential to working with similarly dimensioned dense square matrices. A band matrix can be likened in complexity to a rectangular matrix whose row dimension is equal to the bandwidth of the band matrix. Thus the work involved in performing operations such as multiplication falls significantly, often leading to huge savings in terms of calculation time and complexity.
Given a n-by-n band matrix with m1 rows below the diagonal and m2 rows above. The matrix is compactly stored in an array A[0,n-1][0,m1+m2]. The diagonal elements are in A[0,n-1][m1]. Subdiagonal elements are in A[j,n-1][0,m1-1] with j > 0 appropriate to the number of elements on each subdiagonal. Superdiagonal elements are in A[0,j][m1+1,m2+m2] with j < n-1 appropriate to the number of elements on each superdiagonal.
Modifier and Type | Class and Description |
---|---|
static class |
FloatBandMatrix.Cholesky
The Cholesky decomposition of a symmetric, positive-definite matrix.
|
static class |
FloatBandMatrix.LU
The LU decomposition.
|
Constructor and Description |
---|
FloatBandMatrix(int m,
int n,
int kl,
int ku)
Constructor.
|
FloatBandMatrix(int m,
int n,
int kl,
int ku,
float[][] AB)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
FloatBandMatrix.Cholesky |
cholesky()
Cholesky decomposition for symmetric and positive definite matrix.
|
FloatBandMatrix |
clone() |
boolean |
equals(FloatBandMatrix o,
float eps)
Returns if two matrices equals given an error margin.
|
boolean |
equals(java.lang.Object o) |
float |
get(int i,
int j)
Returns A[i, j].
|
boolean |
isSymmetric()
Return if the matrix is symmetric (uplo != null).
|
int |
kl()
Returns the number of subdiagonals.
|
int |
ku()
Returns the number of superdiagonals.
|
Layout |
layout()
Returns the matrix layout.
|
int |
ld()
Returns the leading dimension.
|
FloatBandMatrix.LU |
lu()
LU decomposition.
|
void |
mv(float[] work,
int inputOffset,
int outputOffset)
Matrix-vector multiplication A * x.
|
void |
mv(Transpose trans,
float alpha,
float[] x,
float beta,
float[] y)
Matrix-vector multiplication.
|
int |
ncols()
Returns the number of columns.
|
int |
nrows()
Returns the number of rows.
|
FloatBandMatrix |
set(int i,
int j,
float x)
Sets A[i,j] = x.
|
long |
size()
Returns the number of stored matrix elements.
|
void |
tv(float[] work,
int inputOffset,
int outputOffset)
Matrix-vector multiplication A' * x.
|
UPLO |
uplo()
Gets the format of packed matrix.
|
FloatBandMatrix |
uplo(UPLO uplo)
Sets the format of symmetric band matrix.
|
apply, diag, market, mv, mv, mv, trace, tv, tv, tv, update
public FloatBandMatrix(int m, int n, int kl, int ku)
m
- the number of rows.n
- the number of columns.kl
- the number of subdiagonals.ku
- the number of superdiagonals.public FloatBandMatrix(int m, int n, int kl, int ku, float[][] AB)
m
- the number of rows.n
- the number of columns.kl
- the number of subdiagonals.ku
- the number of superdiagonals.AB
- the band matrix. A[i, j] is stored in
AB[ku+i-j, j] for max(0, j-ku) <= i <= min(m-1, j+kl).public FloatBandMatrix clone()
clone
in class java.lang.Object
public int nrows()
IMatrix
public int ncols()
IMatrix
public long size()
IMatrix
public int kl()
public int ku()
public Layout layout()
public int ld()
public boolean isSymmetric()
public FloatBandMatrix uplo(UPLO uplo)
public UPLO uplo()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean equals(FloatBandMatrix o, float eps)
o
- the other matrix.eps
- the error margin.public float get(int i, int j)
SMatrix
public FloatBandMatrix set(int i, int j, float x)
SMatrix
public void mv(Transpose trans, float alpha, float[] x, float beta, float[] y)
SMatrix
y = alpha * op(A) * x + beta * y
where op is the transpose operation.public void mv(float[] work, int inputOffset, int outputOffset)
IMatrix
public void tv(float[] work, int inputOffset, int outputOffset)
IMatrix
public FloatBandMatrix.LU lu()
public FloatBandMatrix.Cholesky cholesky()
java.lang.ArithmeticException
- if the matrix is not positive definite.