Class LinearAlgebra

java.lang.Object
gorsat.Regression.LinearAlgebra

public class LinearAlgebra extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addMultipleOf(double[] x, double a, double[] y, int offset, int upTo)
    Adds a * y to x.
    static void
    choleskyFactorize(double[][] A, int dim)
    Decomposes the matrix to A = UU^T where U is upper triangular.
    static double
    dotProd(double[] x, double[] y, int len)
    Computes the dot product of the sub-vectors of x and y consisting of the elements whose index is < len.
    static double
    dotProd(double[] x, double[] y, int offset, int upTo)
    Computes the dot product of the sub-vectors of x and y consisting of the elements whose index is < upTo and ≥ offset.
    static void
    invertUpperTriangular(double[][] U, double[][] X, int n)
    Inverts the upper triangular matrix n x n matrix U.
    static void
    QRFactorize(double[][] X, double[] rDiag, int m)
    QR decomposes X.
    static void
    solveLower(double[][] L, double[] x, double[] y, int n)
    Solves Lx = y and writes the result to x.
    static void
    solveSymPosDef(double[][] A, double[] x, double[] b)
    Solves Ax = b and writes the results to x.
    static void
    solveUpper(double[][] U, double[] x, double[] y, int n)
    Solves Ux = y and writes the result to x.
    static double
    sum(double[] x, int len)
    Computes the sum of the elements of x with index < len.
    static double
    sum(double[] x, int offset, int upTo)
    Computes the sum the elements of x whose index is < upTo and ≥ offset.
    static double
    tripleDotProd(double[] x, double[] y, double[] z, int len)
    Computes the triple dot product of the sub-vectors of x, y, z consisting of the elements whose index is < len.
    static double
    tripleDotProd(double[] x, double[] y, double[] z, int offset, int upTo)
    Computes the tripte dot product of the sub-vectors of x, y, z consisting of the elements whose index is < upTo and ≥ offset.

    Methods inherited from class java.lang.Object

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

    • solveSymPosDef

      public static void solveSymPosDef(double[][] A, double[] x, double[] b)
      Solves Ax = b and writes the results to x. The matrix A must be symmetric and positively determined.
    • choleskyFactorize

      public static void choleskyFactorize(double[][] A, int dim)
      Decomposes the matrix to A = UU^T where U is upper triangular. Writes the result to A.
    • solveUpper

      public static void solveUpper(double[][] U, double[] x, double[] y, int n)
      Solves Ux = y and writes the result to x. It is ok if x and y are the same vector. The matrix U should be transposed.
    • solveLower

      public static void solveLower(double[][] L, double[] x, double[] y, int n)
      Solves Lx = y and writes the result to x. The vector x must be different from y.
    • QRFactorize

      public static void QRFactorize(double[][] X, double[] rDiag, int m)
      QR decomposes X. The matrix X is indexed (column, row) (it is transposed). The results are written to X s.t. in X[i] we write r_0i, r_1i,...,r_i-1i, h_i0, h_i1, ...,h_im-i-1 where h_i is the i-th Householder reflector vector. In rDiag we write r_00, r_11,...,r_nn where n is the number of columns in X. The number m is the number of rows in X.
    • invertUpperTriangular

      public static void invertUpperTriangular(double[][] U, double[][] X, int n)
      Inverts the upper triangular matrix n x n matrix U. Writes the results to X.
    • dotProd

      public static double dotProd(double[] x, double[] y, int len)
      Computes the dot product of the sub-vectors of x and y consisting of the elements whose index is < len.
    • dotProd

      public static double dotProd(double[] x, double[] y, int offset, int upTo)
      Computes the dot product of the sub-vectors of x and y consisting of the elements whose index is < upTo and ≥ offset.
    • tripleDotProd

      public static double tripleDotProd(double[] x, double[] y, double[] z, int len)
      Computes the triple dot product of the sub-vectors of x, y, z consisting of the elements whose index is < len.
    • tripleDotProd

      public static double tripleDotProd(double[] x, double[] y, double[] z, int offset, int upTo)
      Computes the tripte dot product of the sub-vectors of x, y, z consisting of the elements whose index is < upTo and ≥ offset.
    • sum

      public static double sum(double[] x, int len)
      Computes the sum of the elements of x with index < len.
    • sum

      public static double sum(double[] x, int offset, int upTo)
      Computes the sum the elements of x whose index is < upTo and ≥ offset.
    • addMultipleOf

      public static void addMultipleOf(double[] x, double a, double[] y, int offset, int upTo)
      Adds a * y to x.