Boost logo

Boost Users :

Subject: Re: [Boost-users] multiprecision modf
From: Paul A. Bristow (pbristow_at_[hidden])
Date: 2016-08-03 05:00:20


I haven’t looked into this in detail, but I think not,

 

but Boost.Math does

 

#include <boost/math/special_functions/modf.hpp>

 

You might also need to add this to your local function(s) to aid Argument Dependant Lookup (ADL).

 

BOOST_MATH_STD_USING

 

http://www.boost.org/doc/libs/1_61_0/libs/math/doc/html/math_toolkit/config_macros.html#math_toolkit.config_macros.boost_math_macros

 

Table 11. Boost.Math Macros

 

“Provides using statements for many std:: (abs to sqrt) and boost::math (rounds, modf) functions. This allows these functions to be called unqualified so that if <http://en.wikipedia.org/wiki/Argument-dependent_name_lookup> argument-dependent Argument Dependent Lookup fails to find a suitable overload, then the std:: versions will also be considered.”

 

HTH

 

Paul

 

 

From: Boost-users [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Daniel Brake
Sent: 03 August 2016 06:37
To: boost-users_at_[hidden]
Subject: [Boost-users] multiprecision modf

 

Hi Boost,

 

Does Boost.Multiprecision provide modf for floating point types? I need it for generating with Karma, unless the fact that mpfr_float with variable precision not having numeric_traits might get in the way.

 

Thanks for any help. Error message follows.

 

In file included from test/generating/mpfr_float.cpp:27:

In file included from ./include/bertini2/io/generators.hpp:38:

In file included from /usr/local/include/boost/spirit/include/karma.hpp:16:

In file included from /usr/local/include/boost/spirit/home/karma.hpp:15:

In file included from /usr/local/include/boost/spirit/home/karma/numeric.hpp:16:

In file included from /usr/local/include/boost/spirit/home/karma/numeric/real.hpp:32:

In file included from /usr/local/include/boost/spirit/home/karma/numeric/real_policies.hpp:21:

/usr/local/include/boost/spirit/home/karma/numeric/detail/real_utils.hpp:115:33: error: no matching function for call to 'modf'

            U fractional_part = modf(n, &integer_part);

                                ^~~~

/usr/local/include/boost/spirit/home/karma/numeric/real_policies.hpp:94:30: note: in instantiation of function template specialization

      'boost::spirit::karma::real_inserter<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>,

      bertini::generators::BertiniNumPolicy<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> >, boost::spirit::unused_type,

      boost::spirit::unused_type>::call_n<boost::spirit::karma::detail::output_iterator<std::__1::back_insert_iterator<std::__1::basic_string<char> >,

      mpl_::int_<0>, boost::spirit::unused_type>, boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> >' requested here

            return Inserter::call_n(sink, n, p);

                             ^

/usr/local/include/boost/spirit/home/karma/numeric/detail/real_utils.hpp:56:31: note: in instantiation of function template specialization

      'boost::spirit::karma::real_policies<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>

>::call<boost::spirit::karma::real_inserter<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>,

      bertini::generators::BertiniNumPolicy<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> >, boost::spirit::unused_type, boost::spirit::unused_type>,

      boost::spirit::karma::detail::output_iterator<std::__1::back_insert_iterator<std::__1::basic_string<char> >, mpl_::int_<0>,

      boost::spirit::unused_type>,

      bertini::generators::BertiniNumPolicy<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> > >' requested here

            return p.template call<real_inserter>(sink, n, p);

                              ^

/usr/local/include/boost/spirit/home/karma/numeric/real.hpp:192:35: note: in instantiation of function template specialization

      'boost::spirit::karma::real_inserter<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>,

      bertini::generators::BertiniNumPolicy<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> >, boost::spirit::unused_type,

      boost::spirit::unused_type>::call<boost::spirit::karma::detail::output_iterator<std::__1::back_insert_iterator<std::__1::basic_string<char> >,

      mpl_::int_<0>, boost::spirit::unused_type>, boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> >' requested here

            return inserter_type::call(sink, traits::extract_from<T>(attr, context), p_) &&

                                  ^

/usr/local/include/boost/spirit/home/karma/generate.hpp:69:45: note: in instantiation of function template specialization

      'boost::spirit::karma::any_real_generator<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>,

      bertini::generators::BertiniNumPolicy<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> >, boost::spirit::unused_type,

      boost::spirit::unused_type>::generate<boost::spirit::karma::detail::output_iterator<std::__1::back_insert_iterator<std::__1::basic_string<char> >,

      mpl_::int_<0>, boost::spirit::unused_type>, boost::spirit::context<boost::fusion::cons<const

      boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> &, boost::fusion::nil_>, boost::spirit::locals<mpl_::na, mpl_::na, mpl_::na, mpl_::na,

      mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, boost::spirit::unused_type,

      boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> >' requested here

        return compile<karma::domain>(expr).generate(sink, context, unused, attr);

                                            ^

/usr/local/include/boost/spirit/home/karma/generate.hpp:91:23: note: in instantiation of function template specialization

      'boost::spirit::karma::generate<std::__1::back_insert_iterator<std::__1::basic_string<char> >, mpl_::int_<0>,

      boost::spirit::karma::real_generator<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>,

      bertini::generators::BertiniNumPolicy<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> > >, boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0,

      allocate_dynamic>, boost::multiprecision::expression_template_option::et_on> >' requested here

        return karma::generate(sink, expr, attr);

                      ^

./include/bertini2/io/generators.hpp:149:21: note: in instantiation of function template specialization

      'boost::spirit::karma::generate<std::__1::back_insert_iterator<std::__1::basic_string<char> >,

      boost::spirit::karma::real_generator<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>,

      bertini::generators::BertiniNumPolicy<boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on> > >, boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0,

      allocate_dynamic>, boost::multiprecision::expression_template_option::et_on> >' requested here

                    return generate(sink,

                           ^

test/generating/mpfr_float.cpp:53:47: note: in instantiation of function template specialization

      'bertini::generators::Classic::generate<std::__1::back_insert_iterator<std::__1::basic_string<char> > >' requested here

    BOOST_CHECK(bertini::generators::Classic::generate(sink, z));

                                              ^

/usr/include/math.h:407:15: note: candidate function not viable: no known conversion from

      'boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>' to 'double' for 1st argument

extern double modf(double, double *);

              ^

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:940:46: note: candidate function not

      viable: no known conversion from 'boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>' to 'float' for 1st argument

inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return modff(__lcpp_x, __lcpp_y);}

                                             ^

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cmath:941:46: note: candidate function not

      viable: no known conversion from 'boost::multiprecision::number<boost::multiprecision::backends::mpfr_float_backend<0, allocate_dynamic>,

      boost::multiprecision::expression_template_option::et_on>' to 'long double' for 1st argument

inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);}

Daniel Brake



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net