Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Boost multiprecision fails because the implementation of complex tries to cast to double in internal functions like _Isinf or _Isnan

I need a BSD-like licensed C(++) multiprecision library with complex numbers support so I tried boost.

The following code fails:

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <complex>

using namespace boost::multiprecision;    
std::complex<cpp_dec_float_50>(1.0, 2.0) / std::complex<cpp_dec_float_50>(1.0, 2.0)

in Visual Studio 2012 with an error C2440 because the implementation of complex tries to cast to double in internal functions like _Isinf or _Isnan.

Is this an error on my part? How can I fix this? Are there better libraries?

like image 780
xnor Avatar asked Oct 04 '22 23:10

xnor


1 Answers

From C++11 26.4/2:

The effect of instantiating the template complex for any type other than float, double, or long double is unspecified.

So you can't reliably use std::complex with other types, but perhaps boost has a complex type that works with cpp_dec_float_50.

like image 198
Mark B Avatar answered Oct 13 '22 11:10

Mark B