public abstract class MatrixAlgebra extends Object
| Constructor and Description |
|---|
MatrixAlgebra() |
| Modifier and Type | Method and Description |
|---|---|
Matrix |
add(Matrix m1,
Matrix m2)
Adds two matrices.
|
Matrix |
divide(Matrix m1,
Matrix m2)
Returns the quotient of two matrices $C = \frac{A}{B} = AB^{-1}$, where
$B^{-1}$ is the pseudo-inverse of $B$ i.e.
|
abstract double |
getCondition(Matrix m)
Returns the condition number of the matrix.
|
abstract double |
getDeterminant(Matrix m)
Returns the determinant of the matrix.
|
abstract double |
getInnerProduct(Matrix m1,
Matrix m2)
Returns the inner (or dot) product.
|
abstract DoubleMatrix |
getInverse(Matrix m)
Returns the inverse (or pseudo-inverse) of the matrix.
|
abstract double |
getNorm1(Matrix m)
For a vector, returns the $L_1$ norm
(also known as the Taxicab norm or Manhattan norm), i.e.
|
abstract double |
getNorm2(Matrix m)
For a vector, returns $L_2$ norm (also known as the
Euclidean norm).
|
abstract double |
getNormInfinity(Matrix m)
For a vector, returns the $L_\infty$ norm.
|
abstract DoubleMatrix |
getOuterProduct(Matrix m1,
Matrix m2)
Returns the outer product.
|
abstract DoubleMatrix |
getPower(Matrix m,
double p)
Returns a matrix raised to a power, $\mathbf{A}^3 = \mathbf{A}\mathbf{A}\mathbf{A}$.
|
abstract DoubleMatrix |
getPower(Matrix m,
int p)
Returns a matrix raised to an integer power, e.g.
|
abstract double |
getTrace(Matrix m)
Returns the trace (i.e.
|
abstract DoubleMatrix |
getTranspose(Matrix m)
Returns the transpose of a matrix.
|
Matrix |
kroneckerProduct(Matrix m1,
Matrix m2)
Returns the Kronecker product of two matrices.
|
DoubleMatrix |
matrixTransposeMultiplyMatrix(DoubleMatrix a)
Compute $A^T A$, where A is a matrix.
|
abstract Matrix |
multiply(Matrix m1,
Matrix m2)
Multiplies two matrices.
|
Matrix |
scale(Matrix m,
double scale)
Scale a vector or matrix by a given amount, i.e.
|
Matrix |
subtract(Matrix m1,
Matrix m2)
Subtracts two matrices.
|
public Matrix add(Matrix m1, Matrix m2)
m1 - The first matrix, not nullm2 - The second matrix, not nullIllegalArgumentException - If the matrices are not of the same type, if the matrices are not the same shape.public Matrix divide(Matrix m1, Matrix m2)
m1 - The numerator matrix, not null. This matrix must be a DoubleMatrix.m2 - The denominator, not null. This matrix must be a DoubleMatrix.public Matrix kroneckerProduct(Matrix m1, Matrix m2)
m1 - The first matrix, not null. This matrix must be a DoubleMatrix.m2 - The second matrix, not null. This matrix must be a DoubleMatrix.public abstract Matrix multiply(Matrix m1, Matrix m2)
m1 - The first matrix, not null.m2 - The second matrix, not null.public Matrix scale(Matrix m, double scale)
m - A vector or matrix, not nullscale - The scalepublic Matrix subtract(Matrix m1, Matrix m2)
m1 - The first matrix, not nullm2 - The second matrix, not nullIllegalArgumentException - If the matrices are not of the same type, if the matrices are not the same shape.public abstract double getCondition(Matrix m)
m - A matrix, not nullpublic abstract double getDeterminant(Matrix m)
m - A matrix, not nullpublic abstract DoubleMatrix getInverse(Matrix m)
m - A matrix, not nullpublic abstract double getInnerProduct(Matrix m1, Matrix m2)
m1 - A vector, not nullm2 - A vector, not nullIllegalArgumentException - If the vectors are not the same sizepublic abstract DoubleMatrix getOuterProduct(Matrix m1, Matrix m2)
m1 - A vector, not nullm2 - A vector, not nullIllegalArgumentException - If the vectors are not the same sizepublic abstract double getNorm1(Matrix m)
For a matrix, returns the maximum absolute column sum norm of the matrix.
m - A vector or matrix, not nullpublic abstract double getNorm2(Matrix m)
For a matrix, returns the spectral norm
m - A vector or matrix, not nullpublic abstract double getNormInfinity(Matrix m)
For a matrix, returns the maximum absolute row sum norm
m - a vector or a matrix, not nullpublic abstract DoubleMatrix getPower(Matrix m, int p)
m - A square matrix, not nullp - An integer powerpublic abstract DoubleMatrix getPower(Matrix m, double p)
m - A square matrix, not nullp - The powerpublic abstract double getTrace(Matrix m)
m - A matrix, not null. The matrix must be square.public abstract DoubleMatrix getTranspose(Matrix m)
m - A matrix, not nullpublic DoubleMatrix matrixTransposeMultiplyMatrix(DoubleMatrix a)
a - The matrixCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.