2010-05-19 01:53:57 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2010-11-16 22:09:02 +00:00
|
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
|
|
// Source Licenses. See LICENSE.TXT for details.
|
2010-05-19 01:53:57 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// <random>
|
|
|
|
|
|
|
|
// template<class IntType = int>
|
|
|
|
// class discrete_distribution
|
|
|
|
|
|
|
|
// result_type max() const;
|
|
|
|
|
|
|
|
#include <random>
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
typedef std::discrete_distribution<> D;
|
|
|
|
double p0[] = {.3, .1, .6};
|
|
|
|
D d(p0, p0+3);
|
|
|
|
assert(d.max() == 2);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
typedef std::discrete_distribution<> D;
|
|
|
|
double p0[] = {.3, .1, .6, .2};
|
|
|
|
D d(p0, p0+4);
|
|
|
|
assert(d.max() == 3);
|
|
|
|
}
|
|
|
|
}
|