public final class MatrixCalc
extends java.lang.Object
Constructor and Description |
---|
MatrixCalc() |
Modifier and Type | Method and Description |
---|---|
static double[][] |
choleskyFactor(double[][] inMatrix)
Cholesky factorization (aka Cholesky Decomposition)
This factorization can be used when square matrix is symmetric and positive definite.
|
static double[] |
choleskySolve(double[][] matrix,
double[] vector)
Cholesky solve
Once the matrix is decomposed with the above routine, one can solve the triangular factor with backsubstitution.
|
static double[][] |
copyMatrix(double[][] matrix)
copy one matrix into another
|
static double[][] |
deleteMatrixColumn(double[][] matrix,
int column)
takes a matrix and deletes a column
|
static double[][] |
deleteMatrixRow(double[][] matrix,
int row)
takes a matrix and deletes a row
|
static double[] |
getColumn(double[][] matrix,
int column)
takes a matrix and gets a column, then returns it as a vector
|
static double |
innerProduct(double[] vector1,
double[] vector2,
int x)
innerProdect
calculates inner product of two vectors from i down
|
static double[] |
lowerSolve(double[][] matrix,
double[] vector,
double diag)
lower Solve
forward elimination with (optional) default diagonal value
|
static double[][] |
reverseMatrix(double[][] matrix)
reverse a matrix
|
static double[] |
reverseVector(double[] vector)
reverse a vector
|
static double |
sumVector(double[] vector)
sum a vector
|
static double[] |
upperSolve(double[][] matrix,
double[] vector,
double diag)
upperSolve
back substitution with optional over-riding diagonal
|
public static double[][] choleskyFactor(double[][] inMatrix) throws MatrixCalcException.NotSquareMatrixException, MatrixCalcException.PositiveDefiniteException
inMatrix
- square symmetric matrix to perform cholesky factorizationMatrixCalcException.NotSquareMatrixException
MatrixCalcException.PositiveDefiniteException
public static double[] choleskySolve(double[][] matrix, double[] vector) throws MatrixCalcException.NotSquareMatrixException
matrix
- matrix to perform cholesky solve (probably used after factorization)vector
- vector to solve matrix * vector = returnMatrixCalcException.NotSquareMatrixException
public static double[] lowerSolve(double[][] matrix, double[] vector, double diag)
matrix
- the matrix to perform the forward eliminationvector
- diag
- the default diagonal valuepublic static double[] upperSolve(double[][] matrix, double[] vector, double diag)
matrix
- the matrix to perform the back substitutionvector
- diag
- the default diagonal valuepublic static double innerProduct(double[] vector1, double[] vector2, int x) throws java.lang.IndexOutOfBoundsException
vector1
- the first vectorvector2
- the second vectorx
- the starting intjava.lang.IndexOutOfBoundsException
public static double[] getColumn(double[][] matrix, int column)
matrix
- the matrix from which the column will be returnedcolumn
- the number of the column to returnpublic static double[][] deleteMatrixRow(double[][] matrix, int row)
matrix
- the matrix from which to delete the rowrow
- the number of the row to deletepublic static double[][] deleteMatrixColumn(double[][] matrix, int column)
matrix
- the matrix from which to delete the columncolumn
- the number of the column to deletepublic static double[] reverseVector(double[] vector)
vector
- the vector to reversepublic static double[][] reverseMatrix(double[][] matrix)
matrix
- the matrix to reversepublic static double sumVector(double[] vector)
vector
- the input vectorpublic static double[][] copyMatrix(double[][] matrix)
matrix
- the matrix to copyhttp://code.google.com/p/jebl2/