Reputation: 12904
I am using boost multiprecision library floating point number. I need to map a gmp_float
to an tanh
and then take it as a double because value of tanh
will be [0, 1)
. When I use convert_to<double>()
I get compilation error as shown in the snippet bellow.
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);
However explicitly casting it to double (double)sigmapped_v
works
Upvotes: 1
Views: 225
Reputation: 392833
Going out on a limb, you are probably in a template context and float_type
is a depends on a template argument.
You need to give the compiler type hints here:
double sigmoid_velocity = sigmapped_v.template convert_to<double>();
// ^^
Without the disambiguation hint the compiler will parse <
as operator<
See also Where and why do I have to put the "template" and "typename" keywords?
Upvotes: 1