forked from noelex/GeographicLib.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Add GeographicLib v2.4 parity for trig accuracy, Hypot3, and Jacobi amplitude #2
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
Draft
Copilot
wants to merge
3
commits into
master
Choose a base branch
from
copilot/update-library-to-v2-4-feature-parity
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
|
||
| namespace GeographicLib.Tests | ||
| { | ||
| [TestClass] | ||
| public class EllipticFunctionTests | ||
| { | ||
| [DataTestMethod] | ||
| [DataRow(0d, 1.25d)] | ||
| [DataRow(1d, 1.25d)] | ||
| public void TestAm_SpecialModulusCases(double k2, double x) | ||
| { | ||
| var ell = new EllipticFunction(k2); | ||
| var expected = k2 == 0 ? x : System.Math.Atan(System.Math.Sinh(x)); | ||
|
|
||
| Assert.AreEqual(expected, ell.Am(x), 1e-15); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void TestAm_MatchesSncndnAndInverseF() | ||
| { | ||
| var ell = new EllipticFunction(0.5); | ||
| var x = 1.25; | ||
|
|
||
| var phi = ell.Am(x, out var sn, out var cn, out var dn); | ||
| ell.Sncndn(x, out var sn1, out var cn1, out var dn1); | ||
|
|
||
| Assert.AreEqual(phi, System.Math.Atan2(sn, cn), 1e-15); | ||
| Assert.AreEqual(x, ell.F(phi), 1e-14); | ||
| Assert.AreEqual(sn1, sn, 1e-15); | ||
| Assert.AreEqual(cn1, cn, 1e-15); | ||
| Assert.AreEqual(dn1, dn, 1e-15); | ||
| } | ||
| } | ||
| } |
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
Am, the AGM loop can exit becauselreachesnum_(whenGEOGRAPHICLIB_PANICis false and the convergence test never triggers). In that casel == num_and the subsequenta[l]/c[l]indexing will throwIndexOutOfRangeException. Please clampltonum_ - 1(or decrement when the loop ends via the iteration limit), or allocatea/cwith lengthnum_ + 1to make the indexing safe on non-convergence paths.