public final class LinearMath extends AbstractMath
| Modifier and Type | Method and Description |
|---|---|
static double[] |
eigenSolveHermitian(ComplexSquareMatrix matrix,
ComplexVector[] eigenvector)
This method finds the eigenvalues and eigenvectors of a Hermitian matrix.
|
static double[] |
eigenSolveSymmetric(DoubleSquareMatrix matrix,
DoubleVector[] eigenvector)
This method finds the eigenvalues and eigenvectors of a symmetric square matrix.
|
static double[] |
eigenSolveSymmetric(DoubleTridiagonalMatrix matrix,
DoubleVector[] eigenvector)
This method finds the eigenvalues and eigenvectors of a symmetric tridiagonal matrix by the QL method.
|
static double[] |
eigenvalueSolveHermitian(ComplexSquareMatrix matrix)
This method finds the eigenvalues of a Hermitian matrix.
|
static double[] |
eigenvalueSolveSymmetric(DoubleSquareMatrix matrix)
This method finds the eigenvalues of a symmetric square matrix.
|
static double[] |
eigenvalueSolveSymmetric(DoubleTridiagonalMatrix matrix)
This method finds the eigenvalues of a symmetric tridiagonal matrix by the QL method.
|
static DoubleVector |
leastSquaresFit(int n,
double[][] data)
Fits an nth degree polynomial to data using the method of least squares.
|
static DoubleVector |
linearRegression(double[][] data)
Fits a line to multi-dimensional data using the method of least squares.
|
static DoubleVector[] |
orthonormalize(DoubleVector[] vecs)
The Gram-Schmidt orthonormalization method.
|
static DoubleVector |
solve(DoubleSquareMatrix M,
DoubleVector v)
Solves the linear system Mx=v.
|
static DoubleVector |
solveGMRes(DoubleMatrix A,
DoubleVector b,
int max_iter,
double tol)
Solves the unsymmetric linear system Ax=b using the
Generalized Minimum Residual method (doesn't require A
to be nonsingular).
|
public static DoubleVector solve(DoubleSquareMatrix M, DoubleVector v)
M - a double square matrix.v - a double vector.public static DoubleVector solveGMRes(DoubleMatrix A, DoubleVector b, int max_iter, double tol) throws MaximumIterationsExceededException
max_iter - maximum number of iterations.tol - tolerance.java.lang.IllegalArgumentException - If either the tolerance
or the number of iterations is not positive.
Also, if an unexpected error occurs.MaximumIterationsExceededException - If it cannot
converge according to the given parameters.public static DoubleVector leastSquaresFit(int n, double[][] data)
n - the degree of the polynomial.data - [0][] contains the x-series,
[1][] contains the y-series.public static DoubleVector linearRegression(double[][] data)
data - [0...n-1][] contains the x-series' (they must be linearly uncorrelated),
[n][] contains the y-series.public static DoubleVector[] orthonormalize(DoubleVector[] vecs)
vecs - a set of linearly independent vectors.public static double[] eigenvalueSolveHermitian(ComplexSquareMatrix matrix) throws MaximumIterationsExceededException
matrix - a Hermitian matrix.MaximumIterationsExceededException - If it takes more than 50 iterations to determine an eigenvalue.public static double[] eigenSolveHermitian(ComplexSquareMatrix matrix, ComplexVector[] eigenvector) throws MaximumIterationsExceededException
matrix - a Hermitian matrix.eigenvector - an empty array of complex vectors to hold the eigenvectors.
All eigenvectors will be orthogonal.MaximumIterationsExceededException - If it takes more than 50 iterations to determine an eigenvalue.public static double[] eigenvalueSolveSymmetric(DoubleTridiagonalMatrix matrix) throws MaximumIterationsExceededException
matrix - a double symmetric tridiagonal matrix.MaximumIterationsExceededException - If it takes more than 50 iterations to determine an eigenvalue.public static double[] eigenSolveSymmetric(DoubleTridiagonalMatrix matrix, DoubleVector[] eigenvector) throws MaximumIterationsExceededException
matrix - a double symmetric tridiagonal matrix.eigenvector - an empty array of double vectors to hold the eigenvectors.
All eigenvectors will be orthogonal.MaximumIterationsExceededException - If it takes more than 50 iterations to determine an eigenvalue.public static double[] eigenvalueSolveSymmetric(DoubleSquareMatrix matrix) throws MaximumIterationsExceededException
matrix - a double symmetric square matrix.MaximumIterationsExceededException - If it takes more than 50 iterations to determine an eigenvalue.public static double[] eigenSolveSymmetric(DoubleSquareMatrix matrix, DoubleVector[] eigenvector) throws MaximumIterationsExceededException
matrix - a double symmetric square matrix.eigenvector - an empty array of double vectors to hold the eigenvectors.
All eigenvectors will be orthogonal.MaximumIterationsExceededException - If it takes more than 50 iterations to determine an eigenvalue.