-
-
Notifications
You must be signed in to change notification settings - Fork 747
Add std.complex.coshisinh and remove uses of creal math. #5698
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
Conversation
|
Thanks for your pull request, @ibuclaw! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
std/complex.d
Outdated
| */ | ||
| Complex!real coshisinh(real y) @safe pure nothrow @nogc | ||
| { | ||
| import std.math : cosh, sinh; |
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.
Is this the most efficient way of performing the calculation? I'm only asking because the one in std.math is implemented differently, using exp()/expm1().
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.
std.math.coshisinh just inlines the cosh+sinh implementations.
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.
Yes, but the purpose of that seems to be to reduce two exp() calls to one. Does the compiler perform the same optimisation in your case?
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.
Two calls would be made. One for cosh, one for sinh.
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.
std.math.coshisinh makes only one exp call. In fact, that seems to be its raison d'être.
|
Added one fast path. I also noticed there could be a few more functions added here. log, exp and tan are some of the notable that should be easy to add, but missing. |
@ibuclaw do you intend to add them in this PR, or is it now good to go? |
|
I can add other functions in latter PRs. I should alzo add another unittest for |
wilzbach
left a comment
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.
As this is technically a new symbol, it requires approval from @andralex
| } | ||
| } | ||
|
|
||
| @safe pure nothrow @nogc unittest |
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.
How about making this a publicly documented example?
| Note: | ||
| $(D coshisinh) is included here for convenience and for easy migration of code | ||
| that uses $(REF _coshisinh, std,math). |
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.
What is the motivation behind the move?
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.
Are we deprecating complex real?
| static import std.math; | ||
| if (std.math.fabs(y) <= 0.5) | ||
| return Complex!real(std.math.cosh(y), std.math.sinh(y)); | ||
| else |
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.
redundant control flow
andralex
left a comment
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 shouldn't be blocked on me as I'm not an expert.
|
cc math people @9il @klickverbot @WalterBright |
Small addition for dlang/dmd#7081
Everything else looks like just deleting support code from phobos.