Skip to content
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

complex pow fails with boost::float128_t #979

Open
gpeterhoff opened this issue Apr 26, 2023 · 2 comments
Open

complex pow fails with boost::float128_t #979

gpeterhoff opened this issue Apr 26, 2023 · 2 comments

Comments

@gpeterhoff
Copy link

Hi,
std::pow(std::complex<boost::float128_t>, boost::float128_t>) works not with negative real and zero imag, eg:

template <typename Type>
void show_complex_pow(const Type r, const Type i, const Type e)
{
 std::complex<Type> c(r, i);
 c = std::pow(c, e);
 std::cout << c << std::endl;
}
const double
 r = -0.7,
 i = 0.0,
 e = 2.3;
show_complex_pow<double>(r, i, e);
show_complex_pow<boost::float128_t>(r, i, e);

(+0.258788,+0.356191)
(-nan,+0)

@gpeterhoff gpeterhoff changed the title complex pow for boost::float128_t complex pow fails with boost::float128_t Apr 26, 2023
@mborland
Copy link
Member

Are you using GCC on x86-64 so boost::float128_t is a typedef of __float128? Does it work if you call cpowq instead of pow?

@gpeterhoff
Copy link
Author

yes + yes

__complex128 c = r + i;
 c= cpowq(c, e);
 std::cout << '(' <<crealq(c) << ','<< cimagq(c) << ")\n";

(+0.258788,+0.356191)
The problem is the overload in boost/math/cstdfloat/cstdfloat_complex_std.hpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants