12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644 |
- ///////////////////////////////////////////////////////////////////////////////
- // Copyright 2011 John Maddock. Distributed under the Boost
- // Software License, Version 1.0. (See accompanying file
- // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
- #ifndef BOOST_MP_MPFR_HPP
- #define BOOST_MP_MPFR_HPP
- #include <boost/multiprecision/detail/standalone_config.hpp>
- #include <boost/multiprecision/number.hpp>
- #include <boost/multiprecision/debug_adaptor.hpp>
- #include <boost/multiprecision/logged_adaptor.hpp>
- #include <boost/multiprecision/gmp.hpp>
- #include <boost/multiprecision/detail/digits.hpp>
- #include <boost/multiprecision/detail/float128_functions.hpp>
- #include <boost/multiprecision/detail/atomic.hpp>
- #include <boost/multiprecision/traits/max_digits10.hpp>
- #include <boost/multiprecision/detail/hash.hpp>
- #include <boost/multiprecision/detail/no_exceptions_support.hpp>
- #include <boost/multiprecision/detail/assert.hpp>
- #include <boost/multiprecision/detail/fpclassify.hpp>
- #include <mpfr.h>
- #include <cmath>
- #include <cstdint>
- #include <algorithm>
- #include <utility>
- #include <type_traits>
- #include <atomic>
- #ifdef BOOST_MP_MATH_AVAILABLE
- #include <boost/math/constants/constants.hpp>
- #include <boost/math/special_functions/gamma.hpp>
- #endif
- #ifndef BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION
- #define BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION 20
- #endif
- namespace boost {
- namespace multiprecision {
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- struct number_category<backends::mpfr_float_backend<digits10, AllocationType> > : public std::integral_constant<int, number_kind_floating_point>
- {};
- namespace backends {
- namespace detail {
- template <bool b>
- struct mpfr_cleanup
- {
- //
- // There are 2 seperate cleanup objects here, one calls
- // mpfr_free_cache on destruction to perform global cleanup
- // the other is declared thread_local and calls
- // mpfr_free_cache2(MPFR_FREE_LOCAL_CACHE) to free thread local data.
- //
- struct initializer
- {
- initializer() {}
- ~initializer() { mpfr_free_cache(); }
- void force_instantiate() const {}
- };
- #if MPFR_VERSION_MAJOR >= 4
- struct thread_initializer
- {
- thread_initializer() {}
- ~thread_initializer() { mpfr_free_cache2(MPFR_FREE_LOCAL_CACHE); }
- void force_instantiate() const {}
- };
- #endif
- static const initializer init;
- static void force_instantiate()
- {
- #if MPFR_VERSION_MAJOR >= 4
- static const BOOST_MP_THREAD_LOCAL thread_initializer thread_init;
- thread_init.force_instantiate();
- #endif
- 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
- using signed_types = std::tuple<long, long long> ;
- using unsigned_types = std::tuple<unsigned long, unsigned long long>;
- #else
- using signed_types = std::tuple<long> ;
- using unsigned_types = std::tuple<unsigned long>;
- #endif
- using float_types = std::tuple<double, long double>;
- using exponent_type = long ;
- mpfr_float_imp()
- {
- mpfr_init2(m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<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, preserve_source_precision() ? mpfr_get_prec(o.data()) : static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision())));
- if (o.m_data[0]._mpfr_d)
- mpfr_set(m_data, o.m_data, GMP_RNDN);
- }
- // rvalue copy
- mpfr_float_imp(mpfr_float_imp&& o) noexcept
- {
- mpfr_prec_t binary_default_precision = static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision()));
- if ((this->get_default_options() != variable_precision_options::preserve_target_precision) || (mpfr_get_prec(o.data()) == binary_default_precision))
- {
- m_data[0] = o.m_data[0];
- o.m_data[0]._mpfr_d = nullptr;
- }
- else
- {
- // NOTE: C allocation interface must not throw:
- mpfr_init2(m_data, binary_default_precision);
- if (o.m_data[0]._mpfr_d)
- mpfr_set(m_data, o.m_data, GMP_RNDN);
- }
- }
- mpfr_float_imp& operator=(const mpfr_float_imp& o)
- {
- if ((o.m_data[0]._mpfr_d) && (this != &o))
- {
- if (m_data[0]._mpfr_d == nullptr)
- {
- mpfr_init2(m_data, preserve_source_precision() ? static_cast<mpfr_prec_t>(mpfr_get_prec(o.m_data)) : static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision())));
- }
- else if (preserve_source_precision() && (mpfr_get_prec(o.data()) != mpfr_get_prec(data())))
- {
- mpfr_set_prec(m_data, mpfr_get_prec(o.m_data));
- }
- mpfr_set(m_data, o.m_data, GMP_RNDN);
- }
- return *this;
- }
- // rvalue assign
- mpfr_float_imp& operator=(mpfr_float_imp&& o) noexcept
- {
- if ((this->get_default_options() != variable_precision_options::preserve_target_precision) || (mpfr_get_prec(o.data()) == mpfr_get_prec(data())))
- mpfr_swap(m_data, o.m_data);
- else
- *this = static_cast<const mpfr_float_imp&>(o);
- return *this;
- }
- #ifdef BOOST_HAS_LONG_LONG
- #ifdef _MPFR_H_HAVE_INTMAX_T
- mpfr_float_imp& operator=(unsigned long long i)
- {
- if (m_data[0]._mpfr_d == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
- mpfr_set_uj(m_data, i, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(long long i)
- {
- if (m_data[0]._mpfr_d == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
- mpfr_set_sj(m_data, i, GMP_RNDN);
- return *this;
- }
- #else
- mpfr_float_imp& operator=(unsigned long long i)
- {
- if (m_data[0]._mpfr_d == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
- unsigned long long 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<mpfr_prec_t>(std::numeric_limits<unsigned long long>::digits), static_cast<mpfr_prec_t>(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=(long long i)
- {
- if (m_data[0]._mpfr_d == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<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
- #ifdef BOOST_HAS_INT128
- mpfr_float_imp& operator=(uint128_type i)
- {
- if (m_data[0]._mpfr_d == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
- unsigned long long 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<mpfr_prec_t>(std::numeric_limits<unsigned long long>::digits), static_cast<mpfr_prec_t>(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=(int128_type i)
- {
- if (m_data[0]._mpfr_d == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<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
- mpfr_float_imp& operator=(unsigned long i)
- {
- if (m_data[0]._mpfr_d == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<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 == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<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 == nullptr)
- mpfr_init2(m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<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 == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
- mpfr_set_ld(m_data, a, GMP_RNDN);
- return *this;
- }
- #ifdef BOOST_HAS_FLOAT128
- mpfr_float_imp& operator=(float128_type a)
- {
- BOOST_MP_FLOAT128_USING
- if (m_data[0]._mpfr_d == nullptr)
- mpfr_init2(m_data, multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision())));
- if (a == 0)
- {
- mpfr_set_si(m_data, 0, GMP_RNDN);
- return *this;
- }
- if (a == 1)
- {
- mpfr_set_si(m_data, 1, GMP_RNDN);
- return *this;
- }
- if (BOOST_MP_ISINF(a))
- {
- mpfr_set_inf(m_data, a < 0 ? -1 : 1);
- return *this;
- }
- if (BOOST_MP_ISNAN(a))
- {
- mpfr_set_nan(m_data);
- return *this;
- }
- int e;
- float128_type f, term;
- mpfr_set_ui(m_data, 0u, GMP_RNDN);
- f = frexp(a, &e);
- constexpr const int shift = std::numeric_limits<int>::digits - 1;
- while (f)
- {
- // extract int sized bits from f:
- f = ldexp(f, shift);
- term = floor(f);
- e -= shift;
- mpfr_mul_2exp(m_data, m_data, shift, GMP_RNDN);
- if (term > 0)
- mpfr_add_ui(m_data, m_data, static_cast<unsigned>(term), GMP_RNDN);
- else
- mpfr_sub_ui(m_data, m_data, static_cast<unsigned>(-term), GMP_RNDN);
- f -= term;
- }
- if (e > 0)
- mpfr_mul_2exp(m_data, m_data, e, GMP_RNDN);
- else if (e < 0)
- mpfr_div_2exp(m_data, m_data, -e, GMP_RNDN);
- return *this;
- }
- #endif
- mpfr_float_imp& operator=(const char* s)
- {
- if (m_data[0]._mpfr_d == nullptr)
- mpfr_init2(m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(digits10 ? digits10 : static_cast<unsigned>(get_default_precision()))));
- if (mpfr_set_str(m_data, s, 10, GMP_RNDN) != 0)
- {
- BOOST_MP_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse string \"") + s + std::string("\"as a valid floating point number.")));
- }
- return *this;
- }
- void swap(mpfr_float_imp& o) noexcept
- {
- mpfr_swap(m_data, o.m_data);
- }
- std::string str(std::streamsize digits, std::ios_base::fmtflags f) const
- {
- BOOST_MP_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;
- if (mpfr_signbit(m_data))
- result = "-0";
- else
- result = "0";
- }
- else if (fixed)
- {
- // We actually need a different number of digits to what one might expect:
- char* ps = mpfr_get_str(nullptr, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
- --e;
- 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(nullptr, &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(nullptr, &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")
- mpfr_free_str(ps);
- digits -= old_e - e;
- ps = mpfr_get_str(nullptr, &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(nullptr, &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);
- }
- else
- {
- char* ps = mpfr_get_str(nullptr, &e, 10, static_cast<std::size_t>(digits), m_data, GMP_RNDN);
- --e; // To match with what our formatter expects.
- 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() noexcept
- {
- if (m_data[0]._mpfr_d)
- mpfr_clear(m_data);
- detail::mpfr_cleanup<true>::force_instantiate();
- }
- void negate() noexcept
- {
- BOOST_MP_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_MP_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_MP_ASSERT(m_data[0]._mpfr_d);
- return mpfr_cmp_si(m_data, i);
- }
- int compare(double i) const
- {
- BOOST_MP_ASSERT(m_data[0]._mpfr_d);
- return mpfr_cmp_d(m_data, i);
- }
- int compare(long double i) const
- {
- BOOST_MP_ASSERT(m_data[0]._mpfr_d);
- return mpfr_cmp_ld(m_data, i);
- }
- int compare(unsigned long i) const
- {
- BOOST_MP_ASSERT(m_data[0]._mpfr_d);
- return mpfr_cmp_ui(m_data, i);
- }
- template <class V>
- int compare(V v) const
- {
- mpfr_float_backend<digits10, allocate_dynamic> d(0uL, mpfr_get_prec(m_data));
- d = v;
- return compare(d);
- }
- mpfr_t& data() noexcept
- {
- BOOST_MP_ASSERT(m_data[0]._mpfr_d);
- return m_data;
- }
- const mpfr_t& data() const noexcept
- {
- BOOST_MP_ASSERT(m_data[0]._mpfr_d);
- return m_data;
- }
- protected:
- mpfr_t m_data;
- static boost::multiprecision::detail::precision_type& get_global_default_precision() noexcept
- {
- static boost::multiprecision::detail::precision_type val(BOOST_MULTIPRECISION_MPFR_DEFAULT_PRECISION);
- return val;
- }
- static unsigned& get_default_precision() noexcept
- {
- static BOOST_MP_THREAD_LOCAL unsigned val(get_global_default_precision());
- return val;
- }
- #ifndef BOOST_MT_NO_ATOMIC_INT
- static std::atomic<variable_precision_options>& get_global_default_options() noexcept
- {
- static std::atomic<variable_precision_options> val{variable_precision_options::preserve_related_precision};
- return val;
- }
- #else
- static variable_precision_options& get_global_default_options() noexcept
- {
- static variable_precision_options val{variable_precision_options::preserve_related_precision};
- return val;
- }
- #endif
- static variable_precision_options& get_default_options()noexcept
- {
- static BOOST_MP_THREAD_LOCAL variable_precision_options val(get_global_default_options());
- return val;
- }
- static bool preserve_source_precision() noexcept
- {
- return get_default_options() >= variable_precision_options::preserve_source_precision;
- }
- };
- #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
- using signed_types = std::tuple<long, long long> ;
- using unsigned_types = std::tuple<unsigned long, unsigned long long>;
- #else
- using signed_types = std::tuple<long> ;
- using unsigned_types = std::tuple<unsigned long>;
- #endif
- using float_types = std::tuple<double, long double>;
- using exponent_type = long ;
- static constexpr const unsigned digits2 = (digits10 * 1000uL) / 301uL + ((digits10 * 1000uL) % 301 ? 2u : 1u);
- static constexpr const unsigned limb_count = mpfr_custom_get_size(digits2) / sizeof(mp_limb_t);
- ~mpfr_float_imp() 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=(unsigned long long i)
- {
- mpfr_set_uj(m_data, i, GMP_RNDN);
- return *this;
- }
- mpfr_float_imp& operator=(long long i)
- {
- mpfr_set_sj(m_data, i, GMP_RNDN);
- return *this;
- }
- #else
- mpfr_float_imp& operator=(unsigned long long i)
- {
- unsigned long long 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=(long long 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
- #ifdef BOOST_HAS_INT128
- mpfr_float_imp& operator=(uint128_type i)
- {
- unsigned long long 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=(int128_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
- 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;
- }
- #ifdef BOOST_HAS_FLOAT128
- mpfr_float_imp& operator=(float128_type a)
- {
- BOOST_MP_FLOAT128_USING
- if (a == 0)
- {
- mpfr_set_si(m_data, 0, GMP_RNDN);
- return *this;
- }
- if (a == 1)
- {
- mpfr_set_si(m_data, 1, GMP_RNDN);
- return *this;
- }
- if (BOOST_MP_ISINF(a))
- {
- mpfr_set_inf(m_data, a < 0 ? -1 : 1);
- return *this;
- }
- if (BOOST_MP_ISNAN(a))
- {
- mpfr_set_nan(m_data);
- return *this;
- }
- int e;
- float128_type f, term;
- mpfr_set_ui(m_data, 0u, GMP_RNDN);
- f = frexp(a, &e);
- constexpr const int shift = std::numeric_limits<int>::digits - 1;
- while (f)
- {
- // extract int sized bits from f:
- f = ldexp(f, shift);
- term = floor(f);
- e -= shift;
- mpfr_mul_2exp(m_data, m_data, shift, GMP_RNDN);
- if (term > 0)
- mpfr_add_ui(m_data, m_data, static_cast<unsigned>(term), GMP_RNDN);
- else
- mpfr_sub_ui(m_data, m_data, static_cast<unsigned>(-term), GMP_RNDN);
- f -= term;
- }
- if (e > 0)
- mpfr_mul_2exp(m_data, m_data, e, GMP_RNDN);
- else if (e < 0)
- mpfr_div_2exp(m_data, m_data, -e, GMP_RNDN);
- return *this;
- }
- #endif
- mpfr_float_imp& operator=(const char* s)
- {
- if (mpfr_set_str(m_data, s, 10, GMP_RNDN) != 0)
- {
- BOOST_MP_THROW_EXCEPTION(std::runtime_error(std::string("Unable to parse string \"") + s + std::string("\"as a valid floating point number.")));
- }
- return *this;
- }
- void swap(mpfr_float_imp& o) 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_MP_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(nullptr, &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(nullptr, &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(nullptr, &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(nullptr, &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() noexcept
- {
- mpfr_neg(m_data, m_data, GMP_RNDN);
- }
- template <mpfr_allocation_type AllocationType>
- int compare(const mpfr_float_backend<digits10, AllocationType>& o) const
- {
- return mpfr_cmp(m_data, o.m_data);
- }
- int compare(long i) const
- {
- return mpfr_cmp_si(m_data, i);
- }
- int compare(unsigned long i) const
- {
- return mpfr_cmp_ui(m_data, i);
- }
- int compare(double i) const
- {
- return mpfr_cmp_d(m_data, i);
- }
- int compare(long double i) const
- {
- return mpfr_cmp_ld(m_data, i);
- }
- template <class V>
- int compare(V v) const
- {
- mpfr_float_backend<digits10, allocate_stack> d;
- d = v;
- return compare(d);
- }
- mpfr_t& data() noexcept
- {
- return m_data;
- }
- const mpfr_t& data() const 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) {}
- // rvalue copy
- mpfr_float_backend(mpfr_float_backend&& o) noexcept : detail::mpfr_float_imp<digits10, AllocationType>(static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o))
- {}
- template <unsigned D, mpfr_allocation_type AT>
- mpfr_float_backend(const mpfr_float_backend<D, AT>& val, typename std::enable_if<D <= digits10>::type* = nullptr)
- : 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 std::enable_if<!(D <= digits10)>::type* = nullptr)
- : 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 std::enable_if<D <= digits10>::type* = nullptr)
- : 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 std::enable_if<!(D <= digits10)>::type* = nullptr)
- : 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;
- }
- // rvalue assign
- mpfr_float_backend& operator=(mpfr_float_backend&& o) noexcept
- {
- *static_cast<detail::mpfr_float_imp<digits10, AllocationType>*>(this) = static_cast<detail::mpfr_float_imp<digits10, AllocationType>&&>(o);
- return *this;
- }
- template <class V>
- typename std::enable_if<std::is_assignable<detail::mpfr_float_imp<digits10, AllocationType>, V>::value, mpfr_float_backend&>::type 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 == nullptr)
- 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 == nullptr)
- 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 == nullptr)
- 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 == nullptr)
- 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 == nullptr)
- 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 == nullptr)
- 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 == nullptr)
- 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 == nullptr)
- 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>(preserve_all_precision() ? static_cast<unsigned>(mpfr_get_prec(val)) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(get_default_precision())))
- {
- mpfr_set(this->m_data, val, GMP_RNDN);
- }
- mpfr_float_backend(const mpf_t val)
- : detail::mpfr_float_imp<0, allocate_dynamic>(preserve_all_precision() ? static_cast<unsigned>(mpf_get_prec(val)) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(get_default_precision())))
- {
- 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) {}
- // rvalue copy
- mpfr_float_backend(mpfr_float_backend&& o) noexcept : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast<detail::mpfr_float_imp<0, allocate_dynamic>&&>(o))
- {}
- template <class V>
- mpfr_float_backend(const V& o, unsigned digits10)
- : detail::mpfr_float_imp<0, allocate_dynamic>(static_cast<unsigned>(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>(static_cast<unsigned>(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>(static_cast<unsigned>(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>(static_cast<unsigned>(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>(preserve_related_precision() ? static_cast<unsigned>(mpfr_get_prec(val.data())) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(get_default_precision())))
- {
- 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>(preserve_all_precision() ? static_cast<unsigned>(mpf_get_prec(val.data())) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(get_default_precision())))
- {
- mpfr_set_f(this->m_data, val.data(), GMP_RNDN);
- }
- mpfr_float_backend(const gmp_int& val)
- : detail::mpfr_float_imp<0, allocate_dynamic>(preserve_all_precision() ? static_cast<unsigned>(used_gmp_int_bits(val)) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(thread_default_precision())))
- {
- mpfr_set_z(this->m_data, val.data(), GMP_RNDN);
- }
- mpfr_float_backend(const gmp_rational& val)
- : detail::mpfr_float_imp<0, allocate_dynamic>(preserve_all_precision() ? static_cast<unsigned>(used_gmp_rational_bits(val)) : static_cast<unsigned>(boost::multiprecision::detail::digits10_2_2(thread_default_precision())))
- {
- mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
- }
- mpfr_float_backend& operator=(const mpfr_float_backend& o) = default;
- // rvalue assign
- mpfr_float_backend& operator=(mpfr_float_backend&& o) noexcept = default;
- template <class V>
- typename std::enable_if<std::is_assignable<detail::mpfr_float_imp<0, allocate_dynamic>, V>::value, mpfr_float_backend&>::type operator=(const V& v)
- {
- constexpr unsigned d10 = std::is_floating_point<V>::value ?
- std::numeric_limits<V>::digits10 :
- std::numeric_limits<V>::digits10 ? 1 + std::numeric_limits<V>::digits10 :
- 1 + boost::multiprecision::detail::digits2_2_10(std::numeric_limits<V>::digits);
- if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
- {
- BOOST_IF_CONSTEXPR(std::is_floating_point<V>::value)
- {
- if (std::numeric_limits<V>::digits > mpfr_get_prec(this->data()))
- mpfr_set_prec(this->data(), std::numeric_limits<V>::digits);
- }
- else
- {
- if(precision() < d10)
- this->precision(d10);
- }
- }
- *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 == nullptr)
- mpfr_init2(this->m_data, preserve_all_precision() ? static_cast<mpfr_prec_t>(mpfr_get_prec(val)) : static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision())));
- else if(preserve_all_precision())
- 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 == nullptr)
- mpfr_init2(this->m_data, preserve_all_precision() ? static_cast<mpfr_prec_t>(mpf_get_prec(val)) : static_cast<mpfr_prec_t>(boost::multiprecision::detail::digits10_2_2(get_default_precision())));
- else if(preserve_all_precision())
- mpfr_set_prec(this->m_data, static_cast<mpfr_prec_t>(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 == nullptr)
- mpfr_init2(this->m_data, static_cast<mpfr_prec_t>(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 == nullptr)
- mpfr_init2(this->m_data, static_cast<mpfr_prec_t>(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 == nullptr)
- mpfr_init2(this->m_data, preserve_related_precision() ? static_cast<mpfr_prec_t>(mpfr_get_prec(val.data())) : boost::multiprecision::detail::digits10_2_2(get_default_precision()));
- else if (preserve_related_precision())
- 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 == nullptr)
- mpfr_init2(this->m_data, preserve_all_precision() ? static_cast<mpfr_prec_t>(mpf_get_prec(val.data())) : boost::multiprecision::detail::digits10_2_2(get_default_precision()));
- else if (preserve_all_precision())
- mpfr_set_prec(this->m_data, static_cast<mpfr_prec_t>(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 == nullptr)
- {
- unsigned requested_precision = this->thread_default_precision();
- if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
- {
- unsigned d2 = static_cast<unsigned>(used_gmp_int_bits(val));
- unsigned d10 = static_cast<unsigned>(1ULL + multiprecision::detail::digits2_2_10(d2));
- if (d10 > requested_precision)
- requested_precision = d10;
- }
- mpfr_init2(this->m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(requested_precision)));
- }
- else if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
- {
- unsigned requested_precision = this->thread_default_precision();
- unsigned d2 = static_cast<unsigned>(used_gmp_int_bits(val));
- unsigned d10 = static_cast<unsigned>(1ULL + multiprecision::detail::digits2_2_10(d2));
- if (d10 > requested_precision)
- this->precision(d10);
- }
- 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 == nullptr)
- {
- unsigned requested_precision = this->get_default_precision();
- if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
- {
- unsigned d10 = static_cast<unsigned>(1u + multiprecision::detail::digits2_2_10(used_gmp_rational_bits(val)));
- if (d10 > requested_precision)
- requested_precision = d10;
- }
- mpfr_init2(this->m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2(requested_precision)));
- }
- else if (thread_default_variable_precision_options() >= variable_precision_options::preserve_all_precision)
- {
- unsigned requested_precision = this->get_default_precision();
- unsigned d10 = static_cast<unsigned>(1u + multiprecision::detail::digits2_2_10(used_gmp_rational_bits(val)));
- if (d10 > requested_precision)
- this->precision(d10);
- }
- mpfr_set_q(this->m_data, val.data(), GMP_RNDN);
- return *this;
- }
- static unsigned default_precision() noexcept
- {
- return get_global_default_precision();
- }
- static void default_precision(unsigned v) noexcept
- {
- get_global_default_precision() = v;
- }
- static unsigned thread_default_precision() noexcept
- {
- return get_default_precision();
- }
- static void thread_default_precision(unsigned v) noexcept
- {
- get_default_precision() = v;
- }
- unsigned precision() const noexcept
- {
- return static_cast<unsigned>(multiprecision::detail::digits2_2_10(static_cast<unsigned long>(mpfr_get_prec(this->m_data))));
- }
- void precision(unsigned digits10) noexcept
- {
- mpfr_prec_round(this->m_data, static_cast<mpfr_prec_t>(multiprecision::detail::digits10_2_2((digits10))), GMP_RNDN);
- }
- //
- // Variable precision options:
- //
- static variable_precision_options default_variable_precision_options()noexcept
- {
- return get_global_default_options();
- }
- static variable_precision_options thread_default_variable_precision_options()noexcept
- {
- return get_default_options();
- }
- static void default_variable_precision_options(variable_precision_options opts)
- {
- get_global_default_options() = opts;
- }
- static void thread_default_variable_precision_options(variable_precision_options opts)
- {
- get_default_options() = opts;
- }
- static bool preserve_source_precision()
- {
- return get_default_options() >= variable_precision_options::preserve_source_precision;
- }
- static bool preserve_related_precision()
- {
- return get_default_options() >= variable_precision_options::preserve_related_precision;
- }
- static bool preserve_all_precision()
- {
- return get_default_options() >= variable_precision_options::preserve_all_precision;
- }
- };
- template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
- inline typename std::enable_if<boost::multiprecision::detail::is_arithmetic<T>::value, bool>::type eval_eq(const mpfr_float_backend<digits10, AllocationType>& a, const T& b)
- {
- return a.compare(b) == 0;
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
- inline typename std::enable_if<boost::multiprecision::detail::is_arithmetic<T>::value, bool>::type eval_lt(const mpfr_float_backend<digits10, AllocationType>& a, const T& b)
- {
- return a.compare(b) < 0;
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType, class T>
- inline typename std::enable_if<boost::multiprecision::detail::is_arithmetic<T>::value, bool>::type eval_gt(const mpfr_float_backend<digits10, AllocationType>& a, const T& b)
- {
- return a.compare(b) > 0;
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline bool eval_eq(const mpfr_float_backend<digits10, AllocationType>& a, const mpfr_float_backend<digits10, AllocationType>& b)noexcept
- {
- return mpfr_equal_p(a.data(), b.data());
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline bool eval_lt(const mpfr_float_backend<digits10, AllocationType>& a, const mpfr_float_backend<digits10, AllocationType>& b) noexcept
- {
- return mpfr_less_p(a.data(), b.data());
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline bool eval_gt(const mpfr_float_backend<digits10, AllocationType>& a, const mpfr_float_backend<digits10, AllocationType>& b) noexcept
- {
- return mpfr_greater_p(a.data(), b.data());
- }
- 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(), static_cast<typename std::make_unsigned<long>::type>(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, mpfr_allocation_type A3>
- inline void eval_add(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& 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, mpfr_allocation_type A3>
- inline void eval_subtract(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& 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(), static_cast<typename std::make_unsigned<long>::type>(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, mpfr_allocation_type A3>
- inline void eval_multiply(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& 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, mpfr_allocation_type A3>
- inline void eval_divide(mpfr_float_backend<D1, A1>& a, const mpfr_float_backend<D2, A2>& x, const mpfr_float_backend<D3, A3>& 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) 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) 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_MP_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_MP_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(unsigned long long* result, const mpfr_float_backend<digits10, AllocationType>& val)
- {
- if (mpfr_nan_p(val.data()))
- {
- BOOST_MP_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(long long* result, const mpfr_float_backend<digits10, AllocationType>& val)
- {
- if (mpfr_nan_p(val.data()))
- {
- BOOST_MP_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) 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) 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) noexcept
- {
- *result = mpfr_get_ld(val.data(), GMP_RNDN);
- }
- #ifdef BOOST_HAS_INT128
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(int128_type* result, const mpfr_float_backend<digits10, AllocationType>& val) noexcept
- {
- gmp_int i;
- mpfr_get_z(i.data(), val.data(), GMP_RNDN);
- eval_convert_to(result, i);
- }
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(uint128_type* result, const mpfr_float_backend<digits10, AllocationType>& val) noexcept
- {
- gmp_int i;
- mpfr_get_z(i.data(), val.data(), GMP_RNDN);
- eval_convert_to(result, i);
- }
- #endif
- #if defined(BOOST_HAS_FLOAT128)
- template <unsigned digits10, mpfr_allocation_type AllocationType>
- inline void eval_convert_to(float128_type* result, const mpfr_float_backend<digits10, AllocationType>& val) noexcept
- {
- *result = float128_procs::strtoflt128(val.str(0, std::ios_base::scientific).c_str(), nullptr);
- }
- #endif
- //
- // 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)
- {
- using local_uint_type = typename boost::multiprecision::detail::make_unsigned<long>::type;
- if (e > 0)
- mpfr_mul_2exp(result.data(), val.data(), static_cast<local_uint_type>(e), GMP_RNDN);
- else if (e < 0)
- mpfr_div_2exp(result.data(), val.data(), static_cast<local_uint_type>(-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)
- {
- if (mpfr_zero_p(val.data()))
- {
- *e = 0;
- result = val;
- return;
- }
- mp_exp_t v = mpfr_get_exp(val.data());
- *e = static_cast<int>(v);
- if (v)
- eval_ldexp(result, val, -v);
- 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, long* e)
- {
- if (mpfr_zero_p(val.data()))
- {
- *e = 0;
- result = val;
- return;
- }
- mp_exp_t v = mpfr_get_exp(val.data());
- *e = v;
- if(v)
- eval_ldexp(result, val, -v);
- else
- result = val;
- }
- template <unsigned Digits10, mpfr_allocation_type AllocateType>
- inline int eval_fpclassify(const mpfr_float_backend<Digits10, AllocateType>& val) 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 std::enable_if<boost::multiprecision::detail::is_signed<Integer>::value && boost::multiprecision::detail::is_integral<Integer>::value && (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 std::enable_if<boost::multiprecision::detail::is_unsigned<Integer>::value && (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 (pipart == nullptr)
- {
- 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 = static_cast<int>(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::multiprecision::detail::hash_combine(result, val.data()[0]._mpfr_d[i]);
- boost::multiprecision::detail::hash_combine(result, val.data()[0]._mpfr_exp, val.data()[0]._mpfr_sign);
- return result;
- }
- } // namespace backends
- namespace detail {
- template <>
- struct is_variable_precision<backends::mpfr_float_backend<0> > : public std::integral_constant<bool, true>
- {};
- } // namespace detail
- template <>
- struct number_category<detail::canonical<mpfr_t, backends::mpfr_float_backend<0> >::type> : public std::integral_constant<int, number_kind_floating_point>
- {};
- template <unsigned D, boost::multiprecision::mpfr_allocation_type A1, boost::multiprecision::mpfr_allocation_type A2>
- struct is_equivalent_number_type<backends::mpfr_float_backend<D, A1>, backends::mpfr_float_backend<D, A2> > : public std::integral_constant<bool, true> {};
- 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 {
- #ifndef BOOST_MP_MATH_AVAILABLE
- template <typename T>
- inline int digits();
- template <typename T>
- inline T max_value();
- template <typename T>
- inline T min_value();
- #endif
- inline void set_output_precision(const boost::multiprecision::mpfr_float& val, std::ostream& os)
- {
- os << std::setprecision(static_cast<int>(val.precision()));
- }
- template <>
- inline int digits<boost::multiprecision::mpfr_float>()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::thread_default_precision()));
- }
- template <>
- inline int digits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, boost::multiprecision::et_off> >()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::mpfr_float::thread_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(), static_cast<typename std::make_unsigned<mpfr_exp_t>::type>(mpfr_get_emax()), GMP_RNDN);
- BOOST_MP_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(), static_cast<typename std::make_unsigned<mpfr_exp_t>::type>(-mpfr_get_emin()), GMP_RNDN);
- BOOST_MP_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(), static_cast<typename std::make_unsigned<mpfr_exp_t>::type>(mpfr_get_emax()), GMP_RNDN);
- BOOST_MP_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(), static_cast<typename std::make_unsigned<mpfr_exp_t>::type>(-mpfr_get_emin()), GMP_RNDN);
- BOOST_MP_ASSERT(mpfr_number_p(result.backend().data()));
- return result;
- }
- //
- // Over again with debug_adaptor:
- //
- template <>
- inline int digits<boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::thread_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
- noexcept
- #endif
- {
- return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float::backend_type> >::thread_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();
- }
- //
- // Over again with logged_adaptor:
- //
- template <>
- inline int digits<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision()));
- }
- template <>
- inline int digits<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off> >()
- #ifdef BOOST_MATH_NOEXCEPT
- noexcept
- #endif
- {
- return static_cast<int>(multiprecision::detail::digits10_2_2(boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> >::default_precision()));
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> >
- max_value<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
- {
- return max_value<boost::multiprecision::mpfr_float>().backend();
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> >
- min_value<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float::backend_type> > >()
- {
- return min_value<boost::multiprecision::mpfr_float>().backend();
- }
- template <>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
- max_value<boost::multiprecision::number<boost::multiprecision::backends::logged_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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<0> >, boost::multiprecision::et_off>
- min_value<boost::multiprecision::number<boost::multiprecision::backends::logged_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;
- 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> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::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> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::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> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::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> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_catalan(result.backend().data(), GMP_RNDN);
- return result;
- }
- };
- //
- // Over again with debug_adaptor:
- //
- 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> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_pi(result.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- 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> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_log2(result.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- 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> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_euler(result.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- 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> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // Rely on C++11 thread safe initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::integral_constant<int, 0>&)
- {
- result_type result;
- mpfr_const_catalan(result.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- };
- //
- // Over again with logged_adaptor:
- //
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct constant_pi<boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >
- {
- using result_type = boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>;
- template <int N>
- static inline const result_type& get(const std::integral_constant<int, N>&)
- {
- // C++11 thread safe static initialization:
- static result_type result{get(std::integral_constant<int, 0>())};
- return result;
- }
- static inline const result_type get(const std::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;
- }
- //
- // Over again with debug_adaptor:
- //
- 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> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_asinh(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- 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> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_acosh(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- 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> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_atanh(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- 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> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_cbrt(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- 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> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_erf(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- 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> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_erfc(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- 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> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_expm1(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- 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> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_lngamma(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- 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> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_gamma(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- 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> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_log1p(result.backend().value().data(), arg.backend().value().data(), GMP_RNDN);
- result.backend().update_view();
- return result;
- }
- //
- // Over again with logged_adaptor:
- //
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_asinh(result.backend().value().data(), arg.backend().value().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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_acosh(result.backend().value().data(), arg.backend().value().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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_atanh(result.backend().value().data(), arg.backend().value().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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_cbrt(result.backend().value().data(), arg.backend().value().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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_erf(result.backend().value().data(), arg.backend().value().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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_erfc(result.backend().value().data(), arg.backend().value().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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_expm1(result.backend().value().data(), arg.backend().value().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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_lngamma(result.backend().value().data(), arg.backend().value().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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_gamma(result.backend().value().data(), arg.backend().value().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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- boost::multiprecision::detail::scoped_default_precision<number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> > precision_guard(arg);
- boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> result;
- mpfr_log1p(result.backend().value().data(), arg.backend().value().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%)", nullptr, 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%)", nullptr, 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%)", nullptr, 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;
- if (mpfr_nan_p(arg.backend().data()))
- return policies::raise_domain_error("cbrt<%1%>(%1%)", "Input is a NaN", result, Policy());
- 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%)", nullptr, 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;
- if (mpfr_nan_p(arg.backend().data()))
- return policies::raise_domain_error("erf<%1%>(%1%)", "Input is a NaN", result, pol);
- 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%)", nullptr, 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;
- if (mpfr_nan_p(arg.backend().data()))
- return policies::raise_domain_error("erf<%1%>(%1%)", "Input is a NaN", result, pol);
- 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%)", nullptr, 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;
- if (mpfr_nan_p(arg.backend().data()))
- return policies::raise_domain_error("erf<%1%>(%1%)", "Input is a NaN", result, pol);
- 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%)", nullptr, 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> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return expm1(arg, policies::policy<>());
- }
- #ifdef BOOST_MP_MATH_AVAILABLE
- 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%)", nullptr, 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<>());
- }
- #endif // BOOST_MP_MATH_AVAILABLE
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline typename std::enable_if<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%)", nullptr, 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 (arg == -1 ? -1 : 1) * policies::raise_overflow_error<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >("log1p<%1%>(%1%)", nullptr, 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<>());
- }
- 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> rsqrt 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_rec_sqrt(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> >("rsqrt<%1%>(%1%)", nullptr, pol);
- if (mpfr_nan_p(result.backend().data()))
- return policies::raise_evaluation_error("rsqrt<%1%>(%1%)", "Negative argument, 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> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>& arg)
- {
- return rsqrt(arg, policies::policy<>());
- }
- //
- // Over again with debug_adaptor:
- //
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return asinh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return acosh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return atanh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return cbrt(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return erf(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return erfc(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return expm1(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> exm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> arg, int* sign, const Policy& pol)
- {
- return lgamma(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), sign, pol).backend();
- }
- 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> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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 std::enable_if<boost::math::policies::is_policy<Policy>::value, boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >::type tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return tgamma(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return log1p(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- return log1p(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::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return rsqrt(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- 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> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::debug_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- return rsqrt(arg, policies::policy<>());
- }
- //
- // Over again with logged_adaptor:
- //
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return asinh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> asinh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return acosh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> acosh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return atanh(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> atanh BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return cbrt(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> cbrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return erf(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erf BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return erfc(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> erfc BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> expm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return expm1(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> exm1 BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> arg, int* sign, const Policy& pol)
- {
- return lgamma(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), sign, pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> lgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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 std::enable_if<boost::math::policies::is_policy<Policy>::value, boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> >::type tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return tgamma(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> tgamma BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return log1p(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> log1p BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- return log1p(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::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg, const Policy& pol)
- {
- return rsqrt(boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>(arg.backend().value()), pol).backend();
- }
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- inline boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates> rsqrt BOOST_PREVENT_MACRO_SUBSTITUTION(const boost::multiprecision::number<boost::multiprecision::backends::logged_adaptor<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType> >, ExpressionTemplates>& arg)
- {
- return rsqrt(arg, policies::policy<>());
- }
- } // namespace math
- } // namespace boost
- namespace Eigen
- {
- template <class B1, class B2>
- struct NumTraitsImp;
- template <boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- struct NumTraitsImp<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>, boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>>
- {
- using self_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>;
- using Real = typename boost::multiprecision::scalar_result_from_possible_complex<self_type>::type;
- using NonInteger = self_type; // Not correct but we can't do much better??
- using Literal = double;
- using Nested = self_type;
- enum
- {
- IsComplex = boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_complex,
- IsInteger = boost::multiprecision::number_category<self_type>::value == boost::multiprecision::number_kind_integer,
- ReadCost = 1,
- AddCost = 4,
- MulCost = 8,
- IsSigned = std::numeric_limits<self_type>::is_specialized ? std::numeric_limits<self_type>::is_signed : true,
- RequireInitialization = 1,
- };
- static Real epsilon()
- {
- #ifdef BOOST_MP_MATH_AVAILABLE
- return boost::math::tools::epsilon< boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>>();
- #else
- self_type result{1};
- mpfr_div_2exp(result.backend().data(), result.backend().data(), std::numeric_limits<self_type>::digits - 1, GMP_RNDN);
- return result;
- #endif
- }
- static Real dummy_precision()
- {
- return 1000 * epsilon();
- }
- static Real highest()
- {
- #ifdef BOOST_MP_MATH_AVAILABLE
- return boost::math::tools::max_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>>();
- #else
- self_type value(0.5);
- mpfr_mul_2exp(value.backend().data(), value.backend().data(), mpfr_get_emax(), GMP_RNDN);
- return value;
- #endif
- }
- static Real lowest()
- {
- #ifdef BOOST_MP_MATH_AVAILABLE
- return boost::math::tools::min_value<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0, AllocateType>, ExpressionTemplates>>();
- #else
- return -(highest)();
- #endif
- }
- static int digits10()
- {
- return Real::thread_default_precision();
- }
- static int digits()
- {
- return boost::math::tools::digits<Real>();
- }
- static int min_exponent()
- {
- return static_cast<int>(mpfr_get_emin());
- }
- static int max_exponent()
- {
- return static_cast<int>(mpfr_get_emax());
- }
- static Real infinity()
- {
- return std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<50, AllocateType>, ExpressionTemplates>>::infinity();
- }
- static Real quiet_NaN()
- {
- return std::numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<50, AllocateType>, ExpressionTemplates>>::quiet_NaN();
- }
- };
- }
- 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> >
- {
- using number_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates>;
- static number_type get_min()
- {
- number_type result{0.5};
- mpfr_div_2exp(result.backend().data(), result.backend().data(), -mpfr_get_emin(), GMP_RNDN);
- return result;
- }
- static number_type get_max()
- {
- number_type result{0.5};
- mpfr_mul_2exp(result.backend().data(), result.backend().data(), mpfr_get_emax(), GMP_RNDN);
- return result;
- }
- static number_type get_eps()
- {
- number_type result{1};
- mpfr_div_2exp(result.backend().data(), result.backend().data(), std::numeric_limits<number_type>::digits - 1, GMP_RNDN);
- return result;
- }
- public:
- static constexpr bool is_specialized = true;
- static number_type(min)()
- {
- static number_type value{get_min()};
- return value;
- }
- static number_type(max)()
- {
- static number_type value{get_max()};
- return value;
- }
- static constexpr number_type lowest()
- {
- return -(max)();
- }
- static constexpr int digits = static_cast<int>((Digits10 * 1000L) / 301L + ((Digits10 * 1000L) % 301 ? 2 : 1));
- static constexpr int digits10 = Digits10;
- // Is this really correct???
- static constexpr int max_digits10 = static_cast<int>(boost::multiprecision::detail::calc_max_digits10<static_cast<unsigned>(digits)>::value);
- static constexpr bool is_signed = true;
- static constexpr bool is_integer = false;
- static constexpr bool is_exact = false;
- static constexpr int radix = 2;
- static number_type epsilon()
- {
- static number_type value{get_eps()};
- return value;
- }
- // What value should this be????
- static number_type round_error()
- {
- // returns epsilon/2
- return 0.5;
- }
- static constexpr long min_exponent = MPFR_EMIN_DEFAULT;
- static constexpr long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
- static constexpr long max_exponent = MPFR_EMAX_DEFAULT;
- static constexpr long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
- static constexpr bool has_infinity = true;
- static constexpr bool has_quiet_NaN = true;
- static constexpr bool has_signaling_NaN = false;
- #ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4996)
- #endif
- static constexpr float_denorm_style has_denorm = denorm_absent;
- #ifdef _MSC_VER
- #pragma warning(pop)
- #endif
- static constexpr bool has_denorm_loss = false;
- static number_type infinity()
- {
- 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 constexpr number_type signaling_NaN()
- {
- return number_type(0);
- }
- static constexpr number_type denorm_min() { return (min)(); }
- static constexpr bool is_iec559 = false;
- static constexpr bool is_bounded = true;
- static constexpr bool is_modulo = false;
- static constexpr bool traps = true;
- static constexpr bool tinyness_before = false;
- static constexpr float_round_style round_style = round_to_nearest;
- };
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_signaling_NaN;
- #ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4996)
- #endif
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::has_denorm;
- #ifdef _MSC_VER
- #pragma warning(pop)
- #endif
- template <unsigned Digits10, boost::multiprecision::mpfr_allocation_type AllocateType, boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr 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>
- constexpr float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<Digits10, AllocateType>, ExpressionTemplates> >::round_style;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- class numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >
- {
- using number_type = boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates>;
- public:
- 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)();
- }
- static constexpr int digits = INT_MAX;
- static constexpr int digits10 = INT_MAX;
- static constexpr int max_digits10 = INT_MAX;
- static constexpr bool is_signed = true;
- static constexpr bool is_integer = false;
- static constexpr bool is_exact = false;
- static constexpr int radix = 2;
- static number_type epsilon()
- {
- number_type value(1);
- mpfr_div_2exp(value.backend().data(), value.backend().data(), boost::multiprecision::detail::digits10_2_2(number_type::thread_default_precision()) - 1, GMP_RNDN);
- return value;
- }
- static number_type round_error()
- {
- return 0.5;
- }
- static constexpr long min_exponent = MPFR_EMIN_DEFAULT;
- static constexpr long min_exponent10 = (MPFR_EMIN_DEFAULT / 1000) * 301L;
- static constexpr long max_exponent = MPFR_EMAX_DEFAULT;
- static constexpr long max_exponent10 = (MPFR_EMAX_DEFAULT / 1000) * 301L;
- static constexpr bool has_infinity = true;
- static constexpr bool has_quiet_NaN = true;
- static constexpr bool has_signaling_NaN = false;
- #ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4996)
- #endif
- static constexpr float_denorm_style has_denorm = denorm_absent;
- #ifdef _MSC_VER
- #pragma warning(pop)
- #endif
- static constexpr bool has_denorm_loss = false;
- static number_type infinity()
- {
- 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 (min)(); }
- static constexpr bool is_iec559 = false;
- static constexpr bool is_bounded = true;
- static constexpr bool is_modulo = false;
- static constexpr bool traps = false;
- static constexpr bool tinyness_before = false;
- static constexpr float_round_style round_style = round_toward_zero;
- };
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::digits10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_digits10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_signed;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_integer;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_exact;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr int numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::radix;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::min_exponent;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::min_exponent10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr long numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::max_exponent10;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_infinity;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_quiet_NaN;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_signaling_NaN;
- #ifdef _MSC_VER
- #pragma warning(push)
- #pragma warning(disable : 4996)
- #endif
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr float_denorm_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_denorm;
- #ifdef _MSC_VER
- #pragma warning(pop)
- #endif
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::has_denorm_loss;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_iec559;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_bounded;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::is_modulo;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::traps;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr bool numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::tinyness_before;
- template <boost::multiprecision::expression_template_option ExpressionTemplates>
- constexpr float_round_style numeric_limits<boost::multiprecision::number<boost::multiprecision::mpfr_float_backend<0>, ExpressionTemplates> >::round_style;
- } // namespace std
- #endif
|