1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786 |
- ///////////////////////////////////////////////////////////////////////////////
- // 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_MATH_BN_MPFI_HPP
- #define BOOST_MATH_BN_MPFI_HPP
- #include <algorithm>
- #include <cmath>
- #include <cstdint>
- #include <type_traits>
- #include <boost/multiprecision/number.hpp>
- #include <boost/math/special_functions/fpclassify.hpp>
- #include <boost/multiprecision/detail/big_lanczos.hpp>
- #include <boost/multiprecision/detail/digits.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/math/constants/constants.hpp>
- #include <boost/functional/hash_fwd.hpp>
- #include <mpfi.h>
- #ifndef BOOST_MULTIPRECISION_MPFI_DEFAULT_PRECISION
- #define BOOST_MULTIPRECISION_MPFI_DEFAULT_PRECISION 20
- #endif
- namespace boost {
- namespace multiprecision {
- namespace backends {
- template <unsigned digits10>
- struct mpfi_float_backend;
- } // namespace backends
- 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 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_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, boost::long_long_type> ;
- using unsigned_types = std::tuple<unsigned long, boost::ulong_long_type>;
- #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, mpfi_get_prec(o.data()));
- if (o.m_data[0].left._mpfr_d)
- mpfi_set(m_data, o.m_data);
- }
- // rvalue copy
- mpfi_float_imp(mpfi_float_imp&& o) noexcept
- {
- m_data[0] = o.m_data[0];
- o.m_data[0].left._mpfr_d = 0;
- }
- mpfi_float_imp& operator=(const mpfi_float_imp& o)
- {
- if (m_data[0].left._mpfr_d == 0)
- mpfi_init2(m_data, mpfi_get_prec(o.data()));
- if (mpfi_get_prec(o.data()) != mpfi_get_prec(data()))
- {
- mpfi_float_imp t(mpfi_get_prec(o.data()));
- t = o;
- t.swap(*this);
- }
- else
- {
- if (o.m_data[0].left._mpfr_d)
- mpfi_set(m_data, o.m_data);
- }
- return *this;
- }
- // rvalue assign
- mpfi_float_imp& operator=(mpfi_float_imp&& o) noexcept
- {
- mpfi_swap(m_data, o.m_data);
- return *this;
- }
- #ifdef BOOST_HAS_LONG_LONG
- #ifdef _MPFR_H_HAVE_INTMAX_T
- mpfi_float_imp& operator=(boost::ulong_long_type i)
- {
- if (m_data[0].left._mpfr_d == 0)
- 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=(boost::long_long_type i)
- {
- if (m_data[0].left._mpfr_d == 0)
- 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=(boost::ulong_long_type i)
- {
- if (m_data[0].left._mpfr_d == 0)
- mpfi_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- boost::ulong_long_type 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<boost::ulong_long_type>::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=(boost::long_long_type i)
- {
- if (m_data[0].left._mpfr_d == 0)
- 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
- mpfi_float_imp& operator=(unsigned long i)
- {
- if (m_data[0].left._mpfr_d == 0)
- 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 == 0)
- 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 == 0)
- 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 == 0)
- 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;
- }
- mpfi_float_imp& operator=(const char* s)
- {
- using default_ops::eval_fpclassify;
- if (m_data[0].left._mpfr_d == 0)
- 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 + 1, 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) == (int)FP_NAN)
- {
- mpfi_set_fr(this->data(), a.data());
- }
- else if (eval_fpclassify(b) == (int)FP_NAN)
- {
- mpfi_set_fr(this->data(), b.data());
- }
- else
- {
- if (a.compare(b) > 0)
- {
- BOOST_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_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_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_ASSERT(m_data[0].left._mpfr_d);
- mpfi_neg(m_data, m_data);
- }
- int compare(const mpfi_float_imp& o) const noexcept
- {
- BOOST_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_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_ASSERT(m_data[0].left._mpfr_d);
- return m_data;
- }
- const mpfi_t& data() const noexcept
- {
- BOOST_ASSERT(m_data[0].left._mpfr_d);
- return m_data;
- }
- mpfr_ptr left_data() noexcept
- {
- BOOST_ASSERT(m_data[0].left._mpfr_d);
- return &(m_data[0].left);
- }
- mpfr_srcptr left_data() const noexcept
- {
- BOOST_ASSERT(m_data[0].left._mpfr_d);
- return &(m_data[0].left);
- }
- mpfr_ptr right_data() noexcept
- {
- BOOST_ASSERT(m_data[0].left._mpfr_d);
- return &(m_data[0].right);
- }
- mpfr_srcptr right_data() const noexcept
- {
- BOOST_ASSERT(m_data[0].left._mpfr_d);
- return &(m_data[0].right);
- }
- protected:
- mpfi_t m_data;
- static boost::multiprecision::detail::precision_type& get_default_precision() noexcept
- {
- static boost::multiprecision::detail::precision_type val(BOOST_MULTIPRECISION_MPFI_DEFAULT_PRECISION);
- return val;
- }
- };
- } // 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* = 0)
- : detail::mpfi_float_imp<digits10>()
- {
- mpfi_set(this->m_data, val.data());
- }
- template <unsigned D>
- explicit mpfi_float_backend(const mpfi_float_backend<D>& val, typename std::enable_if<!(D <= digits10)>::type* = 0)
- : 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* = 0)
- : 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* = 0)
- : 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>
- mpfi_float_backend& 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) {}
- // 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))
- {
- 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)
- {
- mpfi_set_prec(this->m_data, mpfi_get_prec(o.data()));
- mpfi_set(this->m_data, o.data());
- return *this;
- }
- // rvalue assign
- mpfi_float_backend& operator=(mpfi_float_backend&& o) noexcept
- {
- *static_cast<detail::mpfi_float_imp<0>*>(this) = static_cast<detail::mpfi_float_imp<0>&&>(o);
- return *this;
- }
- template <class V>
- mpfi_float_backend& operator=(const V& v)
- {
- *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 default_precision() noexcept
- {
- return get_default_precision();
- }
- static void default_precision(unsigned v) noexcept
- {
- get_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);
- }
- };
- 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(boost::ulong_long_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(boost::long_long_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);
- }
- 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)
- {
- using default_ops::eval_fpclassify;
- if (eval_fpclassify(a) == (int)FP_NAN)
- {
- mpfi_set_fr(result.data(), a.data());
- }
- else if (eval_fpclassify(b) == (int)FP_NAN)
- {
- mpfi_set_fr(result.data(), b.data());
- }
- else
- {
- if (a.compare(b) > 0)
- {
- BOOST_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_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_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::hash_combine(result, val.left_data()[0]._mpfr_d[i]);
- boost::hash_combine(result, val.left_data()[0]._mpfr_exp);
- boost::hash_combine(result, 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::hash_combine(result, val.right_data()[0]._mpfr_d[i]);
- boost::hash_combine(result, val.right_data()[0]._mpfr_exp);
- boost::hash_combine(result, 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;
- 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;
- 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;
- mpfr_float_backend<D> t;
- mpfi_mid(t.data(), from.data());
- generic_interconvert(to, t, to_type, from_type);
- }
- } // namespace backends
- namespace detail {
- template <>
- struct is_variable_precision<backends::mpfi_float_backend<0> > : public std::integral_constant<bool, true>
- {};
- } // namespace detail
- 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>
- {};
- using boost::multiprecision::backends::mpfi_float_backend;
- using mpfi_float_50 = number<mpfi_float_backend<50> > ;
- using mpfi_float_100 = number<mpfi_float_backend<100> > ;
- using mpfi_float_500 = number<mpfi_float_backend<500> > ;
- using mpfi_float_1000 = number<mpfi_float_backend<1000> >;
- using mpfi_float = number<mpfi_float_backend<0> > ;
- //
- // 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_default_precision<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_default_precision<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_default_precision<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_default_precision<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;
- }
- 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;
- }
- } // 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::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::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_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_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_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_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::default_precision());
- }
- template <>
- inline int digits<logged_type2>()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return multiprecision::detail::digits10_2_2(logged_type1::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_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_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_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_ASSERT(mpfi_number_p(result.backend().data()));
- 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>&)
- {
- static result_type result;
- static bool has_init = false;
- if (!has_init)
- {
- has_init = true;
- mpfi_const_pi(result.backend().data());
- }
- 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>&)
- {
- static result_type result;
- static bool has_init = false;
- if (!has_init)
- {
- has_init = true;
- mpfi_const_log2(result.backend().data());
- }
- 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>&)
- {
- static result_type result;
- static bool has_init = false;
- if (!has_init)
- {
- has_init = true;
- mpfi_const_euler(result.backend().data());
- }
- 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>&)
- {
- static result_type result;
- static bool has_init = false;
- if (!has_init)
- {
- has_init = true;
- mpfi_const_catalan(result.backend().data());
- }
- return result;
- }
- static inline result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfi_const_catalan(result.backend().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>;
- public:
- static constexpr bool is_specialized = true;
- static number_type(min)()
- {
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 0.5;
- mpfi_div_2exp(value.second.backend().data(), value.second.backend().data(), -mpfr_get_emin());
- }
- return value.second;
- }
- static number_type(max)()
- {
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 0.5;
- mpfi_mul_2exp(value.second.backend().data(), value.second.backend().data(), mpfr_get_emax());
- }
- return value.second;
- }
- 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 std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 1;
- mpfi_div_2exp(value.second.backend().data(), value.second.backend().data(), std::numeric_limits<number_type>::digits - 1);
- }
- return value.second;
- }
- // What value should this be????
- static number_type round_error()
- {
- // returns epsilon/2
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 1;
- mpfi_div_2exp(value.second.backend().data(), value.second.backend().data(), 1);
- }
- return value.second;
- }
- 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;
- static constexpr float_denorm_style has_denorm = denorm_absent;
- static constexpr bool has_denorm_loss = false;
- static number_type infinity()
- {
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- boost::multiprecision::mpfr_float_backend<Digits10> t;
- mpfr_set_inf(t.data(), 1);
- value.first = true;
- mpfi_set_fr(value.second.backend().data(), t.data());
- }
- return value.second;
- }
- static number_type quiet_NaN()
- {
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- boost::multiprecision::mpfr_float_backend<Digits10> t;
- mpfr_set_nan(t.data());
- value.first = true;
- mpfi_set_fr(value.second.backend().data(), t.data());
- }
- return value.second;
- }
- static constexpr number_type signaling_NaN()
- {
- return number_type(0);
- }
- static constexpr number_type denorm_min() { return number_type(0); }
- 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;
- 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;
- 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;
- static constexpr float_denorm_style has_denorm = denorm_absent;
- 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;
- 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;
- 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
|