Package org.drip.numerical.linearalgebra
Class Matrix
java.lang.Object
org.drip.numerical.linearalgebra.Matrix
public class Matrix
extends java.lang.Object
Matrix implements Matrix manipulation routines. It exports the following functionality:
- Matrix Inversion using Closed form solutions (for low-dimension matrices), or using Gaussian elimination
- Matrix Product
- Matrix Diagonalization and Diagonal Pivoting
- Matrix Regularization through Row Addition/Row Swap
- Module = Computational Core Module
- Library = Numerical Analysis Library
- Project = Numerical Quadrature, Differentiation, Eigenization, Linear Algebra, and Utilities
- Package = Linear Algebra Matrix Transform Library
- Author:
- Lakshmi Krishnamurthy
-
Field Summary
Fields Modifier and Type Field Description static int
LOWER_AND_UPPER_TRIANGULAR
Lower+Upper Triangular Matrixstatic int
LOWER_TRIANGULAR
Lower Triangular Matrixstatic int
NON_TRIANGULAR
Non Triangular Matrixstatic int
UPPER_TRIANGULAR
Upper Triangular Matrix -
Constructor Summary
Constructors Constructor Description Matrix()
-
Method Summary
Modifier and Type Method Description static double[][]
CholeskyBanachiewiczFactorization(double[][] aadblA)
Compute the Cholesky-Banachiewicz Factorization of the specified Matrix.static double[][]
CrossProduct(double[] vector1, double[] vector2)
Compute the Cross Product between the Specified Vectorsstatic boolean
DiagonalizeRow(int iQ, double[][] aadblZ2XJack, double[][] aadblZ2YJack)
Diagonalize the specified row in the source matrix, and apply comparable operations to the targetstatic double
DotProduct(double[] adblA, double[] adblE)
Dot Product of Vectors A and Estatic double[][]
GrahamSchmidtOrthogonalization(double[][] aadblV)
Orthogonalize the Specified Matrix Using the Graham-Schmidt Methodstatic double[][]
GrahamSchmidtOrthonormalization(double[][] aadblV)
Orthonormalize the Specified Matrix Using the Graham-Schmidt Methodstatic double[][]
Invert(double[][] aadblA, java.lang.String strMethod)
Invert the input matrix using the specified Methodstatic double[][]
Invert2DMatrixUsingCramerRule(double[][] aadblA)
Invert a 2D Matrix using Cramer's Rulestatic double[][]
InvertUsingGaussianElimination(double[][] aadblSource)
Invert the Source Matrix using Gaussian Eliminationstatic boolean
IsDiagonal(double[][] matrix)
Indicate if the Specified Matrix is Diagonalstatic double[][]
MakeSquareDiagonal(double[] adblA)
Make a Square Diagonal Matrix from a Rowstatic double
Modulus(double[] adbl)
Compute the Modulus of the Input Vectorstatic boolean
NegativeOrZero(double[] adbl)
Indicate if the Array Entries are Negative or Zerostatic double[]
Normalize(double[] adbl)
Normalize the Input Vectorstatic MatrixComplementTransform
PivotDiagonal(double[][] aadblA)
Pivot the Diagonal of the Input Matrixstatic boolean
PositiveLinearlyIndependent(double[] adbl)
Indicate if the Array Entries are Positive Linearly Independentstatic boolean
PositiveOrZero(double[] adbl)
Indicate if the Array Entries are Positive or Zerostatic double[]
Product(double[][] aadblA, double[] adblB)
Compute the Product of an Input Matrix and a Columnstatic double[][]
Product(double[][] aadblA, double[][] aadblB)
Compute the Product of the input matricesstatic double[][]
Product(double[] adblA, double[][] aadblB)
Compute the Product of an input column and a matrixstatic double[]
Project(double[] adblA, double[] adblE)
Project the Vector A along the Vector Estatic QR
QRDecomposition(double[][] aadblA)
Perform a QR Decomposition on the Input Matrixstatic int
Rank(double[][] aadblSource)
Compute the Rank of the Matrixstatic double
RayleighQuotient(double[][] matrix, double[] eigenvector)
Compute the Rayleigh Quotient given the Matrix and one of its Eigenvectorstatic boolean
RegularizeUsingRowAddition(MatrixComplementTransform mct)
Regularize the specified diagonal entry of the input matrix using Row Additionstatic boolean
RegularizeUsingRowSwap(MatrixComplementTransform mct)
Regularize the specified diagonal entry of the input matrix using Row Swappingstatic double[]
Scale1D(double[] vector, double scaleFactor)
Scale the Entries of the Input Vector by the Factorstatic double[][]
Scale2D(double[][] matrix, double scaleFactor)
Scale the Entries of the Input Matrix by the Factorstatic double
Sum(double[] adbl)
Compute the Sum of the Input Vectorstatic double[][]
Transpose(double[][] aadblA)
Transpose the specified Square Matrixstatic int
TriangularType(double[][] aadblA, double dblFloor)
Retrieve the Triangular Type of the MatrixMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
LOWER_TRIANGULAR
public static int LOWER_TRIANGULARLower Triangular Matrix -
UPPER_TRIANGULAR
public static int UPPER_TRIANGULARUpper Triangular Matrix -
LOWER_AND_UPPER_TRIANGULAR
public static int LOWER_AND_UPPER_TRIANGULARLower+Upper Triangular Matrix -
NON_TRIANGULAR
public static int NON_TRIANGULARNon Triangular Matrix
-
-
Constructor Details
-
Matrix
public Matrix()
-
-
Method Details
-
DiagonalizeRow
public static final boolean DiagonalizeRow(int iQ, double[][] aadblZ2XJack, double[][] aadblZ2YJack)Diagonalize the specified row in the source matrix, and apply comparable operations to the target- Parameters:
iQ
- Row in the Source MatrixaadblZ2XJack
- Source MatrixaadblZ2YJack
- Target Matrix- Returns:
- TRUE - Diagonalization was successful
-
Product
public static final double[] Product(double[][] aadblA, double[] adblB)Compute the Product of an Input Matrix and a Column- Parameters:
aadblA
- Matrix AadblB
- Array B- Returns:
- The Product
-
Product
public static final double[][] Product(double[] adblA, double[][] aadblB)Compute the Product of an input column and a matrix- Parameters:
adblA
- Column AaadblB
- Matrix B- Returns:
- The Product
-
Product
public static final double[][] Product(double[][] aadblA, double[][] aadblB)Compute the Product of the input matrices- Parameters:
aadblA
- Matrix AaadblB
- Matrix B- Returns:
- The Product
-
MakeSquareDiagonal
public static final double[][] MakeSquareDiagonal(double[] adblA)Make a Square Diagonal Matrix from a Row- Parameters:
adblA
- The Row Array- Returns:
- The corresponding Square Diagonal Matrix
-
Invert2DMatrixUsingCramerRule
public static final double[][] Invert2DMatrixUsingCramerRule(double[][] aadblA)Invert a 2D Matrix using Cramer's Rule- Parameters:
aadblA
- Input 2D Matrix- Returns:
- The Inverted Matrix
-
RegularizeUsingRowSwap
Regularize the specified diagonal entry of the input matrix using Row Swapping- Parameters:
mct
- The Input Matrix Complement Transform- Returns:
- The Regularization was successful
-
RegularizeUsingRowAddition
Regularize the specified diagonal entry of the input matrix using Row Addition- Parameters:
mct
- The Input Matrix Complement Transform- Returns:
- The Regularization was successful
-
PivotDiagonal
Pivot the Diagonal of the Input Matrix- Parameters:
aadblA
- The Input Matrix- Returns:
- The Matrix Complement Transform Instance
-
InvertUsingGaussianElimination
public static final double[][] InvertUsingGaussianElimination(double[][] aadblSource)Invert the Source Matrix using Gaussian Elimination- Parameters:
aadblSource
- Source Matrix- Returns:
- The Inverted Matrix
-
Invert
public static final double[][] Invert(double[][] aadblA, java.lang.String strMethod)Invert the input matrix using the specified Method- Parameters:
aadblA
- Input MatrixstrMethod
- The Inversion Method- Returns:
- The Inverted Matrix
-
Rank
public static final int Rank(double[][] aadblSource) throws java.lang.ExceptionCompute the Rank of the Matrix- Parameters:
aadblSource
- Source Matrix- Returns:
- The Rank of the Matrix
- Throws:
java.lang.Exception
- Thrown if the Rank Cannot be computed
-
Transpose
public static final double[][] Transpose(double[][] aadblA)Transpose the specified Square Matrix- Parameters:
aadblA
- The Input Square Matrix- Returns:
- The Transpose of the Square Matrix
-
CholeskyBanachiewiczFactorization
public static final double[][] CholeskyBanachiewiczFactorization(double[][] aadblA)Compute the Cholesky-Banachiewicz Factorization of the specified Matrix.- Parameters:
aadblA
- The Input Matrix- Returns:
- The Factorized Matrix
-
DotProduct
public static final double DotProduct(double[] adblA, double[] adblE) throws java.lang.ExceptionDot Product of Vectors A and E- Parameters:
adblA
- Vector AadblE
- Vector E- Returns:
- The Dot Product
- Throws:
java.lang.Exception
- Thrown if the Dot-Product cannot be computed
-
CrossProduct
public static final double[][] CrossProduct(double[] vector1, double[] vector2)Compute the Cross Product between the Specified Vectors- Parameters:
vector1
- Vector #1vector2
- Vector #2- Returns:
- The Cross Product
-
Project
public static final double[] Project(double[] adblA, double[] adblE)Project the Vector A along the Vector E- Parameters:
adblA
- Vector AadblE
- Vector E- Returns:
- The Vector of Projection of A along E
-
Sum
public static final double Sum(double[] adbl) throws java.lang.ExceptionCompute the Sum of the Input Vector- Parameters:
adbl
- The Input Vector- Returns:
- TRUE - The Sum of the Input Vector
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
Modulus
public static final double Modulus(double[] adbl) throws java.lang.ExceptionCompute the Modulus of the Input Vector- Parameters:
adbl
- The Input Vector- Returns:
- TRUE - The Modulus of the Input Vector
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
PositiveOrZero
public static final boolean PositiveOrZero(double[] adbl) throws java.lang.ExceptionIndicate if the Array Entries are Positive or Zero- Parameters:
adbl
- The Array- Returns:
- TRUE - The Array Entries are Positive or Zero
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
NegativeOrZero
public static final boolean NegativeOrZero(double[] adbl) throws java.lang.ExceptionIndicate if the Array Entries are Negative or Zero- Parameters:
adbl
- The Array- Returns:
- The Array Entries are Negative or Zero
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
PositiveLinearlyIndependent
public static final boolean PositiveLinearlyIndependent(double[] adbl) throws java.lang.ExceptionIndicate if the Array Entries are Positive Linearly Independent- Parameters:
adbl
- The Array- Returns:
- TRUE - The Array Entries are Positive Linearly Independent
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
Normalize
public static final double[] Normalize(double[] adbl)Normalize the Input Vector- Parameters:
adbl
- The Input Vector- Returns:
- The Normalized Vector
-
GrahamSchmidtOrthogonalization
public static final double[][] GrahamSchmidtOrthogonalization(double[][] aadblV)Orthogonalize the Specified Matrix Using the Graham-Schmidt Method- Parameters:
aadblV
- The Input Matrix- Returns:
- The Orthogonalized Matrix
-
GrahamSchmidtOrthonormalization
public static final double[][] GrahamSchmidtOrthonormalization(double[][] aadblV)Orthonormalize the Specified Matrix Using the Graham-Schmidt Method- Parameters:
aadblV
- The Input Matrix- Returns:
- The Orthonormalized Matrix
-
QRDecomposition
Perform a QR Decomposition on the Input Matrix- Parameters:
aadblA
- The Input Matrix- Returns:
- The Output of QR Decomposition
-
TriangularType
public static final int TriangularType(double[][] aadblA, double dblFloor)Retrieve the Triangular Type of the Matrix- Parameters:
aadblA
- The Input MatrixdblFloor
- The Floor Level that means "Zero"- Returns:
- The Triangular Type
-
RayleighQuotient
public static final double RayleighQuotient(double[][] matrix, double[] eigenvector) throws java.lang.ExceptionCompute the Rayleigh Quotient given the Matrix and one of its Eigenvector- Parameters:
matrix
- The Given Matrixeigenvector
- The corresponding Eigenvector- Returns:
- The Computed Rayleigh Quotient
- Throws:
java.lang.Exception
- Thrown if the Inputs are Invalid
-
Scale1D
public static final double[] Scale1D(double[] vector, double scaleFactor)Scale the Entries of the Input Vector by the Factor- Parameters:
vector
- The Input VectorscaleFactor
- The Scale Factor- Returns:
- The Scaled Matrix
-
Scale2D
public static final double[][] Scale2D(double[][] matrix, double scaleFactor)Scale the Entries of the Input Matrix by the Factor- Parameters:
matrix
- The Input MatrixscaleFactor
- The Scale Factor- Returns:
- The Scaled Matrix
-
IsDiagonal
public static final boolean IsDiagonal(double[][] matrix)Indicate if the Specified Matrix is Diagonal- Parameters:
matrix
- The Matrix- Returns:
- TRUE - The Specified Matrix is Diagonal
-