我正在使用 boost 多精度库浮点数。我需要将 a 映射gmp_float到 antanh然后将其作为双精度值,因为值为tanhwill [0, 1)。当我使用时,convert_to<double>()我得到编译错误,如下面的代码片段所示。
typedef boost::multiprecision::number<boost::multiprecision::gmp_float<4>> float_type;
float_type previous_v = agent->_velocity(i, j);
float_type sigmapped_v = boost::multiprecision::tanh(previous_v);
double sigmoid_velocity = sigmapped_v.convert_to<double>();
// expected primary-expression before ‘double’ ^^
double v_probable = abs(sigmoid_velocity);
但是明确地将其转换为双重(double)sigmapped_v工作