-
Notifications
You must be signed in to change notification settings - Fork 107
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
Implement erfinv
for Float32
and Float64
#1344
Open
ararslan
wants to merge
1
commit into
google-research:main
Choose a base branch
from
ararslan:aa/erfinv
base: main
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.
Open
Changes from all commits
Commits
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 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 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 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
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.
This duplicates the
evalpoly
function in the same file, though yours is maybe a little more general since it doesn't require azero
.https://github.com/google-research/dex-lang/blob/main/lib/prelude.dx#L2225
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.
Ah right, thanks for pointing this out, I should have left a comment about it somewhere. The duplication is unfortunate but was intentional, because:
evalpoly
, nor any of the reduction machinery, isn't yet defined at this point in the prelude, and writing out a polynomial evaluation by Horner's method by hand with a lot of coefficients in multiple branches is quite tedious. (I believe one of the other special functions does this.) I was unsure about the ramifications of shuffling around the contents of the prelude to facilitate, so I left things in place.evalpoly
requires aVSpace
andFloat
but we want to be able to support bothFloat
(AKAFloat32
) andFloat64
, but the latter doesn't implementVSpace
(see also Can't negate aFloat64
#1345).I tried to differentiate it from
evalpoly
as more of an internal helper than an intended user-facing function in part by prefixing it withunsafe_
, which seemed appropriate since it directly uses two functions similarly marked as unsafe.As an aside, IIUC, I think mine does still require a
zero
since that's part of theAdd
interface and I havea|Add
.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.
Oh, thanks for explaining. Yes, moving things within the prelude is a punishing game of dependency tetris. @dougalm has usually been fine with me moving things around as long as the tests still pass, but I would be surprised if you could move
evalpoly
up 1000 lines and have it still work.Good point about the
zero
, I got mixed up about which method is in which class.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.
Actually, it might take a bit of additional shuffling and/or finagling, but I think the
Floating
interface and its instances could be moved down belowevalpoly
. That way they'd also be able to usecopysign
,inf
, andnan
(at least for theFloat32
implementation, anyway). I believe the only use ofFloating
prior to the definition ofevalpoly
is forstd
, which would need to be moved as well. Though even if this shuffling is done,evalpoly
itself would need to be amended in order to be usable for theFloat64
definition.