123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559 |
- ///////////////////////////////////////////////////////////////////////////////
- // Copyright 2011 John Maddock. Distributed under the Boost
- // Software License, Version 1.0. (See accompanying file
- // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- #ifndef BOOST_MP_MPFI_HPP
- #define BOOST_MP_MPFI_HPP
- #include <algorithm>
- #include <cmath>
- #include <cstdint>
- #include <type_traits>
- #include <string>
- #include <boost/multiprecision/detail/standalone_config.hpp>
- #include <boost/multiprecision/detail/fpclassify.hpp>
- #include <boost/multiprecision/number.hpp>
- #include <boost/multiprecision/detail/digits.hpp>
- #include <boost/multiprecision/detail/precision.hpp>
- #include <boost/multiprecision/detail/atomic.hpp>
- #include <boost/multiprecision/traits/max_digits10.hpp>
- #include <boost/multiprecision/mpfr.hpp>
- #include <boost/multiprecision/logged_adaptor.hpp>
- #include <boost/multiprecision/detail/hash.hpp>
- #include <boost/multiprecision/detail/no_exceptions_support.hpp>
- #include <boost/multiprecision/detail/assert.hpp>
- #include <mpfi.h>
- #ifdef BOOST_MP_MATH_AVAILABLE
- #include <boost/math/constants/constants.hpp>
- #endif
- #ifndef BOOST_MULTIPRECISION_MPFI_DEFAULT_PRECISION
- #define BOOST_MULTIPRECISION_MPFI_DEFAULT_PRECISION 20
- #endif
- namespace boost {
- namespace multiprecision {
- template <unsigned digits10>
- struct number_category<backends::mpfi_float_backend<digits10> > : public std::integral_constant<int, number_kind_floating_point>
- {};
- struct interval_error : public std::runtime_error
- {
- interval_error(const std::string& s) : std::runtime_error(s) {}
- };
- namespace detail {
- template <>
- struct is_variable_precision<backends::mpfi_float_backend<0> > : public std::integral_constant<bool, true>
- {};
- } // namespace detail
- namespace backends {
- namespace detail {
- inline int mpfi_sgn(mpfi_srcptr p)
- {
- if (mpfi_is_zero(p))
- return 0;
- if (mpfi_is_strictly_pos(p))
- return 1;
- if (mpfi_is_strictly_neg(p))
- return -1;
- BOOST_MP_THROW_EXCEPTION(interval_error("Sign of interval is ambiguous."));
- }
- template <unsigned digits10>
- struct mpfi_float_imp;
- template <unsigned digits10>
- struct mpfi_float_imp
- {
- #ifdef BOOST_HAS_LONG_LONG
- using signed_types = std::tuple<long, long long> ;
- using unsigned_types = std::tuple<unsigned long, unsigned long long>;
- #else
- using signed_types = std::tuple<long> ;
- using unsigned_types = std::tuple<unsigned long>;
- #endif
- using float_types = std::tuple<double, long double>;
- using exponent_type = long ;
- mpfi_float_imp()
- {
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfi_set_ui(m_data, 0u);
- }
- mpfi_float_imp(unsigned prec)
- {
- mpfi_init2(m_data, prec);
- mpfi_set_ui(m_data, 0u);
- }
- mpfi_float_imp(const mpfi_float_imp& o)
- {
- mpfi_init2(m_data, preserve_source_precision() ? mpfi_get_prec(o.data()) : boost::multiprecision::detail::digits10_2_2(get_default_precision()));
- if (o.m_data[0].left._mpfr_d)
- mpfi_set(m_data, o.m_data);
- }
- template <unsigned D, mpfr_allocation_type AllocationType>
- mpfi_float_imp(const mpfr_float_imp<D, AllocationType>& o)
- {
- mpfi_init2(m_data, (D == 0 ? preserve_component_precision() : preserve_related_precision()) ? mpfr_get_prec(o.data()) : boost::multiprecision::detail::digits10_2_2(get_default_precision()));
- if (o.data()[0]._mpfr_d)
- mpfi_set_fr(m_data, o.data());
- }
- // rvalue copy
- mpfi_float_imp(mpfi_float_imp&& o) noexcept
- {
- mpfr_prec_t binary_default_precision = boost::multiprecision::detail::digits10_2_2(get_default_precision());
- if ((this->get_default_options() != variable_precision_options::preserve_target_precision) || (mpfi_get_prec(o.data()) == binary_default_precision))
- {
- m_data[0] = o.m_data[0];
- o.m_data[0].left._mpfr_d = nullptr;
- }
- else
- {
- // NOTE: C allocation interface must not throw:
- mpfi_init2(m_data, binary_default_precision);
- mpfi_set(m_data, o.m_data);
- }
- }
- mpfi_float_imp& operator=(const mpfi_float_imp& o)
- {
- if (this != &o)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, preserve_source_precision() ? mpfi_get_prec(o.m_data) : boost::multiprecision::detail::digits10_2_2(get_default_precision()));
- else if (preserve_source_precision() && (mpfi_get_prec(o.data()) != mpfi_get_prec(data())))
- {
- mpfi_set_prec(m_data, mpfi_get_prec(o.m_data));
- }
- mpfi_set(m_data, o.m_data);
- }
- return *this;
- }
- // rvalue assign
- mpfi_float_imp& operator=(mpfi_float_imp&& o) noexcept
- {
- if ((this->get_default_options() != variable_precision_options::preserve_target_precision) || (mpfi_get_prec(o.data()) == mpfi_get_prec(data())))
- mpfi_swap(m_data, o.m_data);
- else
- *this = static_cast<const mpfi_float_imp&>(o);
- return *this;
- }
- #ifdef BOOST_HAS_LONG_LONG
- #ifdef _MPFR_H_HAVE_INTMAX_T
- mpfi_float_imp& operator=(unsigned long long i)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_uj(left_data(), i, GMP_RNDD);
- mpfr_set_uj(right_data(), i, GMP_RNDU);
- return *this;
- }
- mpfi_float_imp& operator=(long long i)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_sj(left_data(), i, GMP_RNDD);
- mpfr_set_sj(right_data(), i, GMP_RNDU);
- return *this;
- }
- #else
- mpfi_float_imp& operator=(unsigned long long i)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- unsigned long long mask = ((((1uLL << (std::numeric_limits<unsigned long>::digits - 1)) - 1) << 1) | 1u);
- unsigned shift = 0;
- mpfi_t t;
- mpfi_init2(t, (std::max)(static_cast<mpfr_prec_t>(std::numeric_limits<unsigned long long>::digits), static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(digits10))));
- mpfi_set_ui(m_data, 0);
- while (i)
- {
- mpfi_set_ui(t, static_cast<unsigned long>(i & mask));
- if (shift)
- mpfi_mul_2exp(t, t, shift);
- mpfi_add(m_data, m_data, t);
- shift += std::numeric_limits<unsigned long>::digits;
- i >>= std::numeric_limits<unsigned long>::digits;
- }
- mpfi_clear(t);
- return *this;
- }
- mpfi_float_imp& operator=(long long i)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- bool neg = i < 0;
- *this = boost::multiprecision::detail::unsigned_abs(i);
- if (neg)
- mpfi_neg(m_data, m_data);
- return *this;
- }
- #endif
- #endif
- #ifdef BOOST_HAS_INT128
- mpfi_float_imp& operator=(uint128_type i)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- constexpr uint128_type mask = ((((static_cast<uint128_type>(1u) << (std::numeric_limits<unsigned long>::digits - 1)) - 1) << 1) | 1u);
- unsigned shift = 0;
- mpfi_t t;
- mpfi_init2(t, (std::max)(static_cast<mpfr_prec_t>(128), static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(digits10))));
- mpfi_set_ui(m_data, 0);
- while (i)
- {
- mpfi_set_ui(t, static_cast<unsigned long>(i & mask));
- if (shift)
- mpfi_mul_2exp(t, t, shift);
- mpfi_add(m_data, m_data, t);
- shift += std::numeric_limits<unsigned long>::digits;
- i >>= std::numeric_limits<unsigned long>::digits;
- }
- mpfi_clear(t);
- return *this;
- }
- mpfi_float_imp& operator=(int128_type i)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- bool neg = i < 0;
- *this = boost::multiprecision::detail::unsigned_abs(i);
- if (neg)
- mpfi_neg(m_data, m_data);
- return *this;
- }
- #endif
- mpfi_float_imp& operator=(unsigned long i)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfi_set_ui(m_data, i);
- return *this;
- }
- mpfi_float_imp& operator=(long i)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfi_set_si(m_data, i);
- return *this;
- }
- mpfi_float_imp& operator=(double d)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfi_set_d(m_data, d);
- return *this;
- }
- mpfi_float_imp& operator=(long double a)
- {
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_ld(left_data(), a, GMP_RNDD);
- mpfr_set_ld(right_data(), a, GMP_RNDU);
- return *this;
- }
- #ifdef BOOST_HAS_FLOAT128
- mpfi_float_imp& operator=(float128_type a)
- {
- BOOST_MP_FLOAT128_USING
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- if (a == 0)
- {
- mpfi_set_si(m_data, 0);
- return *this;
- }
- if (a == 1)
- {
- mpfi_set_si(m_data, 1);
- return *this;
- }
- BOOST_MP_ASSERT(!BOOST_MP_ISINF(a));
- BOOST_MP_ASSERT(!BOOST_MP_ISNAN(a));
- int e;
- float128_type f, term;
- mpfi_set_ui(m_data, 0u);
- f = frexp(a, &e);
- constexpr const int shift = std::numeric_limits<int>::digits - 1;
- while (f)
- {
- // extract int sized bits from f:
- f = ldexp(f, shift);
- term = floor(f);
- e -= shift;
- mpfi_mul_2exp(m_data, m_data, shift);
- if (term > 0)
- mpfi_add_ui(m_data, m_data, static_cast<unsigned>(term));
- else
- mpfi_sub_ui(m_data, m_data, static_cast<unsigned>(-term));
- f -= term;
- }
- if (e > 0)
- mpfi_mul_2exp(m_data, m_data, e);
- else if (e < 0)
- mpfi_div_2exp(m_data, m_data, -e);
- return *this;
- }
- #endif
- mpfi_float_imp& operator=(const char* s)
- {
- using default_ops::eval_fpclassify;
- if (m_data[0].left._mpfr_d == nullptr)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- if (s && (*s == '{'))
- {
- mpfr_float_backend<digits10> a, b;
- std::string part;
- const char* p = ++s;
- while (*p && (*p != ',') && (*p != '}'))
- ++p;
- part.assign(s, p);
- a = part.c_str();
- s = p;
- if (*p && (*p != '}'))
- {
- ++p;
- while (*p && (*p != ',') && (*p != '}'))
- ++p;
- part.assign(s + 1, p);
- }
- else
- part.erase();
- b = part.c_str();
- if (eval_fpclassify(a) == static_cast<int>(FP_NAN))
- {
- mpfi_set_fr(this->data(), a.data());
- }
- else if (eval_fpclassify(b) == static_cast<int>(FP_NAN))
- {
- mpfi_set_fr(this->data(), b.data());
- }
- else
- {
- if (a.compare(b) > 0)
- {
- BOOST_MP_THROW_EXCEPTION(std::runtime_error("Attempt to create interval with invalid range (start is greater than end)."));
- }
- mpfi_interv_fr(m_data, a.data(), b.data());
- }
- }
- else if (mpfi_set_str(m_data, s, 10) != 0)
- {
- BOOST_MP_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse string \"") + s + std::string("\"as a valid floating point number.")));
- }
- return *this;
- }
- void swap(mpfi_float_imp& o) noexcept
- {
- mpfi_swap(m_data, o.m_data);
- }
- std::string str(std::streamsize digits, std::ios_base::fmtflags f) const
- {
- BOOST_MP_ASSERT(m_data[0].left._mpfr_d);
- mpfr_float_backend<digits10> a, b;
- mpfi_get_left(a.data(), m_data);
- mpfi_get_right(b.data(), m_data);
- if (a.compare(b) == 0)
- return a.str(digits, f);
- return "{" + a.str(digits, f) + "," + b.str(digits, f) + "}";
- }
- ~mpfi_float_imp() noexcept
- {
- if (m_data[0].left._mpfr_d)
- mpfi_clear(m_data);
- }
- void negate() noexcept
- {
- BOOST_MP_ASSERT(m_data[0].left._mpfr_d);
- mpfi_neg(m_data, m_data);
- }
- int compare(const mpfi_float_imp& o) const noexcept
- {
- BOOST_MP_ASSERT(m_data[0].left._mpfr_d && o.m_data[0].left._mpfr_d);
- if (mpfr_cmp(right_data(), o.left_data()) < 0)
- return -1;
- if (mpfr_cmp(left_data(), o.right_data()) > 0)
- return 1;
- if ((mpfr_cmp(left_data(), o.left_data()) == 0) && (mpfr_cmp(right_data(), o.right_data()) == 0))
- return 0;
- BOOST_MP_THROW_EXCEPTION(interval_error("Ambiguous comparison between two values."));
- return 0;
- }
- template <class V>
- int compare(V v) const noexcept
- {
- mpfi_float_imp d;
- d = v;
- return compare(d);
- }
- mpfi_t& data() noexcept
- {
- BOOST_MP_ASSERT(m_data[0].left._mpfr_d);
- return m_data;
- }
- const mpfi_t& data() const noexcept
- {
- BOOST_MP_ASSERT(m_data[0].left._mpfr_d);
- return m_data;
- }
- mpfr_ptr left_data() noexcept
- {
- BOOST_MP_ASSERT(m_data[0].left._mpfr_d);
- return &(m_data[0].left);
- }
- mpfr_srcptr left_data() const noexcept
- {
- BOOST_MP_ASSERT(m_data[0].left._mpfr_d);
- return &(m_data[0].left);
- }
- mpfr_ptr right_data() noexcept
- {
- BOOST_MP_ASSERT(m_data[0].left._mpfr_d);
- return &(m_data[0].right);
- }
- mpfr_srcptr right_data() const noexcept
- {
- BOOST_MP_ASSERT(m_data[0].left._mpfr_d);
- return &(m_data[0].right);
- }
- protected:
- mpfi_t m_data;
- static boost::multiprecision::detail::precision_type& get_global_default_precision() noexcept
- {
- static boost::multiprecision::detail::precision_type val(BOOST_MULTIPRECISION_MPFI_DEFAULT_PRECISION);
- return val;
- }
- static unsigned& get_default_precision() noexcept
- {
- static BOOST_MP_THREAD_LOCAL unsigned val(get_global_default_precision());
- return val;
- }
- #ifndef BOOST_MT_NO_ATOMIC_INT
- static std::atomic<variable_precision_options>& get_global_default_options() noexcept
- #else
- static variable_precision_options& get_global_default_options() noexcept
- #endif
- {
- #ifndef BOOST_MT_NO_ATOMIC_INT
- static std::atomic<variable_precision_options> val{variable_precision_options::preserve_related_precision};
- #else
- static variable_precision_optionss val{variable_precision_options::preserve_related_precision};
- #endif
- return val;
- }
- static variable_precision_options& get_default_options() noexcept
- {
- static BOOST_MP_THREAD_LOCAL variable_precision_options val(get_global_default_options());
- return val;
- }
- static bool preserve_source_precision() noexcept
- {
- return get_default_options() >= variable_precision_options::preserve_source_precision;
- }
- static bool preserve_component_precision() noexcept
- {
- return get_default_options() >= variable_precision_options::preserve_component_precision;
- }
- static bool preserve_related_precision() noexcept
- {
- return get_default_options() >= variable_precision_options::preserve_related_precision;
- }
- static bool preserve_all_precision() noexcept
- {
- return get_default_options() >= variable_precision_options::preserve_all_precision;
- }
- };
- } // namespace detail
- template <unsigned digits10>
- struct mpfi_float_backend : public detail::mpfi_float_imp<digits10>
- {
- mpfi_float_backend() : detail::mpfi_float_imp<digits10>() {}
- mpfi_float_backend(const mpfi_float_backend& o) : detail::mpfi_float_imp<digits10>(o) {}
- // rvalue copy
- mpfi_float_backend(mpfi_float_backend&& o) : detail::mpfi_float_imp<digits10>(static_cast<detail::mpfi_float_imp<digits10>&&>(o))
- {}
- template <unsigned D>
- mpfi_float_backend(const mpfi_float_backend<D>& val, typename std::enable_if<D <= digits10>::type* = nullptr)
- : detail::mpfi_float_imp<digits10>()
- {
- mpfi_set(this->m_data, val.data());
- }
- template <unsigned D, mpfr_allocation_type AllocationType>
- mpfi_float_backend(const mpfr_float_backend<D, AllocationType>& val, typename std::enable_if<D <= digits10>::type* = nullptr)
- : detail::mpfi_float_imp<digits10>(val) {}
- template <unsigned D>
- explicit mpfi_float_backend(const mpfi_float_backend<D>& val, typename std::enable_if<!(D <= digits10)>::type* = nullptr)
- : detail::mpfi_float_imp<digits10>()
- {
- mpfi_set(this->m_data, val.data());
- }
- mpfi_float_backend(const mpfi_t val)
- : detail::mpfi_float_imp<digits10>()
- {
- mpfi_set(this->m_data, val);
- }
- mpfi_float_backend& operator=(const mpfi_float_backend& o)
- {
- *static_cast<detail::mpfi_float_imp<digits10>*>(this) = static_cast<detail::mpfi_float_imp<digits10> const&>(o);
- return *this;
- }
- template <unsigned D>
- mpfi_float_backend(const mpfr_float_backend<D>& val, typename std::enable_if<D <= digits10>::type* = nullptr)
- : detail::mpfi_float_imp<digits10>()
- {
- mpfi_set_fr(this->m_data, val.data());
- }
- template <unsigned D>
- mpfi_float_backend& operator=(const mpfr_float_backend<D>& val)
- {
- mpfi_set_fr(this->m_data, val.data());
- return *this;
- }
- template <unsigned D>
- explicit mpfi_float_backend(const mpfr_float_backend<D>& val, typename std::enable_if<!(D <= digits10)>::type* = nullptr)
- : detail::mpfi_float_imp<digits10>()
- {
- mpfi_set_fr(this->m_data, val.data());
- }
- // rvalue copy
- mpfi_float_backend& operator=(mpfi_float_backend&& o) noexcept
- {
- *static_cast<detail::mpfi_float_imp<digits10>*>(this) = static_cast<detail::mpfi_float_imp<digits10>&&>(o);
- return *this;
- }
- template <class V>
- typename std::enable_if<std::is_assignable<detail::mpfi_float_imp<digits10>, V>::value, mpfi_float_backend&>::type operator=(const V& v)
- {
- *static_cast<detail::mpfi_float_imp<digits10>*>(this) = v;
- return *this;
- }
- mpfi_float_backend& operator=(const mpfi_t val)
- {
- mpfi_set(this->m_data, val);
- return *this;
- }
- // We don't change our precision here, this is a fixed precision type:
- template <unsigned D>
- mpfi_float_backend& operator=(const mpfi_float_backend<D>& val)
- {
- mpfi_set(this->m_data, val.data());
- return *this;
- }
- };
- template <unsigned D1, unsigned D2, mpfr_allocation_type AllocationType>
- void assign_components(mpfi_float_backend<D1>& result, const mpfr_float_backend<D2, AllocationType>& a, const mpfr_float_backend<D2, AllocationType>& b);
- template <unsigned Digits10, class V>
- typename std::enable_if<std::is_constructible<number<mpfr_float_backend<Digits10, allocate_dynamic>, et_on>, V>::value || std::is_convertible<V, const char*>::value>::type
- assign_components(mpfi_float_backend<Digits10>& result, const V& a, const V& b);
- template <>
- struct mpfi_float_backend<0> : public detail::mpfi_float_imp<0>
- {
- mpfi_float_backend() : detail::mpfi_float_imp<0>() {}
- mpfi_float_backend(const mpfi_t val)
- : detail::mpfi_float_imp<0>(mpfi_get_prec(val))
- {
- mpfi_set(this->m_data, val);
- }
- mpfi_float_backend(const mpfi_float_backend& o) : detail::mpfi_float_imp<0>(o) {}
- template <unsigned D, mpfr_allocation_type AllocationType>
- mpfi_float_backend(const mpfr_float_backend<D, AllocationType>& val)
- : detail::mpfi_float_imp<0>(val) {}
- // rvalue copy
- mpfi_float_backend(mpfi_float_backend&& o) noexcept : detail::mpfi_float_imp<0>(static_cast<detail::mpfi_float_imp<0>&&>(o))
- {}
- mpfi_float_backend(const mpfi_float_backend& o, unsigned digits10)
- : detail::mpfi_float_imp<0>(multiprecision::detail::digits10_2_2(digits10))
- {
- mpfi_set(this->m_data, o.data());
- }
- template <class V>
- mpfi_float_backend(const V& a, const V& b, unsigned digits10)
- : detail::mpfi_float_imp<0>(multiprecision::detail::digits10_2_2(digits10))
- {
- boost::multiprecision::detail::scoped_target_precision<mpfi_float_backend<0> > opts;
- assign_components(*this, a, b);
- }
- template <unsigned D>
- mpfi_float_backend(const mpfi_float_backend<D>& val)
- : detail::mpfi_float_imp<0>(mpfi_get_prec(val.data()))
- {
- mpfi_set(this->m_data, val.data());
- }
- mpfi_float_backend& operator=(const mpfi_float_backend& o) = default;
- // rvalue assign
- mpfi_float_backend& operator=(mpfi_float_backend&& o) noexcept = default;
- template <class V>
- mpfi_float_backend& operator=(const V& v)
- {
- constexpr unsigned d10 = std::is_floating_point<V>::value ?
- std::numeric_limits<V>::digits10 :
- std::numeric_limits<V>::digits10 ? 1 + std::numeric_limits<V>::digits10 :
- 1 + boost::multiprecision::detail::digits2_2_10(std::numeric_limits<V>::digits);
- if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
- {
- BOOST_IF_CONSTEXPR(std::is_floating_point<V>::value)
- {
- if (std::numeric_limits<V>::digits > mpfi_get_prec(this->data()))
- mpfi_set_prec(this->data(), std::numeric_limits<V>::digits);
- }
- else
- {
- if (precision() < d10)
- this->precision(d10);
- }
- }
- *static_cast<detail::mpfi_float_imp<0>*>(this) = v;
- return *this;
- }
- mpfi_float_backend& operator=(const mpfi_t val)
- {
- mpfi_set_prec(this->m_data, mpfi_get_prec(val));
- mpfi_set(this->m_data, val);
- return *this;
- }
- template <unsigned D>
- mpfi_float_backend& operator=(const mpfi_float_backend<D>& val)
- {
- mpfi_set_prec(this->m_data, mpfi_get_prec(val.data()));
- mpfi_set(this->m_data, val.data());
- return *this;
- }
- static unsigned thread_default_precision() noexcept
- {
- return get_default_precision();
- }
- static void thread_default_precision(unsigned v) noexcept
- {
- get_default_precision() = v;
- }
- static unsigned default_precision() noexcept
- {
- return get_global_default_precision();
- }
- static void default_precision(unsigned v) noexcept
- {
- get_global_default_precision() = v;
- }
- unsigned precision() const noexcept
- {
- return multiprecision::detail::digits2_2_10(mpfi_get_prec(this->m_data));
- }
- void precision(unsigned digits10) noexcept
- {
- mpfi_float_backend t(*this, digits10);
- this->swap(t);
- }
- //
- // Variable precision options:
- //
- static variable_precision_options default_variable_precision_options() noexcept
- {
- return get_global_default_options();
- }
- static variable_precision_options thread_default_variable_precision_options() noexcept
- {
- return get_default_options();
- }
- static void default_variable_precision_options(variable_precision_options opts)
- {
- get_global_default_options() = opts;
- }
- static void thread_default_variable_precision_options(variable_precision_options opts)
- {
- get_default_options() = opts;
- }
- };
- template <unsigned digits10, class T>
- inline typename std::enable_if<boost::multiprecision::detail::is_arithmetic<T>::value, bool>::type eval_eq(const mpfi_float_backend<digits10>& a, const T& b) noexcept
- {
- return a.compare(b) == 0;
- }
- template <unsigned digits10, class T>
- inline typename std::enable_if<boost::multiprecision::detail::is_arithmetic<T>::value, bool>::type eval_lt(const mpfi_float_backend<digits10>& a, const T& b) noexcept
- {
- return a.compare(b) < 0;
- }
- template <unsigned digits10, class T>
- inline typename std::enable_if<boost::multiprecision::detail::is_arithmetic<T>::value, bool>::type eval_gt(const mpfi_float_backend<digits10>& a, const T& b) noexcept
- {
- return a.compare(b) > 0;
- }
- template <unsigned D1, unsigned D2>
- inline void eval_add(mpfi_float_backend<D1>& result, const mpfi_float_backend<D2>& o)
- {
- mpfi_add(result.data(), result.data(), o.data());
- }
- template <unsigned D1, unsigned D2>
- inline void eval_subtract(mpfi_float_backend<D1>& result, const mpfi_float_backend<D2>& o)
- {
- mpfi_sub(result.data(), result.data(), o.data());
- }
- template <unsigned D1, unsigned D2>
- inline void eval_multiply(mpfi_float_backend<D1>& result, const mpfi_float_backend<D2>& o)
- {
- if ((void*)&result == (void*)&o)
- mpfi_sqr(result.data(), o.data());
- else
- mpfi_mul(result.data(), result.data(), o.data());
- }
- template <unsigned D1, unsigned D2>
- inline void eval_divide(mpfi_float_backend<D1>& result, const mpfi_float_backend<D2>& o)
- {
- mpfi_div(result.data(), result.data(), o.data());
- }
- template <unsigned digits10>
- inline void eval_add(mpfi_float_backend<digits10>& result, unsigned long i)
- {
- mpfi_add_ui(result.data(), result.data(), i);
- }
- template <unsigned digits10>
- inline void eval_subtract(mpfi_float_backend<digits10>& result, unsigned long i)
- {
- mpfi_sub_ui(result.data(), result.data(), i);
- }
- template <unsigned digits10>
- inline void eval_multiply(mpfi_float_backend<digits10>& result, unsigned long i)
- {
- mpfi_mul_ui(result.data(), result.data(), i);
- }
- template <unsigned digits10>
- inline void eval_divide(mpfi_float_backend<digits10>& result, unsigned long i)
- {
- mpfi_div_ui(result.data(), result.data(), i);
- }
- template <unsigned digits10>
- inline void eval_add(mpfi_float_backend<digits10>& result, long i)
- {
- if (i > 0)
- mpfi_add_ui(result.data(), result.data(), i);
- else
- mpfi_sub_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i));
- }
- template <unsigned digits10>
- inline void eval_subtract(mpfi_float_backend<digits10>& result, long i)
- {
- if (i > 0)
- mpfi_sub_ui(result.data(), result.data(), i);
- else
- mpfi_add_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i));
- }
- template <unsigned digits10>
- inline void eval_multiply(mpfi_float_backend<digits10>& result, long i)
- {
- mpfi_mul_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i));
- if (i < 0)
- mpfi_neg(result.data(), result.data());
- }
- template <unsigned digits10>
- inline void eval_divide(mpfi_float_backend<digits10>& result, long i)
- {
- mpfi_div_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i));
- if (i < 0)
- mpfi_neg(result.data(), result.data());
- }
- //
- // Specialised 3 arg versions of the basic operators:
- //
- template <unsigned D1, unsigned D2, unsigned D3>
- inline void eval_add(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, const mpfi_float_backend<D3>& y)
- {
- mpfi_add(a.data(), x.data(), y.data());
- }
- template <unsigned D1, unsigned D2>
- inline void eval_add(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, unsigned long y)
- {
- mpfi_add_ui(a.data(), x.data(), y);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_add(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, long y)
- {
- if (y < 0)
- mpfi_sub_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y));
- else
- mpfi_add_ui(a.data(), x.data(), y);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_add(mpfi_float_backend<D1>& a, unsigned long x, const mpfi_float_backend<D2>& y)
- {
- mpfi_add_ui(a.data(), y.data(), x);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_add(mpfi_float_backend<D1>& a, long x, const mpfi_float_backend<D2>& y)
- {
- if (x < 0)
- {
- mpfi_ui_sub(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data());
- mpfi_neg(a.data(), a.data());
- }
- else
- mpfi_add_ui(a.data(), y.data(), x);
- }
- template <unsigned D1, unsigned D2, unsigned D3>
- inline void eval_subtract(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, const mpfi_float_backend<D3>& y)
- {
- mpfi_sub(a.data(), x.data(), y.data());
- }
- template <unsigned D1, unsigned D2>
- inline void eval_subtract(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, unsigned long y)
- {
- mpfi_sub_ui(a.data(), x.data(), y);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_subtract(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, long y)
- {
- if (y < 0)
- mpfi_add_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y));
- else
- mpfi_sub_ui(a.data(), x.data(), y);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_subtract(mpfi_float_backend<D1>& a, unsigned long x, const mpfi_float_backend<D2>& y)
- {
- mpfi_ui_sub(a.data(), x, y.data());
- }
- template <unsigned D1, unsigned D2>
- inline void eval_subtract(mpfi_float_backend<D1>& a, long x, const mpfi_float_backend<D2>& y)
- {
- if (x < 0)
- {
- mpfi_add_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x));
- mpfi_neg(a.data(), a.data());
- }
- else
- mpfi_ui_sub(a.data(), x, y.data());
- }
- template <unsigned D1, unsigned D2, unsigned D3>
- inline void eval_multiply(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, const mpfi_float_backend<D3>& y)
- {
- if ((void*)&x == (void*)&y)
- mpfi_sqr(a.data(), x.data());
- else
- mpfi_mul(a.data(), x.data(), y.data());
- }
- template <unsigned D1, unsigned D2>
- inline void eval_multiply(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, unsigned long y)
- {
- mpfi_mul_ui(a.data(), x.data(), y);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_multiply(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, long y)
- {
- if (y < 0)
- {
- mpfi_mul_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y));
- a.negate();
- }
- else
- mpfi_mul_ui(a.data(), x.data(), y);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_multiply(mpfi_float_backend<D1>& a, unsigned long x, const mpfi_float_backend<D2>& y)
- {
- mpfi_mul_ui(a.data(), y.data(), x);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_multiply(mpfi_float_backend<D1>& a, long x, const mpfi_float_backend<D2>& y)
- {
- if (x < 0)
- {
- mpfi_mul_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x));
- mpfi_neg(a.data(), a.data());
- }
- else
- mpfi_mul_ui(a.data(), y.data(), x);
- }
- template <unsigned D1, unsigned D2, unsigned D3>
- inline void eval_divide(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, const mpfi_float_backend<D3>& y)
- {
- mpfi_div(a.data(), x.data(), y.data());
- }
- template <unsigned D1, unsigned D2>
- inline void eval_divide(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, unsigned long y)
- {
- mpfi_div_ui(a.data(), x.data(), y);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_divide(mpfi_float_backend<D1>& a, const mpfi_float_backend<D2>& x, long y)
- {
- if (y < 0)
- {
- mpfi_div_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y));
- a.negate();
- }
- else
- mpfi_div_ui(a.data(), x.data(), y);
- }
- template <unsigned D1, unsigned D2>
- inline void eval_divide(mpfi_float_backend<D1>& a, unsigned long x, const mpfi_float_backend<D2>& y)
- {
- mpfi_ui_div(a.data(), x, y.data());
- }
- template <unsigned D1, unsigned D2>
- inline void eval_divide(mpfi_float_backend<D1>& a, long x, const mpfi_float_backend<D2>& y)
- {
- if (x < 0)
- {
- mpfi_ui_div(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data());
- mpfi_neg(a.data(), a.data());
- }
- else
- mpfi_ui_div(a.data(), x, y.data());
- }
- template <unsigned digits10>
- inline bool eval_is_zero(const mpfi_float_backend<digits10>& val) noexcept
- {
- return 0 != mpfi_is_zero(val.data());
- }
- template <unsigned digits10>
- inline int eval_get_sign(const mpfi_float_backend<digits10>& val)
- {
- return detail::mpfi_sgn(val.data());
- }
- template <unsigned digits10>
- inline void eval_convert_to(unsigned long* result, const mpfi_float_backend<digits10>& val)
- {
- mpfr_float_backend<digits10> t;
- mpfi_mid(t.data(), val.data());
- eval_convert_to(result, t);
- }
- template <unsigned digits10>
- inline void eval_convert_to(long* result, const mpfi_float_backend<digits10>& val)
- {
- mpfr_float_backend<digits10> t;
- mpfi_mid(t.data(), val.data());
- eval_convert_to(result, t);
- }
- #ifdef _MPFR_H_HAVE_INTMAX_T
- template <unsigned digits10>
- inline void eval_convert_to(unsigned long long* result, const mpfi_float_backend<digits10>& val)
- {
- mpfr_float_backend<digits10> t;
- mpfi_mid(t.data(), val.data());
- eval_convert_to(result, t);
- }
- template <unsigned digits10>
- inline void eval_convert_to(long long* result, const mpfi_float_backend<digits10>& val)
- {
- mpfr_float_backend<digits10> t;
- mpfi_mid(t.data(), val.data());
- eval_convert_to(result, t);
- }
- #endif
- #ifdef BOOST_HAS_INT128
- template <unsigned digits10>
- inline void eval_convert_to(uint128_type* result, const mpfi_float_backend<digits10>& val)
- {
- mpfr_float_backend<digits10> t;
- mpfi_mid(t.data(), val.data());
- eval_convert_to(result, t);
- }
- template <unsigned digits10>
- inline void eval_convert_to(int128_type* result, const mpfi_float_backend<digits10>& val)
- {
- mpfr_float_backend<digits10> t;
- mpfi_mid(t.data(), val.data());
- eval_convert_to(result, t);
- }
- #endif
- template <unsigned digits10>
- inline void eval_convert_to(double* result, const mpfi_float_backend<digits10>& val) noexcept
- {
- *result = mpfi_get_d(val.data());
- }
- template <unsigned digits10>
- inline void eval_convert_to(long double* result, const mpfi_float_backend<digits10>& val) noexcept
- {
- mpfr_float_backend<digits10> t;
- mpfi_mid(t.data(), val.data());
- eval_convert_to(result, t);
- }
- #ifdef BOOST_HAS_FLOAT128
- template <unsigned digits10>
- inline void eval_convert_to(float128_type* result, const mpfi_float_backend<digits10>& val)
- {
- mpfr_float_backend<digits10> t;
- mpfi_mid(t.data(), val.data());
- eval_convert_to(result, t);
- }
- #endif
- template <mpfr_allocation_type AllocationType>
- inline void assign_components_set_precision(mpfi_float_backend<0>& result, const mpfr_float_backend<0, AllocationType>& a, const mpfr_float_backend<0, AllocationType>& b)
- {
- if (result.thread_default_variable_precision_options() >= variable_precision_options::preserve_component_precision)
- {
- unsigned long prec = (std::max)(mpfr_get_prec(a.data()), mpfr_get_prec(b.data()));
- mpfi_set_prec(result.data(), prec);
- }
- }
- template <unsigned D2, mpfr_allocation_type AllocationType>
- inline void assign_components_set_precision(mpfi_float_backend<0>& result, const mpfr_float_backend<D2, AllocationType>& a, const mpfr_float_backend<D2, AllocationType>& b)
- {
- if (result.thread_default_variable_precision_options() >= variable_precision_options::preserve_related_precision)
- {
- unsigned long prec = (std::max)(mpfr_get_prec(a.data()), mpfr_get_prec(b.data()));
- mpfi_set_prec(result.data(), prec);
- }
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type AllocationType>
- inline void assign_components_set_precision(mpfi_float_backend<D1>&, const mpfr_float_backend<D2, AllocationType>&, const mpfr_float_backend<D2, AllocationType>&)
- {
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type AllocationType>
- inline void assign_components(mpfi_float_backend<D1>& result, const mpfr_float_backend<D2, AllocationType>& a, const mpfr_float_backend<D2, AllocationType>& b)
- {
- //
- // This is called from class number's constructors, so if we have variable
- // precision, then copy the precision of the source variables.
- //
- assign_components_set_precision(result, a, b);
- using default_ops::eval_fpclassify;
- if (eval_fpclassify(a) == static_cast<int>(FP_NAN))
- {
- mpfi_set_fr(result.data(), a.data());
- }
- else if (eval_fpclassify(b) == static_cast<int>(FP_NAN))
- {
- mpfi_set_fr(result.data(), b.data());
- }
- else
- {
- if (a.compare(b) > 0)
- {
- BOOST_MP_THROW_EXCEPTION(std::runtime_error("Attempt to create interval with invalid range (start is greater than end)."));
- }
- mpfi_interv_fr(result.data(), a.data(), b.data());
- }
- }
- template <unsigned Digits10, class V>
- inline typename std::enable_if<std::is_constructible<number<mpfr_float_backend<Digits10, allocate_dynamic>, et_on>, V>::value || std::is_convertible<V, const char*>::value>::type
- assign_components(mpfi_float_backend<Digits10>& result, const V& a, const V& b)
- {
- number<mpfr_float_backend<Digits10, allocate_dynamic>, et_on> x(a), y(b);
- assign_components(result, x.backend(), y.backend());
- }
- //
- // Native non-member operations:
- //
- template <unsigned Digits10>
- inline void eval_sqrt(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& val)
- {
- mpfi_sqrt(result.data(), val.data());
- }
- template <unsigned Digits10>
- inline void eval_abs(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& val)
- {
- mpfi_abs(result.data(), val.data());
- }
- template <unsigned Digits10>
- inline void eval_fabs(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& val)
- {
- mpfi_abs(result.data(), val.data());
- }
- template <unsigned Digits10>
- inline void eval_ceil(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& val)
- {
- mpfr_float_backend<Digits10> a, b;
- mpfr_set(a.data(), val.left_data(), GMP_RNDN);
- mpfr_set(b.data(), val.right_data(), GMP_RNDN);
- eval_ceil(a, a);
- eval_ceil(b, b);
- if (a.compare(b) != 0)
- {
- BOOST_MP_THROW_EXCEPTION(interval_error("Attempt to take the ceil of a value that straddles an integer boundary."));
- }
- mpfi_set_fr(result.data(), a.data());
- }
- template <unsigned Digits10>
- inline void eval_floor(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& val)
- {
- mpfr_float_backend<Digits10> a, b;
- mpfr_set(a.data(), val.left_data(), GMP_RNDN);
- mpfr_set(b.data(), val.right_data(), GMP_RNDN);
- eval_floor(a, a);
- eval_floor(b, b);
- if (a.compare(b) != 0)
- {
- BOOST_MP_THROW_EXCEPTION(interval_error("Attempt to take the floor of a value that straddles an integer boundary."));
- }
- mpfi_set_fr(result.data(), a.data());
- }
- template <unsigned Digits10>
- inline void eval_ldexp(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& val, long e)
- {
- if (e > 0)
- mpfi_mul_2exp(result.data(), val.data(), e);
- else if (e < 0)
- mpfi_div_2exp(result.data(), val.data(), -e);
- else
- result = val;
- }
- template <unsigned Digits10>
- inline void eval_frexp(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& val, int* e)
- {
- mpfr_float_backend<Digits10> t, rt;
- mpfi_mid(t.data(), val.data());
- eval_frexp(rt, t, e);
- eval_ldexp(result, val, -*e);
- }
- template <unsigned Digits10>
- inline void eval_frexp(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& val, long* e)
- {
- mpfr_float_backend<Digits10> t, rt;
- mpfi_mid(t.data(), val.data());
- eval_frexp(rt, t, e);
- eval_ldexp(result, val, -*e);
- }
- template <unsigned Digits10>
- inline int eval_fpclassify(const mpfi_float_backend<Digits10>& val) noexcept
- {
- return mpfi_inf_p(val.data()) ? FP_INFINITE : mpfi_nan_p(val.data()) ? FP_NAN : mpfi_is_zero(val.data()) ? FP_ZERO : FP_NORMAL;
- }
- template <unsigned Digits10>
- inline void eval_pow(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& b, const mpfi_float_backend<Digits10>& e)
- {
- using ui_type = typename boost::multiprecision::detail::canonical<unsigned, mpfi_float_backend<Digits10> >::type;
- using default_ops::eval_get_sign;
- int s = eval_get_sign(b);
- if (s == 0)
- {
- if (eval_get_sign(e) == 0)
- {
- result = ui_type(1);
- }
- else
- {
- result = ui_type(0);
- }
- return;
- }
- if (s < 0)
- {
- if (eval_get_sign(e) < 0)
- {
- mpfi_float_backend<Digits10> t1, t2;
- t1 = e;
- t1.negate();
- eval_pow(t2, b, t1);
- t1 = ui_type(1);
- eval_divide(result, t1, t2);
- return;
- }
- typename boost::multiprecision::detail::canonical<std::uintmax_t, mpfi_float_backend<Digits10> >::type an;
- #ifndef BOOST_NO_EXCEPTIONS
- try
- {
- #endif
- using default_ops::eval_convert_to;
- eval_convert_to(&an, e);
- if (e.compare(an) == 0)
- {
- mpfi_float_backend<Digits10> pb(b);
- pb.negate();
- eval_pow(result, pb, e);
- if (an & 1u)
- result.negate();
- return;
- }
- #ifndef BOOST_NO_EXCEPTIONS
- }
- catch (const std::exception&)
- {
- // conversion failed, just fall through, value is not an integer.
- }
- #endif
- result = std::numeric_limits<number<mpfi_float_backend<Digits10>, et_on> >::quiet_NaN().backend();
- return;
- }
- mpfi_log(result.data(), b.data());
- mpfi_mul(result.data(), result.data(), e.data());
- mpfi_exp(result.data(), result.data());
- }
- template <unsigned Digits10>
- inline void eval_exp(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_exp(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_exp2(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_exp2(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_log(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_log(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_log10(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_log10(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_sin(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_sin(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_cos(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_cos(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_tan(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_tan(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_asin(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_asin(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_acos(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_acos(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_atan(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_atan(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_atan2(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg1, const mpfi_float_backend<Digits10>& arg2)
- {
- mpfi_atan2(result.data(), arg1.data(), arg2.data());
- }
- template <unsigned Digits10>
- inline void eval_sinh(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_sinh(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_cosh(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_cosh(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_tanh(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_tanh(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline void eval_log2(mpfi_float_backend<Digits10>& result, const mpfi_float_backend<Digits10>& arg)
- {
- mpfi_log2(result.data(), arg.data());
- }
- template <unsigned Digits10>
- inline std::size_t hash_value(const mpfi_float_backend<Digits10>& val)
- {
- std::size_t result = 0;
- std::size_t len = val.left_data()[0]._mpfr_prec / mp_bits_per_limb;
- if (val.left_data()[0]._mpfr_prec % mp_bits_per_limb)
- ++len;
- for (std::size_t i = 0; i < len; ++i)
- boost::multiprecision::detail::hash_combine(result, val.left_data()[0]._mpfr_d[i]);
- boost::multiprecision::detail::hash_combine(result, val.left_data()[0]._mpfr_exp, val.left_data()[0]._mpfr_sign);
- len = val.right_data()[0]._mpfr_prec / mp_bits_per_limb;
- if (val.right_data()[0]._mpfr_prec % mp_bits_per_limb)
- ++len;
- for (std::size_t i = 0; i < len; ++i)
- boost::multiprecision::detail::hash_combine(result, val.right_data()[0]._mpfr_d[i]);
- boost::multiprecision::detail::hash_combine(result, val.right_data()[0]._mpfr_exp, val.right_data()[0]._mpfr_sign);
- return result;
- }
- template <class To, unsigned D>
- void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const std::integral_constant<int, number_kind_integer>& to_type, const std::integral_constant<int, number_kind_floating_point>& from_type)
- {
- using boost::multiprecision::detail::generic_interconvert;
- boost::multiprecision::detail::scoped_precision_options<number<mpfr_float_backend<D>>> scoped(from);
- mpfr_float_backend<D> t;
- mpfi_mid(t.data(), from.data());
- generic_interconvert(to, t, to_type, from_type);
- }
- template <class To, unsigned D>
- void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const std::integral_constant<int, number_kind_rational>& to_type, const std::integral_constant<int, number_kind_floating_point>& from_type)
- {
- using boost::multiprecision::detail::generic_interconvert;
- boost::multiprecision::detail::scoped_precision_options<number<mpfr_float_backend<D>>> scoped(from);
- mpfr_float_backend<D> t;
- mpfi_mid(t.data(), from.data());
- generic_interconvert(to, t, to_type, from_type);
- }
- template <class To, unsigned D>
- void generic_interconvert(To& to, const mpfi_float_backend<D>& from, const std::integral_constant<int, number_kind_floating_point>& to_type, const std::integral_constant<int, number_kind_floating_point>& from_type)
- {
- using boost::multiprecision::detail::generic_interconvert;
- boost::multiprecision::detail::scoped_precision_options<number<mpfr_float_backend<D>>> scoped(from);
- mpfr_float_backend<D> t;
- mpfi_mid(t.data(), from.data());
- generic_interconvert(to, t, to_type, from_type);
- }
- } // namespace backends
- template <>
- struct number_category<detail::canonical<mpfi_t, backends::mpfi_float_backend<0> >::type> : public std::integral_constant<int, number_kind_floating_point>
- {};
- template <unsigned Digits10>
- struct is_interval_number<backends::mpfi_float_backend<Digits10> > : public std::integral_constant<bool, true>
- {};
- //
- // Special interval specific functions:
- //
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<mpfr_float_backend<Digits10>, ExpressionTemplates> lower(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_precision_options<number<mpfr_float_backend<Digits10>, ExpressionTemplates> > precision_guard(val);
- number<mpfr_float_backend<Digits10> > result;
- mpfr_set(result.backend().data(), val.backend().left_data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<mpfr_float_backend<Digits10>, ExpressionTemplates> upper(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_precision_options<number<mpfr_float_backend<Digits10>, ExpressionTemplates> > precision_guard(val);
- number<mpfr_float_backend<Digits10> > result;
- mpfr_set(result.backend().data(), val.backend().right_data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<mpfr_float_backend<Digits10>, ExpressionTemplates> median(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_precision_options<number<mpfr_float_backend<Digits10>, ExpressionTemplates> > precision_guard(val);
- number<mpfr_float_backend<Digits10> > result;
- mpfi_mid(result.backend().data(), val.backend().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<mpfr_float_backend<Digits10>, ExpressionTemplates> width(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_precision_options<number<mpfr_float_backend<Digits10>, ExpressionTemplates> > precision_guard(val);
- number<mpfr_float_backend<Digits10> > result;
- mpfi_diam_abs(result.backend().data(), val.backend().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<mpfi_float_backend<Digits10>, ExpressionTemplates> intersect(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a, const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b)
- {
- boost::multiprecision::detail::scoped_default_precision<number<mpfi_float_backend<Digits10>, ExpressionTemplates> > precision_guard(a, b);
- number<mpfi_float_backend<Digits10>, ExpressionTemplates> result;
- mpfi_intersect(result.backend().data(), a.backend().data(), b.backend().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<mpfi_float_backend<Digits10>, ExpressionTemplates> hull(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a, const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b)
- {
- boost::multiprecision::detail::scoped_default_precision<number<mpfi_float_backend<Digits10>, ExpressionTemplates> > precision_guard(a, b);
- number<mpfi_float_backend<Digits10>, ExpressionTemplates> result;
- mpfi_union(result.backend().data(), a.backend().data(), b.backend().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool overlap(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a, const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b)
- {
- return (lower(a) <= lower(b) && lower(b) <= upper(a)) ||
- (lower(b) <= lower(a) && lower(a) <= upper(b));
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates1, expression_template_option ExpressionTemplates2>
- inline bool in(const number<mpfr_float_backend<Digits10>, ExpressionTemplates1>& a, const number<mpfi_float_backend<Digits10>, ExpressionTemplates2>& b)
- {
- return mpfi_is_inside_fr(a.backend().data(), b.backend().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool zero_in(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a)
- {
- return mpfi_has_zero(a.backend().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool subset(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a, const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b)
- {
- return mpfi_is_inside(a.backend().data(), b.backend().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool proper_subset(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a, const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& b)
- {
- return mpfi_is_strictly_inside(a.backend().data(), b.backend().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool empty(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a)
- {
- return mpfi_is_empty(a.backend().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool singleton(const number<mpfi_float_backend<Digits10>, ExpressionTemplates>& a)
- {
- return mpfr_cmp(a.backend().left_data(), a.backend().right_data()) == 0;
- }
- //
- // Again with debug_adaptor:
- //
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<debug_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> lower(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_default_precision<number<debug_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(val);
- number<debug_adaptor<mpfr_float_backend<Digits10> > > result;
- mpfr_set(result.backend().value().data(), val.backend().value().left_data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<debug_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> upper(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_default_precision<number<debug_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(val);
- number<debug_adaptor<mpfr_float_backend<Digits10> > > result;
- mpfr_set(result.backend().value().data(), val.backend().value().right_data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<debug_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> median(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_default_precision<number<debug_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(val);
- number<debug_adaptor<mpfr_float_backend<Digits10> > > result;
- mpfi_mid(result.backend().value().data(), val.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<debug_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> width(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_default_precision<number<debug_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(val);
- number<debug_adaptor<mpfr_float_backend<Digits10> > > result;
- mpfi_diam_abs(result.backend().value().data(), val.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> intersect(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- boost::multiprecision::detail::scoped_default_precision<number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(a, b);
- number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_intersect(result.backend().value().data(), a.backend().value().data(), b.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> hull(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- boost::multiprecision::detail::scoped_default_precision<number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(a, b);
- number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_union(result.backend().value().data(), a.backend().value().data(), b.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool overlap(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- return (lower(a) <= lower(b) && lower(b) <= upper(a)) ||
- (lower(b) <= lower(a) && lower(a) <= upper(b));
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates1, expression_template_option ExpressionTemplates2>
- inline bool in(const number<debug_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates1>& a, const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates2>& b)
- {
- return mpfi_is_inside_fr(a.backend().value().data(), b.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool zero_in(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a)
- {
- return mpfi_has_zero(a.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool subset(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- return mpfi_is_inside(a.backend().value().data(), b.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool proper_subset(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- return mpfi_is_strictly_inside(a.backend().value().data(), b.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool empty(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a)
- {
- return mpfi_is_empty(a.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool singleton(const number<debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a)
- {
- return mpfr_cmp(a.backend().value().left_data(), a.backend().value().right_data()) == 0;
- }
- //
- // Again with logged_adaptor:
- //
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<logged_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> lower(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_default_precision<number<logged_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(val);
- number<logged_adaptor<mpfr_float_backend<Digits10> > > result;
- mpfr_set(result.backend().value().data(), val.backend().value().left_data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<logged_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> upper(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_default_precision<number<logged_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(val);
- number<logged_adaptor<mpfr_float_backend<Digits10> > > result;
- mpfr_set(result.backend().value().data(), val.backend().value().right_data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<logged_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> median(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_default_precision<number<logged_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(val);
- number<logged_adaptor<mpfr_float_backend<Digits10> > > result;
- mpfi_mid(result.backend().value().data(), val.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<logged_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> width(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& val)
- {
- boost::multiprecision::detail::scoped_default_precision<number<logged_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(val);
- number<logged_adaptor<mpfr_float_backend<Digits10> > > result;
- mpfi_diam_abs(result.backend().value().data(), val.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> intersect(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- boost::multiprecision::detail::scoped_default_precision<number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(a, b);
- number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_intersect(result.backend().value().data(), a.backend().value().data(), b.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> hull(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- boost::multiprecision::detail::scoped_default_precision<number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(a, b);
- number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_union(result.backend().value().data(), a.backend().value().data(), b.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool overlap(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- return (lower(a) <= lower(b) && lower(b) <= upper(a)) ||
- (lower(b) <= lower(a) && lower(a) <= upper(b));
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates1, expression_template_option ExpressionTemplates2>
- inline bool in(const number<logged_adaptor<mpfr_float_backend<Digits10> >, ExpressionTemplates1>& a, const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates2>& b)
- {
- return mpfi_is_inside_fr(a.backend().value().data(), b.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool zero_in(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a)
- {
- return mpfi_has_zero(a.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool subset(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- return mpfi_is_inside(a.backend().value().data(), b.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool proper_subset(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a, const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& b)
- {
- return mpfi_is_strictly_inside(a.backend().value().data(), b.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool empty(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a)
- {
- return mpfi_is_empty(a.backend().value().data()) != 0;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline bool singleton(const number<logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates>& a)
- {
- return mpfr_cmp(a.backend().value().left_data(), a.backend().value().right_data()) == 0;
- }
- //
- // component_type specialization:
- //
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- struct component_type<number<mpfi_float_backend<Digits10>, ExpressionTemplates> >
- {
- using type = number<mpfr_float_backend<Digits10>, ExpressionTemplates>;
- };
- //
- // Overloaded special functions which call native mpfr routines:
- //
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<mpfi_float_backend<Digits10>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> result;
- mpfi_asinh(result.backend().data(), arg.backend().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<mpfi_float_backend<Digits10>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> result;
- mpfi_acosh(result.backend().data(), arg.backend().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<mpfi_float_backend<Digits10>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> result;
- mpfi_atanh(result.backend().data(), arg.backend().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<mpfi_float_backend<Digits10>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> result;
- mpfi_cbrt(result.backend().data(), arg.backend().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<mpfi_float_backend<Digits10>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> result;
- mpfi_expm1(result.backend().data(), arg.backend().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<mpfi_float_backend<Digits10>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> result;
- mpfi_log1p(result.backend().data(), arg.backend().data());
- return result;
- }
- //
- // And again with debug_adaptor:
- //
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_asinh(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_acosh(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_atanh(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_cbrt(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_expm1(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::debug_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_log1p(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- //
- // And again with logged_adaptor:
- //
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_asinh(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_acosh(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_atanh(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_cbrt(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_expm1(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- template <unsigned Digits10, expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<mpfi_float_backend<Digits10> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> result;
- mpfi_log1p(result.backend().value().data(), arg.backend().value().data());
- return result;
- }
- } // namespace multiprecision
- namespace math {
- namespace tools {
- inline void set_output_precision(const boost::multiprecision::mpfi_float& val, std::ostream& os)
- {
- os << std::setprecision(val.precision());
- }
- template <>
- inline int digits<boost::multiprecision::mpfi_float>()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return multiprecision::detail::digits10_2_2(boost::multiprecision::mpfi_float::thread_default_precision());
- }
- template <>
- inline int digits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, boost::multiprecision::et_off> >()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return multiprecision::detail::digits10_2_2(boost::multiprecision::mpfi_float::thread_default_precision());
- }
- template <>
- inline boost::multiprecision::mpfi_float
- max_value<boost::multiprecision::mpfi_float>()
- {
- boost::multiprecision::mpfi_float result(0.5);
- mpfi_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline boost::multiprecision::mpfi_float
- min_value<boost::multiprecision::mpfi_float>()
- {
- boost::multiprecision::mpfi_float result(0.5);
- mpfi_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, boost::multiprecision::et_off>
- max_value<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, boost::multiprecision::et_off> >()
- {
- boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, boost::multiprecision::et_off> result(0.5);
- mpfi_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, boost::multiprecision::et_off>
- min_value<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, boost::multiprecision::et_off> >()
- {
- boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, boost::multiprecision::et_off> result(0.5);
- mpfi_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- return result;
- }
- // mpfi gets used with logged_adaptor fairly often, so specialize for that use case as well:
- using logged_type1 = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float::backend_type>, boost::multiprecision::et_on> ;
- using logged_type2 = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float::backend_type>, boost::multiprecision::et_off>;
- template <>
- inline int digits<logged_type1>()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return multiprecision::detail::digits10_2_2(logged_type1::thread_default_precision());
- }
- template <>
- inline int digits<logged_type2>()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return multiprecision::detail::digits10_2_2(logged_type1::thread_default_precision());
- }
- template <>
- inline logged_type1
- max_value<logged_type1>()
- {
- logged_type1 result(0.5);
- mpfi_mul_2exp(result.backend().value().data(), result.backend().value().data(), mpfr_get_emax());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline logged_type1
- min_value<logged_type1>()
- {
- logged_type1 result(0.5);
- mpfi_div_2exp(result.backend().value().data(), result.backend().value().data(), -mpfr_get_emin());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline logged_type2
- max_value<logged_type2>()
- {
- logged_type2 result(0.5);
- mpfi_mul_2exp(result.backend().value().data(), result.backend().value().data(), mpfr_get_emax());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline logged_type2
- min_value<logged_type2>()
- {
- logged_type2 result(0.5);
- mpfi_div_2exp(result.backend().value().data(), result.backend().value().data(), -mpfr_get_emin());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- return result;
- }
- // mpfi gets used with debug_adaptor fairly often, so specialize for that use case as well:
- using debug_type1 = boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float::backend_type>, boost::multiprecision::et_on> ;
- using debug_type2 = boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float::backend_type>, boost::multiprecision::et_off>;
- template <>
- inline int digits<debug_type1>()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return multiprecision::detail::digits10_2_2(debug_type1::default_precision());
- }
- template <>
- inline int digits<debug_type2>()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return multiprecision::detail::digits10_2_2(debug_type1::default_precision());
- }
- template <>
- inline debug_type1
- max_value<debug_type1>()
- {
- debug_type1 result(0.5);
- mpfi_mul_2exp(result.backend().value().data(), result.backend().value().data(), mpfr_get_emax());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- result.backend().update_view();
- return result;
- }
- template <>
- inline debug_type1
- min_value<debug_type1>()
- {
- debug_type1 result(0.5);
- mpfi_div_2exp(result.backend().value().data(), result.backend().value().data(), -mpfr_get_emin());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- result.backend().update_view();
- return result;
- }
- template <>
- inline debug_type2
- max_value<debug_type2>()
- {
- debug_type2 result(0.5);
- mpfi_mul_2exp(result.backend().value().data(), result.backend().value().data(), mpfr_get_emax());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- result.backend().update_view();
- return result;
- }
- template <>
- inline debug_type2
- min_value<debug_type2>()
- {
- debug_type2 result(0.5);
- mpfi_div_2exp(result.backend().value().data(), result.backend().value().data(), -mpfr_get_emin());
- //BOOST_MP_ASSERT(mpfi_number_p(result.backend().data()));
- result.backend().update_view();
- return result;
- }
- } // namespace tools
- namespace constants { namespace detail {
- template <class T>
- struct constant_pi;
- template <class T>
- struct constant_ln_two;
- template <class T>
- struct constant_euler;
- template <class T>
- struct constant_catalan;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_pi<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_pi(result.backend().data());
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_log2(result.backend().data());
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_euler<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_euler(result.backend().data());
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_catalan<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_catalan(result.backend().data());
- return result;
- }
- };
- //
- // And again with debug_adaptor:
- //
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_pi<boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_pi(result.backend().value().data());
- result.backend().update_view();
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_log2(result.backend().value().data());
- result.backend().update_view();
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_euler<boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_euler(result.backend().value().data());
- result.backend().update_view();
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_catalan<boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_catalan(result.backend().value().data());
- result.backend().update_view();
- return result;
- }
- };
- //
- // And again with logged_adaptor:
- //
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_pi<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_pi(result.backend().value().data());
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_log2(result.backend().value().data());
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_euler<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_euler(result.backend().value().data());
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_catalan<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfi_float_backend<Digits10> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_catalan(result.backend().value().data());
- return result;
- }
- };
- }} // namespace constants::detail
- } // namespace math
- } // namespace boost
- namespace std {
- //
- // numeric_limits [partial] specializations for the types declared in this header:
- //
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >
- {
- using number_type = boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates>;
- static number_type get_min()
- {
- number_type value(0.5);
- mpfi_div_2exp(value.backend().data(), value.backend().data(), -mpfr_get_emin());
- return value;
- }
- static number_type get_max()
- {
- number_type value(0.5);
- mpfi_mul_2exp(value.backend().data(), value.backend().data(), mpfr_get_emax());
- return value;
- }
- static number_type get_epsilon()
- {
- number_type value(1);
- mpfi_div_2exp(value.backend().data(), value.backend().data(), std::numeric_limits<number_type>::digits - 1);
- return value;
- }
- static number_type get_infinity()
- {
- number_type value;
- boost::multiprecision::mpfr_float_backend<Digits10> t;
- mpfr_set_inf(t.data(), 1);
- mpfi_set_fr(value.backend().data(), t.data());
- return value;
- }
- static number_type get_quiet_NaN()
- {
- number_type value;
- boost::multiprecision::mpfr_float_backend<Digits10> t;
- mpfr_set_nan(t.data());
- mpfi_set_fr(value.backend().data(), t.data());
- return value;
- }
- public:
- static constexpr bool is_specialized = true;
- static number_type(min)()
- {
- static number_type value{get_min()};
- return value;
- }
- static number_type(max)()
- {
- static number_type value{get_max()};
- return value;
- }
- static constexpr number_type lowest()
- {
- return -(max)();
- }
- static constexpr int digits = static_cast<int>((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301 ? 2 : 1));
- static constexpr int digits10 = Digits10;
- // Is this really correct???
- static constexpr int max_digits10 = boost::multiprecision::detail::calc_max_digits10<digits>::value;
- static constexpr bool is_signed = true;
- static constexpr bool is_integer = false;
- static constexpr bool is_exact = false;
- static constexpr int radix = 2;
- static number_type epsilon()
- {
- static number_type value{get_epsilon()};
- return value;
- }
- // What value should this be????
- static number_type round_error()
- {
- return 0.5;
- }
- static constexpr long min_exponent = MPFR_EMIN_DEFAULT;
- static constexpr long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
- static constexpr long max_exponent = MPFR_EMAX_DEFAULT;
- static constexpr long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
- static constexpr bool has_infinity = true;
- static constexpr bool has_quiet_NaN = true;
- static constexpr bool has_signaling_NaN = false;
- #ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4996)
- #endif
- static constexpr float_denorm_style has_denorm = denorm_absent;
- #ifdef _MSC_VER
- #pragma warning(pop)
- #endif
- static constexpr bool has_denorm_loss = false;
- static number_type infinity()
- {
- static number_type value{get_infinity()};
- return value;
- }
- static number_type quiet_NaN()
- {
- static number_type value{get_quiet_NaN()};
- return value;
- }
- static constexpr number_type signaling_NaN()
- {
- return number_type(0);
- }
- static constexpr number_type denorm_min() { return (min)(); }
- static constexpr bool is_iec559 = false;
- static constexpr bool is_bounded = true;
- static constexpr bool is_modulo = false;
- static constexpr bool traps = true;
- static constexpr bool tinyness_before = false;
- static constexpr float_round_style round_style = round_to_nearest;
- };
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::digits;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::digits10;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::max_digits10;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::is_signed;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::is_integer;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::is_exact;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::radix;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::min_exponent;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::min_exponent10;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::max_exponent;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::max_exponent10;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::has_infinity;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::has_quiet_NaN;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::has_signaling_NaN;
- #ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4996)
- #endif
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::has_denorm;
- #ifdef _MSC_VER
- #pragma warning(pop)
- #endif
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::has_denorm_loss;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::is_iec559;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::is_bounded;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::is_modulo;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::traps;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::tinyness_before;
- template <unsigned Digits10, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<Digits10>, ExpressionTemplates> >::round_style;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >
- {
- using number_type = boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates>;
- public:
- static constexpr bool is_specialized = false;
- static number_type(min)() { return number_type(0); }
- static number_type(max)() { return number_type(0); }
- static number_type lowest() { return number_type(0); }
- static constexpr int digits = 0;
- static constexpr int digits10 = 0;
- static constexpr int max_digits10 = 0;
- static constexpr bool is_signed = false;
- static constexpr bool is_integer = false;
- static constexpr bool is_exact = false;
- static constexpr int radix = 0;
- static number_type epsilon() { return number_type(0); }
- static number_type round_error() { return number_type(0); }
- static constexpr int min_exponent = 0;
- static constexpr int min_exponent10 = 0;
- static constexpr int max_exponent = 0;
- static constexpr int max_exponent10 = 0;
- static constexpr bool has_infinity = false;
- static constexpr bool has_quiet_NaN = false;
- static constexpr bool has_signaling_NaN = false;
- #ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4996)
- #endif
- static constexpr float_denorm_style has_denorm = denorm_absent;
- #ifdef _MSC_VER
- #pragma warning(pop)
- #endif
- static constexpr bool has_denorm_loss = false;
- static number_type infinity() { return number_type(0); }
- static number_type quiet_NaN() { return number_type(0); }
- static number_type signaling_NaN() { return number_type(0); }
- static number_type denorm_min() { return number_type(0); }
- static constexpr bool is_iec559 = false;
- static constexpr bool is_bounded = false;
- static constexpr bool is_modulo = false;
- static constexpr bool traps = false;
- static constexpr bool tinyness_before = false;
- static constexpr float_round_style round_style = round_toward_zero;
- };
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::digits;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::digits10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::max_digits10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::is_signed;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::is_integer;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::is_exact;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::radix;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::min_exponent;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::min_exponent10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::max_exponent;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::max_exponent10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::has_infinity;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::has_quiet_NaN;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::has_signaling_NaN;
- #ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4996)
- #endif
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::has_denorm;
- #ifdef _MSC_VER
- #pragma warning(pop)
- #endif
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::has_denorm_loss;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::is_iec559;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::is_bounded;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::is_modulo;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::traps;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::tinyness_before;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfi_float_backend<0>, ExpressionTemplates> >::round_style;
- } // namespace std
- #endif
|