1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632 |
- ///////////////////////////////////////////////////////////////////////////////
- // 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_MPFR_HPP
- #define BOOST_MATH_BN_MPFR_HPP
- #include <boost/multiprecision/number.hpp>
- #include <boost/multiprecision/debug_adaptor.hpp>
- #include <boost/multiprecision/gmp.hpp>
- #include <boost/math/special_functions/fpclassify.hpp>
- #include <boost/cstdint.hpp>
- #include <boost/multiprecision/detail/big_lanczos.hpp>
- #include <boost/multiprecision/detail/digits.hpp>
- #include <boost/multiprecision/detail/atomic.hpp>
- #include <mpfr.h>
- #include <cmath>
- #include <algorithm>
- #ifndef BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION
- #define BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION 20
- #endif
- namespace boost {
- namespace multiprecision {
- enum mpfr_allocation_type
- {
- allocate_stack,
- allocate_dynamic
- };
- namespace backends {
- template <unsigned digits10, mpfr_allocation_type AllocationType = allocate_dynamic>
- struct mpfr_float_backend;
- template <>
- struct mpfr_float_backend<0, allocate_stack>;
- } // namespace backends
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- struct number_category<backends::mpfr_float_backend<digits10, AllocationType> > : public mpl::int_<number_kind_floating_point>
- {};
- namespace backends {
- namespace detail {
- template <bool b>
- struct mpfr_cleanup
- {
- struct initializer
- {
- initializer() {}
- ~initializer() { mpfr_free_cache(); }
- void force_instantiate() const {}
- };
- static const initializer init;
- static void force_instantiate() { init.force_instantiate(); }
- };
- template <bool b>
- typename mpfr_cleanup<b>::initializer const mpfr_cleanup<b>::init;
- inline void mpfr_copy_precision(mpfr_t dest, const mpfr_t src)
- {
- mpfr_prec_t p_dest = mpfr_get_prec(dest);
- mpfr_prec_t p_src = mpfr_get_prec(src);
- if (p_dest != p_src)
- mpfr_set_prec(dest, p_src);
- }
- inline void mpfr_copy_precision(mpfr_t dest, const mpfr_t src1, const mpfr_t src2)
- {
- mpfr_prec_t p_dest = mpfr_get_prec(dest);
- mpfr_prec_t p_src1 = mpfr_get_prec(src1);
- mpfr_prec_t p_src2 = mpfr_get_prec(src2);
- if (p_src2 > p_src1)
- p_src1 = p_src2;
- if (p_dest != p_src1)
- mpfr_set_prec(dest, p_src1);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- struct mpfr_float_imp;
- template <unsigned digits10>
- struct mpfr_float_imp<digits10, allocate_dynamic>
- {
- #ifdef BOOST_HAS_LONG_LONG
- typedef mpl::list<long, boost::long_long_type> signed_types;
- typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types;
- #else
- typedef mpl::list<long> signed_types;
- typedef mpl::list<unsigned long> unsigned_types;
- #endif
- typedef mpl::list<double, long double> float_types;
- typedef long exponent_type;
- mpfr_float_imp()
- {
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_ui(m_data, 0u, GMP_RNDN);
- }
- mpfr_float_imp(unsigned digits2)
- {
- mpfr_init2(m_data, digits2);
- mpfr_set_ui(m_data, 0u, GMP_RNDN);
- }
- mpfr_float_imp(const mpfr_float_imp& o)
- {
- mpfr_init2(m_data, mpfr_get_prec(o.m_data));
- if (o.m_data[0]._mpfr_d)
- mpfr_set(m_data, o.m_data, GMP_RNDN);
- }
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- mpfr_float_imp(mpfr_float_imp&& o) BOOST_NOEXCEPT
- {
- m_data[0] = o.m_data[0];
- o.m_data[0]._mpfr_d = 0;
- }
- #endif
- mpfr_float_imp& operator=(const mpfr_float_imp& o)
- {
- if ((o.m_data[0]._mpfr_d) && (this != &o))
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, mpfr_get_prec(o.m_data));
- mpfr_set(m_data, o.m_data, GMP_RNDN);
- }
- return *this;
- }
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- mpfr_float_imp& operator=(mpfr_float_imp&& o) BOOST_NOEXCEPT
- {
- mpfr_swap(m_data, o.m_data);
- return *this;
- }
- #endif
- #ifdef BOOST_HAS_LONG_LONG
- #ifdef _MPFR_H_HAVE_INTMAX_T
- mpfr_float_imp& operator=(boost::ulong_long_type i)
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_uj(m_data, i, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(boost::long_long_type i)
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_sj(m_data, i, GMP_RNDN);
- return *this;
- }
- #else
- mpfr_float_imp& operator=(boost::ulong_long_type i)
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_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) | 1uLL);
- unsigned shift = 0;
- mpfr_t t;
- mpfr_init2(t, (std::max)(static_cast<unsigned long>(std::numeric_limits<boost::ulong_long_type>::digits), mpfr_get_prec(m_data)));
- mpfr_set_ui(m_data, 0, GMP_RNDN);
- while (i)
- {
- mpfr_set_ui(t, static_cast<unsigned long>(i & mask), GMP_RNDN);
- if (shift)
- mpfr_mul_2exp(t, t, shift, GMP_RNDN);
- mpfr_add(m_data, m_data, t, GMP_RNDN);
- shift += std::numeric_limits<unsigned long>::digits;
- i >>= std::numeric_limits<unsigned long>::digits;
- }
- mpfr_clear(t);
- return *this;
- }
- mpfr_float_imp& operator=(boost::long_long_type i)
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_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)
- mpfr_neg(m_data, m_data, GMP_RNDN);
- return *this;
- }
- #endif
- #endif
- mpfr_float_imp& operator=(unsigned long i)
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_ui(m_data, i, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(long i)
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_si(m_data, i, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(double d)
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_d(m_data, d, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(long double a)
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- mpfr_set_ld(m_data, a, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(const char* s)
- {
- if (m_data[0]._mpfr_d == 0)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : (unsigned)get_default_precision()));
- if (mpfr_set_str(m_data, s, 10, GMP_RNDN) != 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(mpfr_float_imp& o) BOOST_NOEXCEPT
- {
- mpfr_swap(m_data, o.m_data);
- }
- std::string str(std::streamsize digits, std::ios_base::fmtflags f) const
- {
- BOOST_ASSERT(m_data[0]._mpfr_d);
- bool scientific = (f & std::ios_base::scientific) == std::ios_base::scientific;
- bool fixed = (f & std::ios_base::fixed) == std::ios_base::fixed;
- std::streamsize org_digits(digits);
- if (scientific && digits)
- ++digits;
- std::string result;
- mp_exp_t e;
- if (mpfr_inf_p(m_data))
- {
- if (mpfr_sgn(m_data) < 0)
- result = "-inf";
- else if (f & std::ios_base::showpos)
- result = "+inf";
- else
- result = "inf";
- return result;
- }
- if (mpfr_nan_p(m_data))
- {
- result = "nan";
- return result;
- }
- if (mpfr_zero_p(m_data))
- {
- e = 0;
- result = "0";
- }
- else
- {
- char* ps = mpfr_get_str(0, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
- --e; // To match with what our formatter expects.
- if (fixed && e != -1)
- {
- // Oops we actually need a different number of digits to what we asked for:
- mpfr_free_str(ps);
- digits += e + 1;
- if (digits == 0)
- {
- // We need to get *all* the digits and then possibly round up,
- // we end up with either "0" or "1" as the result.
- ps = mpfr_get_str(0, &e, 10, 0, m_data, GMP_RNDN);
- --e;
- unsigned offset = *ps == '-' ? 1 : 0;
- if (ps[offset] > '5')
- {
- ++e;
- ps[offset] = '1';
- ps[offset + 1] = 0;
- }
- else if (ps[offset] == '5')
- {
- unsigned i = offset + 1;
- bool round_up = false;
- while (ps[i] != 0)
- {
- if (ps[i] != '0')
- {
- round_up = true;
- break;
- }
- ++i;
- }
- if (round_up)
- {
- ++e;
- ps[offset] = '1';
- ps[offset + 1] = 0;
- }
- else
- {
- ps[offset] = '0';
- ps[offset + 1] = 0;
- }
- }
- else
- {
- ps[offset] = '0';
- ps[offset + 1] = 0;
- }
- }
- else if (digits > 0)
- {
- mp_exp_t old_e = e;
- ps = mpfr_get_str(0, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
- --e; // To match with what our formatter expects.
- if (old_e > e)
- {
- // in some cases, when we ask for more digits of precision, it will
- // change the number of digits to the left of the decimal, if that
- // happens, account for it here.
- // example: cout << fixed << setprecision(3) << mpf_float_50("99.9809")
- digits -= old_e - e;
- ps = mpfr_get_str(0, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
- --e; // To match with what our formatter expects.
- }
- }
- else
- {
- ps = mpfr_get_str(0, &e, 10, 1, m_data, GMP_RNDN);
- --e;
- unsigned offset = *ps == '-' ? 1 : 0;
- ps[offset] = '0';
- ps[offset + 1] = 0;
- }
- }
- result = ps ? ps : "0";
- if (ps)
- mpfr_free_str(ps);
- }
- boost::multiprecision::detail::format_float_string(result, e, org_digits, f, 0 != mpfr_zero_p(m_data));
- return result;
- }
- ~mpfr_float_imp() BOOST_NOEXCEPT
- {
- if (m_data[0]._mpfr_d)
- mpfr_clear(m_data);
- detail::mpfr_cleanup<true>::force_instantiate();
- }
- void negate() BOOST_NOEXCEPT
- {
- BOOST_ASSERT(m_data[0]._mpfr_d);
- mpfr_neg(m_data, m_data, GMP_RNDN);
- }
- template <mpfr_allocation_type AllocationType>
- int compare(const mpfr_float_backend<digits10, AllocationType>& o) const BOOST_NOEXCEPT
- {
- BOOST_ASSERT(m_data[0]._mpfr_d && o.m_data[0]._mpfr_d);
- return mpfr_cmp(m_data, o.m_data);
- }
- int compare(long i) const BOOST_NOEXCEPT
- {
- BOOST_ASSERT(m_data[0]._mpfr_d);
- return mpfr_cmp_si(m_data, i);
- }
- int compare(unsigned long i) const BOOST_NOEXCEPT
- {
- BOOST_ASSERT(m_data[0]._mpfr_d);
- return mpfr_cmp_ui(m_data, i);
- }
- template <class V>
- int compare(V v) const BOOST_NOEXCEPT
- {
- mpfr_float_backend<digits10, allocate_dynamic> d(0uL, mpfr_get_prec(m_data));
- d = v;
- return compare(d);
- }
- mpfr_t& data() BOOST_NOEXCEPT
- {
- BOOST_ASSERT(m_data[0]._mpfr_d);
- return m_data;
- }
- const mpfr_t& data() const BOOST_NOEXCEPT
- {
- BOOST_ASSERT(m_data[0]._mpfr_d);
- return m_data;
- }
- protected:
- mpfr_t m_data;
- static boost::multiprecision::detail::precision_type& get_default_precision() BOOST_NOEXCEPT
- {
- static boost::multiprecision::detail::precision_type val(BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION);
- return val;
- }
- };
- #ifdef BOOST_MSVC
- #pragma warning(push)
- #pragma warning(disable : 4127) // Conditional expression is constant
- #endif
- template <unsigned digits10>
- struct mpfr_float_imp<digits10, allocate_stack>
- {
- #ifdef BOOST_HAS_LONG_LONG
- typedef mpl::list<long, boost::long_long_type> signed_types;
- typedef mpl::list<unsigned long, boost::ulong_long_type> unsigned_types;
- #else
- typedef mpl::list<long> signed_types;
- typedef mpl::list<unsigned long> unsigned_types;
- #endif
- typedef mpl::list<double, long double> float_types;
- typedef long exponent_type;
- static const unsigned digits2 = (digits10 * 1000uL) / 301uL + ((digits10 * 1000uL) % 301 ? 2u : 1u);
- static const unsigned limb_count = mpfr_custom_get_size(digits2) / sizeof(mp_limb_t);
- ~mpfr_float_imp() BOOST_NOEXCEPT
- {
- detail::mpfr_cleanup<true>::force_instantiate();
- }
- mpfr_float_imp()
- {
- mpfr_custom_init(m_buffer, digits2);
- mpfr_custom_init_set(m_data, MPFR_NAN_KIND, 0, digits2, m_buffer);
- mpfr_set_ui(m_data, 0u, GMP_RNDN);
- }
- mpfr_float_imp(const mpfr_float_imp& o)
- {
- mpfr_custom_init(m_buffer, digits2);
- mpfr_custom_init_set(m_data, MPFR_NAN_KIND, 0, digits2, m_buffer);
- mpfr_set(m_data, o.m_data, GMP_RNDN);
- }
- mpfr_float_imp& operator=(const mpfr_float_imp& o)
- {
- mpfr_set(m_data, o.m_data, GMP_RNDN);
- return *this;
- }
- #ifdef BOOST_HAS_LONG_LONG
- #ifdef _MPFR_H_HAVE_INTMAX_T
- mpfr_float_imp& operator=(boost::ulong_long_type i)
- {
- mpfr_set_uj(m_data, i, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(boost::long_long_type i)
- {
- mpfr_set_sj(m_data, i, GMP_RNDN);
- return *this;
- }
- #else
- mpfr_float_imp& operator=(boost::ulong_long_type i)
- {
- boost::ulong_long_type mask = ((((1uLL << (std::numeric_limits<unsigned long>::digits - 1)) - 1) << 1) | 1uL);
- unsigned shift = 0;
- mpfr_t t;
- mp_limb_t t_limbs[limb_count];
- mpfr_custom_init(t_limbs, digits2);
- mpfr_custom_init_set(t, MPFR_NAN_KIND, 0, digits2, t_limbs);
- mpfr_set_ui(m_data, 0, GMP_RNDN);
- while (i)
- {
- mpfr_set_ui(t, static_cast<unsigned long>(i & mask), GMP_RNDN);
- if (shift)
- mpfr_mul_2exp(t, t, shift, GMP_RNDN);
- mpfr_add(m_data, m_data, t, GMP_RNDN);
- shift += std::numeric_limits<unsigned long>::digits;
- i >>= std::numeric_limits<unsigned long>::digits;
- }
- return *this;
- }
- mpfr_float_imp& operator=(boost::long_long_type i)
- {
- bool neg = i < 0;
- *this = boost::multiprecision::detail::unsigned_abs(i);
- if (neg)
- mpfr_neg(m_data, m_data, GMP_RNDN);
- return *this;
- }
- #endif
- #endif
- mpfr_float_imp& operator=(unsigned long i)
- {
- mpfr_set_ui(m_data, i, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(long i)
- {
- mpfr_set_si(m_data, i, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(double d)
- {
- mpfr_set_d(m_data, d, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(long double a)
- {
- mpfr_set_ld(m_data, a, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(const char* s)
- {
- if (mpfr_set_str(m_data, s, 10, GMP_RNDN) != 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(mpfr_float_imp& o) BOOST_NOEXCEPT
- {
- // We have to swap by copying:
- mpfr_float_imp t(*this);
- *this = o;
- o = t;
- }
- std::string str(std::streamsize digits, std::ios_base::fmtflags f) const
- {
- BOOST_ASSERT(m_data[0]._mpfr_d);
- bool scientific = (f & std::ios_base::scientific) == std::ios_base::scientific;
- bool fixed = (f & std::ios_base::fixed) == std::ios_base::fixed;
- std::streamsize org_digits(digits);
- if (scientific && digits)
- ++digits;
- std::string result;
- mp_exp_t e;
- if (mpfr_inf_p(m_data))
- {
- if (mpfr_sgn(m_data) < 0)
- result = "-inf";
- else if (f & std::ios_base::showpos)
- result = "+inf";
- else
- result = "inf";
- return result;
- }
- if (mpfr_nan_p(m_data))
- {
- result = "nan";
- return result;
- }
- if (mpfr_zero_p(m_data))
- {
- e = 0;
- result = "0";
- }
- else
- {
- char* ps = mpfr_get_str(0, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
- --e; // To match with what our formatter expects.
- if (fixed && e != -1)
- {
- // Oops we actually need a different number of digits to what we asked for:
- mpfr_free_str(ps);
- digits += e + 1;
- if (digits == 0)
- {
- // We need to get *all* the digits and then possibly round up,
- // we end up with either "0" or "1" as the result.
- ps = mpfr_get_str(0, &e, 10, 0, m_data, GMP_RNDN);
- --e;
- unsigned offset = *ps == '-' ? 1 : 0;
- if (ps[offset] > '5')
- {
- ++e;
- ps[offset] = '1';
- ps[offset + 1] = 0;
- }
- else if (ps[offset] == '5')
- {
- unsigned i = offset + 1;
- bool round_up = false;
- while (ps[i] != 0)
- {
- if (ps[i] != '0')
- {
- round_up = true;
- break;
- }
- }
- if (round_up)
- {
- ++e;
- ps[offset] = '1';
- ps[offset + 1] = 0;
- }
- else
- {
- ps[offset] = '0';
- ps[offset + 1] = 0;
- }
- }
- else
- {
- ps[offset] = '0';
- ps[offset + 1] = 0;
- }
- }
- else if (digits > 0)
- {
- ps = mpfr_get_str(0, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
- --e; // To match with what our formatter expects.
- }
- else
- {
- ps = mpfr_get_str(0, &e, 10, 1, m_data, GMP_RNDN);
- --e;
- unsigned offset = *ps == '-' ? 1 : 0;
- ps[offset] = '0';
- ps[offset + 1] = 0;
- }
- }
- result = ps ? ps : "0";
- if (ps)
- mpfr_free_str(ps);
- }
- boost::multiprecision::detail::format_float_string(result, e, org_digits, f, 0 != mpfr_zero_p(m_data));
- return result;
- }
- void negate() BOOST_NOEXCEPT
- {
- mpfr_neg(m_data, m_data, GMP_RNDN);
- }
- template <mpfr_allocation_type AllocationType>
- int compare(const mpfr_float_backend<digits10, AllocationType>& o) const BOOST_NOEXCEPT
- {
- return mpfr_cmp(m_data, o.m_data);
- }
- int compare(long i) const BOOST_NOEXCEPT
- {
- return mpfr_cmp_si(m_data, i);
- }
- int compare(unsigned long i) const BOOST_NOEXCEPT
- {
- return mpfr_cmp_ui(m_data, i);
- }
- template <class V>
- int compare(V v) const BOOST_NOEXCEPT
- {
- mpfr_float_backend<digits10, allocate_stack> d;
- d = v;
- return compare(d);
- }
- mpfr_t& data() BOOST_NOEXCEPT
- {
- return m_data;
- }
- const mpfr_t& data() const BOOST_NOEXCEPT
- {
- return m_data;
- }
- protected:
- mpfr_t m_data;
- mp_limb_t m_buffer[limb_count];
- };
- #ifdef BOOST_MSVC
- #pragma warning(pop)
- #endif
- } // namespace detail
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- struct mpfr_float_backend : public detail::mpfr_float_imp<digits10, AllocationType>
- {
- mpfr_float_backend() : detail::mpfr_float_imp<digits10, AllocationType>() {}
- mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<digits10, AllocationType>(o) {}
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- mpfr_float_backend(mpfr_float_backend&& o) BOOST_NOEXCEPT : detail::mpfr_float_imp<digits10, AllocationType>(static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o))
- {}
- #endif
- template <unsigned D, mpfr_allocation_type AT>
- mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename enable_if_c<D <= digits10>::type* = 0)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set(this->m_data, val.data(), GMP_RNDN);
- }
- template <unsigned D, mpfr_allocation_type AT>
- explicit mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename disable_if_c<D <= digits10>::type* = 0)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set(this->m_data, val.data(), GMP_RNDN);
- }
- template <unsigned D>
- mpfr_float_backend(const gmp_float<D>& val, typename enable_if_c<D <= digits10>::type* = 0)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
- }
- template <unsigned D>
- mpfr_float_backend(const gmp_float<D>& val, typename disable_if_c<D <= digits10>::type* = 0)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
- }
- mpfr_float_backend(const gmp_int& val)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
- }
- mpfr_float_backend(const gmp_rational& val)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
- }
- mpfr_float_backend(const mpfr_t val)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set(this->m_data, val, GMP_RNDN);
- }
- mpfr_float_backend(const mpf_t val)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set_f(this->m_data, val, GMP_RNDN);
- }
- mpfr_float_backend(const mpz_t val)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set_z(this->m_data, val, GMP_RNDN);
- }
- mpfr_float_backend(const mpq_t val)
- : detail::mpfr_float_imp<digits10, AllocationType>()
- {
- mpfr_set_q(this->m_data, val, GMP_RNDN);
- }
- // Construction with precision: we ignore the precision here.
- template <class V>
- mpfr_float_backend(const V& o, unsigned)
- {
- *this = o;
- }
- mpfr_float_backend& operator=(const mpfr_float_backend& o)
- {
- *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = static_cast<detail::mpfr_float_imp<digits10, AllocationType> const&>(o);
- return *this;
- }
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- mpfr_float_backend& operator=(mpfr_float_backend&& o) BOOST_NOEXCEPT
- {
- *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o);
- return *this;
- }
- #endif
- template <class V>
- mpfr_float_backend& operator=(const V& v)
- {
- *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = v;
- return *this;
- }
- mpfr_float_backend& operator=(const mpfr_t val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
- mpfr_set(this->m_data, val, GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const mpf_t val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
- mpfr_set_f(this->m_data, val, GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const mpz_t val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
- mpfr_set_z(this->m_data, val, GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const mpq_t val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
- mpfr_set_q(this->m_data, val, GMP_RNDN);
- return *this;
- }
- // We don't change our precision here, this is a fixed precision type:
- template <unsigned D, mpfr_allocation_type AT>
- mpfr_float_backend& operator=(const mpfr_float_backend<D, AT>& val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
- mpfr_set(this->m_data, val.data(), GMP_RNDN);
- return *this;
- }
- template <unsigned D>
- mpfr_float_backend& operator=(const gmp_float<D>& val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
- mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const gmp_int& val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
- mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const gmp_rational& val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(digits10));
- mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
- return *this;
- }
- };
- template <>
- struct mpfr_float_backend<0, allocate_dynamic> : public detail::mpfr_float_imp<0, allocate_dynamic>
- {
- mpfr_float_backend() : detail::mpfr_float_imp<0, allocate_dynamic>() {}
- mpfr_float_backend(const mpfr_t val)
- : detail::mpfr_float_imp<0, allocate_dynamic>((unsigned)mpfr_get_prec(val))
- {
- mpfr_set(this->m_data, val, GMP_RNDN);
- }
- mpfr_float_backend(const mpf_t val)
- : detail::mpfr_float_imp<0, allocate_dynamic>((unsigned)mpf_get_prec(val))
- {
- mpfr_set_f(this->m_data, val, GMP_RNDN);
- }
- mpfr_float_backend(const mpz_t val)
- : detail::mpfr_float_imp<0, allocate_dynamic>()
- {
- mpfr_set_z(this->m_data, val, GMP_RNDN);
- }
- mpfr_float_backend(const mpq_t val)
- : detail::mpfr_float_imp<0, allocate_dynamic>()
- {
- mpfr_set_q(this->m_data, val, GMP_RNDN);
- }
- mpfr_float_backend(const mpfr_float_backend& o) : detail::mpfr_float_imp<0, allocate_dynamic>(o) {}
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- mpfr_float_backend(mpfr_float_backend&& o) BOOST_NOEXCEPT : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast<detail::mpfr_float_imp<0, allocate_dynamic>&&>(o))
- {}
- #endif
- template <class V>
- mpfr_float_backend(const V& o, unsigned digits10)
- : detail::mpfr_float_imp<0, allocate_dynamic>(multiprecision::detail::digits10_2_2(digits10))
- {
- *this = o;
- }
- #ifndef BOOST_NO_CXX17_HDR_STRING_VIEW
- mpfr_float_backend(const std::string_view& o, unsigned digits10)
- : detail::mpfr_float_imp<0, allocate_dynamic>(multiprecision::detail::digits10_2_2(digits10))
- {
- std::string s(o);
- *this = s.c_str();
- }
- #endif
- template <unsigned D>
- mpfr_float_backend(const gmp_float<D>& val, unsigned digits10)
- : detail::mpfr_float_imp<0, allocate_dynamic>(multiprecision::detail::digits10_2_2(digits10))
- {
- mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
- }
- template <unsigned D>
- mpfr_float_backend(const mpfr_float_backend<D>& val, unsigned digits10)
- : detail::mpfr_float_imp<0, allocate_dynamic>(multiprecision::detail::digits10_2_2(digits10))
- {
- mpfr_set(this->m_data, val.data(), GMP_RNDN);
- }
- template <unsigned D>
- mpfr_float_backend(const mpfr_float_backend<D>& val)
- : detail::mpfr_float_imp<0, allocate_dynamic>(mpfr_get_prec(val.data()))
- {
- mpfr_set(this->m_data, val.data(), GMP_RNDN);
- }
- template <unsigned D>
- mpfr_float_backend(const gmp_float<D>& val)
- : detail::mpfr_float_imp<0, allocate_dynamic>(mpf_get_prec(val.data()))
- {
- mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
- }
- mpfr_float_backend(const gmp_int& val)
- : detail::mpfr_float_imp<0, allocate_dynamic>()
- {
- mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
- }
- mpfr_float_backend(const gmp_rational& val)
- : detail::mpfr_float_imp<0, allocate_dynamic>()
- {
- mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
- }
- mpfr_float_backend& operator=(const mpfr_float_backend& o)
- {
- if (this != &o)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, mpfr_get_prec(o.data()));
- else
- detail::mpfr_copy_precision(this->m_data, o.data());
- mpfr_set(this->m_data, o.data(), GMP_RNDN);
- }
- return *this;
- }
- #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- mpfr_float_backend& operator=(mpfr_float_backend&& o) BOOST_NOEXCEPT
- {
- *static_cast<detail::mpfr_float_imp<0, allocate_dynamic>*>(this) = static_cast<detail::mpfr_float_imp<0, allocate_dynamic>&&>(o);
- return *this;
- }
- #endif
- template <class V>
- mpfr_float_backend& operator=(const V& v)
- {
- *static_cast<detail::mpfr_float_imp<0, allocate_dynamic>*>(this) = v;
- return *this;
- }
- mpfr_float_backend& operator=(const mpfr_t val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, mpfr_get_prec(val));
- else
- mpfr_set_prec(this->m_data, mpfr_get_prec(val));
- mpfr_set(this->m_data, val, GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const mpf_t val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, (mpfr_prec_t)mpf_get_prec(val));
- else
- mpfr_set_prec(this->m_data, (unsigned)mpf_get_prec(val));
- mpfr_set_f(this->m_data, val, GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const mpz_t val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
- mpfr_set_z(this->m_data, val, GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const mpq_t val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
- mpfr_set_q(this->m_data, val, GMP_RNDN);
- return *this;
- }
- template <unsigned D>
- mpfr_float_backend& operator=(const mpfr_float_backend<D>& val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, mpfr_get_prec(val.data()));
- else
- mpfr_set_prec(this->m_data, mpfr_get_prec(val.data()));
- mpfr_set(this->m_data, val.data(), GMP_RNDN);
- return *this;
- }
- template <unsigned D>
- mpfr_float_backend& operator=(const gmp_float<D>& val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, mpf_get_prec(val.data()));
- else
- mpfr_set_prec(this->m_data, mpf_get_prec(val.data()));
- mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const gmp_int& val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
- mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
- return *this;
- }
- mpfr_float_backend& operator=(const gmp_rational& val)
- {
- if (this->m_data[0]._mpfr_d == 0)
- mpfr_init2(this->m_data, multiprecision::detail::digits10_2_2(get_default_precision()));
- mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
- return *this;
- }
- static unsigned default_precision() BOOST_NOEXCEPT
- {
- return get_default_precision();
- }
- static void default_precision(unsigned v) BOOST_NOEXCEPT
- {
- get_default_precision() = v;
- }
- unsigned precision() const BOOST_NOEXCEPT
- {
- return multiprecision::detail::digits2_2_10(mpfr_get_prec(this->m_data));
- }
- void precision(unsigned digits10) BOOST_NOEXCEPT
- {
- mpfr_prec_round(this->m_data, multiprecision::detail::digits10_2_2((digits10)), GMP_RNDN);
- }
- };
- template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
- inline typename enable_if<is_arithmetic<T>, bool>::type eval_eq(const mpfr_float_backend<digits10, AllocationType>& a, const T& b) BOOST_NOEXCEPT
- {
- return a.compare(b) == 0;
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
- inline typename enable_if<is_arithmetic<T>, bool>::type eval_lt(const mpfr_float_backend<digits10, AllocationType>& a, const T& b) BOOST_NOEXCEPT
- {
- return a.compare(b) < 0;
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
- inline typename enable_if<is_arithmetic<T>, bool>::type eval_gt(const mpfr_float_backend<digits10, AllocationType>& a, const T& b) BOOST_NOEXCEPT
- {
- return a.compare(b) > 0;
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_add(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
- {
- mpfr_add(result.data(), result.data(), o.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_subtract(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
- {
- mpfr_sub(result.data(), result.data(), o.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_multiply(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
- {
- if ((void*)&o == (void*)&result)
- mpfr_sqr(result.data(), o.data(), GMP_RNDN);
- else
- mpfr_mul(result.data(), result.data(), o.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_divide(mpfr_float_backend<D1, A1>& result, const mpfr_float_backend<D2, A2>& o)
- {
- mpfr_div(result.data(), result.data(), o.data(), GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_add(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
- {
- mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_subtract(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
- {
- mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_multiply(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
- {
- mpfr_mul_ui(result.data(), result.data(), i, GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_divide(mpfr_float_backend<digits10, AllocationType>& result, unsigned long i)
- {
- mpfr_div_ui(result.data(), result.data(), i, GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_add(mpfr_float_backend<digits10, AllocationType>& result, long i)
- {
- if (i > 0)
- mpfr_add_ui(result.data(), result.data(), i, GMP_RNDN);
- else
- mpfr_sub_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_subtract(mpfr_float_backend<digits10, AllocationType>& result, long i)
- {
- if (i > 0)
- mpfr_sub_ui(result.data(), result.data(), i, GMP_RNDN);
- else
- mpfr_add_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_multiply(mpfr_float_backend<digits10, AllocationType>& result, long i)
- {
- mpfr_mul_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
- if (i < 0)
- mpfr_neg(result.data(), result.data(), GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_divide(mpfr_float_backend<digits10, AllocationType>& result, long i)
- {
- mpfr_div_ui(result.data(), result.data(), boost::multiprecision::detail::unsigned_abs(i), GMP_RNDN);
- if (i < 0)
- mpfr_neg(result.data(), result.data(), GMP_RNDN);
- }
- //
- // Specialised 3 arg versions of the basic operators:
- //
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
- inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
- {
- mpfr_add(a.data(), x.data(), y.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
- {
- mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
- {
- if (y < 0)
- mpfr_sub_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
- else
- mpfr_add_ui(a.data(), x.data(), y, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_add(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
- {
- mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_add(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
- {
- if (x < 0)
- {
- mpfr_ui_sub(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data(), GMP_RNDN);
- mpfr_neg(a.data(), a.data(), GMP_RNDN);
- }
- else
- mpfr_add_ui(a.data(), y.data(), x, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
- inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
- {
- mpfr_sub(a.data(), x.data(), y.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
- {
- mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
- {
- if (y < 0)
- mpfr_add_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
- else
- mpfr_sub_ui(a.data(), x.data(), y, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_subtract(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
- {
- mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_subtract(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
- {
- if (x < 0)
- {
- mpfr_add_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x), GMP_RNDN);
- mpfr_neg(a.data(), a.data(), GMP_RNDN);
- }
- else
- mpfr_ui_sub(a.data(), x, y.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
- inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
- {
- if ((void*)&x == (void*)&y)
- mpfr_sqr(a.data(), x.data(), GMP_RNDN);
- else
- mpfr_mul(a.data(), x.data(), y.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
- {
- mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
- {
- if (y < 0)
- {
- mpfr_mul_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
- a.negate();
- }
- else
- mpfr_mul_ui(a.data(), x.data(), y, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_multiply(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
- {
- mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_multiply(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
- {
- if (x < 0)
- {
- mpfr_mul_ui(a.data(), y.data(), boost::multiprecision::detail::unsigned_abs(x), GMP_RNDN);
- mpfr_neg(a.data(), a.data(), GMP_RNDN);
- }
- else
- mpfr_mul_ui(a.data(), y.data(), x, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2, unsigned D3>
- inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3>& y)
- {
- mpfr_div(a.data(), x.data(), y.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, unsigned long y)
- {
- mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, long y)
- {
- if (y < 0)
- {
- mpfr_div_ui(a.data(), x.data(), boost::multiprecision::detail::unsigned_abs(y), GMP_RNDN);
- a.negate();
- }
- else
- mpfr_div_ui(a.data(), x.data(), y, GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_divide(mpfr_float_backend<D1, A1>& a, unsigned long x, const mpfr_float_backend<D2, A2>& y)
- {
- mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
- }
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- inline void eval_divide(mpfr_float_backend<D1, A1>& a, long x, const mpfr_float_backend<D2, A2>& y)
- {
- if (x < 0)
- {
- mpfr_ui_div(a.data(), boost::multiprecision::detail::unsigned_abs(x), y.data(), GMP_RNDN);
- mpfr_neg(a.data(), a.data(), GMP_RNDN);
- }
- else
- mpfr_ui_div(a.data(), x, y.data(), GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline bool eval_is_zero(const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
- {
- return 0 != mpfr_zero_p(val.data());
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline int eval_get_sign(const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
- {
- return mpfr_sgn(val.data());
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(unsigned long* result, const mpfr_float_backend<digits10, AllocationType>& val)
- {
- if (mpfr_nan_p(val.data()))
- {
- BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
- }
- *result = mpfr_get_ui(val.data(), GMP_RNDZ);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(long* result, const mpfr_float_backend<digits10, AllocationType>& val)
- {
- if (mpfr_nan_p(val.data()))
- {
- BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
- }
- *result = mpfr_get_si(val.data(), GMP_RNDZ);
- }
- #ifdef _MPFR_H_HAVE_INTMAX_T
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(boost::ulong_long_type* result, const mpfr_float_backend<digits10, AllocationType>& val)
- {
- if (mpfr_nan_p(val.data()))
- {
- BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
- }
- *result = mpfr_get_uj(val.data(), GMP_RNDZ);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(boost::long_long_type* result, const mpfr_float_backend<digits10, AllocationType>& val)
- {
- if (mpfr_nan_p(val.data()))
- {
- BOOST_THROW_EXCEPTION(std::runtime_error("Could not convert NaN to integer."));
- }
- *result = mpfr_get_sj(val.data(), GMP_RNDZ);
- }
- #endif
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(float* result, const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
- {
- *result = mpfr_get_flt(val.data(), GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(double* result, const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
- {
- *result = mpfr_get_d(val.data(), GMP_RNDN);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(long double* result, const mpfr_float_backend<digits10, AllocationType>& val) BOOST_NOEXCEPT
- {
- *result = mpfr_get_ld(val.data(), GMP_RNDN);
- }
- //
- // Native non-member operations:
- //
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_sqrt(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
- {
- mpfr_sqrt(result.data(), val.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_abs(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
- {
- mpfr_abs(result.data(), val.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_fabs(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
- {
- mpfr_abs(result.data(), val.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_ceil(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
- {
- mpfr_ceil(result.data(), val.data());
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_floor(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
- {
- mpfr_floor(result.data(), val.data());
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_trunc(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val)
- {
- mpfr_trunc(result.data(), val.data());
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_ldexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, long e)
- {
- if (e > 0)
- mpfr_mul_2exp(result.data(), val.data(), e, GMP_RNDN);
- else if (e < 0)
- mpfr_div_2exp(result.data(), val.data(), -e, GMP_RNDN);
- else
- result = val;
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_frexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, int* e)
- {
- long v;
- mpfr_get_d_2exp(&v, val.data(), GMP_RNDN);
- *e = v;
- eval_ldexp(result, val, -v);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_frexp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& val, long* e)
- {
- mpfr_get_d_2exp(e, val.data(), GMP_RNDN);
- return eval_ldexp(result, val, -*e);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline int eval_fpclassify(const mpfr_float_backend<Digits10, AllocateType>& val) BOOST_NOEXCEPT
- {
- return mpfr_inf_p(val.data()) ? FP_INFINITE : mpfr_nan_p(val.data()) ? FP_NAN : mpfr_zero_p(val.data()) ? FP_ZERO : FP_NORMAL;
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& e)
- {
- if (mpfr_zero_p(b.data()) && mpfr_integer_p(e.data()) && (mpfr_signbit(e.data()) == 0) && mpfr_fits_ulong_p(e.data(), GMP_RNDN) && (mpfr_get_ui(e.data(), GMP_RNDN) & 1))
- {
- mpfr_set(result.data(), b.data(), GMP_RNDN);
- }
- else
- mpfr_pow(result.data(), b.data(), e.data(), GMP_RNDN);
- }
- #ifdef BOOST_MSVC
- //
- // The enable_if usage below doesn't work with msvc - but only when
- // certain other enable_if usages are defined first. It's a capricious
- // and rather annoying compiler bug in other words....
- //
- #define BOOST_MP_ENABLE_IF_WORKAROUND (Digits10 || !Digits10)&&
- #else
- #define BOOST_MP_ENABLE_IF_WORKAROUND
- #endif
- template <unsigned Digits10, mpfr_allocation_type AllocateType, class Integer>
- inline typename enable_if<mpl::and_<is_signed<Integer>, mpl::bool_<BOOST_MP_ENABLE_IF_WORKAROUND(sizeof(Integer) <= sizeof(long))> > >::type
- eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const Integer& e)
- {
- mpfr_pow_si(result.data(), b.data(), e, GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType, class Integer>
- inline typename enable_if<mpl::and_<is_unsigned<Integer>, mpl::bool_<BOOST_MP_ENABLE_IF_WORKAROUND(sizeof(Integer) <= sizeof(long))> > >::type
- eval_pow(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& b, const Integer& e)
- {
- mpfr_pow_ui(result.data(), b.data(), e, GMP_RNDN);
- }
- #undef BOOST_MP_ENABLE_IF_WORKAROUND
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_exp(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_exp(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_exp2(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_exp2(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_log(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_log(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_log10(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_log10(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_sin(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_sin(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_cos(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_cos(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_tan(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_tan(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_asin(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_asin(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_acos(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_acos(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_atan(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_atan(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_atan2(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg1, const mpfr_float_backend<Digits10, AllocateType>& arg2)
- {
- mpfr_atan2(result.data(), arg1.data(), arg2.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_sinh(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_sinh(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_cosh(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_cosh(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_tanh(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_tanh(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_log2(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- mpfr_log2(result.data(), arg.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_modf(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& arg, mpfr_float_backend<Digits10, AllocateType>* pipart)
- {
- if (0 == pipart)
- {
- mpfr_float_backend<Digits10, AllocateType> ipart;
- mpfr_modf(ipart.data(), result.data(), arg.data(), GMP_RNDN);
- }
- else
- {
- mpfr_modf(pipart->data(), result.data(), arg.data(), GMP_RNDN);
- }
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_remainder(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
- {
- mpfr_remainder(result.data(), a.data(), b.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_remquo(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b, int* pi)
- {
- long l;
- mpfr_remquo(result.data(), &l, a.data(), b.data(), GMP_RNDN);
- if (pi)
- *pi = l;
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_fmod(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
- {
- mpfr_fmod(result.data(), a.data(), b.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_multiply_add(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
- {
- mpfr_fma(result.data(), a.data(), b.data(), result.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_multiply_add(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& c)
- {
- mpfr_fma(result.data(), a.data(), b.data(), c.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_multiply_subtract(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b)
- {
- mpfr_fms(result.data(), a.data(), b.data(), result.data(), GMP_RNDN);
- result.negate();
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline void eval_multiply_subtract(mpfr_float_backend<Digits10, AllocateType>& result, const mpfr_float_backend<Digits10, AllocateType>& a, const mpfr_float_backend<Digits10, AllocateType>& b, const mpfr_float_backend<Digits10, AllocateType>& c)
- {
- mpfr_fms(result.data(), a.data(), b.data(), c.data(), GMP_RNDN);
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline int eval_signbit BOOST_PREVENT_MACRO_SUBSTITUTION(const mpfr_float_backend<Digits10, AllocateType>& arg)
- {
- return (arg.data()[0]._mpfr_sign < 0) ? 1 : 0;
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline std::size_t hash_value(const mpfr_float_backend<Digits10, AllocateType>& val)
- {
- std::size_t result = 0;
- std::size_t len = val.data()[0]._mpfr_prec / mp_bits_per_limb;
- if (val.data()[0]._mpfr_prec % mp_bits_per_limb)
- ++len;
- for (std::size_t i = 0; i < len; ++i)
- boost::hash_combine(result, val.data()[0]._mpfr_d[i]);
- boost::hash_combine(result, val.data()[0]._mpfr_exp);
- boost::hash_combine(result, val.data()[0]._mpfr_sign);
- return result;
- }
- } // namespace backends
- #ifdef BOOST_NO_SFINAE_EXPR
- namespace detail {
- template <unsigned D1, unsigned D2, mpfr_allocation_type A1, mpfr_allocation_type A2>
- struct is_explicitly_convertible<backends::mpfr_float_backend<D1, A1>, backends::mpfr_float_backend<D2, A2> > : public mpl::true_
- {};
- } // namespace detail
- #endif
- namespace detail {
- template <>
- struct is_variable_precision<backends::mpfr_float_backend<0> > : public true_type
- {};
- } // namespace detail
- template <>
- struct number_category<detail::canonical<mpfr_t, backends::mpfr_float_backend<0> >::type> : public mpl::int_<number_kind_floating_point>
- {};
- using boost::multiprecision::backends::mpfr_float_backend;
- typedef number<mpfr_float_backend<50> > mpfr_float_50;
- typedef number<mpfr_float_backend<100> > mpfr_float_100;
- typedef number<mpfr_float_backend<500> > mpfr_float_500;
- typedef number<mpfr_float_backend<1000> > mpfr_float_1000;
- typedef number<mpfr_float_backend<0> > mpfr_float;
- typedef number<mpfr_float_backend<50, allocate_stack> > static_mpfr_float_50;
- typedef number<mpfr_float_backend<100, allocate_stack> > static_mpfr_float_100;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> copysign BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& a, const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& b)
- {
- return (boost::multiprecision::signbit)(a) != (boost::multiprecision::signbit)(b) ? boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(-a) : a;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> copysign BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& a, const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& b)
- {
- return (boost::multiprecision::signbit)(a) != (boost::multiprecision::signbit)(b) ? boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>(-a) : a;
- }
- } // namespace multiprecision
- namespace math {
- using boost::multiprecision::copysign;
- using boost::multiprecision::signbit;
- namespace tools {
- template <>
- inline int digits<boost::multiprecision::mpfr_float>()
- #ifdef BOOST_MATH_NOEXCEPT
- BOOST_NOEXCEPT
- #endif
- {
- return multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::default_precision());
- }
- template <>
- inline int digits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
- #ifdef BOOST_MATH_NOEXCEPT
- BOOST_NOEXCEPT
- #endif
- {
- return multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::default_precision());
- }
- template <>
- inline boost::multiprecision::mpfr_float
- max_value<boost::multiprecision::mpfr_float>()
- {
- boost::multiprecision::mpfr_float result(0.5);
- mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN);
- BOOST_ASSERT(mpfr_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline boost::multiprecision::mpfr_float
- min_value<boost::multiprecision::mpfr_float>()
- {
- boost::multiprecision::mpfr_float result(0.5);
- mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN);
- BOOST_ASSERT(mpfr_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off>
- max_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
- {
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> result(0.5);
- mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN);
- BOOST_ASSERT(mpfr_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off>
- min_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
- {
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> result(0.5);
- mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN);
- BOOST_ASSERT(mpfr_number_p(result.backend().data()));
- return result;
- }
- template <>
- inline int digits<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
- #ifdef BOOST_MATH_NOEXCEPT
- BOOST_NOEXCEPT
- #endif
- {
- return multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision());
- }
- template <>
- inline int digits<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
- #ifdef BOOST_MATH_NOEXCEPT
- BOOST_NOEXCEPT
- #endif
- {
- return multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision());
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >
- max_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
- {
- return max_value<boost::multiprecision::mpfr_float>().backend();
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >
- min_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
- {
- return min_value<boost::multiprecision::mpfr_float>().backend();
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
- max_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
- {
- return max_value<boost::multiprecision::mpfr_float>().backend();
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
- min_value<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
- {
- return min_value<boost::multiprecision::mpfr_float>().backend();
- }
- } // 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;
- namespace detail {
- template <class T, int N>
- struct mpfr_constant_initializer
- {
- static void force_instantiate()
- {
- init.force_instantiate();
- }
- private:
- struct initializer
- {
- initializer()
- {
- T::get(boost::integral_constant<int, N>());
- }
- void force_instantiate() const {}
- };
- static const initializer init;
- };
- template <class T, int N>
- typename mpfr_constant_initializer<T, N>::initializer const mpfr_constant_initializer<T, N>::init;
- } // namespace detail
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
- template <int N>
- static inline const result_type& get(const boost::integral_constant<int, N>&)
- {
- detail::mpfr_constant_initializer<constant_pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
- static result_type result;
- static bool has_init = false;
- if (!has_init)
- {
- mpfr_const_pi(result.backend().data(), GMP_RNDN);
- has_init = true;
- }
- return result;
- }
- static inline const result_type get(const boost::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_pi(result.backend().data(), GMP_RNDN);
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
- template <int N>
- static inline const result_type& get(const boost::integral_constant<int, N>&)
- {
- detail::mpfr_constant_initializer<constant_ln_two<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
- static result_type result;
- static bool init = false;
- if (!init)
- {
- mpfr_const_log2(result.backend().data(), GMP_RNDN);
- init = true;
- }
- return result;
- }
- static inline const result_type get(const boost::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_log2(result.backend().data(), GMP_RNDN);
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_euler<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
- template <int N>
- static inline const result_type& get(const boost::integral_constant<int, N>&)
- {
- detail::mpfr_constant_initializer<constant_euler<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
- static result_type result;
- static bool init = false;
- if (!init)
- {
- mpfr_const_euler(result.backend().data(), GMP_RNDN);
- init = true;
- }
- return result;
- }
- static inline const result_type get(const boost::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_euler(result.backend().data(), GMP_RNDN);
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_catalan<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result_type;
- template <int N>
- static inline const result_type& get(const boost::integral_constant<int, N>&)
- {
- detail::mpfr_constant_initializer<constant_catalan<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >, N>::force_instantiate();
- static result_type result;
- static bool init = false;
- if (!init)
- {
- mpfr_const_catalan(result.backend().data(), GMP_RNDN);
- init = true;
- }
- return result;
- }
- static inline const result_type get(const boost::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_catalan(result.backend().data(), GMP_RNDN);
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_pi<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
- template <int N>
- static inline const result_type& get(const boost::integral_constant<int, N>&)
- {
- detail::mpfr_constant_initializer<constant_pi<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
- static result_type result;
- static bool has_init = false;
- if (!has_init)
- {
- mpfr_const_pi(result.backend().value().data(), GMP_RNDN);
- has_init = true;
- }
- return result;
- }
- static inline const result_type get(const boost::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_pi(result.backend().value().data(), GMP_RNDN);
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_ln_two<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
- template <int N>
- static inline const result_type& get(const boost::integral_constant<int, N>&)
- {
- detail::mpfr_constant_initializer<constant_ln_two<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
- static result_type result;
- static bool init = false;
- if (!init)
- {
- mpfr_const_log2(result.backend().value().data(), GMP_RNDN);
- init = true;
- }
- return result;
- }
- static inline const result_type get(const boost::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_log2(result.backend().value().data(), GMP_RNDN);
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_euler<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
- template <int N>
- static inline const result_type& get(const boost::integral_constant<int, N>&)
- {
- detail::mpfr_constant_initializer<constant_euler<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
- static result_type result;
- static bool init = false;
- if (!init)
- {
- mpfr_const_euler(result.backend().value().data(), GMP_RNDN);
- init = true;
- }
- return result;
- }
- static inline const result_type get(const boost::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_euler(result.backend().value().data(), GMP_RNDN);
- return result;
- }
- };
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_catalan<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result_type;
- template <int N>
- static inline const result_type& get(const boost::integral_constant<int, N>&)
- {
- detail::mpfr_constant_initializer<constant_catalan<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >, N>::force_instantiate();
- static result_type result;
- static bool init = false;
- if (!init)
- {
- mpfr_const_catalan(result.backend().value().data(), GMP_RNDN);
- init = true;
- }
- return result;
- }
- static inline const result_type get(const boost::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_catalan(result.backend().value().data(), GMP_RNDN);
- return result;
- }
- };
- }} // namespace constants::detail
- } // namespace math
- namespace multiprecision {
- //
- // Overloaded special functions which call native mpfr routines:
- //
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_asinh(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_acosh(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_atanh(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_cbrt(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_erf(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_erfc(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_expm1(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_lngamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_gamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_log1p(result.backend().data(), arg.backend().data(), GMP_RNDN);
- return result;
- }
- } // namespace multiprecision
- namespace math {
- //
- // Overloaded special functions which call native mpfr routines:
- //
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy&)
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_asinh(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("asinh<%1%>(%1%)", 0, Policy());
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("asinh<%1%>(%1%)", "Unknown error, result is a NaN", result, Policy());
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return asinh(arg, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy&)
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_acosh(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("acosh<%1%>(%1%)", 0, Policy());
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("acosh<%1%>(%1%)", "Unknown error, result is a NaN", result, Policy());
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return acosh(arg, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& )
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_atanh(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("atanh<%1%>(%1%)", 0, Policy());
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("atanh<%1%>(%1%)", "Unknown error, result is a NaN", result, Policy());
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return atanh(arg, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy&)
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_cbrt(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("cbrt<%1%>(%1%)", 0, Policy());
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("cbrt<%1%>(%1%)", "Unknown error, result is a NaN", result, Policy());
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return cbrt(arg, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_erf(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("erf<%1%>(%1%)", 0, pol);
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("erf<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return erf(arg, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_erfc(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("erfc<%1%>(%1%)", 0, pol);
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("erfc<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return erfc(arg, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_expm1(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("expm1<%1%>(%1%)", 0, pol);
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("expm1<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> exm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return expm1(arg, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> arg, int* sign, const Policy& pol)
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- (void)precision_guard; // warning suppression
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- if (arg > 0)
- {
- mpfr_lngamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (sign)
- *sign = 1;
- }
- else
- {
- if (floor(arg) == arg)
- return policies::raise_pole_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >(
- "lgamma<%1%>", "Evaluation of lgamma at a negative integer %1%.", arg, pol);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> t = detail::sinpx(arg);
- arg = -arg;
- if (t < 0)
- {
- t = -t;
- }
- result = boost::multiprecision::log(boost::math::constants::pi<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >()) - lgamma(arg, 0, pol) - boost::multiprecision::log(t);
- if (sign)
- {
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> phase = 1 - arg;
- phase = floor(phase) / 2;
- if (floor(phase) == phase)
- *sign = -1;
- else
- *sign = 1;
- }
- }
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("lgamma<%1%>(%1%)", 0, pol);
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("lgamma<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, int* sign)
- {
- return lgamma(arg, sign, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
- {
- return lgamma(arg, 0, pol);
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return lgamma(arg, 0, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline typename boost::enable_if_c<boost::math::policies::is_policy<Policy>::value, boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::type tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_gamma(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("tgamma<%1%>(%1%)", 0, pol);
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("tgamma<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return tgamma(arg, policies::policy<>());
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg, const Policy& pol)
- {
- boost::multiprecision::detail::scoped_default_precision<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> result;
- mpfr_log1p(result.backend().data(), arg.backend().data(), GMP_RNDN);
- if (mpfr_inf_p(result.backend().data()))
- return policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("log1p<%1%>(%1%)", 0, pol);
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("log1p<%1%>(%1%)", "Unknown error, result is a NaN", result, pol);
- return result;
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return log1p(arg, policies::policy<>());
- }
- } // namespace math
- } // namespace boost
- namespace std {
- //
- // numeric_limits [partial] specializations for the types declared in this header:
- //
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> number_type;
- public:
- BOOST_STATIC_CONSTEXPR bool is_specialized = true;
- static number_type(min)()
- {
- initializer.do_nothing();
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 0.5;
- mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), -mpfr_get_emin(), GMP_RNDN);
- }
- return value.second;
- }
- static number_type(max)()
- {
- initializer.do_nothing();
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 0.5;
- mpfr_mul_2exp(value.second.backend().data(), value.second.backend().data(), mpfr_get_emax(), GMP_RNDN);
- }
- return value.second;
- }
- BOOST_STATIC_CONSTEXPR number_type lowest()
- {
- return -(max)();
- }
- BOOST_STATIC_CONSTEXPR int digits = static_cast<int>((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301 ? 2 : 1));
- BOOST_STATIC_CONSTEXPR int digits10 = Digits10;
- // Is this really correct???
- BOOST_STATIC_CONSTEXPR int max_digits10 = Digits10 + 3;
- BOOST_STATIC_CONSTEXPR bool is_signed = true;
- BOOST_STATIC_CONSTEXPR bool is_integer = false;
- BOOST_STATIC_CONSTEXPR bool is_exact = false;
- BOOST_STATIC_CONSTEXPR int radix = 2;
- static number_type epsilon()
- {
- initializer.do_nothing();
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 1;
- mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), std::numeric_limits<number_type>::digits - 1, GMP_RNDN);
- }
- return value.second;
- }
- // What value should this be????
- static number_type round_error()
- {
- // returns epsilon/2
- initializer.do_nothing();
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 1;
- mpfr_div_2exp(value.second.backend().data(), value.second.backend().data(), 1, GMP_RNDN);
- }
- return value.second;
- }
- BOOST_STATIC_CONSTEXPR long min_exponent = MPFR_EMIN_DEFAULT;
- BOOST_STATIC_CONSTEXPR long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
- BOOST_STATIC_CONSTEXPR long max_exponent = MPFR_EMAX_DEFAULT;
- BOOST_STATIC_CONSTEXPR long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
- BOOST_STATIC_CONSTEXPR bool has_infinity = true;
- BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = true;
- BOOST_STATIC_CONSTEXPR bool has_signaling_NaN = false;
- BOOST_STATIC_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
- BOOST_STATIC_CONSTEXPR bool has_denorm_loss = false;
- static number_type infinity()
- {
- // returns epsilon/2
- initializer.do_nothing();
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 1;
- mpfr_set_inf(value.second.backend().data(), 1);
- }
- return value.second;
- }
- static number_type quiet_NaN()
- {
- // returns epsilon/2
- initializer.do_nothing();
- static std::pair<bool, number_type> value;
- if (!value.first)
- {
- value.first = true;
- value.second = 1;
- mpfr_set_nan(value.second.backend().data());
- }
- return value.second;
- }
- BOOST_STATIC_CONSTEXPR number_type signaling_NaN()
- {
- return number_type(0);
- }
- BOOST_STATIC_CONSTEXPR number_type denorm_min() { return number_type(0); }
- BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
- BOOST_STATIC_CONSTEXPR bool is_bounded = true;
- BOOST_STATIC_CONSTEXPR bool is_modulo = false;
- BOOST_STATIC_CONSTEXPR bool traps = true;
- BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
- BOOST_STATIC_CONSTEXPR float_round_style round_style = round_to_nearest;
- private:
- struct data_initializer
- {
- data_initializer()
- {
- std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::epsilon();
- std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::round_error();
- (std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::min)();
- (std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::max)();
- std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::infinity();
- std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<digits10, AllocateType> > >::quiet_NaN();
- }
- void do_nothing() const {}
- };
- static const data_initializer initializer;
- };
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- const typename numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::data_initializer numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::initializer;
- #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::digits;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::digits10;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_digits10;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_signed;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_integer;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_exact;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::radix;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::min_exponent;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::min_exponent10;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_exponent;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::max_exponent10;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_infinity;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_quiet_NaN;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_signaling_NaN;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_denorm;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_denorm_loss;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_iec559;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_bounded;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::is_modulo;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::traps;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::tinyness_before;
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::round_style;
- #endif
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >
- {
- typedef boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> number_type;
- public:
- BOOST_STATIC_CONSTEXPR bool is_specialized = false;
- static number_type(min)()
- {
- number_type value(0.5);
- mpfr_div_2exp(value.backend().data(), value.backend().data(), -mpfr_get_emin(), GMP_RNDN);
- return value;
- }
- static number_type(max)()
- {
- number_type value(0.5);
- mpfr_mul_2exp(value.backend().data(), value.backend().data(), mpfr_get_emax(), GMP_RNDN);
- return value;
- }
- static number_type lowest()
- {
- return -(max)();
- }
- BOOST_STATIC_CONSTEXPR int digits = INT_MAX;
- BOOST_STATIC_CONSTEXPR int digits10 = INT_MAX;
- BOOST_STATIC_CONSTEXPR int max_digits10 = INT_MAX;
- BOOST_STATIC_CONSTEXPR bool is_signed = true;
- BOOST_STATIC_CONSTEXPR bool is_integer = false;
- BOOST_STATIC_CONSTEXPR bool is_exact = false;
- BOOST_STATIC_CONSTEXPR int radix = 2;
- static number_type epsilon()
- {
- number_type value(1);
- mpfr_div_2exp(value.backend().data(), value.backend().data(), boost::multiprecision::detail::digits10_2_2(number_type::default_precision()) - 1, GMP_RNDN);
- return value;
- }
- static number_type round_error()
- {
- return epsilon() / 2;
- }
- BOOST_STATIC_CONSTEXPR long min_exponent = MPFR_EMIN_DEFAULT;
- BOOST_STATIC_CONSTEXPR long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
- BOOST_STATIC_CONSTEXPR long max_exponent = MPFR_EMAX_DEFAULT;
- BOOST_STATIC_CONSTEXPR long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
- BOOST_STATIC_CONSTEXPR bool has_infinity = true;
- BOOST_STATIC_CONSTEXPR bool has_quiet_NaN = true;
- BOOST_STATIC_CONSTEXPR bool has_signaling_NaN = false;
- BOOST_STATIC_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
- BOOST_STATIC_CONSTEXPR bool has_denorm_loss = false;
- static number_type infinity()
- {
- number_type value;
- mpfr_set_inf(value.backend().data(), 1);
- return value;
- }
- static number_type quiet_NaN()
- {
- number_type value;
- mpfr_set_nan(value.backend().data());
- return value;
- }
- static number_type signaling_NaN() { return number_type(0); }
- static number_type denorm_min() { return number_type(0); }
- BOOST_STATIC_CONSTEXPR bool is_iec559 = false;
- BOOST_STATIC_CONSTEXPR bool is_bounded = true;
- BOOST_STATIC_CONSTEXPR bool is_modulo = false;
- BOOST_STATIC_CONSTEXPR bool traps = false;
- BOOST_STATIC_CONSTEXPR bool tinyness_before = false;
- BOOST_STATIC_CONSTEXPR float_round_style round_style = round_toward_zero;
- };
- #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_digits10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_signed;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_integer;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_exact;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::radix;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::min_exponent;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::min_exponent10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_infinity;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_quiet_NaN;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_signaling_NaN;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_denorm;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_denorm_loss;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_iec559;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_bounded;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_modulo;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::traps;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::tinyness_before;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- BOOST_CONSTEXPR_OR_CONST float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::round_style;
- #endif
- } // namespace std
- #endif
|