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

Replace array_search with floating-point filter in Eigenvector::eigenvectors #473

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