Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Moore-Penrose inverse #469

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from

Commits on Nov 7, 2023

  1. Test Eigenvectors can handle numerical imprecision

    To mimic the error found in the QR algorithm, we have to test with matrices that have duplicate eigenvalues and introduce numerical precision errors.
    
    To do this, a list of perturbed eigenvalues is passed to the eigenvectors method. The perturbation is achieved by adding a random +/- offset on an order of magnitude smaller than the default matrix error. This should allow the math to work out fine while causing the floating point comparison to fail.
    Aweptimum committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    32f8bff View commit details
    Browse the repository at this point in the history
  2. Replace array_search with floating-point filter

    array_search seems to fail in most cases when looking for a float in an array of floats. And even if it does find a match, if the key is 0, php evaluates `!0` to true.
    
    To find a match, we can instead loop through and compare the numbers with `Arithmetic::almostEqual` and then explicitly check if `$key === false`
    Aweptimum committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    163c0f9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    67c9097 View commit details
    Browse the repository at this point in the history
  4. Add NumericMatrix->pseudoInverse()

    Calculates the Moore-Penrose inverse of the matrix using SVD
    Aweptimum committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    50a3147 View commit details
    Browse the repository at this point in the history
  5. Add NumericDiagonalMatrix->pseudoInverse

    Just an alias for inverse
    Aweptimum committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    8331a97 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    48b5b6d View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    93eddf9 View commit details
    Browse the repository at this point in the history
  8. SVD: Diagonalize S

    If it isn't, create a permutation matrix, P, such that SP is diagonal.
    Multiply V by its inverse to balance the eqn.
    Aweptimum committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    efdfcf6 View commit details
    Browse the repository at this point in the history
  9. SVD: Sort S's diagonal

    After diagonalizing S and ensuring its values are positive,
    check that its values are sorted. If not, permute it
    Aweptimum committed Nov 7, 2023
    Configuration menu
    Copy the full SHA
    e622e7f View commit details
    Browse the repository at this point in the history

Commits on Dec 4, 2023

  1. SVD: Refactor diagonalization for 'tall' matrices

    The method of diagonalization permuted columns. However, if the row count exceeds the column count, there's a chance the column permutation won't diagonalize S. To address this, the diagonalization has been refactored to sort on the bigger dimension.
    Aweptimum committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    379bdb4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    aa34e9a View commit details
    Browse the repository at this point in the history
  3. SVD: remove union type from helper

    Not available in php 7.0
    Aweptimum committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    fd4c22c View commit details
    Browse the repository at this point in the history
  4. Rename SVD->isStandardBasisVector

    to getStandardBasisIndex
    Aweptimum committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    b52e36a View commit details
    Browse the repository at this point in the history
  5. SVD: allow zero rows in diagonalize

    Because 0 can be a singular value, the S matrix can have zero-entries along the diagonal.
    To allow this, we first check if the vector magnitude is 0 before calling getStandardBasisIndex
    Aweptimum committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    746303b View commit details
    Browse the repository at this point in the history
  6. SVD: add error to getStandardBasisIndex

    Since we're checking for non-zero components using Arithmetic::almostEqual, it seems appropriate to pass in the error of the matrix
    Aweptimum committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    8399246 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    3ff591e View commit details
    Browse the repository at this point in the history
  8. Add two failures to SVDTestCase

    Adds the case from the pseudoinverse test
    Aweptimum committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    9d3c271 View commit details
    Browse the repository at this point in the history
  9. Check for floating point in SVD diagonal

    If the diagonal has duplicate eigenvalues that are floats, the sort operation can shuffle them around. The strict equivalence then fails when it technically should not.
    
    Instead, we can compare the diagonal entries to the sorted entries using `AlmostEqual` with the matrix error for tolerance.
    Aweptimum committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    9764083 View commit details
    Browse the repository at this point in the history
  10. Numeric: use error in isRectangularDiagonal

    Previously was just using the default error of `Support::isZero`
    Aweptimum committed Dec 4, 2023
    Configuration menu
    Copy the full SHA
    77de387 View commit details
    Browse the repository at this point in the history