gpt4 book ai didi

c++ - Boost multiprecision 失败,因为 complex 的实现试图在 _Isinf 或 _Isnan 等内部函数中转换为 double

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:35:24 25 4
gpt4 key购买 nike

我需要一个类 BSD 许可的 C(++) 多精度库,支持复数,所以我尝试了 boost。

以下代码失败:

#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)

在 Visual Studio 2012 中出现错误 C2440,因为 complex 的实现试图在 _Isinf 或 _Isnan 等内部函数中强制转换为 double。

这是我的错误吗?我怎样才能解决这个问题?有更好的库吗?

最佳答案

来自 C++11 26.4/2:

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

所以你不能可靠地将 std::complex 与其他类型一起使用,但也许 boost 有一个 complex 类型可以与 cpp_dec_float_50 一起使用.

关于c++ - Boost multiprecision 失败,因为 complex 的实现试图在 _Isinf 或 _Isnan 等内部函数中转换为 double,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16861798/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com