| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882 |
- // Random number extensions -*- C++ -*-
- // Copyright (C) 2012-2021 Free Software Foundation, Inc.
- //
- // This file is part of the GNU ISO C++ Library. This library is free
- // software; you can redistribute it and/or modify it under the
- // terms of the GNU General Public License as published by the
- // Free Software Foundation; either version 3, or (at your option)
- // any later version.
- // This library is distributed in the hope that it will be useful,
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- // GNU General Public License for more details.
- // Under Section 7 of GPL version 3, you are granted additional
- // permissions described in the GCC Runtime Library Exception, version
- // 3.1, as published by the Free Software Foundation.
- // You should have received a copy of the GNU General Public License and
- // a copy of the GCC Runtime Library Exception along with this program;
- // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
- // <http://www.gnu.org/licenses/>.
- /** @file ext/random
- * This file is a GNU extension to the Standard C++ Library.
- */
- #ifndef _EXT_RANDOM
- #define _EXT_RANDOM 1
- #pragma GCC system_header
- #if __cplusplus < 201103L
- # include <bits/c++0x_warning.h>
- #else
- #include <random>
- #include <algorithm>
- #include <array>
- #include <ext/cmath>
- #ifdef __SSE2__
- # include <emmintrin.h>
- #endif
- #if defined(_GLIBCXX_USE_C99_STDINT_TR1) && defined(UINT32_C)
- namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
- {
- _GLIBCXX_BEGIN_NAMESPACE_VERSION
- #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- /* Mersenne twister implementation optimized for vector operations.
- *
- * Reference: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/
- */
- template<typename _UIntType, size_t __m,
- size_t __pos1, size_t __sl1, size_t __sl2,
- size_t __sr1, size_t __sr2,
- uint32_t __msk1, uint32_t __msk2,
- uint32_t __msk3, uint32_t __msk4,
- uint32_t __parity1, uint32_t __parity2,
- uint32_t __parity3, uint32_t __parity4>
- class simd_fast_mersenne_twister_engine
- {
- static_assert(std::is_unsigned<_UIntType>::value, "template argument "
- "substituting _UIntType not an unsigned integral type");
- static_assert(__sr1 < 32, "first right shift too large");
- static_assert(__sr2 < 16, "second right shift too large");
- static_assert(__sl1 < 32, "first left shift too large");
- static_assert(__sl2 < 16, "second left shift too large");
- public:
- typedef _UIntType result_type;
- private:
- static constexpr size_t m_w = sizeof(result_type) * 8;
- static constexpr size_t _M_nstate = __m / 128 + 1;
- static constexpr size_t _M_nstate32 = _M_nstate * 4;
- static_assert(std::is_unsigned<_UIntType>::value, "template argument "
- "substituting _UIntType not an unsigned integral type");
- static_assert(__pos1 < _M_nstate, "POS1 not smaller than state size");
- static_assert(16 % sizeof(_UIntType) == 0,
- "UIntType size must divide 16");
- template<typename _Sseq>
- using _If_seed_seq
- = typename std::enable_if<std::__detail::__is_seed_seq<
- _Sseq, simd_fast_mersenne_twister_engine, result_type>::value
- >::type;
- public:
- static constexpr size_t state_size = _M_nstate * (16
- / sizeof(result_type));
- static constexpr result_type default_seed = 5489u;
- // constructors and member functions
- simd_fast_mersenne_twister_engine()
- : simd_fast_mersenne_twister_engine(default_seed)
- { }
- explicit
- simd_fast_mersenne_twister_engine(result_type __sd)
- { seed(__sd); }
- template<typename _Sseq, typename = _If_seed_seq<_Sseq>>
- explicit
- simd_fast_mersenne_twister_engine(_Sseq& __q)
- { seed(__q); }
- void
- seed(result_type __sd = default_seed);
- template<typename _Sseq>
- _If_seed_seq<_Sseq>
- seed(_Sseq& __q);
- static constexpr result_type
- min()
- { return 0; }
- static constexpr result_type
- max()
- { return std::numeric_limits<result_type>::max(); }
- void
- discard(unsigned long long __z);
- result_type
- operator()()
- {
- if (__builtin_expect(_M_pos >= state_size, 0))
- _M_gen_rand();
- return _M_stateT[_M_pos++];
- }
- template<typename _UIntType_2, size_t __m_2,
- size_t __pos1_2, size_t __sl1_2, size_t __sl2_2,
- size_t __sr1_2, size_t __sr2_2,
- uint32_t __msk1_2, uint32_t __msk2_2,
- uint32_t __msk3_2, uint32_t __msk4_2,
- uint32_t __parity1_2, uint32_t __parity2_2,
- uint32_t __parity3_2, uint32_t __parity4_2>
- friend bool
- operator==(const simd_fast_mersenne_twister_engine<_UIntType_2,
- __m_2, __pos1_2, __sl1_2, __sl2_2, __sr1_2, __sr2_2,
- __msk1_2, __msk2_2, __msk3_2, __msk4_2,
- __parity1_2, __parity2_2, __parity3_2, __parity4_2>& __lhs,
- const simd_fast_mersenne_twister_engine<_UIntType_2,
- __m_2, __pos1_2, __sl1_2, __sl2_2, __sr1_2, __sr2_2,
- __msk1_2, __msk2_2, __msk3_2, __msk4_2,
- __parity1_2, __parity2_2, __parity3_2, __parity4_2>& __rhs);
- template<typename _UIntType_2, size_t __m_2,
- size_t __pos1_2, size_t __sl1_2, size_t __sl2_2,
- size_t __sr1_2, size_t __sr2_2,
- uint32_t __msk1_2, uint32_t __msk2_2,
- uint32_t __msk3_2, uint32_t __msk4_2,
- uint32_t __parity1_2, uint32_t __parity2_2,
- uint32_t __parity3_2, uint32_t __parity4_2,
- typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>& __os,
- const __gnu_cxx::simd_fast_mersenne_twister_engine
- <_UIntType_2,
- __m_2, __pos1_2, __sl1_2, __sl2_2, __sr1_2, __sr2_2,
- __msk1_2, __msk2_2, __msk3_2, __msk4_2,
- __parity1_2, __parity2_2, __parity3_2, __parity4_2>& __x);
- template<typename _UIntType_2, size_t __m_2,
- size_t __pos1_2, size_t __sl1_2, size_t __sl2_2,
- size_t __sr1_2, size_t __sr2_2,
- uint32_t __msk1_2, uint32_t __msk2_2,
- uint32_t __msk3_2, uint32_t __msk4_2,
- uint32_t __parity1_2, uint32_t __parity2_2,
- uint32_t __parity3_2, uint32_t __parity4_2,
- typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>& __is,
- __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType_2,
- __m_2, __pos1_2, __sl1_2, __sl2_2, __sr1_2, __sr2_2,
- __msk1_2, __msk2_2, __msk3_2, __msk4_2,
- __parity1_2, __parity2_2, __parity3_2, __parity4_2>& __x);
- private:
- union
- {
- #ifdef __SSE2__
- __m128i _M_state[_M_nstate];
- #endif
- #ifdef __ARM_NEON
- #ifdef __aarch64__
- __Uint32x4_t _M_state[_M_nstate];
- #endif
- #endif
- uint32_t _M_state32[_M_nstate32];
- result_type _M_stateT[state_size];
- } __attribute__ ((__aligned__ (16)));
- size_t _M_pos;
- void _M_gen_rand(void);
- void _M_period_certification();
- };
- template<typename _UIntType, size_t __m,
- size_t __pos1, size_t __sl1, size_t __sl2,
- size_t __sr1, size_t __sr2,
- uint32_t __msk1, uint32_t __msk2,
- uint32_t __msk3, uint32_t __msk4,
- uint32_t __parity1, uint32_t __parity2,
- uint32_t __parity3, uint32_t __parity4>
- inline bool
- operator!=(const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
- __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3,
- __msk4, __parity1, __parity2, __parity3, __parity4>& __lhs,
- const __gnu_cxx::simd_fast_mersenne_twister_engine<_UIntType,
- __m, __pos1, __sl1, __sl2, __sr1, __sr2, __msk1, __msk2, __msk3,
- __msk4, __parity1, __parity2, __parity3, __parity4>& __rhs)
- { return !(__lhs == __rhs); }
- /* Definitions for the SIMD-oriented Fast Mersenne Twister as defined
- * in the C implementation by Daito and Matsumoto, as both a 32-bit
- * and 64-bit version.
- */
- typedef simd_fast_mersenne_twister_engine<uint32_t, 607, 2,
- 15, 3, 13, 3,
- 0xfdff37ffU, 0xef7f3f7dU,
- 0xff777b7dU, 0x7ff7fb2fU,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0x5986f054U>
- sfmt607;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 607, 2,
- 15, 3, 13, 3,
- 0xfdff37ffU, 0xef7f3f7dU,
- 0xff777b7dU, 0x7ff7fb2fU,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0x5986f054U>
- sfmt607_64;
- typedef simd_fast_mersenne_twister_engine<uint32_t, 1279, 7,
- 14, 3, 5, 1,
- 0xf7fefffdU, 0x7fefcfffU,
- 0xaff3ef3fU, 0xb5ffff7fU,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0x20000000U>
- sfmt1279;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 1279, 7,
- 14, 3, 5, 1,
- 0xf7fefffdU, 0x7fefcfffU,
- 0xaff3ef3fU, 0xb5ffff7fU,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0x20000000U>
- sfmt1279_64;
- typedef simd_fast_mersenne_twister_engine<uint32_t, 2281, 12,
- 19, 1, 5, 1,
- 0xbff7ffbfU, 0xfdfffffeU,
- 0xf7ffef7fU, 0xf2f7cbbfU,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0x41dfa600U>
- sfmt2281;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 2281, 12,
- 19, 1, 5, 1,
- 0xbff7ffbfU, 0xfdfffffeU,
- 0xf7ffef7fU, 0xf2f7cbbfU,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0x41dfa600U>
- sfmt2281_64;
- typedef simd_fast_mersenne_twister_engine<uint32_t, 4253, 17,
- 20, 1, 7, 1,
- 0x9f7bffffU, 0x9fffff5fU,
- 0x3efffffbU, 0xfffff7bbU,
- 0xa8000001U, 0xaf5390a3U,
- 0xb740b3f8U, 0x6c11486dU>
- sfmt4253;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 4253, 17,
- 20, 1, 7, 1,
- 0x9f7bffffU, 0x9fffff5fU,
- 0x3efffffbU, 0xfffff7bbU,
- 0xa8000001U, 0xaf5390a3U,
- 0xb740b3f8U, 0x6c11486dU>
- sfmt4253_64;
- typedef simd_fast_mersenne_twister_engine<uint32_t, 11213, 68,
- 14, 3, 7, 3,
- 0xeffff7fbU, 0xffffffefU,
- 0xdfdfbfffU, 0x7fffdbfdU,
- 0x00000001U, 0x00000000U,
- 0xe8148000U, 0xd0c7afa3U>
- sfmt11213;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 11213, 68,
- 14, 3, 7, 3,
- 0xeffff7fbU, 0xffffffefU,
- 0xdfdfbfffU, 0x7fffdbfdU,
- 0x00000001U, 0x00000000U,
- 0xe8148000U, 0xd0c7afa3U>
- sfmt11213_64;
- typedef simd_fast_mersenne_twister_engine<uint32_t, 19937, 122,
- 18, 1, 11, 1,
- 0xdfffffefU, 0xddfecb7fU,
- 0xbffaffffU, 0xbffffff6U,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0x13c9e684U>
- sfmt19937;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 19937, 122,
- 18, 1, 11, 1,
- 0xdfffffefU, 0xddfecb7fU,
- 0xbffaffffU, 0xbffffff6U,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0x13c9e684U>
- sfmt19937_64;
- typedef simd_fast_mersenne_twister_engine<uint32_t, 44497, 330,
- 5, 3, 9, 3,
- 0xeffffffbU, 0xdfbebfffU,
- 0xbfbf7befU, 0x9ffd7bffU,
- 0x00000001U, 0x00000000U,
- 0xa3ac4000U, 0xecc1327aU>
- sfmt44497;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 44497, 330,
- 5, 3, 9, 3,
- 0xeffffffbU, 0xdfbebfffU,
- 0xbfbf7befU, 0x9ffd7bffU,
- 0x00000001U, 0x00000000U,
- 0xa3ac4000U, 0xecc1327aU>
- sfmt44497_64;
- typedef simd_fast_mersenne_twister_engine<uint32_t, 86243, 366,
- 6, 7, 19, 1,
- 0xfdbffbffU, 0xbff7ff3fU,
- 0xfd77efffU, 0xbf9ff3ffU,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0xe9528d85U>
- sfmt86243;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 86243, 366,
- 6, 7, 19, 1,
- 0xfdbffbffU, 0xbff7ff3fU,
- 0xfd77efffU, 0xbf9ff3ffU,
- 0x00000001U, 0x00000000U,
- 0x00000000U, 0xe9528d85U>
- sfmt86243_64;
- typedef simd_fast_mersenne_twister_engine<uint32_t, 132049, 110,
- 19, 1, 21, 1,
- 0xffffbb5fU, 0xfb6ebf95U,
- 0xfffefffaU, 0xcff77fffU,
- 0x00000001U, 0x00000000U,
- 0xcb520000U, 0xc7e91c7dU>
- sfmt132049;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 132049, 110,
- 19, 1, 21, 1,
- 0xffffbb5fU, 0xfb6ebf95U,
- 0xfffefffaU, 0xcff77fffU,
- 0x00000001U, 0x00000000U,
- 0xcb520000U, 0xc7e91c7dU>
- sfmt132049_64;
- typedef simd_fast_mersenne_twister_engine<uint32_t, 216091, 627,
- 11, 3, 10, 1,
- 0xbff7bff7U, 0xbfffffffU,
- 0xbffffa7fU, 0xffddfbfbU,
- 0xf8000001U, 0x89e80709U,
- 0x3bd2b64bU, 0x0c64b1e4U>
- sfmt216091;
- typedef simd_fast_mersenne_twister_engine<uint64_t, 216091, 627,
- 11, 3, 10, 1,
- 0xbff7bff7U, 0xbfffffffU,
- 0xbffffa7fU, 0xffddfbfbU,
- 0xf8000001U, 0x89e80709U,
- 0x3bd2b64bU, 0x0c64b1e4U>
- sfmt216091_64;
- #endif // __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- /**
- * @brief A beta continuous distribution for random numbers.
- *
- * The formula for the beta probability density function is:
- * @f[
- * p(x|\alpha,\beta) = \frac{1}{B(\alpha,\beta)}
- * x^{\alpha - 1} (1 - x)^{\beta - 1}
- * @f]
- */
- template<typename _RealType = double>
- class beta_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef beta_distribution<_RealType> distribution_type;
- friend class beta_distribution<_RealType>;
- param_type() : param_type(1) { }
- explicit
- param_type(_RealType __alpha_val, _RealType __beta_val = _RealType(1))
- : _M_alpha(__alpha_val), _M_beta(__beta_val)
- {
- __glibcxx_assert(_M_alpha > _RealType(0));
- __glibcxx_assert(_M_beta > _RealType(0));
- }
- _RealType
- alpha() const
- { return _M_alpha; }
- _RealType
- beta() const
- { return _M_beta; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return (__p1._M_alpha == __p2._M_alpha
- && __p1._M_beta == __p2._M_beta); }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- void
- _M_initialize();
- _RealType _M_alpha;
- _RealType _M_beta;
- };
- public:
- beta_distribution() : beta_distribution(1.0) { }
- /**
- * @brief Constructs a beta distribution with parameters
- * @f$\alpha@f$ and @f$\beta@f$.
- */
- explicit
- beta_distribution(_RealType __alpha_val,
- _RealType __beta_val = _RealType(1))
- : _M_param(__alpha_val, __beta_val)
- { }
- explicit
- beta_distribution(const param_type& __p)
- : _M_param(__p)
- { }
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { }
- /**
- * @brief Returns the @f$\alpha@f$ of the distribution.
- */
- _RealType
- alpha() const
- { return _M_param.alpha(); }
- /**
- * @brief Returns the @f$\beta@f$ of the distribution.
- */
- _RealType
- beta() const
- { return _M_param.beta(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return result_type(0); }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return result_type(1); }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, _M_param); }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two beta distributions have the same
- * parameters and the sequences that would be generated
- * are equal.
- */
- friend bool
- operator==(const beta_distribution& __d1,
- const beta_distribution& __d2)
- { return __d1._M_param == __d2._M_param; }
- /**
- * @brief Inserts a %beta_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %beta_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>& __os,
- const __gnu_cxx::beta_distribution<_RealType1>& __x);
- /**
- * @brief Extracts a %beta_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %beta_distribution random number generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>& __is,
- __gnu_cxx::beta_distribution<_RealType1>& __x);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- };
- /**
- * @brief Return true if two beta distributions are different.
- */
- template<typename _RealType>
- inline bool
- operator!=(const __gnu_cxx::beta_distribution<_RealType>& __d1,
- const __gnu_cxx::beta_distribution<_RealType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A multi-variate normal continuous distribution for random numbers.
- *
- * The formula for the normal probability density function is
- * @f[
- * p(\overrightarrow{x}|\overrightarrow{\mu },\Sigma) =
- * \frac{1}{\sqrt{(2\pi )^k\det(\Sigma))}}
- * e^{-\frac{1}{2}(\overrightarrow{x}-\overrightarrow{\mu})^\text{T}
- * \Sigma ^{-1}(\overrightarrow{x}-\overrightarrow{\mu})}
- * @f]
- *
- * where @f$\overrightarrow{x}@f$ and @f$\overrightarrow{\mu}@f$ are
- * vectors of dimension @f$k@f$ and @f$\Sigma@f$ is the covariance
- * matrix (which must be positive-definite).
- */
- template<std::size_t _Dimen, typename _RealType = double>
- class normal_mv_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- static_assert(_Dimen != 0, "dimension is zero");
- public:
- /** The type of the range of the distribution. */
- typedef std::array<_RealType, _Dimen> result_type;
- /** Parameter type. */
- class param_type
- {
- static constexpr size_t _M_t_size = _Dimen * (_Dimen + 1) / 2;
- public:
- typedef normal_mv_distribution<_Dimen, _RealType> distribution_type;
- friend class normal_mv_distribution<_Dimen, _RealType>;
- param_type()
- {
- std::fill(_M_mean.begin(), _M_mean.end(), _RealType(0));
- auto __it = _M_t.begin();
- for (size_t __i = 0; __i < _Dimen; ++__i)
- {
- std::fill_n(__it, __i, _RealType(0));
- __it += __i;
- *__it++ = _RealType(1);
- }
- }
- template<typename _ForwardIterator1, typename _ForwardIterator2>
- param_type(_ForwardIterator1 __meanbegin,
- _ForwardIterator1 __meanend,
- _ForwardIterator2 __varcovbegin,
- _ForwardIterator2 __varcovend)
- {
- __glibcxx_function_requires(_ForwardIteratorConcept<
- _ForwardIterator1>)
- __glibcxx_function_requires(_ForwardIteratorConcept<
- _ForwardIterator2>)
- _GLIBCXX_DEBUG_ASSERT(std::distance(__meanbegin, __meanend)
- <= _Dimen);
- const auto __dist = std::distance(__varcovbegin, __varcovend);
- _GLIBCXX_DEBUG_ASSERT(__dist == _Dimen * _Dimen
- || __dist == _Dimen * (_Dimen + 1) / 2
- || __dist == _Dimen);
- if (__dist == _Dimen * _Dimen)
- _M_init_full(__meanbegin, __meanend, __varcovbegin, __varcovend);
- else if (__dist == _Dimen * (_Dimen + 1) / 2)
- _M_init_lower(__meanbegin, __meanend, __varcovbegin, __varcovend);
- else
- {
- __glibcxx_assert(__dist == _Dimen);
- _M_init_diagonal(__meanbegin, __meanend,
- __varcovbegin, __varcovend);
- }
- }
- param_type(std::initializer_list<_RealType> __mean,
- std::initializer_list<_RealType> __varcov)
- {
- _GLIBCXX_DEBUG_ASSERT(__mean.size() <= _Dimen);
- _GLIBCXX_DEBUG_ASSERT(__varcov.size() == _Dimen * _Dimen
- || __varcov.size() == _Dimen * (_Dimen + 1) / 2
- || __varcov.size() == _Dimen);
- if (__varcov.size() == _Dimen * _Dimen)
- _M_init_full(__mean.begin(), __mean.end(),
- __varcov.begin(), __varcov.end());
- else if (__varcov.size() == _Dimen * (_Dimen + 1) / 2)
- _M_init_lower(__mean.begin(), __mean.end(),
- __varcov.begin(), __varcov.end());
- else
- {
- __glibcxx_assert(__varcov.size() == _Dimen);
- _M_init_diagonal(__mean.begin(), __mean.end(),
- __varcov.begin(), __varcov.end());
- }
- }
- std::array<_RealType, _Dimen>
- mean() const
- { return _M_mean; }
- std::array<_RealType, _M_t_size>
- varcov() const
- { return _M_t; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return __p1._M_mean == __p2._M_mean && __p1._M_t == __p2._M_t; }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- template <typename _InputIterator1, typename _InputIterator2>
- void _M_init_full(_InputIterator1 __meanbegin,
- _InputIterator1 __meanend,
- _InputIterator2 __varcovbegin,
- _InputIterator2 __varcovend);
- template <typename _InputIterator1, typename _InputIterator2>
- void _M_init_lower(_InputIterator1 __meanbegin,
- _InputIterator1 __meanend,
- _InputIterator2 __varcovbegin,
- _InputIterator2 __varcovend);
- template <typename _InputIterator1, typename _InputIterator2>
- void _M_init_diagonal(_InputIterator1 __meanbegin,
- _InputIterator1 __meanend,
- _InputIterator2 __varbegin,
- _InputIterator2 __varend);
- // param_type constructors apply Cholesky decomposition to the
- // varcov matrix in _M_init_full and _M_init_lower, but the
- // varcov matrix output ot a stream is already decomposed, so
- // we need means to restore it as-is when reading it back in.
- template<size_t _Dimen1, typename _RealType1,
- typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>& __is,
- __gnu_cxx::normal_mv_distribution<_Dimen1, _RealType1>&
- __x);
- param_type(std::array<_RealType, _Dimen> const &__mean,
- std::array<_RealType, _M_t_size> const &__varcov)
- : _M_mean (__mean), _M_t (__varcov)
- {}
- std::array<_RealType, _Dimen> _M_mean;
- std::array<_RealType, _M_t_size> _M_t;
- };
- public:
- normal_mv_distribution()
- : _M_param(), _M_nd()
- { }
- template<typename _ForwardIterator1, typename _ForwardIterator2>
- normal_mv_distribution(_ForwardIterator1 __meanbegin,
- _ForwardIterator1 __meanend,
- _ForwardIterator2 __varcovbegin,
- _ForwardIterator2 __varcovend)
- : _M_param(__meanbegin, __meanend, __varcovbegin, __varcovend),
- _M_nd()
- { }
- normal_mv_distribution(std::initializer_list<_RealType> __mean,
- std::initializer_list<_RealType> __varcov)
- : _M_param(__mean, __varcov), _M_nd()
- { }
- explicit
- normal_mv_distribution(const param_type& __p)
- : _M_param(__p), _M_nd()
- { }
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { _M_nd.reset(); }
- /**
- * @brief Returns the mean of the distribution.
- */
- result_type
- mean() const
- { return _M_param.mean(); }
- /**
- * @brief Returns the compact form of the variance/covariance
- * matrix of the distribution.
- */
- std::array<_RealType, _Dimen * (_Dimen + 1) / 2>
- varcov() const
- { return _M_param.varcov(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { result_type __res;
- __res.fill(std::numeric_limits<_RealType>::lowest());
- return __res; }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { result_type __res;
- __res.fill(std::numeric_limits<_RealType>::max());
- return __res; }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, _M_param); }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { return this->__generate_impl(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { return this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two multi-variant normal distributions have
- * the same parameters and the sequences that would
- * be generated are equal.
- */
- template<size_t _Dimen1, typename _RealType1>
- friend bool
- operator==(const
- __gnu_cxx::normal_mv_distribution<_Dimen1, _RealType1>&
- __d1,
- const
- __gnu_cxx::normal_mv_distribution<_Dimen1, _RealType1>&
- __d2);
- /**
- * @brief Inserts a %normal_mv_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %normal_mv_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<size_t _Dimen1, typename _RealType1,
- typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>& __os,
- const
- __gnu_cxx::normal_mv_distribution<_Dimen1, _RealType1>&
- __x);
- /**
- * @brief Extracts a %normal_mv_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %normal_mv_distribution random number generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error
- * state.
- */
- template<size_t _Dimen1, typename _RealType1,
- typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>& __is,
- __gnu_cxx::normal_mv_distribution<_Dimen1, _RealType1>&
- __x);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- std::normal_distribution<_RealType> _M_nd;
- };
- /**
- * @brief Return true if two multi-variate normal distributions are
- * different.
- */
- template<size_t _Dimen, typename _RealType>
- inline bool
- operator!=(const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
- __d1,
- const __gnu_cxx::normal_mv_distribution<_Dimen, _RealType>&
- __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A Rice continuous distribution for random numbers.
- *
- * The formula for the Rice probability density function is
- * @f[
- * p(x|\nu,\sigma) = \frac{x}{\sigma^2}
- * \exp\left(-\frac{x^2+\nu^2}{2\sigma^2}\right)
- * I_0\left(\frac{x \nu}{\sigma^2}\right)
- * @f]
- * where @f$I_0(z)@f$ is the modified Bessel function of the first kind
- * of order 0 and @f$\nu >= 0@f$ and @f$\sigma > 0@f$.
- *
- * <table border=1 cellpadding=10 cellspacing=0>
- * <caption align=top>Distribution Statistics</caption>
- * <tr><td>Mean</td><td>@f$\sqrt{\pi/2}L_{1/2}(-\nu^2/2\sigma^2)@f$</td></tr>
- * <tr><td>Variance</td><td>@f$2\sigma^2 + \nu^2
- * + (\pi\sigma^2/2)L^2_{1/2}(-\nu^2/2\sigma^2)@f$</td></tr>
- * <tr><td>Range</td><td>@f$[0, \infty)@f$</td></tr>
- * </table>
- * where @f$L_{1/2}(x)@f$ is the Laguerre polynomial of order 1/2.
- */
- template<typename _RealType = double>
- class
- rice_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef rice_distribution<result_type> distribution_type;
- param_type() : param_type(0) { }
- param_type(result_type __nu_val,
- result_type __sigma_val = result_type(1))
- : _M_nu(__nu_val), _M_sigma(__sigma_val)
- {
- __glibcxx_assert(_M_nu >= result_type(0));
- __glibcxx_assert(_M_sigma > result_type(0));
- }
- result_type
- nu() const
- { return _M_nu; }
- result_type
- sigma() const
- { return _M_sigma; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return __p1._M_nu == __p2._M_nu && __p1._M_sigma == __p2._M_sigma; }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- void _M_initialize();
- result_type _M_nu;
- result_type _M_sigma;
- };
- /**
- * @brief Constructors.
- * @{
- */
- rice_distribution() : rice_distribution(0) { }
- explicit
- rice_distribution(result_type __nu_val,
- result_type __sigma_val = result_type(1))
- : _M_param(__nu_val, __sigma_val),
- _M_ndx(__nu_val, __sigma_val),
- _M_ndy(result_type(0), __sigma_val)
- { }
- explicit
- rice_distribution(const param_type& __p)
- : _M_param(__p),
- _M_ndx(__p.nu(), __p.sigma()),
- _M_ndy(result_type(0), __p.sigma())
- { }
- /// @}
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- {
- _M_ndx.reset();
- _M_ndy.reset();
- }
- /**
- * @brief Return the parameters of the distribution.
- */
- result_type
- nu() const
- { return _M_param.nu(); }
- result_type
- sigma() const
- { return _M_param.sigma(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return result_type(0); }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return std::numeric_limits<result_type>::max(); }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- {
- result_type __x = this->_M_ndx(__urng);
- result_type __y = this->_M_ndy(__urng);
- #if _GLIBCXX_USE_C99_MATH_TR1
- return std::hypot(__x, __y);
- #else
- return std::sqrt(__x * __x + __y * __y);
- #endif
- }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- {
- typename std::normal_distribution<result_type>::param_type
- __px(__p.nu(), __p.sigma()), __py(result_type(0), __p.sigma());
- result_type __x = this->_M_ndx(__px, __urng);
- result_type __y = this->_M_ndy(__py, __urng);
- #if _GLIBCXX_USE_C99_MATH_TR1
- return std::hypot(__x, __y);
- #else
- return std::sqrt(__x * __x + __y * __y);
- #endif
- }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two Rice distributions have
- * the same parameters and the sequences that would
- * be generated are equal.
- */
- friend bool
- operator==(const rice_distribution& __d1,
- const rice_distribution& __d2)
- { return (__d1._M_param == __d2._M_param
- && __d1._M_ndx == __d2._M_ndx
- && __d1._M_ndy == __d2._M_ndy); }
- /**
- * @brief Inserts a %rice_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %rice_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>&,
- const rice_distribution<_RealType1>&);
- /**
- * @brief Extracts a %rice_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %rice_distribution random number
- * generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>&,
- rice_distribution<_RealType1>&);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- std::normal_distribution<result_type> _M_ndx;
- std::normal_distribution<result_type> _M_ndy;
- };
- /**
- * @brief Return true if two Rice distributions are not equal.
- */
- template<typename _RealType1>
- inline bool
- operator!=(const rice_distribution<_RealType1>& __d1,
- const rice_distribution<_RealType1>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A Nakagami continuous distribution for random numbers.
- *
- * The formula for the Nakagami probability density function is
- * @f[
- * p(x|\mu,\omega) = \frac{2\mu^\mu}{\Gamma(\mu)\omega^\mu}
- * x^{2\mu-1}e^{-\mu x / \omega}
- * @f]
- * where @f$\Gamma(z)@f$ is the gamma function and @f$\mu >= 0.5@f$
- * and @f$\omega > 0@f$.
- */
- template<typename _RealType = double>
- class
- nakagami_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef nakagami_distribution<result_type> distribution_type;
- param_type() : param_type(1) { }
- param_type(result_type __mu_val,
- result_type __omega_val = result_type(1))
- : _M_mu(__mu_val), _M_omega(__omega_val)
- {
- __glibcxx_assert(_M_mu >= result_type(0.5L));
- __glibcxx_assert(_M_omega > result_type(0));
- }
- result_type
- mu() const
- { return _M_mu; }
- result_type
- omega() const
- { return _M_omega; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return __p1._M_mu == __p2._M_mu && __p1._M_omega == __p2._M_omega; }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- void _M_initialize();
- result_type _M_mu;
- result_type _M_omega;
- };
- /**
- * @brief Constructors.
- * @{
- */
- nakagami_distribution() : nakagami_distribution(1) { }
- explicit
- nakagami_distribution(result_type __mu_val,
- result_type __omega_val = result_type(1))
- : _M_param(__mu_val, __omega_val),
- _M_gd(__mu_val, __omega_val / __mu_val)
- { }
- explicit
- nakagami_distribution(const param_type& __p)
- : _M_param(__p),
- _M_gd(__p.mu(), __p.omega() / __p.mu())
- { }
- /// @}
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { _M_gd.reset(); }
- /**
- * @brief Return the parameters of the distribution.
- */
- result_type
- mu() const
- { return _M_param.mu(); }
- result_type
- omega() const
- { return _M_param.omega(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return result_type(0); }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return std::numeric_limits<result_type>::max(); }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return std::sqrt(this->_M_gd(__urng)); }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- {
- typename std::gamma_distribution<result_type>::param_type
- __pg(__p.mu(), __p.omega() / __p.mu());
- return std::sqrt(this->_M_gd(__pg, __urng));
- }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two Nakagami distributions have
- * the same parameters and the sequences that would
- * be generated are equal.
- */
- friend bool
- operator==(const nakagami_distribution& __d1,
- const nakagami_distribution& __d2)
- { return (__d1._M_param == __d2._M_param
- && __d1._M_gd == __d2._M_gd); }
- /**
- * @brief Inserts a %nakagami_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %nakagami_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>&,
- const nakagami_distribution<_RealType1>&);
- /**
- * @brief Extracts a %nakagami_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %nakagami_distribution random number
- * generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>&,
- nakagami_distribution<_RealType1>&);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- std::gamma_distribution<result_type> _M_gd;
- };
- /**
- * @brief Return true if two Nakagami distributions are not equal.
- */
- template<typename _RealType>
- inline bool
- operator!=(const nakagami_distribution<_RealType>& __d1,
- const nakagami_distribution<_RealType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A Pareto continuous distribution for random numbers.
- *
- * The formula for the Pareto cumulative probability function is
- * @f[
- * P(x|\alpha,\mu) = 1 - \left(\frac{\mu}{x}\right)^\alpha
- * @f]
- * The formula for the Pareto probability density function is
- * @f[
- * p(x|\alpha,\mu) = \frac{\alpha + 1}{\mu}
- * \left(\frac{\mu}{x}\right)^{\alpha + 1}
- * @f]
- * where @f$x >= \mu@f$ and @f$\mu > 0@f$, @f$\alpha > 0@f$.
- *
- * <table border=1 cellpadding=10 cellspacing=0>
- * <caption align=top>Distribution Statistics</caption>
- * <tr><td>Mean</td><td>@f$\alpha \mu / (\alpha - 1)@f$
- * for @f$\alpha > 1@f$</td></tr>
- * <tr><td>Variance</td><td>@f$\alpha \mu^2 / [(\alpha - 1)^2(\alpha - 2)]@f$
- * for @f$\alpha > 2@f$</td></tr>
- * <tr><td>Range</td><td>@f$[\mu, \infty)@f$</td></tr>
- * </table>
- */
- template<typename _RealType = double>
- class
- pareto_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef pareto_distribution<result_type> distribution_type;
- param_type() : param_type(1) { }
- param_type(result_type __alpha_val,
- result_type __mu_val = result_type(1))
- : _M_alpha(__alpha_val), _M_mu(__mu_val)
- {
- __glibcxx_assert(_M_alpha > result_type(0));
- __glibcxx_assert(_M_mu > result_type(0));
- }
- result_type
- alpha() const
- { return _M_alpha; }
- result_type
- mu() const
- { return _M_mu; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return __p1._M_alpha == __p2._M_alpha && __p1._M_mu == __p2._M_mu; }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- void _M_initialize();
- result_type _M_alpha;
- result_type _M_mu;
- };
- /**
- * @brief Constructors.
- * @{
- */
- pareto_distribution() : pareto_distribution(1) { }
- explicit
- pareto_distribution(result_type __alpha_val,
- result_type __mu_val = result_type(1))
- : _M_param(__alpha_val, __mu_val),
- _M_ud()
- { }
- explicit
- pareto_distribution(const param_type& __p)
- : _M_param(__p),
- _M_ud()
- { }
- /// @}
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- {
- _M_ud.reset();
- }
- /**
- * @brief Return the parameters of the distribution.
- */
- result_type
- alpha() const
- { return _M_param.alpha(); }
- result_type
- mu() const
- { return _M_param.mu(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return this->mu(); }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return std::numeric_limits<result_type>::max(); }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- {
- return this->mu() * std::pow(this->_M_ud(__urng),
- -result_type(1) / this->alpha());
- }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- {
- return __p.mu() * std::pow(this->_M_ud(__urng),
- -result_type(1) / __p.alpha());
- }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two Pareto distributions have
- * the same parameters and the sequences that would
- * be generated are equal.
- */
- friend bool
- operator==(const pareto_distribution& __d1,
- const pareto_distribution& __d2)
- { return (__d1._M_param == __d2._M_param
- && __d1._M_ud == __d2._M_ud); }
- /**
- * @brief Inserts a %pareto_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %pareto_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>&,
- const pareto_distribution<_RealType1>&);
- /**
- * @brief Extracts a %pareto_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %pareto_distribution random number
- * generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>&,
- pareto_distribution<_RealType1>&);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- std::uniform_real_distribution<result_type> _M_ud;
- };
- /**
- * @brief Return true if two Pareto distributions are not equal.
- */
- template<typename _RealType>
- inline bool
- operator!=(const pareto_distribution<_RealType>& __d1,
- const pareto_distribution<_RealType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A K continuous distribution for random numbers.
- *
- * The formula for the K probability density function is
- * @f[
- * p(x|\lambda, \mu, \nu) = \frac{2}{x}
- * \left(\frac{\lambda\nu x}{\mu}\right)^{\frac{\lambda + \nu}{2}}
- * \frac{1}{\Gamma(\lambda)\Gamma(\nu)}
- * K_{\nu - \lambda}\left(2\sqrt{\frac{\lambda\nu x}{\mu}}\right)
- * @f]
- * where @f$I_0(z)@f$ is the modified Bessel function of the second kind
- * of order @f$\nu - \lambda@f$ and @f$\lambda > 0@f$, @f$\mu > 0@f$
- * and @f$\nu > 0@f$.
- *
- * <table border=1 cellpadding=10 cellspacing=0>
- * <caption align=top>Distribution Statistics</caption>
- * <tr><td>Mean</td><td>@f$\mu@f$</td></tr>
- * <tr><td>Variance</td><td>@f$\mu^2\frac{\lambda + \nu + 1}{\lambda\nu}@f$</td></tr>
- * <tr><td>Range</td><td>@f$[0, \infty)@f$</td></tr>
- * </table>
- */
- template<typename _RealType = double>
- class
- k_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef k_distribution<result_type> distribution_type;
- param_type() : param_type(1) { }
- param_type(result_type __lambda_val,
- result_type __mu_val = result_type(1),
- result_type __nu_val = result_type(1))
- : _M_lambda(__lambda_val), _M_mu(__mu_val), _M_nu(__nu_val)
- {
- __glibcxx_assert(_M_lambda > result_type(0));
- __glibcxx_assert(_M_mu > result_type(0));
- __glibcxx_assert(_M_nu > result_type(0));
- }
- result_type
- lambda() const
- { return _M_lambda; }
- result_type
- mu() const
- { return _M_mu; }
- result_type
- nu() const
- { return _M_nu; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- {
- return __p1._M_lambda == __p2._M_lambda
- && __p1._M_mu == __p2._M_mu
- && __p1._M_nu == __p2._M_nu;
- }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- void _M_initialize();
- result_type _M_lambda;
- result_type _M_mu;
- result_type _M_nu;
- };
- /**
- * @brief Constructors.
- * @{
- */
- k_distribution() : k_distribution(1) { }
- explicit
- k_distribution(result_type __lambda_val,
- result_type __mu_val = result_type(1),
- result_type __nu_val = result_type(1))
- : _M_param(__lambda_val, __mu_val, __nu_val),
- _M_gd1(__lambda_val, result_type(1) / __lambda_val),
- _M_gd2(__nu_val, __mu_val / __nu_val)
- { }
- explicit
- k_distribution(const param_type& __p)
- : _M_param(__p),
- _M_gd1(__p.lambda(), result_type(1) / __p.lambda()),
- _M_gd2(__p.nu(), __p.mu() / __p.nu())
- { }
- /// @}
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- {
- _M_gd1.reset();
- _M_gd2.reset();
- }
- /**
- * @brief Return the parameters of the distribution.
- */
- result_type
- lambda() const
- { return _M_param.lambda(); }
- result_type
- mu() const
- { return _M_param.mu(); }
- result_type
- nu() const
- { return _M_param.nu(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return result_type(0); }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return std::numeric_limits<result_type>::max(); }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator&);
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator&, const param_type&);
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two K distributions have
- * the same parameters and the sequences that would
- * be generated are equal.
- */
- friend bool
- operator==(const k_distribution& __d1,
- const k_distribution& __d2)
- { return (__d1._M_param == __d2._M_param
- && __d1._M_gd1 == __d2._M_gd1
- && __d1._M_gd2 == __d2._M_gd2); }
- /**
- * @brief Inserts a %k_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %k_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>&,
- const k_distribution<_RealType1>&);
- /**
- * @brief Extracts a %k_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %k_distribution random number
- * generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>&,
- k_distribution<_RealType1>&);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- std::gamma_distribution<result_type> _M_gd1;
- std::gamma_distribution<result_type> _M_gd2;
- };
- /**
- * @brief Return true if two K distributions are not equal.
- */
- template<typename _RealType>
- inline bool
- operator!=(const k_distribution<_RealType>& __d1,
- const k_distribution<_RealType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief An arcsine continuous distribution for random numbers.
- *
- * The formula for the arcsine probability density function is
- * @f[
- * p(x|a,b) = \frac{1}{\pi \sqrt{(x - a)(b - x)}}
- * @f]
- * where @f$x >= a@f$ and @f$x <= b@f$.
- *
- * <table border=1 cellpadding=10 cellspacing=0>
- * <caption align=top>Distribution Statistics</caption>
- * <tr><td>Mean</td><td>@f$ (a + b) / 2 @f$</td></tr>
- * <tr><td>Variance</td><td>@f$ (b - a)^2 / 8 @f$</td></tr>
- * <tr><td>Range</td><td>@f$[a, b]@f$</td></tr>
- * </table>
- */
- template<typename _RealType = double>
- class
- arcsine_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef arcsine_distribution<result_type> distribution_type;
- param_type() : param_type(0) { }
- param_type(result_type __a, result_type __b = result_type(1))
- : _M_a(__a), _M_b(__b)
- {
- __glibcxx_assert(_M_a <= _M_b);
- }
- result_type
- a() const
- { return _M_a; }
- result_type
- b() const
- { return _M_b; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- void _M_initialize();
- result_type _M_a;
- result_type _M_b;
- };
- /**
- * @brief Constructors.
- * :{
- */
- arcsine_distribution() : arcsine_distribution(0) { }
- explicit
- arcsine_distribution(result_type __a, result_type __b = result_type(1))
- : _M_param(__a, __b),
- _M_ud(-1.5707963267948966192313216916397514L,
- +1.5707963267948966192313216916397514L)
- { }
- explicit
- arcsine_distribution(const param_type& __p)
- : _M_param(__p),
- _M_ud(-1.5707963267948966192313216916397514L,
- +1.5707963267948966192313216916397514L)
- { }
- /// @}
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { _M_ud.reset(); }
- /**
- * @brief Return the parameters of the distribution.
- */
- result_type
- a() const
- { return _M_param.a(); }
- result_type
- b() const
- { return _M_param.b(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return this->a(); }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return this->b(); }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- {
- result_type __x = std::sin(this->_M_ud(__urng));
- return (__x * (this->b() - this->a())
- + this->a() + this->b()) / result_type(2);
- }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- {
- result_type __x = std::sin(this->_M_ud(__urng));
- return (__x * (__p.b() - __p.a())
- + __p.a() + __p.b()) / result_type(2);
- }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two arcsine distributions have
- * the same parameters and the sequences that would
- * be generated are equal.
- */
- friend bool
- operator==(const arcsine_distribution& __d1,
- const arcsine_distribution& __d2)
- { return (__d1._M_param == __d2._M_param
- && __d1._M_ud == __d2._M_ud); }
- /**
- * @brief Inserts a %arcsine_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %arcsine_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>&,
- const arcsine_distribution<_RealType1>&);
- /**
- * @brief Extracts a %arcsine_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %arcsine_distribution random number
- * generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>&,
- arcsine_distribution<_RealType1>&);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- std::uniform_real_distribution<result_type> _M_ud;
- };
- /**
- * @brief Return true if two arcsine distributions are not equal.
- */
- template<typename _RealType>
- inline bool
- operator!=(const arcsine_distribution<_RealType>& __d1,
- const arcsine_distribution<_RealType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A Hoyt continuous distribution for random numbers.
- *
- * The formula for the Hoyt probability density function is
- * @f[
- * p(x|q,\omega) = \frac{(1 + q^2)x}{q\omega}
- * \exp\left(-\frac{(1 + q^2)^2 x^2}{4 q^2 \omega}\right)
- * I_0\left(\frac{(1 - q^4) x^2}{4 q^2 \omega}\right)
- * @f]
- * where @f$I_0(z)@f$ is the modified Bessel function of the first kind
- * of order 0 and @f$0 < q < 1@f$.
- *
- * <table border=1 cellpadding=10 cellspacing=0>
- * <caption align=top>Distribution Statistics</caption>
- * <tr><td>Mean</td><td>@f$ \sqrt{\frac{2}{\pi}} \sqrt{\frac{\omega}{1 + q^2}}
- * E(1 - q^2) @f$</td></tr>
- * <tr><td>Variance</td><td>@f$ \omega \left(1 - \frac{2E^2(1 - q^2)}
- * {\pi (1 + q^2)}\right) @f$</td></tr>
- * <tr><td>Range</td><td>@f$[0, \infty)@f$</td></tr>
- * </table>
- * where @f$E(x)@f$ is the elliptic function of the second kind.
- */
- template<typename _RealType = double>
- class
- hoyt_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef hoyt_distribution<result_type> distribution_type;
- param_type() : param_type(0.5) { }
- param_type(result_type __q, result_type __omega = result_type(1))
- : _M_q(__q), _M_omega(__omega)
- {
- __glibcxx_assert(_M_q > result_type(0));
- __glibcxx_assert(_M_q < result_type(1));
- }
- result_type
- q() const
- { return _M_q; }
- result_type
- omega() const
- { return _M_omega; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return __p1._M_q == __p2._M_q && __p1._M_omega == __p2._M_omega; }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- void _M_initialize();
- result_type _M_q;
- result_type _M_omega;
- };
- /**
- * @brief Constructors.
- * @{
- */
- hoyt_distribution() : hoyt_distribution(0.5) { }
- explicit
- hoyt_distribution(result_type __q, result_type __omega = result_type(1))
- : _M_param(__q, __omega),
- _M_ad(result_type(0.5L) * (result_type(1) + __q * __q),
- result_type(0.5L) * (result_type(1) + __q * __q)
- / (__q * __q)),
- _M_ed(result_type(1))
- { }
- explicit
- hoyt_distribution(const param_type& __p)
- : _M_param(__p),
- _M_ad(result_type(0.5L) * (result_type(1) + __p.q() * __p.q()),
- result_type(0.5L) * (result_type(1) + __p.q() * __p.q())
- / (__p.q() * __p.q())),
- _M_ed(result_type(1))
- { }
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- {
- _M_ad.reset();
- _M_ed.reset();
- }
- /**
- * @brief Return the parameters of the distribution.
- */
- result_type
- q() const
- { return _M_param.q(); }
- result_type
- omega() const
- { return _M_param.omega(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return result_type(0); }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return std::numeric_limits<result_type>::max(); }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng);
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two Hoyt distributions have
- * the same parameters and the sequences that would
- * be generated are equal.
- */
- friend bool
- operator==(const hoyt_distribution& __d1,
- const hoyt_distribution& __d2)
- { return (__d1._M_param == __d2._M_param
- && __d1._M_ad == __d2._M_ad
- && __d1._M_ed == __d2._M_ed); }
- /**
- * @brief Inserts a %hoyt_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %hoyt_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>&,
- const hoyt_distribution<_RealType1>&);
- /**
- * @brief Extracts a %hoyt_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %hoyt_distribution random number
- * generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>&,
- hoyt_distribution<_RealType1>&);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- __gnu_cxx::arcsine_distribution<result_type> _M_ad;
- std::exponential_distribution<result_type> _M_ed;
- };
- /**
- * @brief Return true if two Hoyt distributions are not equal.
- */
- template<typename _RealType>
- inline bool
- operator!=(const hoyt_distribution<_RealType>& __d1,
- const hoyt_distribution<_RealType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A triangular distribution for random numbers.
- *
- * The formula for the triangular probability density function is
- * @f[
- * / 0 for x < a
- * p(x|a,b,c) = | \frac{2(x-a)}{(c-a)(b-a)} for a <= x <= b
- * | \frac{2(c-x)}{(c-a)(c-b)} for b < x <= c
- * \ 0 for c < x
- * @f]
- *
- * <table border=1 cellpadding=10 cellspacing=0>
- * <caption align=top>Distribution Statistics</caption>
- * <tr><td>Mean</td><td>@f$ \frac{a+b+c}{2} @f$</td></tr>
- * <tr><td>Variance</td><td>@f$ \frac{a^2+b^2+c^2-ab-ac-bc}
- * {18}@f$</td></tr>
- * <tr><td>Range</td><td>@f$[a, c]@f$</td></tr>
- * </table>
- */
- template<typename _RealType = double>
- class triangular_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- friend class triangular_distribution<_RealType>;
- param_type() : param_type(0) { }
- explicit
- param_type(_RealType __a,
- _RealType __b = _RealType(0.5),
- _RealType __c = _RealType(1))
- : _M_a(__a), _M_b(__b), _M_c(__c)
- {
- __glibcxx_assert(_M_a <= _M_b);
- __glibcxx_assert(_M_b <= _M_c);
- __glibcxx_assert(_M_a < _M_c);
- _M_r_ab = (_M_b - _M_a) / (_M_c - _M_a);
- _M_f_ab_ac = (_M_b - _M_a) * (_M_c - _M_a);
- _M_f_bc_ac = (_M_c - _M_b) * (_M_c - _M_a);
- }
- _RealType
- a() const
- { return _M_a; }
- _RealType
- b() const
- { return _M_b; }
- _RealType
- c() const
- { return _M_c; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- {
- return (__p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b
- && __p1._M_c == __p2._M_c);
- }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- _RealType _M_a;
- _RealType _M_b;
- _RealType _M_c;
- _RealType _M_r_ab;
- _RealType _M_f_ab_ac;
- _RealType _M_f_bc_ac;
- };
- triangular_distribution() : triangular_distribution(0.0) { }
- /**
- * @brief Constructs a triangle distribution with parameters
- * @f$ a @f$, @f$ b @f$ and @f$ c @f$.
- */
- explicit
- triangular_distribution(result_type __a,
- result_type __b = result_type(0.5),
- result_type __c = result_type(1))
- : _M_param(__a, __b, __c)
- { }
- explicit
- triangular_distribution(const param_type& __p)
- : _M_param(__p)
- { }
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { }
- /**
- * @brief Returns the @f$ a @f$ of the distribution.
- */
- result_type
- a() const
- { return _M_param.a(); }
- /**
- * @brief Returns the @f$ b @f$ of the distribution.
- */
- result_type
- b() const
- { return _M_param.b(); }
- /**
- * @brief Returns the @f$ c @f$ of the distribution.
- */
- result_type
- c() const
- { return _M_param.c(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return _M_param._M_a; }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return _M_param._M_c; }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, _M_param); }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- {
- std::__detail::_Adaptor<_UniformRandomNumberGenerator, result_type>
- __aurng(__urng);
- result_type __rnd = __aurng();
- if (__rnd <= __p._M_r_ab)
- return __p.a() + std::sqrt(__rnd * __p._M_f_ab_ac);
- else
- return __p.c() - std::sqrt((result_type(1) - __rnd)
- * __p._M_f_bc_ac);
- }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two triangle distributions have the same
- * parameters and the sequences that would be generated
- * are equal.
- */
- friend bool
- operator==(const triangular_distribution& __d1,
- const triangular_distribution& __d2)
- { return __d1._M_param == __d2._M_param; }
- /**
- * @brief Inserts a %triangular_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %triangular_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>& __os,
- const __gnu_cxx::triangular_distribution<_RealType1>& __x);
- /**
- * @brief Extracts a %triangular_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %triangular_distribution random number generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>& __is,
- __gnu_cxx::triangular_distribution<_RealType1>& __x);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- };
- /**
- * @brief Return true if two triangle distributions are different.
- */
- template<typename _RealType>
- inline bool
- operator!=(const __gnu_cxx::triangular_distribution<_RealType>& __d1,
- const __gnu_cxx::triangular_distribution<_RealType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A von Mises distribution for random numbers.
- *
- * The formula for the von Mises probability density function is
- * @f[
- * p(x|\mu,\kappa) = \frac{e^{\kappa \cos(x-\mu)}}
- * {2\pi I_0(\kappa)}
- * @f]
- *
- * The generating functions use the method according to:
- *
- * D. J. Best and N. I. Fisher, 1979. "Efficient Simulation of the
- * von Mises Distribution", Journal of the Royal Statistical Society.
- * Series C (Applied Statistics), Vol. 28, No. 2, pp. 152-157.
- *
- * <table border=1 cellpadding=10 cellspacing=0>
- * <caption align=top>Distribution Statistics</caption>
- * <tr><td>Mean</td><td>@f$ \mu @f$</td></tr>
- * <tr><td>Variance</td><td>@f$ 1-I_1(\kappa)/I_0(\kappa) @f$</td></tr>
- * <tr><td>Range</td><td>@f$[-\pi, \pi]@f$</td></tr>
- * </table>
- */
- template<typename _RealType = double>
- class von_mises_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- friend class von_mises_distribution<_RealType>;
- param_type() : param_type(0) { }
- explicit
- param_type(_RealType __mu, _RealType __kappa = _RealType(1))
- : _M_mu(__mu), _M_kappa(__kappa)
- {
- const _RealType __pi = __gnu_cxx::__math_constants<_RealType>::__pi;
- __glibcxx_assert(_M_mu >= -__pi && _M_mu <= __pi);
- __glibcxx_assert(_M_kappa >= _RealType(0));
- auto __tau = std::sqrt(_RealType(4) * _M_kappa * _M_kappa
- + _RealType(1)) + _RealType(1);
- auto __rho = ((__tau - std::sqrt(_RealType(2) * __tau))
- / (_RealType(2) * _M_kappa));
- _M_r = (_RealType(1) + __rho * __rho) / (_RealType(2) * __rho);
- }
- _RealType
- mu() const
- { return _M_mu; }
- _RealType
- kappa() const
- { return _M_kappa; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return __p1._M_mu == __p2._M_mu && __p1._M_kappa == __p2._M_kappa; }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- _RealType _M_mu;
- _RealType _M_kappa;
- _RealType _M_r;
- };
- von_mises_distribution() : von_mises_distribution(0.0) { }
- /**
- * @brief Constructs a von Mises distribution with parameters
- * @f$\mu@f$ and @f$\kappa@f$.
- */
- explicit
- von_mises_distribution(result_type __mu,
- result_type __kappa = result_type(1))
- : _M_param(__mu, __kappa)
- { }
- explicit
- von_mises_distribution(const param_type& __p)
- : _M_param(__p)
- { }
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { }
- /**
- * @brief Returns the @f$ \mu @f$ of the distribution.
- */
- result_type
- mu() const
- { return _M_param.mu(); }
- /**
- * @brief Returns the @f$ \kappa @f$ of the distribution.
- */
- result_type
- kappa() const
- { return _M_param.kappa(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- {
- return -__gnu_cxx::__math_constants<result_type>::__pi;
- }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- {
- return __gnu_cxx::__math_constants<result_type>::__pi;
- }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, _M_param); }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, _M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two von Mises distributions have the same
- * parameters and the sequences that would be generated
- * are equal.
- */
- friend bool
- operator==(const von_mises_distribution& __d1,
- const von_mises_distribution& __d2)
- { return __d1._M_param == __d2._M_param; }
- /**
- * @brief Inserts a %von_mises_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %von_mises_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>& __os,
- const __gnu_cxx::von_mises_distribution<_RealType1>& __x);
- /**
- * @brief Extracts a %von_mises_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %von_mises_distribution random number generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>& __is,
- __gnu_cxx::von_mises_distribution<_RealType1>& __x);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- };
- /**
- * @brief Return true if two von Mises distributions are different.
- */
- template<typename _RealType>
- inline bool
- operator!=(const __gnu_cxx::von_mises_distribution<_RealType>& __d1,
- const __gnu_cxx::von_mises_distribution<_RealType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A discrete hypergeometric random number distribution.
- *
- * The hypergeometric distribution is a discrete probability distribution
- * that describes the probability of @p k successes in @p n draws @a without
- * replacement from a finite population of size @p N containing exactly @p K
- * successes.
- *
- * The formula for the hypergeometric probability density function is
- * @f[
- * p(k|N,K,n) = \frac{\binom{K}{k} \binom{N-K}{n-k}}{\binom{N}{n}}
- * @f]
- * where @f$N@f$ is the total population of the distribution,
- * @f$K@f$ is the total population of the distribution.
- *
- * <table border=1 cellpadding=10 cellspacing=0>
- * <caption align=top>Distribution Statistics</caption>
- * <tr><td>Mean</td><td>@f$ n\frac{K}{N} @f$</td></tr>
- * <tr><td>Variance</td><td>@f$ n\frac{K}{N}\frac{N-K}{N}\frac{N-n}{N-1}
- * @f$</td></tr>
- * <tr><td>Range</td><td>@f$[max(0, n+K-N), min(K, n)]@f$</td></tr>
- * </table>
- */
- template<typename _UIntType = unsigned int>
- class hypergeometric_distribution
- {
- static_assert(std::is_unsigned<_UIntType>::value, "template argument "
- "substituting _UIntType not an unsigned integral type");
- public:
- /** The type of the range of the distribution. */
- typedef _UIntType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef hypergeometric_distribution<_UIntType> distribution_type;
- friend class hypergeometric_distribution<_UIntType>;
- param_type() : param_type(10) { }
- explicit
- param_type(result_type __N, result_type __K = 5,
- result_type __n = 1)
- : _M_N{__N}, _M_K{__K}, _M_n{__n}
- {
- __glibcxx_assert(_M_N >= _M_K);
- __glibcxx_assert(_M_N >= _M_n);
- }
- result_type
- total_size() const
- { return _M_N; }
- result_type
- successful_size() const
- { return _M_K; }
- result_type
- unsuccessful_size() const
- { return _M_N - _M_K; }
- result_type
- total_draws() const
- { return _M_n; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return (__p1._M_N == __p2._M_N)
- && (__p1._M_K == __p2._M_K)
- && (__p1._M_n == __p2._M_n); }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- result_type _M_N;
- result_type _M_K;
- result_type _M_n;
- };
- // constructors and member functions
- hypergeometric_distribution() : hypergeometric_distribution(10) { }
- explicit
- hypergeometric_distribution(result_type __N, result_type __K = 5,
- result_type __n = 1)
- : _M_param{__N, __K, __n}
- { }
- explicit
- hypergeometric_distribution(const param_type& __p)
- : _M_param{__p}
- { }
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { }
- /**
- * @brief Returns the distribution parameter @p N,
- * the total number of items.
- */
- result_type
- total_size() const
- { return this->_M_param.total_size(); }
- /**
- * @brief Returns the distribution parameter @p K,
- * the total number of successful items.
- */
- result_type
- successful_size() const
- { return this->_M_param.successful_size(); }
- /**
- * @brief Returns the total number of unsuccessful items @f$ N - K @f$.
- */
- result_type
- unsuccessful_size() const
- { return this->_M_param.unsuccessful_size(); }
- /**
- * @brief Returns the distribution parameter @p n,
- * the total number of draws.
- */
- result_type
- total_draws() const
- { return this->_M_param.total_draws(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return this->_M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { this->_M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- {
- using _IntType = typename std::make_signed<result_type>::type;
- return static_cast<result_type>(std::max(static_cast<_IntType>(0),
- static_cast<_IntType>(this->total_draws()
- - this->unsuccessful_size())));
- }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return std::min(this->successful_size(), this->total_draws()); }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, this->_M_param); }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, this->_M_param); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two hypergeometric distributions have the same
- * parameters and the sequences that would be generated
- * are equal.
- */
- friend bool
- operator==(const hypergeometric_distribution& __d1,
- const hypergeometric_distribution& __d2)
- { return __d1._M_param == __d2._M_param; }
- /**
- * @brief Inserts a %hypergeometric_distribution random number
- * distribution @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %hypergeometric_distribution random number
- * distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _UIntType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>& __os,
- const __gnu_cxx::hypergeometric_distribution<_UIntType1>&
- __x);
- /**
- * @brief Extracts a %hypergeometric_distribution random number
- * distribution @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %hypergeometric_distribution random number generator
- * distribution.
- *
- * @returns The input stream with @p __x extracted or in an error
- * state.
- */
- template<typename _UIntType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>& __is,
- __gnu_cxx::hypergeometric_distribution<_UIntType1>& __x);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- };
- /**
- * @brief Return true if two hypergeometric distributions are different.
- */
- template<typename _UIntType>
- inline bool
- operator!=(const __gnu_cxx::hypergeometric_distribution<_UIntType>& __d1,
- const __gnu_cxx::hypergeometric_distribution<_UIntType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A logistic continuous distribution for random numbers.
- *
- * The formula for the logistic probability density function is
- * @f[
- * p(x|\a,\b) = \frac{e^{(x - a)/b}}{b[1 + e^{(x - a)/b}]^2}
- * @f]
- * where @f$b > 0@f$.
- *
- * The formula for the logistic probability function is
- * @f[
- * cdf(x|\a,\b) = \frac{e^{(x - a)/b}}{1 + e^{(x - a)/b}}
- * @f]
- * where @f$b > 0@f$.
- *
- * <table border=1 cellpadding=10 cellspacing=0>
- * <caption align=top>Distribution Statistics</caption>
- * <tr><td>Mean</td><td>@f$a@f$</td></tr>
- * <tr><td>Variance</td><td>@f$b^2\pi^2/3@f$</td></tr>
- * <tr><td>Range</td><td>@f$[0, \infty)@f$</td></tr>
- * </table>
- */
- template<typename _RealType = double>
- class
- logistic_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- public:
- /** The type of the range of the distribution. */
- typedef _RealType result_type;
- /** Parameter type. */
- struct param_type
- {
- typedef logistic_distribution<result_type> distribution_type;
- param_type() : param_type(0) { }
- explicit
- param_type(result_type __a, result_type __b = result_type(1))
- : _M_a(__a), _M_b(__b)
- {
- __glibcxx_assert(_M_b > result_type(0));
- }
- result_type
- a() const
- { return _M_a; }
- result_type
- b() const
- { return _M_b; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return __p1._M_a == __p2._M_a && __p1._M_b == __p2._M_b; }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- void _M_initialize();
- result_type _M_a;
- result_type _M_b;
- };
- /**
- * @brief Constructors.
- * @{
- */
- logistic_distribution() : logistic_distribution(0.0) { }
- explicit
- logistic_distribution(result_type __a, result_type __b = result_type(1))
- : _M_param(__a, __b)
- { }
- explicit
- logistic_distribution(const param_type& __p)
- : _M_param(__p)
- { }
- /// @}
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { }
- /**
- * @brief Return the parameters of the distribution.
- */
- result_type
- a() const
- { return _M_param.a(); }
- result_type
- b() const
- { return _M_param.b(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- */
- result_type
- min() const
- { return -std::numeric_limits<result_type>::max(); }
- /**
- * @brief Returns the least upper bound value of the distribution.
- */
- result_type
- max() const
- { return std::numeric_limits<result_type>::max(); }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, this->_M_param); }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator&,
- const param_type&);
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, this->param()); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two logistic distributions have
- * the same parameters and the sequences that would
- * be generated are equal.
- */
- template<typename _RealType1>
- friend bool
- operator==(const logistic_distribution<_RealType1>& __d1,
- const logistic_distribution<_RealType1>& __d2)
- { return __d1.param() == __d2.param(); }
- /**
- * @brief Inserts a %logistic_distribution random number distribution
- * @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %logistic_distribution random number distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>&,
- const logistic_distribution<_RealType1>&);
- /**
- * @brief Extracts a %logistic_distribution random number distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %logistic_distribution random number
- * generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<typename _RealType1, typename _CharT, typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>&,
- logistic_distribution<_RealType1>&);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- };
- /**
- * @brief Return true if two logistic distributions are not equal.
- */
- template<typename _RealType1>
- inline bool
- operator!=(const logistic_distribution<_RealType1>& __d1,
- const logistic_distribution<_RealType1>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A distribution for random coordinates on a unit sphere.
- *
- * The method used in the generation function is attributed by Donald Knuth
- * to G. W. Brown, Modern Mathematics for the Engineer (1956).
- */
- template<std::size_t _Dimen, typename _RealType = double>
- class uniform_on_sphere_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- static_assert(_Dimen != 0, "dimension is zero");
- public:
- /** The type of the range of the distribution. */
- typedef std::array<_RealType, _Dimen> result_type;
- /** Parameter type. */
- struct param_type
- {
- param_type() { }
- friend bool
- operator==(const param_type&, const param_type&)
- { return true; }
- friend bool
- operator!=(const param_type&, const param_type&)
- { return false; }
- };
- /**
- * @brief Constructs a uniform on sphere distribution.
- */
- uniform_on_sphere_distribution()
- : _M_param(), _M_nd()
- { }
- explicit
- uniform_on_sphere_distribution(const param_type& __p)
- : _M_param(__p), _M_nd()
- { }
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { _M_nd.reset(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- * This function makes no sense for this distribution.
- */
- result_type
- min() const
- {
- result_type __res;
- __res.fill(0);
- return __res;
- }
- /**
- * @brief Returns the least upper bound value of the distribution.
- * This function makes no sense for this distribution.
- */
- result_type
- max() const
- {
- result_type __res;
- __res.fill(0);
- return __res;
- }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, _M_param); }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, this->param()); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two uniform on sphere distributions have
- * the same parameters and the sequences that would be
- * generated are equal.
- */
- friend bool
- operator==(const uniform_on_sphere_distribution& __d1,
- const uniform_on_sphere_distribution& __d2)
- { return __d1._M_nd == __d2._M_nd; }
- /**
- * @brief Inserts a %uniform_on_sphere_distribution random number
- * distribution @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %uniform_on_sphere_distribution random number
- * distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<size_t _Dimen1, typename _RealType1, typename _CharT,
- typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>& __os,
- const __gnu_cxx::uniform_on_sphere_distribution<_Dimen1,
- _RealType1>&
- __x);
- /**
- * @brief Extracts a %uniform_on_sphere_distribution random number
- * distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %uniform_on_sphere_distribution random number
- * generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<std::size_t _Dimen1, typename _RealType1, typename _CharT,
- typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>& __is,
- __gnu_cxx::uniform_on_sphere_distribution<_Dimen1,
- _RealType1>& __x);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- std::normal_distribution<_RealType> _M_nd;
- };
- /**
- * @brief Return true if two uniform on sphere distributions are different.
- */
- template<std::size_t _Dimen, typename _RealType>
- inline bool
- operator!=(const __gnu_cxx::uniform_on_sphere_distribution<_Dimen,
- _RealType>& __d1,
- const __gnu_cxx::uniform_on_sphere_distribution<_Dimen,
- _RealType>& __d2)
- { return !(__d1 == __d2); }
- /**
- * @brief A distribution for random coordinates inside a unit sphere.
- */
- template<std::size_t _Dimen, typename _RealType = double>
- class uniform_inside_sphere_distribution
- {
- static_assert(std::is_floating_point<_RealType>::value,
- "template argument not a floating point type");
- static_assert(_Dimen != 0, "dimension is zero");
- public:
- /** The type of the range of the distribution. */
- using result_type = std::array<_RealType, _Dimen>;
- /** Parameter type. */
- struct param_type
- {
- using distribution_type
- = uniform_inside_sphere_distribution<_Dimen, _RealType>;
- friend class uniform_inside_sphere_distribution<_Dimen, _RealType>;
- param_type() : param_type(1.0) { }
- explicit
- param_type(_RealType __radius)
- : _M_radius(__radius)
- {
- __glibcxx_assert(_M_radius > _RealType(0));
- }
- _RealType
- radius() const
- { return _M_radius; }
- friend bool
- operator==(const param_type& __p1, const param_type& __p2)
- { return __p1._M_radius == __p2._M_radius; }
- friend bool
- operator!=(const param_type& __p1, const param_type& __p2)
- { return !(__p1 == __p2); }
- private:
- _RealType _M_radius;
- };
- /**
- * @brief Constructors.
- * @{
- */
- uniform_inside_sphere_distribution()
- : uniform_inside_sphere_distribution(1.0)
- { }
- explicit
- uniform_inside_sphere_distribution(_RealType __radius)
- : _M_param(__radius), _M_uosd()
- { }
- explicit
- uniform_inside_sphere_distribution(const param_type& __p)
- : _M_param(__p), _M_uosd()
- { }
- /// @}
- /**
- * @brief Resets the distribution state.
- */
- void
- reset()
- { _M_uosd.reset(); }
- /**
- * @brief Returns the @f$radius@f$ of the distribution.
- */
- _RealType
- radius() const
- { return _M_param.radius(); }
- /**
- * @brief Returns the parameter set of the distribution.
- */
- param_type
- param() const
- { return _M_param; }
- /**
- * @brief Sets the parameter set of the distribution.
- * @param __param The new parameter set of the distribution.
- */
- void
- param(const param_type& __param)
- { _M_param = __param; }
- /**
- * @brief Returns the greatest lower bound value of the distribution.
- * This function makes no sense for this distribution.
- */
- result_type
- min() const
- {
- result_type __res;
- __res.fill(0);
- return __res;
- }
- /**
- * @brief Returns the least upper bound value of the distribution.
- * This function makes no sense for this distribution.
- */
- result_type
- max() const
- {
- result_type __res;
- __res.fill(0);
- return __res;
- }
- /**
- * @brief Generating functions.
- */
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng)
- { return this->operator()(__urng, _M_param); }
- template<typename _UniformRandomNumberGenerator>
- result_type
- operator()(_UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng)
- { this->__generate(__f, __t, __urng, this->param()); }
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- template<typename _UniformRandomNumberGenerator>
- void
- __generate(result_type* __f, result_type* __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p)
- { this->__generate_impl(__f, __t, __urng, __p); }
- /**
- * @brief Return true if two uniform on sphere distributions have
- * the same parameters and the sequences that would be
- * generated are equal.
- */
- friend bool
- operator==(const uniform_inside_sphere_distribution& __d1,
- const uniform_inside_sphere_distribution& __d2)
- { return __d1._M_param == __d2._M_param && __d1._M_uosd == __d2._M_uosd; }
- /**
- * @brief Inserts a %uniform_inside_sphere_distribution random number
- * distribution @p __x into the output stream @p __os.
- *
- * @param __os An output stream.
- * @param __x A %uniform_inside_sphere_distribution random number
- * distribution.
- *
- * @returns The output stream with the state of @p __x inserted or in
- * an error state.
- */
- template<size_t _Dimen1, typename _RealType1, typename _CharT,
- typename _Traits>
- friend std::basic_ostream<_CharT, _Traits>&
- operator<<(std::basic_ostream<_CharT, _Traits>& __os,
- const __gnu_cxx::uniform_inside_sphere_distribution<_Dimen1,
- _RealType1>&
- );
- /**
- * @brief Extracts a %uniform_inside_sphere_distribution random number
- * distribution
- * @p __x from the input stream @p __is.
- *
- * @param __is An input stream.
- * @param __x A %uniform_inside_sphere_distribution random number
- * generator engine.
- *
- * @returns The input stream with @p __x extracted or in an error state.
- */
- template<std::size_t _Dimen1, typename _RealType1, typename _CharT,
- typename _Traits>
- friend std::basic_istream<_CharT, _Traits>&
- operator>>(std::basic_istream<_CharT, _Traits>& __is,
- __gnu_cxx::uniform_inside_sphere_distribution<_Dimen1,
- _RealType1>&);
- private:
- template<typename _ForwardIterator,
- typename _UniformRandomNumberGenerator>
- void
- __generate_impl(_ForwardIterator __f, _ForwardIterator __t,
- _UniformRandomNumberGenerator& __urng,
- const param_type& __p);
- param_type _M_param;
- uniform_on_sphere_distribution<_Dimen, _RealType> _M_uosd;
- };
- /**
- * @brief Return true if two uniform on sphere distributions are different.
- */
- template<std::size_t _Dimen, typename _RealType>
- inline bool
- operator!=(const __gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
- _RealType>& __d1,
- const __gnu_cxx::uniform_inside_sphere_distribution<_Dimen,
- _RealType>& __d2)
- { return !(__d1 == __d2); }
- _GLIBCXX_END_NAMESPACE_VERSION
- } // namespace __gnu_cxx
- #include <ext/opt_random.h>
- #include <ext/random.tcc>
- #endif // _GLIBCXX_USE_C99_STDINT_TR1 && UINT32_C
- #endif // C++11
- #endif // _EXT_RANDOM
|