Repository navigation
Fix complex overflow, permutation(n, n), matrix printing, and piecewise x order - #23
Merged
Merged
Conversation
…rinting, and piecewise functions. Scale complex division and reciprocal when |z|² overflows, and use hypot for getMagnitude. Return 1 from permutation(a, a). Print matrix entries with string concatenation. Reject piecewise samples whose x values are not strictly increasing. Co-authored-by: Barry G Becker <barrybecker4@yahoo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes four verified correctness bugs. No dependency or unrelated changes.
getMagnitudeno longer overflow for large finite components.getMagnitudeusesMath.hypot. Division uses the historical formula when every product fits in aDouble, and Smith's scaled division whenc² + d²(or a numerator product) overflows. Both the instance path andComplexNumber.divideare covered.(1e200 + 1e200i) / (1e200 + 1e200i)is1, and the matching reciprocal stays finite.MathUtil.permutation(a, a)returns1, matchingbigPermutation. Thea == bcase is special-cased; thea!/b!loop is unchanged, so this does not returna.LinearUtil.printMatrixconcatenates a trailing space (s"$a ") instead of adding the char code of' '(32). Covered withConsole.withOut.PiecewiseFunctionrejectsxValuesthat are not strictly increasing (unsorted or duplicate). Existing interpolation tests are unchanged.Test plan
./gradlew test— 248 tests, 0 failuresgetMagnitude,permutation(5, 5)andpermutation(9, 9),printMatrixcapture, unsorted and duplicate piecewisexvalues