Skip to content

mpfr.hpp math log(…) function conflict with boost::log; compilation error while invoking log(…) #207

@cosurgi

Description

@cosurgi

This line won't compile:

result = log(boost::math::constants::pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >()) - lgamma(arg, 0, pol) - log(t);

My guess is that only eval_log(…) is available there. I encountered this problem in yade pipeline with boost 1.71: https://gitlab.com/yade-dev/trunk/-/jobs/491138134

/usr/include/boost/multiprecision/mpfr.hpp: In function 'boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<digits10, AllocationType>, ExpressionTemplates> boost::math::lgamma(boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<digits10, AllocationType>, ExpressionTemplates>, int*, const Policy&)':
 /usr/include/boost/multiprecision/mpfr.hpp:2233:22: error: expected primary-expression before '(' token
  2233 |          result = log(boost::math::constants::pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >()) - lgamma(arg, 0, pol) - log(t);
       |                      ^
 /usr/include/boost/multiprecision/mpfr.hpp:2233:200: error: expected primary-expression before '(' token
  2233 |          result = log(boost::math::constants::pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >()) - lgamma(arg, 0, pol) - log(t);
       |                                                                                                                                                                                                        ^

I think that replacing it with eval_log(…) fixes the problem. At least this works for me, and test invocations of lgamma pass yade --test. I will prepare a PR with a fix.

EDIT: adding using boost::multiprecision::log; fixes conflict with boost::log namespace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions