-
Notifications
You must be signed in to change notification settings - Fork 248
Adding logarithm of incomplete gamma function #1338
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
Changes from all commits
da8b635
0a2b01b
c80492f
dfb598f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,4 +38,31 @@ Real logaddexp(Real x1, Real x2) noexcept | |
| return x2 + log1p(exp(temp)); | ||
| } | ||
|
|
||
| }} // Namespace boost::math | ||
| template <typename T> | ||
| T logaddexpcomplex(T x1, T x2) noexcept | ||
| { | ||
| using std::log; | ||
| using std::exp; | ||
| using std::abs; | ||
|
|
||
| // Validate inputs first | ||
| if (!(boost::math::isfinite)(x1)) | ||
| { | ||
| return x1; | ||
| } | ||
| else if (!(boost::math::isfinite)(x2)) | ||
| { | ||
| return x2; | ||
| } | ||
|
|
||
| const T temp = x1 - x2; | ||
|
|
||
| if (std::real(temp) > 0) | ||
| { | ||
| return x1 + log(1.0 + exp(-temp)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a really bad change that will kill precision when temp is small.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've reverted this for the |
||
| } | ||
|
|
||
| return x2 + log(1.0 + exp(temp)); | ||
| } | ||
| } | ||
| }// Namespace boost::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.
The trick here, is to add
using std::realabove, and then callreal(temp), that way ADL can findboost::multiprecision::realin the multiprecision case (likewise for any other type that has their own namespace and is forbidden from putting stuff instd::).