Class BandMatrix
- All Implemented Interfaces:
Serializable, Matrix, Tensor
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 an 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]. The subdiagonal elements are in A[j,n-1][0,m1-1]
with j > 0
appropriate to the number of elements on each subdiagonal.
The superdiagonal elements are in A[0,j][m1+1,m2+m2]
with j < n-1
appropriate to the number of elements on each superdiagonal.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionabstract BandMatrix
copy()
Returns a deep copy of matrix.boolean
boolean
Return true if the matrix is symmetric (uplo != null).int
kl()
Returns the number of subdiagonals.int
ku()
Returns the number of superdiagonals.layout()
Returns the matrix layout.int
ld()
Returns the leading dimension.void
Matrix-vector multiplication.int
ncol()
Returns the number of columns.int
nrow()
Returns the number of rows.static BandMatrix
of
(int m, int n, int kl, int ku, double[][] ab) Returns a symmetric matrix from a two-dimensional array.static BandMatrix
of
(int m, int n, int kl, int ku, float[][] ab) Returns a symmetric matrix from a two-dimensional array.scale
(double alpha) A *= alphasolve
(double[] b) Solve A * x = b.solve
(float[] b) Solve A * x = b.void
solve
(DenseMatrix B) Solves the linear systemA * X = B
.Returns the transpose of matrix.uplo()
Gets the format of packed matrix.Sets the format of symmetric band matrix.static BandMatrix
zeros
(ScalarType scalarType, int m, int n, int kl, int ku) Returns a zero matrix.Methods inherited from class Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface Matrix
add, apply, diagonal, dim, div, get, get, length, mul, mv, mv, mv, mv, mv, reshape, set, set, shape, size, sub, toArray, toArray, toString, toString, trace, tv, tv, tv, tv, tv, update, vector, vector, vector, xAx
Methods inherited from interface Tensor
scalarType
-
Method Details
-
zeros
Returns a zero matrix.- Parameters:
m
- the number of rows.n
- the number of columns.kl
- the number of subdiagonals.ku
- the number of superdiagonals.
-
of
Returns a symmetric matrix from a two-dimensional array.- Parameters:
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 inAB[ku+i-j, j]
formax(0, j-ku) <= i <= min(m-1, j+kl)
.
-
of
Returns a symmetric matrix from a two-dimensional array.- Parameters:
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 inAB[ku+i-j, j]
formax(0, j-ku) <= i <= min(m-1, j+kl)
.
-
nrow
-
ncol
-
kl
public int kl()Returns the number of subdiagonals.- Returns:
- the number of subdiagonals.
-
ku
public int ku()Returns the number of superdiagonals.- Returns:
- the number of superdiagonals.
-
layout
-
ld
public int ld()Returns the leading dimension.- Returns:
- the leading dimension.
-
isSymmetric
public boolean isSymmetric()Return true if the matrix is symmetric (uplo != null).- Returns:
- true if the matrix is symmetric (uplo != null).
-
scale
Description copied from interface:Matrix
A *= alpha -
copy
Description copied from interface:Matrix
Returns a deep copy of matrix. -
transpose
Description copied from interface:Matrix
Returns the transpose of matrix. The transpose may share the storage with this matrix. -
withUplo
Sets the format of symmetric band matrix.- Parameters:
uplo
- the format of symmetric band matrix.- Returns:
- this matrix.
-
uplo
-
equals
-
mv
Description copied from interface:Matrix
Matrix-vector multiplication.y = alpha * A * x + beta * y
-
solve
Solve A * x = b.- Parameters:
b
- the right hand side of linear systems.- Returns:
- the solution vector.
- Throws:
RuntimeException
- when the matrix is singular.
-
solve
Solve A * x = b.- Parameters:
b
- the right hand side of linear systems.- Returns:
- the solution vector.
- Throws:
RuntimeException
- when the matrix is singular.
-
solve
Solves the linear systemA * X = B
.- Parameters:
B
- the right hand side of linear systems. On output, B will be overwritten with the solution matrix.
-