我正在使用c++运行物理模拟,为了获得精确的结果,我使用的是boost::Multi精度。到目前为止,我使用了cpp_dec_float_50类型,然而,现在我需要测试不同精度的不同变量的模拟。
那么,如何创建新类型,例如,cpp_dec_float_27(27位精度)?
我试图更改模板代码:
namespace boost{ namespace multiprecision{
template <unsigned Digits10, class ExponentType = boost::int32_t, class Allocator = void>
class cpp_dec_float;
typedef number<cpp_dec_float<50> > cpp_dec_float_50;
typedef number<cpp_dec_float<100> > cpp_dec_float_100;
}} // namespaces但我有很多问题。
发布于 2015-11-15 13:20:03
如果我正确理解,您正在尝试更改您的boost安装,这是您不应该做的,因为其他的boost源可能依赖于它。
如果您想要定义您自己的精度,则需要一个简单的ty清晰度:
typedef number<cpp_dec_float<27> > cpp_dec_float27;你已经准备好走了。
但是,如果您的函数依赖于cpp_dec_float100类型,您可能需要考虑使用这些函数的模板来接受多个精度。
https://stackoverflow.com/questions/33719604
复制相似问题