Package com.imsl.math

Class Matrix

java.lang.Object
com.imsl.math.Matrix

public class Matrix extends Object
Manipulation methods for real-valued rectangular matrices.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Indicates which matrix type is used.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[][]
    add(double[][] a, double[][] b)
    Add two rectangular arrays, a + b.
    static void
    checkMatrix(double[][] a)
    Check that all of the rows in the matrix have the same length.
    static void
    CheckMatrix(double[][] a)
    Deprecated.
    static void
    checkSquareMatrix(double[][] a)
    Check that the matrix is square.
    static void
    CheckSquareMatrix(double[][] a)
    Deprecated.
    static double
    frobeniusNorm(double[][] a)
    Return the Frobenius norm of a matrix.
    static double
    infinityNorm(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 boolean
    isSymmetric(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 multiple java.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 double
    multiply(double[] x, double[][] a, Matrix.MatrixType aType, double[] y, boolean equalVectors)
    Compute vector-matrix-vector product trans(x) * a * y.
    static double
    oneNorm(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • checkMatrix

      public static void checkMatrix(double[][] a)
      Check that all of the rows in the matrix have the same length.
      Parameters:
      a - a double matrix
    • CheckMatrix

      public static void CheckMatrix(double[][] a)
      Deprecated.
      Check that all of the rows in the matrix have the same length.
      Parameters:
      a - a double matrix
    • checkSquareMatrix

      public static void checkSquareMatrix(double[][] a)
      Check that the matrix is square.
      Parameters:
      a - a double matrix
    • CheckSquareMatrix

      public static void CheckSquareMatrix(double[][] a)
      Deprecated.
      Check that the matrix is square.
      Parameters:
      a - a double matrix
    • transpose

      public static double[][] transpose(double[][] a)
      Return the transpose of a matrix.
      Parameters:
      a - a double matrix
      Returns:
      a double matrix 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 - a double row array
      a - a double rectangular matrix
      Returns:
      a double vector representing the product of the arguments, x*a
    • multiply

      public static double[] multiply(double[] x, double[][] a, Matrix.MatrixType aType)
      Return the product of the row array x and the rectangular array a.
      Parameters:
      x - a double row array
      a - a double rectangular matrix
      aType - a MatrixType indicating if matrix a is general or symmetric
      Returns:
      a double vector 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 - a double rectangular matrix
      x - a double column array
      Returns:
      a double vector representing the product of the arguments, a*x
    • multiply

      public static double[] multiply(double[][] a, Matrix.MatrixType aType, double[] x)
      Multiply the rectangular array a and the column array x.
      Parameters:
      a - a double rectangular matrix
      aType - a MatrixType indicating if matrix a is general or symmetric
      x - a double column array
      Returns:
      a double vector 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 - a double rectangular array
      b - a double rectangular array
      Returns:
      the double matrix product of a times b
    • multiply

      public static double[][] multiply(double[][] a, double[][] b, int numberOfThreads)
      Multiply two rectangular arrays, a * b, using multiple java.lang.Threads.
      Parameters:
      a - a double rectangular array
      b - a double rectangular array
      numberOfThreads - An int which specifies the number of java.lang.Thread instances to use. If numberOfThreads is less than 1, then numberOfThreads = 1 is used.
      Returns:
      the double matrix product of a times b
    • 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 - a double rectangular array
      aType - a MatrixType indicating if matrix a is general or symmetric
      b - a double rectangular array
      bType - a matrixType indicating if matrix b is general or symmetric
      numberOfThreads - An int which specifies the number of java.lang.Thread instances to use. If numberOfThreads is less than 1, then numberOfThreads = 1 is used.
      Returns:
      the double matrix product of a times b
    • 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 - a double array
      a - a double rectangular matrix
      aType - a MatrixType indicating if matrix a is general or symmetric
      y - a double array
      equalVectors - a boolean indicating if the two vectors x and y are numerically equal
      Returns:
      a double scalar 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 - a double rectangular array
      b - a double rectangular array
      Returns:
      a double rectangular 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 - a double rectangular array
      b - a double rectangular array
      Returns:
      a double rectangular array representing the matrix difference of the two arguments
    • oneNorm

      public static double oneNorm(double[][] a)
      Return the matrix one norm.
      Parameters:
      a - a double rectangular array
      Returns:
      a double value 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 - a double rectangular array
      Returns:
      a double scalar 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 - a double rectangular array
      Returns:
      a double scalar 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 - a double rectangular array
      Returns:
      a boolean which is true if the matrix is symmetric and false otherwise
      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 - a double square lower triangular matrix
      Returns:
      a double matrix containing the inverse of a
    • inverseUpperTriangular

      public static double[][] inverseUpperTriangular(double[][] a)
      Returns the inverse of the upper triangular matrix a.
      Parameters:
      a - a double square upper triangular matrix
      Returns:
      a double matrix containing the inverse of a