public class MatrixOperations extends Object
Class used to perform matrix operations, focusing on finding vector solutions to the vector equation F(x) = 0.
TODO: Add calculation of eigenvectors. This isn't hard to implement as we've already calculated the eigenvalues and this means all we need to do is solve for x in the matrix equation (A-lambda*I)*x = 0. However, if we have complex eigenvalues then we have a problem. Java doesn't have complex number support natively.
Notes: The majority of the code in this class comes from Numerical Recipes in C, 2nd Edition. The code was translated from C to Java by Eric Harley. Mostly this amounted to figuring out how to deal with function pointers to user defined functions and re-indexing things starting at 0 instead of 1.
References: _Numerical Recipies in C_ (2nd Edition) by Press, Teutolsky, Vetterling, and Flannery Cambridge University Press, 1992
Modifier and Type | Class and Description |
---|---|
static class |
MatrixOperations.MatrixException
This exception is thrown when errors in the computation of matrix-related solutions, their
eigenvalues or eigenvectors.
|
Modifier and Type | Field and Description |
---|---|
static double |
ALF
Ensures sufficient decrease in function value
|
static double |
EPS
Approximate square root of the JVM precision
|
static double |
STPMX
Scaled maximum step length allowed in line searches
|
static double |
TINY
Extremely small value.
|
static double |
TOLF
Convergence criterion on function values
|
static double |
TOLMIN
Criterion deciding whether spurious convergence to a minimum of min
|
static double |
TOLX
Convergence criterion on delta X
|
Constructor and Description |
---|
MatrixOperations() |
Modifier and Type | Method and Description |
---|---|
static void |
balance(double[][] a)
Given a matrix a[1..n][1..n], this routine replaces it by a balanced matrix with identical
eigenvalues.
|
static void |
elmhes(double[][] a)
Reduces a[1..n][1..n] to upper Hessenberg form
|
static int |
hqr(double[][] a,
double[] wr,
double[] wi)
Finds all eigenvalues of an upper Hessenberg matrix a[1..n][1..n].
|
static void |
lubksb(double[][] a,
int[] indx,
double[] b)
Solves the set of n linear equations AX = B.
|
static double |
ludcmp(double[][] a,
int[] indx)
Given a matrix a[1..n][1..n], this routine replaces it by the LU decomposition of a rowwise
permutation of itself. a and n are input. a is output,l arrand as in equation (2.3.14) above;
indx[1..n] is an output vector that records the row permutation effected by the partial
pivoting; d (return value) is output +/- 1 depending on whether the number of row interchanges
was even or odd respectively.
|
static double |
sign(double a,
double b)
Returns the value of a or |a| with the same sign as b
|
public static final double ALF
public static final double EPS
public static final double STPMX
public static final double TINY
public static final double TOLF
public static final double TOLMIN
public static final double TOLX
public static double ludcmp(double[][] a, int[] indx) throws MatrixOperations.MatrixException
a
- the matrix to be decomposedindx
- the array to put the return index intoMatrixOperations.MatrixException
public static void lubksb(double[][] a, int[] indx, double[] b)
a
- the matrix to be solved as describedindx
- the array returned by ludcmpb
- the vector to be solbed as describedpublic static void balance(double[][] a)
a
- the matrix to be balancedpublic static void elmhes(double[][] a)
a
- the matrix to be reducedpublic static double sign(double a, double b)
a
- the input as specified aboveb
- the input as specified abovepublic static int hqr(double[][] a, double[] wr, double[] wi) throws MatrixOperations.MatrixException
a
- the input matrixwr
- the array specified in the function descriptionwi
- the array specified in the function descriptionMatrixOperations.MatrixException
Copyright © 2007–2021. All rights reserved.