Class MatrixMath

java.lang.Object
ffx.numerics.math.MatrixMath

public final class MatrixMath extends Object
The MatrixMath class is a simple matrix math library used mainly by the X-ray package.

All methods are thread-safe and static.

Since:
1.0
Author:
Michael J. Schnieders
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    applyMatrixTranspose(double[] in, double[] out, double[][] matrix)
    Multiply coordinates by the transpose of a matrix.
    static double
    determinant3(double[] m)
    determinant3
    static double
    determinant3(double[][] m)
    Returns the determinant for a 3x3 matrix.
    static double[][]
    mat3Inverse(double[][] m)
    inverse of a 3x3 matrix.
    static double[][]
    mat3Inverse(double[][] m, double[][] res)
    mat3inverse
    static double[][]
    mat3Mat3(double[][] m1, double[][] m2)
    Matrix times a matrix.
    static double[][]
    mat3Mat3(double[][] m1, double[][] m2, double[][] res)
    mat3mat3
    static double[][]
    mat3SymVec6(double[][] m, double[] v)
    matrix times a vector representation of a symmetric 3x3 matrix
    static double[][]
    mat3SymVec6(double[][] m, double[] v, double[][] res)
    mat3SymVec6
    static double[]
    mat3Vec3(double[] v, double[][] m)
    matrix times a vector
    static double[]
    mat3Vec3(double[] v, double[][] m, double[] res)
    mat3vec3
    static double[][]
    mat4Mat4(double[][] m1, double[][] m2)
    Matrix times a matrix (both 4x4).
    static double[][]
    mat4Mat4(double[][] m1, double[][] m2, double[][] res)
    Multiply two 4x4 matrices.
    static double[][]
    scalarMat3Mat3(double scalar, double[][] m1, double[][] m2)
    scalar times a matrix times a matrix.
    static double[][]
    scalarMat3Mat3(double scalar, double[][] m1, double[][] m2, double[][] res)
    scalarMat3mat3
    static double[][]
    symVec6Mat3(double[] v, double[][] m)
    vector representation of a symmetric 3x3 matrix times a matrix
    static double[][]
    symVec6Mat3(double[] v, double[][] m, double[][] res)
    symVec6mat3
    static double[][]
    transpose3(double[][] m)
    transpose3
    static double[][]
    transpose3(double[][] m, double[][] t)
    transpose3
    static double[]
    vec3Mat3(double[] v, double[][] m)
    Vector times a matrix.
    static double[]
    vec3Mat3(double[] v, double[][] m, double[] res)
    vec3mat3

    Methods inherited from class java.lang.Object

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

    • MatrixMath

      public MatrixMath()
  • Method Details

    • determinant3

      public static double determinant3(double[][] m)
      Returns the determinant for a 3x3 matrix.
      Parameters:
      m - input matrix.
      Returns:
      Returns the determinant.
    • determinant3

      public static double determinant3(double[] m)
      determinant3
      Parameters:
      m - an array of double.
      Returns:
      Returns the determinant.
    • mat3Inverse

      public static double[][] mat3Inverse(double[][] m)
      inverse of a 3x3 matrix.
      Parameters:
      m - input matrix.
      Returns:
      Returns the matrix inverse.
    • mat3Inverse

      public static double[][] mat3Inverse(double[][] m, double[][] res)
      mat3inverse
      Parameters:
      m - an array of double.
      res - an array of double.
      Returns:
      Returns the matrix res.
    • mat3Mat3

      public static double[][] mat3Mat3(double[][] m1, double[][] m2)
      Matrix times a matrix.
      Parameters:
      m1 - First input matrix.
      m2 - Second input matrix.
      Returns:
      Returns the matrix product.
    • mat3Mat3

      public static double[][] mat3Mat3(double[][] m1, double[][] m2, double[][] res)
      mat3mat3
      Parameters:
      m1 - an array of double.
      m2 - an array of double.
      res - an array of double.
      Returns:
      Returns the matrix res.
    • mat4Mat4

      public static double[][] mat4Mat4(double[][] m1, double[][] m2)
      Matrix times a matrix (both 4x4).
      Parameters:
      m1 - First input matrix.
      m2 - Second input matrix.
      Returns:
      Returns the matrix product.
    • mat4Mat4

      public static double[][] mat4Mat4(double[][] m1, double[][] m2, double[][] res)
      Multiply two 4x4 matrices.
      Parameters:
      m1 - an array of double (first matrix).
      m2 - an array of double (second matrix).
      res - Resultant matrix.
      Returns:
      Returns the matrix res.
    • mat3SymVec6

      public static double[][] mat3SymVec6(double[][] m, double[] v)
      matrix times a vector representation of a symmetric 3x3 matrix
      Parameters:
      m - input matrix
      v - input vector of the form 11, 22, 33, 12, 13, 23
      Returns:
      matrix product
    • mat3SymVec6

      public static double[][] mat3SymVec6(double[][] m, double[] v, double[][] res)
      mat3SymVec6
      Parameters:
      m - an array of double.
      v - an array of double.
      res - an array of double.
      Returns:
      Returns the matrix res.
    • mat3Vec3

      public static double[] mat3Vec3(double[] v, double[][] m)
      matrix times a vector
      Parameters:
      v - input vector.
      m - input matrix.
      Returns:
      Returns the vector product.
    • mat3Vec3

      public static double[] mat3Vec3(double[] v, double[][] m, double[] res)
      mat3vec3
      Parameters:
      v - an array of double.
      m - an array of double.
      res - an array of double.
      Returns:
      Returns the matrix res.
    • scalarMat3Mat3

      public static double[][] scalarMat3Mat3(double scalar, double[][] m1, double[][] m2)
      scalar times a matrix times a matrix.
      Parameters:
      scalar - Input scalar.
      m1 - First input matrix.
      m2 - Second input matrix.
      Returns:
      Returns the matrix product.
    • scalarMat3Mat3

      public static double[][] scalarMat3Mat3(double scalar, double[][] m1, double[][] m2, double[][] res)
      scalarMat3mat3
      Parameters:
      scalar - a double.
      m1 - an array of double.
      m2 - an array of double.
      res - an array of double.
      Returns:
      Returns the matrix res.
    • symVec6Mat3

      public static double[][] symVec6Mat3(double[] v, double[][] m)
      vector representation of a symmetric 3x3 matrix times a matrix
      Parameters:
      v - input vector of the form 11, 22, 33, 12, 13, 23.
      m - input matrix.
      Returns:
      Returns matrix product.
    • symVec6Mat3

      public static double[][] symVec6Mat3(double[] v, double[][] m, double[][] res)
      symVec6mat3
      Parameters:
      v - an array of double.
      m - an array of double.
      res - an array of double.
      Returns:
      Returns the matrix res.
    • transpose3

      public static double[][] transpose3(double[][] m)
      transpose3
      Parameters:
      m - Matrix m.
      Returns:
      Returns the transposed matrix in a new array.
    • transpose3

      public static double[][] transpose3(double[][] m, double[][] t)
      transpose3
      Parameters:
      m - Matrix m.
      t - Matrix t.
      Returns:
      Returns the matrix t.
    • vec3Mat3

      public static double[] vec3Mat3(double[] v, double[][] m)
      Vector times a matrix.
      Parameters:
      v - input vector.
      m - input matrix.
      Returns:
      Returns the vector product.
    • vec3Mat3

      public static double[] vec3Mat3(double[] v, double[][] m, double[] res)
      vec3mat3
      Parameters:
      v - an array of double.
      m - an array of double.
      res - an array of double.
      Returns:
      Returns the array res.
    • applyMatrixTranspose

      public static void applyMatrixTranspose(double[] in, double[] out, double[][] matrix)
      Multiply coordinates by the transpose of a matrix.
      Parameters:
      in - input coordinates.
      out - output coordinates.
      matrix - multiply by the transpose of this matrix.