Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
random6706 linesDownload Raw Back to include
1// -*- C++ -*-2//===--------------------------- random -----------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX_RANDOM11#define _LIBCUDACXX_RANDOM12 13/*14    random synopsis15 16#include <initializer_list>17 18namespace std19{20 21// Engines22 23template <class UIntType, UIntType a, UIntType c, UIntType m>24class linear_congruential_engine25{26public:27    // types28    typedef UIntType result_type;29 30    // engine characteristics31    static constexpr result_type multiplier = a;32    static constexpr result_type increment = c;33    static constexpr result_type modulus = m;34    static constexpr result_type min() { return c == 0u ? 1u: 0u;}35    static constexpr result_type max() { return m - 1u;}36    static constexpr result_type default_seed = 1u;37 38    // constructors and seeding functions39    explicit linear_congruential_engine(result_type s = default_seed);40    template<class Sseq> explicit linear_congruential_engine(Sseq& q);41    void seed(result_type s = default_seed);42    template<class Sseq> void seed(Sseq& q);43 44    // generating functions45    result_type operator()();46    void discard(unsigned long long z);47};48 49template <class UIntType, UIntType a, UIntType c, UIntType m>50bool51operator==(const linear_congruential_engine<UIntType, a, c, m>& x,52           const linear_congruential_engine<UIntType, a, c, m>& y);53 54template <class UIntType, UIntType a, UIntType c, UIntType m>55bool56operator!=(const linear_congruential_engine<UIntType, a, c, m>& x,57           const linear_congruential_engine<UIntType, a, c, m>& y);58 59template <class charT, class traits,60          class UIntType, UIntType a, UIntType c, UIntType m>61basic_ostream<charT, traits>&62operator<<(basic_ostream<charT, traits>& os,63           const linear_congruential_engine<UIntType, a, c, m>& x);64 65template <class charT, class traits,66          class UIntType, UIntType a, UIntType c, UIntType m>67basic_istream<charT, traits>&68operator>>(basic_istream<charT, traits>& is,69           linear_congruential_engine<UIntType, a, c, m>& x);70 71template <class UIntType, size_t w, size_t n, size_t m, size_t r,72          UIntType a, size_t u, UIntType d, size_t s,73          UIntType b, size_t t, UIntType c, size_t l, UIntType f>74class mersenne_twister_engine75{76public:77    // types78    typedef UIntType result_type;79 80    // engine characteristics81    static constexpr size_t word_size = w;82    static constexpr size_t state_size = n;83    static constexpr size_t shift_size = m;84    static constexpr size_t mask_bits = r;85    static constexpr result_type xor_mask = a;86    static constexpr size_t tempering_u = u;87    static constexpr result_type tempering_d = d;88    static constexpr size_t tempering_s = s;89    static constexpr result_type tempering_b = b;90    static constexpr size_t tempering_t = t;91    static constexpr result_type tempering_c = c;92    static constexpr size_t tempering_l = l;93    static constexpr result_type initialization_multiplier = f;94    static constexpr result_type min () { return 0; }95    static constexpr result_type max() { return 2^w - 1; }96    static constexpr result_type default_seed = 5489u;97 98    // constructors and seeding functions99    explicit mersenne_twister_engine(result_type value = default_seed);100    template<class Sseq> explicit mersenne_twister_engine(Sseq& q);101    void seed(result_type value = default_seed);102    template<class Sseq> void seed(Sseq& q);103 104    // generating functions105    result_type operator()();106    void discard(unsigned long long z);107};108 109template <class UIntType, size_t w, size_t n, size_t m, size_t r,110          UIntType a, size_t u, UIntType d, size_t s,111          UIntType b, size_t t, UIntType c, size_t l, UIntType f>112bool113operator==(114    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,115    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);116 117template <class UIntType, size_t w, size_t n, size_t m, size_t r,118          UIntType a, size_t u, UIntType d, size_t s,119          UIntType b, size_t t, UIntType c, size_t l, UIntType f>120bool121operator!=(122    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x,123    const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& y);124 125template <class charT, class traits,126          class UIntType, size_t w, size_t n, size_t m, size_t r,127          UIntType a, size_t u, UIntType d, size_t s,128          UIntType b, size_t t, UIntType c, size_t l, UIntType f>129basic_ostream<charT, traits>&130operator<<(basic_ostream<charT, traits>& os,131           const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);132 133template <class charT, class traits,134          class UIntType, size_t w, size_t n, size_t m, size_t r,135          UIntType a, size_t u, UIntType d, size_t s,136          UIntType b, size_t t, UIntType c, size_t l, UIntType f>137basic_istream<charT, traits>&138operator>>(basic_istream<charT, traits>& is,139           mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);140 141template<class UIntType, size_t w, size_t s, size_t r>142class subtract_with_carry_engine143{144public:145    // types146    typedef UIntType result_type;147 148    // engine characteristics149    static constexpr size_t word_size = w;150    static constexpr size_t short_lag = s;151    static constexpr size_t long_lag = r;152    static constexpr result_type min() { return 0; }153    static constexpr result_type max() { return m-1; }154    static constexpr result_type default_seed = 19780503u;155 156    // constructors and seeding functions157    explicit subtract_with_carry_engine(result_type value = default_seed);158    template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);159    void seed(result_type value = default_seed);160    template<class Sseq> void seed(Sseq& q);161 162    // generating functions163    result_type operator()();164    void discard(unsigned long long z);165};166 167template<class UIntType, size_t w, size_t s, size_t r>168bool169operator==(170    const subtract_with_carry_engine<UIntType, w, s, r>& x,171    const subtract_with_carry_engine<UIntType, w, s, r>& y);172 173template<class UIntType, size_t w, size_t s, size_t r>174bool175operator!=(176    const subtract_with_carry_engine<UIntType, w, s, r>& x,177    const subtract_with_carry_engine<UIntType, w, s, r>& y);178 179template <class charT, class traits,180          class UIntType, size_t w, size_t s, size_t r>181basic_ostream<charT, traits>&182operator<<(basic_ostream<charT, traits>& os,183           const subtract_with_carry_engine<UIntType, w, s, r>& x);184 185template <class charT, class traits,186          class UIntType, size_t w, size_t s, size_t r>187basic_istream<charT, traits>&188operator>>(basic_istream<charT, traits>& is,189           subtract_with_carry_engine<UIntType, w, s, r>& x);190 191template<class Engine, size_t p, size_t r>192class discard_block_engine193{194public:195    // types196    typedef typename Engine::result_type result_type;197 198    // engine characteristics199    static constexpr size_t block_size = p;200    static constexpr size_t used_block = r;201    static constexpr result_type min() { return Engine::min(); }202    static constexpr result_type max() { return Engine::max(); }203 204    // constructors and seeding functions205    discard_block_engine();206    explicit discard_block_engine(const Engine& e);207    explicit discard_block_engine(Engine&& e);208    explicit discard_block_engine(result_type s);209    template<class Sseq> explicit discard_block_engine(Sseq& q);210    void seed();211    void seed(result_type s);212    template<class Sseq> void seed(Sseq& q);213 214    // generating functions215    result_type operator()();216    void discard(unsigned long long z);217 218    // property functions219    const Engine& base() const noexcept;220};221 222template<class Engine, size_t p, size_t r>223bool224operator==(225    const discard_block_engine<Engine, p, r>& x,226    const discard_block_engine<Engine, p, r>& y);227 228template<class Engine, size_t p, size_t r>229bool230operator!=(231    const discard_block_engine<Engine, p, r>& x,232    const discard_block_engine<Engine, p, r>& y);233 234template <class charT, class traits,235          class Engine, size_t p, size_t r>236basic_ostream<charT, traits>&237operator<<(basic_ostream<charT, traits>& os,238           const discard_block_engine<Engine, p, r>& x);239 240template <class charT, class traits,241          class Engine, size_t p, size_t r>242basic_istream<charT, traits>&243operator>>(basic_istream<charT, traits>& is,244           discard_block_engine<Engine, p, r>& x);245 246template<class Engine, size_t w, class UIntType>247class independent_bits_engine248{249public:250    // types251    typedef UIntType result_type;252 253    // engine characteristics254    static constexpr result_type min() { return 0; }255    static constexpr result_type max() { return 2^w - 1; }256 257    // constructors and seeding functions258    independent_bits_engine();259    explicit independent_bits_engine(const Engine& e);260    explicit independent_bits_engine(Engine&& e);261    explicit independent_bits_engine(result_type s);262    template<class Sseq> explicit independent_bits_engine(Sseq& q);263    void seed();264    void seed(result_type s);265    template<class Sseq> void seed(Sseq& q);266 267    // generating functions268    result_type operator()(); void discard(unsigned long long z);269 270    // property functions271    const Engine& base() const noexcept;272};273 274template<class Engine, size_t w, class UIntType>275bool276operator==(277    const independent_bits_engine<Engine, w, UIntType>& x,278    const independent_bits_engine<Engine, w, UIntType>& y);279 280template<class Engine, size_t w, class UIntType>281bool282operator!=(283    const independent_bits_engine<Engine, w, UIntType>& x,284    const independent_bits_engine<Engine, w, UIntType>& y);285 286template <class charT, class traits,287          class Engine, size_t w, class UIntType>288basic_ostream<charT, traits>&289operator<<(basic_ostream<charT, traits>& os,290           const independent_bits_engine<Engine, w, UIntType>& x);291 292template <class charT, class traits,293          class Engine, size_t w, class UIntType>294basic_istream<charT, traits>&295operator>>(basic_istream<charT, traits>& is,296           independent_bits_engine<Engine, w, UIntType>& x);297 298template<class Engine, size_t k>299class shuffle_order_engine300{301public:302    // types303    typedef typename Engine::result_type result_type;304 305    // engine characteristics306    static constexpr size_t table_size = k;307    static constexpr result_type min() { return Engine::min; }308    static constexpr result_type max() { return Engine::max; }309 310    // constructors and seeding functions311    shuffle_order_engine();312    explicit shuffle_order_engine(const Engine& e);313    explicit shuffle_order_engine(Engine&& e);314    explicit shuffle_order_engine(result_type s);315    template<class Sseq> explicit shuffle_order_engine(Sseq& q);316    void seed();317    void seed(result_type s);318    template<class Sseq> void seed(Sseq& q);319 320    // generating functions321    result_type operator()();322    void discard(unsigned long long z);323 324    // property functions325    const Engine& base() const noexcept;326};327 328template<class Engine, size_t k>329bool330operator==(331    const shuffle_order_engine<Engine, k>& x,332    const shuffle_order_engine<Engine, k>& y);333 334template<class Engine, size_t k>335bool336operator!=(337    const shuffle_order_engine<Engine, k>& x,338    const shuffle_order_engine<Engine, k>& y);339 340template <class charT, class traits,341          class Engine, size_t k>342basic_ostream<charT, traits>&343operator<<(basic_ostream<charT, traits>& os,344           const shuffle_order_engine<Engine, k>& x);345 346template <class charT, class traits,347          class Engine, size_t k>348basic_istream<charT, traits>&349operator>>(basic_istream<charT, traits>& is,350           shuffle_order_engine<Engine, k>& x);351 352typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647>353                                                                   minstd_rand0;354typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647>355                                                                    minstd_rand;356typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31,357                                0x9908b0df,358                                11, 0xffffffff,359                                7,  0x9d2c5680,360                                15, 0xefc60000,361                                18, 1812433253>                         mt19937;362typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31,363                                0xb5026f5aa96619e9,364                                29, 0x5555555555555555,365                                17, 0x71d67fffeda60000,366                                37, 0xfff7eee000000000,367                                43, 6364136223846793005>             mt19937_64;368typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24>     ranlux24_base;369typedef subtract_with_carry_engine<uint_fast64_t, 48,  5, 12>     ranlux48_base;370typedef discard_block_engine<ranlux24_base, 223, 23>                   ranlux24;371typedef discard_block_engine<ranlux48_base, 389, 11>                   ranlux48;372typedef shuffle_order_engine<minstd_rand0, 256>                         knuth_b;373typedef minstd_rand                                       default_random_engine;374 375// Generators376 377class random_device378{379public:380    // types381    typedef unsigned int result_type;382 383    // generator characteristics384    static constexpr result_type min() { return numeric_limits<result_type>::min(); }385    static constexpr result_type max() { return numeric_limits<result_type>::max(); }386 387    // constructors388    explicit random_device(const string& token = "/dev/urandom");389 390    // generating functions391    result_type operator()();392 393    // property functions394    double entropy() const noexcept;395 396    // no copy functions397    random_device(const random_device& ) = delete;398    void operator=(const random_device& ) = delete;399};400 401// Utilities402 403class seed_seq404{405public:406    // types407    typedef uint_least32_t result_type;408 409    // constructors410    seed_seq();411    template<class T>412        seed_seq(initializer_list<T> il);413    template<class InputIterator>414        seed_seq(InputIterator begin, InputIterator end);415 416    // generating functions417    template<class RandomAccessIterator>418        void generate(RandomAccessIterator begin, RandomAccessIterator end);419 420    // property functions421    size_t size() const;422    template<class OutputIterator>423        void param(OutputIterator dest) const;424 425    // no copy functions426    seed_seq(const seed_seq&) = delete;427    void operator=(const seed_seq& ) = delete;428};429 430template<class RealType, size_t bits, class URNG>431    RealType generate_canonical(URNG& g);432 433// Distributions434 435template<class IntType = int>436class uniform_int_distribution437{438public:439    // types440    typedef IntType result_type;441 442    class param_type443    {444    public:445        typedef uniform_int_distribution distribution_type;446 447        explicit param_type(IntType a = 0,448                                    IntType b = numeric_limits<IntType>::max());449 450        result_type a() const;451        result_type b() const;452 453        friend bool operator==(const param_type& x, const param_type& y);454        friend bool operator!=(const param_type& x, const param_type& y);455    };456 457    // constructors and reset functions458    explicit uniform_int_distribution(IntType a = 0,459                                    IntType b = numeric_limits<IntType>::max());460    explicit uniform_int_distribution(const param_type& parm);461    void reset();462 463    // generating functions464    template<class URNG> result_type operator()(URNG& g);465    template<class URNG> result_type operator()(URNG& g, const param_type& parm);466 467    // property functions468    result_type a() const;469    result_type b() const;470 471    param_type param() const;472    void param(const param_type& parm);473 474    result_type min() const;475    result_type max() const;476 477    friend bool operator==(const uniform_int_distribution& x,478                           const uniform_int_distribution& y);479    friend bool operator!=(const uniform_int_distribution& x,480                           const uniform_int_distribution& y);481 482    template <class charT, class traits>483    friend484    basic_ostream<charT, traits>&485    operator<<(basic_ostream<charT, traits>& os,486               const uniform_int_distribution& x);487 488    template <class charT, class traits>489    friend490    basic_istream<charT, traits>&491    operator>>(basic_istream<charT, traits>& is,492               uniform_int_distribution& x);493};494 495template<class RealType = double>496class uniform_real_distribution497{498public:499    // types500    typedef RealType result_type;501 502    class param_type503    {504    public:505        typedef uniform_real_distribution distribution_type;506 507        explicit param_type(RealType a = 0,508                            RealType b = 1);509 510        result_type a() const;511        result_type b() const;512 513        friend bool operator==(const param_type& x, const param_type& y);514        friend bool operator!=(const param_type& x, const param_type& y);515    };516 517    // constructors and reset functions518    explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0);519    explicit uniform_real_distribution(const param_type& parm);520    void reset();521 522    // generating functions523    template<class URNG> result_type operator()(URNG& g);524    template<class URNG> result_type operator()(URNG& g, const param_type& parm);525 526    // property functions527    result_type a() const;528    result_type b() const;529 530    param_type param() const;531    void param(const param_type& parm);532 533    result_type min() const;534    result_type max() const;535 536    friend bool operator==(const uniform_real_distribution& x,537                           const uniform_real_distribution& y);538    friend bool operator!=(const uniform_real_distribution& x,539                           const uniform_real_distribution& y);540 541    template <class charT, class traits>542    friend543    basic_ostream<charT, traits>&544    operator<<(basic_ostream<charT, traits>& os,545               const uniform_real_distribution& x);546 547    template <class charT, class traits>548    friend549    basic_istream<charT, traits>&550    operator>>(basic_istream<charT, traits>& is,551               uniform_real_distribution& x);552};553 554class bernoulli_distribution555{556public:557    // types558    typedef bool result_type;559 560    class param_type561    {562    public:563        typedef bernoulli_distribution distribution_type;564 565        explicit param_type(double p = 0.5);566 567        double p() const;568 569        friend bool operator==(const param_type& x, const param_type& y);570        friend bool operator!=(const param_type& x, const param_type& y);571    };572 573    // constructors and reset functions574    explicit bernoulli_distribution(double p = 0.5);575    explicit bernoulli_distribution(const param_type& parm);576    void reset();577 578    // generating functions579    template<class URNG> result_type operator()(URNG& g);580    template<class URNG> result_type operator()(URNG& g, const param_type& parm);581 582    // property functions583    double p() const;584 585    param_type param() const;586    void param(const param_type& parm);587 588    result_type min() const;589    result_type max() const;590 591    friend bool operator==(const bernoulli_distribution& x,592                           const bernoulli_distribution& y);593    friend bool operator!=(const bernoulli_distribution& x,594                           const bernoulli_distribution& y);595 596    template <class charT, class traits>597    friend598    basic_ostream<charT, traits>&599    operator<<(basic_ostream<charT, traits>& os,600               const bernoulli_distribution& x);601 602    template <class charT, class traits>603    friend604    basic_istream<charT, traits>&605    operator>>(basic_istream<charT, traits>& is,606               bernoulli_distribution& x);607};608 609template<class IntType = int>610class binomial_distribution611{612public:613    // types614    typedef IntType result_type;615 616    class param_type617    {618    public:619        typedef binomial_distribution distribution_type;620 621        explicit param_type(IntType t = 1, double p = 0.5);622 623        IntType t() const;624        double p() const;625 626        friend bool operator==(const param_type& x, const param_type& y);627        friend bool operator!=(const param_type& x, const param_type& y);628    };629 630    // constructors and reset functions631    explicit binomial_distribution(IntType t = 1, double p = 0.5);632    explicit binomial_distribution(const param_type& parm);633    void reset();634 635    // generating functions636    template<class URNG> result_type operator()(URNG& g);637    template<class URNG> result_type operator()(URNG& g, const param_type& parm);638 639    // property functions640    IntType t() const;641    double p() const;642 643    param_type param() const;644    void param(const param_type& parm);645 646    result_type min() const;647    result_type max() const;648 649    friend bool operator==(const binomial_distribution& x,650                           const binomial_distribution& y);651    friend bool operator!=(const binomial_distribution& x,652                           const binomial_distribution& y);653 654    template <class charT, class traits>655    friend656    basic_ostream<charT, traits>&657    operator<<(basic_ostream<charT, traits>& os,658               const binomial_distribution& x);659 660    template <class charT, class traits>661    friend662    basic_istream<charT, traits>&663    operator>>(basic_istream<charT, traits>& is,664               binomial_distribution& x);665};666 667template<class IntType = int>668class geometric_distribution669{670public:671    // types672    typedef IntType result_type;673 674    class param_type675    {676    public:677        typedef geometric_distribution distribution_type;678 679        explicit param_type(double p = 0.5);680 681        double p() const;682 683        friend bool operator==(const param_type& x, const param_type& y);684        friend bool operator!=(const param_type& x, const param_type& y);685    };686 687    // constructors and reset functions688    explicit geometric_distribution(double p = 0.5);689    explicit geometric_distribution(const param_type& parm);690    void reset();691 692    // generating functions693    template<class URNG> result_type operator()(URNG& g);694    template<class URNG> result_type operator()(URNG& g, const param_type& parm);695 696    // property functions697    double p() const;698 699    param_type param() const;700    void param(const param_type& parm);701 702    result_type min() const;703    result_type max() const;704 705    friend bool operator==(const geometric_distribution& x,706                           const geometric_distribution& y);707    friend bool operator!=(const geometric_distribution& x,708                           const geometric_distribution& y);709 710    template <class charT, class traits>711    friend712    basic_ostream<charT, traits>&713    operator<<(basic_ostream<charT, traits>& os,714               const geometric_distribution& x);715 716    template <class charT, class traits>717    friend718    basic_istream<charT, traits>&719    operator>>(basic_istream<charT, traits>& is,720               geometric_distribution& x);721};722 723template<class IntType = int>724class negative_binomial_distribution725{726public:727    // types728    typedef IntType result_type;729 730    class param_type731    {732    public:733        typedef negative_binomial_distribution distribution_type;734 735        explicit param_type(result_type k = 1, double p = 0.5);736 737        result_type k() const;738        double p() const;739 740        friend bool operator==(const param_type& x, const param_type& y);741        friend bool operator!=(const param_type& x, const param_type& y);742    };743 744    // constructor and reset functions745    explicit negative_binomial_distribution(result_type k = 1, double p = 0.5);746    explicit negative_binomial_distribution(const param_type& parm);747    void reset();748 749    // generating functions750    template<class URNG> result_type operator()(URNG& g);751    template<class URNG> result_type operator()(URNG& g, const param_type& parm);752 753    // property functions754    result_type k() const;755    double p() const;756 757    param_type param() const;758    void param(const param_type& parm);759 760    result_type min() const;761    result_type max() const;762 763    friend bool operator==(const negative_binomial_distribution& x,764                           const negative_binomial_distribution& y);765    friend bool operator!=(const negative_binomial_distribution& x,766                           const negative_binomial_distribution& y);767 768    template <class charT, class traits>769    friend770    basic_ostream<charT, traits>&771    operator<<(basic_ostream<charT, traits>& os,772               const negative_binomial_distribution& x);773 774    template <class charT, class traits>775    friend776    basic_istream<charT, traits>&777    operator>>(basic_istream<charT, traits>& is,778               negative_binomial_distribution& x);779};780 781template<class IntType = int>782class poisson_distribution783{784public:785    // types786    typedef IntType result_type;787 788    class param_type789    {790    public:791        typedef poisson_distribution distribution_type;792 793        explicit param_type(double mean = 1.0);794 795        double mean() const;796 797        friend bool operator==(const param_type& x, const param_type& y);798        friend bool operator!=(const param_type& x, const param_type& y);799    };800 801    // constructors and reset functions802    explicit poisson_distribution(double mean = 1.0);803    explicit poisson_distribution(const param_type& parm);804    void reset();805 806    // generating functions807    template<class URNG> result_type operator()(URNG& g);808    template<class URNG> result_type operator()(URNG& g, const param_type& parm);809 810    // property functions811    double mean() const;812 813    param_type param() const;814    void param(const param_type& parm);815 816    result_type min() const;817    result_type max() const;818 819    friend bool operator==(const poisson_distribution& x,820                           const poisson_distribution& y);821    friend bool operator!=(const poisson_distribution& x,822                           const poisson_distribution& y);823 824    template <class charT, class traits>825    friend826    basic_ostream<charT, traits>&827    operator<<(basic_ostream<charT, traits>& os,828               const poisson_distribution& x);829 830    template <class charT, class traits>831    friend832    basic_istream<charT, traits>&833    operator>>(basic_istream<charT, traits>& is,834               poisson_distribution& x);835};836 837template<class RealType = double>838class exponential_distribution839{840public:841    // types842    typedef RealType result_type;843 844    class param_type845    {846    public:847        typedef exponential_distribution distribution_type;848 849        explicit param_type(result_type lambda = 1.0);850 851        result_type lambda() const;852 853        friend bool operator==(const param_type& x, const param_type& y);854        friend bool operator!=(const param_type& x, const param_type& y);855    };856 857    // constructors and reset functions858    explicit exponential_distribution(result_type lambda = 1.0);859    explicit exponential_distribution(const param_type& parm);860    void reset();861 862    // generating functions863    template<class URNG> result_type operator()(URNG& g);864    template<class URNG> result_type operator()(URNG& g, const param_type& parm);865 866    // property functions867    result_type lambda() const;868 869    param_type param() const;870    void param(const param_type& parm);871 872    result_type min() const;873    result_type max() const;874 875    friend bool operator==(const exponential_distribution& x,876                           const exponential_distribution& y);877    friend bool operator!=(const exponential_distribution& x,878                           const exponential_distribution& y);879 880    template <class charT, class traits>881    friend882    basic_ostream<charT, traits>&883    operator<<(basic_ostream<charT, traits>& os,884               const exponential_distribution& x);885 886    template <class charT, class traits>887    friend888    basic_istream<charT, traits>&889    operator>>(basic_istream<charT, traits>& is,890               exponential_distribution& x);891};892 893template<class RealType = double>894class gamma_distribution895{896public:897    // types898    typedef RealType result_type;899 900    class param_type901    {902    public:903        typedef gamma_distribution distribution_type;904 905        explicit param_type(result_type alpha = 1, result_type beta = 1);906 907        result_type alpha() const;908        result_type beta() const;909 910        friend bool operator==(const param_type& x, const param_type& y);911        friend bool operator!=(const param_type& x, const param_type& y);912    };913 914    // constructors and reset functions915    explicit gamma_distribution(result_type alpha = 1, result_type beta = 1);916    explicit gamma_distribution(const param_type& parm);917    void reset();918 919    // generating functions920    template<class URNG> result_type operator()(URNG& g);921    template<class URNG> result_type operator()(URNG& g, const param_type& parm);922 923    // property functions924    result_type alpha() const;925    result_type beta() const;926 927    param_type param() const;928    void param(const param_type& parm);929 930    result_type min() const;931    result_type max() const;932 933    friend bool operator==(const gamma_distribution& x,934                           const gamma_distribution& y);935    friend bool operator!=(const gamma_distribution& x,936                           const gamma_distribution& y);937 938    template <class charT, class traits>939    friend940    basic_ostream<charT, traits>&941    operator<<(basic_ostream<charT, traits>& os,942               const gamma_distribution& x);943 944    template <class charT, class traits>945    friend946    basic_istream<charT, traits>&947    operator>>(basic_istream<charT, traits>& is,948               gamma_distribution& x);949};950 951template<class RealType = double>952class weibull_distribution953{954public:955    // types956    typedef RealType result_type;957 958    class param_type959    {960    public:961        typedef weibull_distribution distribution_type;962 963        explicit param_type(result_type alpha = 1, result_type beta = 1);964 965        result_type a() const;966        result_type b() const;967 968        friend bool operator==(const param_type& x, const param_type& y);969        friend bool operator!=(const param_type& x, const param_type& y);970    };971 972    // constructor and reset functions973    explicit weibull_distribution(result_type a = 1, result_type b = 1);974    explicit weibull_distribution(const param_type& parm);975    void reset();976 977    // generating functions978    template<class URNG> result_type operator()(URNG& g);979    template<class URNG> result_type operator()(URNG& g, const param_type& parm);980 981    // property functions982    result_type a() const;983    result_type b() const;984 985    param_type param() const;986    void param(const param_type& parm);987 988    result_type min() const;989    result_type max() const;990 991    friend bool operator==(const weibull_distribution& x,992                           const weibull_distribution& y);993    friend bool operator!=(const weibull_distribution& x,994                           const weibull_distribution& y);995 996    template <class charT, class traits>997    friend998    basic_ostream<charT, traits>&999    operator<<(basic_ostream<charT, traits>& os,1000               const weibull_distribution& x);1001 1002    template <class charT, class traits>1003    friend1004    basic_istream<charT, traits>&1005    operator>>(basic_istream<charT, traits>& is,1006               weibull_distribution& x);1007};1008 1009template<class RealType = double>1010class extreme_value_distribution1011{1012public:1013    // types1014    typedef RealType result_type;1015 1016    class param_type1017    {1018    public:1019        typedef extreme_value_distribution distribution_type;1020 1021        explicit param_type(result_type a = 0, result_type b = 1);1022 1023        result_type a() const;1024        result_type b() const;1025 1026        friend bool operator==(const param_type& x, const param_type& y);1027        friend bool operator!=(const param_type& x, const param_type& y);1028    };1029 1030    // constructor and reset functions1031    explicit extreme_value_distribution(result_type a = 0, result_type b = 1);1032    explicit extreme_value_distribution(const param_type& parm);1033    void reset();1034 1035    // generating functions1036    template<class URNG> result_type operator()(URNG& g);1037    template<class URNG> result_type operator()(URNG& g, const param_type& parm);1038 1039    // property functions1040    result_type a() const;1041    result_type b() const;1042 1043    param_type param() const;1044    void param(const param_type& parm);1045 1046    result_type min() const;1047    result_type max() const;1048 1049    friend bool operator==(const extreme_value_distribution& x,1050                           const extreme_value_distribution& y);1051    friend bool operator!=(const extreme_value_distribution& x,1052                           const extreme_value_distribution& y);1053 1054    template <class charT, class traits>1055    friend1056    basic_ostream<charT, traits>&1057    operator<<(basic_ostream<charT, traits>& os,1058               const extreme_value_distribution& x);1059 1060    template <class charT, class traits>1061    friend1062    basic_istream<charT, traits>&1063    operator>>(basic_istream<charT, traits>& is,1064               extreme_value_distribution& x);1065};1066 1067template<class RealType = double>1068class normal_distribution1069{1070public:1071    // types1072    typedef RealType result_type;1073 1074    class param_type1075    {1076    public:1077        typedef normal_distribution distribution_type;1078 1079        explicit param_type(result_type mean = 0, result_type stddev = 1);1080 1081        result_type mean() const;1082        result_type stddev() const;1083 1084        friend bool operator==(const param_type& x, const param_type& y);1085        friend bool operator!=(const param_type& x, const param_type& y);1086    };1087 1088    // constructors and reset functions1089    explicit normal_distribution(result_type mean = 0, result_type stddev = 1);1090    explicit normal_distribution(const param_type& parm);1091    void reset();1092 1093    // generating functions1094    template<class URNG> result_type operator()(URNG& g);1095    template<class URNG> result_type operator()(URNG& g, const param_type& parm);1096 1097    // property functions1098    result_type mean() const;1099    result_type stddev() const;1100 1101    param_type param() const;1102    void param(const param_type& parm);1103 1104    result_type min() const;1105    result_type max() const;1106 1107    friend bool operator==(const normal_distribution& x,1108                           const normal_distribution& y);1109    friend bool operator!=(const normal_distribution& x,1110                           const normal_distribution& y);1111 1112    template <class charT, class traits>1113    friend1114    basic_ostream<charT, traits>&1115    operator<<(basic_ostream<charT, traits>& os,1116               const normal_distribution& x);1117 1118    template <class charT, class traits>1119    friend1120    basic_istream<charT, traits>&1121    operator>>(basic_istream<charT, traits>& is,1122               normal_distribution& x);1123};1124 1125template<class RealType = double>1126class lognormal_distribution1127{1128public:1129    // types1130    typedef RealType result_type;1131 1132    class param_type1133    {1134    public:1135        typedef lognormal_distribution distribution_type;1136 1137        explicit param_type(result_type m = 0, result_type s = 1);1138 1139        result_type m() const;1140        result_type s() const;1141 1142        friend bool operator==(const param_type& x, const param_type& y);1143        friend bool operator!=(const param_type& x, const param_type& y);1144    };1145 1146    // constructor and reset functions1147    explicit lognormal_distribution(result_type m = 0, result_type s = 1);1148    explicit lognormal_distribution(const param_type& parm);1149    void reset();1150 1151    // generating functions1152    template<class URNG> result_type operator()(URNG& g);1153    template<class URNG> result_type operator()(URNG& g, const param_type& parm);1154 1155    // property functions1156    result_type m() const;1157    result_type s() const;1158 1159    param_type param() const;1160    void param(const param_type& parm);1161 1162    result_type min() const;1163    result_type max() const;1164 1165    friend bool operator==(const lognormal_distribution& x,1166                           const lognormal_distribution& y);1167    friend bool operator!=(const lognormal_distribution& x,1168                           const lognormal_distribution& y);1169 1170    template <class charT, class traits>1171    friend1172    basic_ostream<charT, traits>&1173    operator<<(basic_ostream<charT, traits>& os,1174               const lognormal_distribution& x);1175 1176    template <class charT, class traits>1177    friend1178    basic_istream<charT, traits>&1179    operator>>(basic_istream<charT, traits>& is,1180               lognormal_distribution& x);1181};1182 1183template<class RealType = double>1184class chi_squared_distribution1185{1186public:1187    // types1188    typedef RealType result_type;1189 1190    class param_type1191    {1192    public:1193        typedef chi_squared_distribution distribution_type;1194 1195        explicit param_type(result_type n = 1);1196 1197        result_type n() const;1198 1199        friend bool operator==(const param_type& x, const param_type& y);1200        friend bool operator!=(const param_type& x, const param_type& y);

Showing the first 1,200 of 6706 lines. Download the file for the rest.

codekingpro/portable-devtools · Team Ai