Class DefaultLinearAlgebra

java.lang.Object
dk.alexandra.fresco.stat.DefaultLinearAlgebra
All Implemented Interfaces:
AdvancedLinearAlgebra

public class DefaultLinearAlgebra
extends Object
implements AdvancedLinearAlgebra
  • Method Summary

    Modifier and Type Method Description
    dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> backSubstitution​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> b)
    Use back substitution to compute a vector x such that ax = b where a is an upper triangular square matrix.
    dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> forwardSubstitution​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> b)
    Use forward substitution to compute a vector x such that ax = b where a is a lower triangular square matrix.
    dk.alexandra.fresco.framework.DRes<List<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>>> gramSchmidt​(List<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> vectors)
    Return a list of mutually orthogonal vectors spanning the same space as the given vectors.
    dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> invertLowerTriangularMatrix​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> l)
    Compute the inverse of a lower triangular matrix.
    dk.alexandra.fresco.framework.DRes<List<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> iterativeEigenvalues​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, int iterations)
    Approximate the eigenvalues of a matrix using the QR-algorithm.
    dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> linearInverseProblem​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> b)
    Solve a linear inverse problem, eg.
    dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> moorePenrosePseudoInverse​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a)
    Compute the Moore-Penrose pseudo-inverse of an m×n-matrix with full column rank.
    dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> normalizeVector​(ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> u)
    Normalize a non-zero vector.
    dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> projection​(ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> u)
    Compute the projection of a vector a onto another vector u.
    dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.framework.util.Pair<dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>,​dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>>> qrDecomposition​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a)
    Compute the QR-decomposition of an mxn-matrix a with m ≥ n and full column rank.

    Methods inherited from class java.lang.Object

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

    • backSubstitution

      public dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> backSubstitution​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> b)
      Description copied from interface: AdvancedLinearAlgebra
      Use back substitution to compute a vector x such that ax = b where a is an upper triangular square matrix.
      Specified by:
      backSubstitution in interface AdvancedLinearAlgebra
      Parameters:
      a - An upper triangular matrix.
      b - A vector.
      Returns:
      A vector x such that ax = b.
    • forwardSubstitution

      public dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> forwardSubstitution​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> b)
      Description copied from interface: AdvancedLinearAlgebra
      Use forward substitution to compute a vector x such that ax = b where a is a lower triangular square matrix.
      Specified by:
      forwardSubstitution in interface AdvancedLinearAlgebra
      Parameters:
      a - An lower triangular matrix.
      b - A vector.
      Returns:
      A vector x such that ax = b.
    • gramSchmidt

      public dk.alexandra.fresco.framework.DRes<List<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>>> gramSchmidt​(List<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> vectors)
      Description copied from interface: AdvancedLinearAlgebra
      Return a list of mutually orthogonal vectors spanning the same space as the given vectors.
      Specified by:
      gramSchmidt in interface AdvancedLinearAlgebra
      Parameters:
      vectors - A set of linearly independent vectors.
      Returns:
      A set of mutually orthogonal vectors spanning the same space as the input.
    • invertLowerTriangularMatrix

      public dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> invertLowerTriangularMatrix​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> l)
      Description copied from interface: AdvancedLinearAlgebra
      Compute the inverse of a lower triangular matrix.
      Specified by:
      invertLowerTriangularMatrix in interface AdvancedLinearAlgebra
      Parameters:
      l - A lower triangular matrix.
      Returns:
      The inverse of l
    • linearInverseProblem

      public dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> linearInverseProblem​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> b)
      Description copied from interface: AdvancedLinearAlgebra
      Solve a linear inverse problem, eg. find an x such that ax = b where a is an m×n-matrix and b is an n-dimensional vector. If a system is overdetermined (m ≥ n), the computation will find the x minimising ||ax - b||.
      Specified by:
      linearInverseProblem in interface AdvancedLinearAlgebra
      Parameters:
      a - An m×n-matrix.
      b - An n-dimensional vector.
      Returns:
      A solution to the equation ax = b or a matrix minimising ax - b.
    • moorePenrosePseudoInverse

      public dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> moorePenrosePseudoInverse​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a)
      Description copied from interface: AdvancedLinearAlgebra
      Compute the Moore-Penrose pseudo-inverse of an m×n-matrix with full column rank.
      Specified by:
      moorePenrosePseudoInverse in interface AdvancedLinearAlgebra
      Parameters:
      a - An m×n-matrix with full column rank.
      Returns:
      The Moore-Penrose pseudo-inverse of a.
    • normalizeVector

      public dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> normalizeVector​(ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> u)
      Description copied from interface: AdvancedLinearAlgebra
      Normalize a non-zero vector.
      Specified by:
      normalizeVector in interface AdvancedLinearAlgebra
      Parameters:
      u - A non-zero vector.
      Returns:
      A vector with the same direction as u and magnitude 1.
    • projection

      public dk.alexandra.fresco.framework.DRes<ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> projection​(ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, ArrayList<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> u)
      Description copied from interface: AdvancedLinearAlgebra
      Compute the projection of a vector a onto another vector u.
      Specified by:
      projection in interface AdvancedLinearAlgebra
      Parameters:
      a - A vector.
      u - A vector.
      Returns:
      a projected onto u.
    • iterativeEigenvalues

      public dk.alexandra.fresco.framework.DRes<List<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>> iterativeEigenvalues​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a, int iterations)
      Description copied from interface: AdvancedLinearAlgebra
      Approximate the eigenvalues of a matrix using the QR-algorithm.
      Specified by:
      iterativeEigenvalues in interface AdvancedLinearAlgebra
      Parameters:
      a - A square matrix.
      iterations - The number of iterations.
      Returns:
      An approximation of the eigenvalues of a.
    • qrDecomposition

      public dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.framework.util.Pair<dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>,​dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>>>> qrDecomposition​(dk.alexandra.fresco.lib.common.collections.Matrix<dk.alexandra.fresco.framework.DRes<dk.alexandra.fresco.lib.fixed.SFixed>> a)
      Description copied from interface: AdvancedLinearAlgebra
      Compute the QR-decomposition of an mxn-matrix a with m ≥ n and full column rank. The QR-decomposition is a pair of matrices (Q,R) with A = QR and where Q is an mxn-matrix with orthonormal columns and R is an upper-triangular nxn-matrix.
      Specified by:
      qrDecomposition in interface AdvancedLinearAlgebra
      Parameters:
      a - An mxn-matrix
      Returns:
      A pair of matrices (Q,R) with a = QR and where * Q is an mxn-matrix with orthonormal columns and R is an upper-triangular * nxn-matrix.