-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Name what ln_gamma does #114754
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
Merged
Merged
Name what ln_gamma does #114754
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 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
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.
Would be okay to merge this as-is, but since it's worth explaining why this sign is useful in the first place, I decided to write up an explanation about how this can be used to compute the complex-valued logarithm from the returned value:
(Note that I say "an imaginary part" since the complex logarithm may add additional factors of 2pi, but that's not super important to say here. So, I am still remaining correct while not worrying anyone about it who doesn't really care.)
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.
Also worth mentioning if you do like this and want to copy it to the
f64
version, you should change the link tof32::PI
tof64::PI
.This also is an indication of why returning the sign as a float instead of an int might be preferable, as discussed on the issue.
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.
I omitted the period on the initial line because it's not actually a complete sentence, nor does it need to be.
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.
I think "the sign [...] is offered as a second return value" needs explanation, i.e. -- this returns 1 on positive (or 0) gamma values and -1 on negative values.
Also while we are at it, do we want to change the sign to be represented as an
f32
? Otherwise it will require somewhat awkward explicit conversion back to a float type.