Package com.imsl.math
Class Matrix
java.lang.Object
com.imsl.math.Matrix
Manipulation methods for real-valued rectangular matrices.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIndicates which matrix type is used. -
Method Summary
Modifier and TypeMethodDescriptionstatic double[][]add(double[][] a, double[][] b) Add two rectangular arrays, a + b.static voidcheckMatrix(double[][] a) Check that all of the rows in the matrix have the same length.static voidCheckMatrix(double[][] a) Deprecated.static voidcheckSquareMatrix(double[][] a) Check that the matrix is square.static voidCheckSquareMatrix(double[][] a) Deprecated.UsecheckSquareMatrix(double[][])instead.static doublefrobeniusNorm(double[][] a) Return the Frobenius norm of a matrix.static doubleinfinityNorm(double[][] a) Return the infinity norm of a matrix.static double[][]inverseLowerTriangular(double[][] a) Returns the inverse of the lower triangular matrix a.static double[][]inverseUpperTriangular(double[][] a) Returns the inverse of the upper triangular matrix a.static booleanisSymmetric(double[][] a) Check if the matrix is symmetric.static double[]multiply(double[][] a, double[] x) Multiply the rectangular array a and the column array x.static double[][]multiply(double[][] a, double[][] b) Multiply two rectangular arrays, a * b.static double[][]multiply(double[][] a, double[][] b, int numberOfThreads) Multiply two rectangular arrays,a*b, using multiplejava.lang.Threads.static double[]multiply(double[][] a, Matrix.MatrixType aType, double[] x) Multiply the rectangular array a and the column array x.static double[][]multiply(double[][] a, Matrix.MatrixType aType, double[][] b, Matrix.MatrixType bType, int numberOfThreads) Multiply two rectangular arrays, a * b.static double[]multiply(double[] x, double[][] a) Return the product of the row array x and the rectangular array a.static double[]multiply(double[] x, double[][] a, Matrix.MatrixType aType) Return the product of the row array x and the rectangular array a.static doublemultiply(double[] x, double[][] a, Matrix.MatrixType aType, double[] y, boolean equalVectors) Compute vector-matrix-vector product trans(x) * a * y.static doubleoneNorm(double[][] a) Return the matrix one norm.static double[][]subtract(double[][] a, double[][] b) Subtract two rectangular arrays, a - b.static double[][]transpose(double[][] a) Return the transpose of a matrix.
-
Method Details
-
checkMatrix
public static void checkMatrix(double[][] a) Check that all of the rows in the matrix have the same length.- Parameters:
a- adoublematrix
-
CheckMatrix
public static void CheckMatrix(double[][] a) Deprecated.UsecheckMatrix(double[][])instead.Check that all of the rows in the matrix have the same length.- Parameters:
a- adoublematrix
-
checkSquareMatrix
public static void checkSquareMatrix(double[][] a) Check that the matrix is square.- Parameters:
a- adoublematrix
-
CheckSquareMatrix
public static void CheckSquareMatrix(double[][] a) Deprecated.UsecheckSquareMatrix(double[][])instead.Check that the matrix is square.- Parameters:
a- adoublematrix
-
transpose
public static double[][] transpose(double[][] a) Return the transpose of a matrix.- Parameters:
a- adoublematrix- Returns:
- a
doublematrix which is the transpose of the argument
-
multiply
public static double[] multiply(double[] x, double[][] a) Return the product of the row array x and the rectangular array a.- Parameters:
x- adoublerow arraya- adoublerectangular matrix- Returns:
- a
doublevector representing the product of the arguments,x*a
-
multiply
Return the product of the row array x and the rectangular array a.- Parameters:
x- adoublerow arraya- adoublerectangular matrixaType- aMatrixTypeindicating if matrixais general or symmetric- Returns:
- a
doublevector representing the product of the arguments,x*a
-
multiply
public static double[] multiply(double[][] a, double[] x) Multiply the rectangular array a and the column array x.- Parameters:
a- adoublerectangular matrixx- adoublecolumn array- Returns:
- a
doublevector representing the product of the arguments,a*x
-
multiply
Multiply the rectangular array a and the column array x.- Parameters:
a- adoublerectangular matrixaType- aMatrixTypeindicating if matrixais general or symmetricx- adoublecolumn array- Returns:
- a
doublevector representing the product of the arguments,a*x
-
multiply
public static double[][] multiply(double[][] a, double[][] b) Multiply two rectangular arrays, a * b.- Parameters:
a- adoublerectangular arrayb- adoublerectangular array- Returns:
- the
doublematrix product ofatimesb
-
multiply
public static double[][] multiply(double[][] a, double[][] b, int numberOfThreads) Multiply two rectangular arrays,a*b, using multiplejava.lang.Threads.- Parameters:
a- adoublerectangular arrayb- adoublerectangular arraynumberOfThreads- Anintwhich specifies the number ofjava.lang.Threadinstances to use. IfnumberOfThreadsis less than 1, thennumberOfThreads= 1 is used.- Returns:
- the
doublematrix product ofatimesb
-
multiply
public static double[][] multiply(double[][] a, Matrix.MatrixType aType, double[][] b, Matrix.MatrixType bType, int numberOfThreads) Multiply two rectangular arrays, a * b.- Parameters:
a- adoublerectangular arrayaType- aMatrixTypeindicating if matrixais general or symmetricb- adoublerectangular arraybType- amatrixTypeindicating if matrixbis general or symmetricnumberOfThreads- Anintwhich specifies the number ofjava.lang.Threadinstances to use. IfnumberOfThreadsis less than 1, thennumberOfThreads= 1 is used.- Returns:
- the
doublematrix product ofatimesb
-
multiply
public static double multiply(double[] x, double[][] a, Matrix.MatrixType aType, double[] y, boolean equalVectors) Compute vector-matrix-vector product trans(x) * a * y.- Parameters:
x- adoublearraya- adoublerectangular matrixaType- aMatrixTypeindicating if matrixais general or symmetricy- adoublearrayequalVectors- abooleanindicating if the two vectorsxandyare numerically equal- Returns:
- a
doublescalar representing the product of the arguments,trans(x)*a*y
-
add
public static double[][] add(double[][] a, double[][] b) Add two rectangular arrays, a + b.- Parameters:
a- adoublerectangular arrayb- adoublerectangular array- Returns:
- a
doublerectangular array representing the matrix sum of the two arguments
-
subtract
public static double[][] subtract(double[][] a, double[][] b) Subtract two rectangular arrays, a - b.- Parameters:
a- adoublerectangular arrayb- adoublerectangular array- Returns:
- a
doublerectangular array representing the matrix difference of the two arguments
-
oneNorm
public static double oneNorm(double[][] a) Return the matrix one norm.- Parameters:
a- adoublerectangular array- Returns:
- a
doublevalue equal to the maximum of the column sums of the absolute values of the array elements
-
frobeniusNorm
public static double frobeniusNorm(double[][] a) Return the Frobenius norm of a matrix.- Parameters:
a- adoublerectangular array- Returns:
- a
doublescalar value equal to the Frobenius norm of the matrix.
-
infinityNorm
public static double infinityNorm(double[][] a) Return the infinity norm of a matrix.- Parameters:
a- adoublerectangular array- Returns:
- a
doublescalar value equal to the maximum of the row sums of the absolute values of the array elements
-
isSymmetric
public static boolean isSymmetric(double[][] a) Check if the matrix is symmetric.- Parameters:
a- adoublerectangular array- Returns:
- a
booleanwhich istrueif the matrix is symmetric andfalseotherwise - Throws:
IllegalArgumentException- This exception is thrown if the lengths of the rows of the input matrix are not uniform.
-
inverseLowerTriangular
public static double[][] inverseLowerTriangular(double[][] a) Returns the inverse of the lower triangular matrix a.- Parameters:
a- adoublesquare lower triangular matrix- Returns:
- a
doublematrix containing the inverse ofa
-
inverseUpperTriangular
public static double[][] inverseUpperTriangular(double[][] a) Returns the inverse of the upper triangular matrix a.- Parameters:
a- adoublesquare upper triangular matrix- Returns:
- a
doublematrix containing the inverse ofa
-
checkMatrix(double[][])instead.