
Mateusz Loskot wrote:
Mateusz Loskot wrote:
Hi,
I'm not sure if I should submit this issue directly to Trac, so I decided to post it here first. Compiling Boost.Math using Comeau + GCC on Linux throws error that suggests mismatch of dobule and long double where single type T is expected:
I've just found very similar issue in other place. It is std::pow specialisations seem ambiguous for Comeau C/C++ compiler.
"../../../boost/math/special_functions/spherical_harmonic.hpp", line 39: error: more than one instance of overloaded function "pow" matches the argument list: function "std::pow(const std::complex<long double> &, const long double &)" function "std::pow(const double &, const std::complex<double> &)" function "std::pow(long double, long double)" function "std::pow(double, int)" function "std::pow(double, double)" argument types are: (double, long double) T leg = detail::legendre_p_imp(n, m, x, pow(fabs(sin_theta), T(m)), pol); ^ detected during: instantiation of "T
boost::math::detail::spherical_harmonic_prefix(unsigned int, unsigned int, T, const Policy &) [with T=long double, Policy=c_policies::c_policy]" at line 71 instantiation of "T boost::math::detail::spherical_harmonic_r(unsigned int, int, T, T, const Policy &) [with T=long double, Policy=c_policies::c_policy]" at line 172
Similarly to original issue with math::tools::fmod_workaround, caching intermediate values solves the problem. Replacing line 39 in boost/math/special_functions/spherical_harmonic.hpp with cached fabs and pow results: T f = fabs(sin_theta); T pfm = pow(f, T(m)); T leg = detail::legendre_p_imp(n, m, x, pfm, pol); By the way, I'm wondering, is it intentional, in Boost.Math, to omit const qualifier for intermediate results? I know modern compilers can optimise perfectly well even if const is not present, but *perhaps* it would help some compilers to in optimisation. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org