• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4<title>Function random</title>
5<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7<link rel="home" href="../../../index.html" title="Boost.Test">
8<link rel="up" href="../../../header/boost/test/data/monomorphic/generators/random_hpp.html" title="Header &lt;boost/test/data/monomorphic/generators/random.hpp&gt;">
9<link rel="prev" href="monomorphic/random_t.html" title="Class template random_t">
10<link rel="next" href="../../../header/boost/test/data/monomorphic/generators/xrange_hpp.html" title="Header &lt;boost/test/data/monomorphic/generators/xrange.hpp&gt;">
11</head>
12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13<table cellpadding="2" width="100%"><tr>
14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
15<td align="center"><a href="../../../../../../../index.html">Home</a></td>
16<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
20</tr></table>
21<hr>
22<div class="spirit-nav">
23<a accesskey="p" href="monomorphic/random_t.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/test/data/monomorphic/generators/random_hpp.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../../header/boost/test/data/monomorphic/generators/xrange_hpp.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
24</div>
25<div class="refentry">
26<a name="boost.unit_test.data.random"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Function random</span></h2>
29<p>boost::unit_test::data::random — Returns an infinite sequence of random numbers. </p>
30</div>
31<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../header/boost/test/data/monomorphic/generators/random_hpp.html" title="Header &lt;boost/test/data/monomorphic/generators/random.hpp&gt;">boost/test/data/monomorphic/generators/random.hpp</a>&gt;
33
34</span>
35<a class="link" href="monomorphic/generated_by.html" title="Class template generated_by">monomorphic::generated_by</a><span class="special">&lt;</span> <a class="link" href="monomorphic/random_t.html" title="Class template random_t">monomorphic::random_t</a><span class="special">&lt;</span><span class="special">&gt;</span> <span class="special">&gt;</span> <span class="identifier">random</span><span class="special">(</span><span class="special">)</span><span class="special">;</span>
36<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> SampleType<span class="special">&gt;</span>
37  <a class="link" href="monomorphic/generated_by.html" title="Class template generated_by">monomorphic::generated_by</a><span class="special">&lt;</span> <a class="link" href="monomorphic/random_t.html" title="Class template random_t">monomorphic::random_t</a><span class="special">&lt;</span> <span class="identifier">SampleType</span> <span class="special">&gt;</span> <span class="special">&gt;</span>
38  <span class="identifier">random</span><span class="special">(</span><span class="identifier">SampleType</span> begin<span class="special">,</span> <span class="identifier">SampleType</span> end<span class="special">)</span><span class="special">;</span>
39<span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Params<span class="special">&gt;</span> <span class="emphasis"><em><span class="identifier">unspecified</span></em></span> <span class="identifier">random</span><span class="special">(</span><span class="identifier">Params</span> <span class="keyword">const</span> <span class="special">&amp;</span> params<span class="special">)</span><span class="special">;</span></pre></div>
40<div class="refsect1">
41<a name="idm46175622714864"></a><h2>Description</h2>
42<p>The following overloads are available: </p>
43<pre class="programlisting"><span class="keyword">auto</span> <span class="identifier">d</span> <span class="special">=</span> <span class="identifier">random</span><span class="special">(</span><span class="special">)</span><span class="special">;</span>
44<span class="keyword">auto</span> <span class="identifier">d</span> <span class="special">=</span> <span class="identifier">random</span><span class="special">(</span><span class="identifier">begin</span><span class="special">,</span> <span class="identifier">end</span><span class="special">)</span><span class="special">;</span>
45<span class="keyword">auto</span> <span class="identifier">d</span> <span class="special">=</span> <span class="identifier">random</span><span class="special">(</span><span class="identifier">params</span><span class="special">)</span><span class="special">;</span>
46</pre>
47<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
48<li class="listitem"><p>The first overload uses the default distribution, which is uniform and which elements are <code class="computeroutput">double</code> type (the values are in [0, 1) ).</p></li>
49<li class="listitem"><p>The second overload generates numbers in the given interval. The distribution is uniform (in [begin, end) for real numbers, and in [begin, end] for integers). The type of the distribution is deduced from the type of the <code class="computeroutput">begin</code> and <code class="computeroutput">end</code> parameters.</p></li>
50<li class="listitem">
51<p>The third overload generates numbers using the named parameter inside <code class="computeroutput">params</code> , which are:</p>
52<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; ">
53<li class="listitem"><p><code class="computeroutput">distribution:</code> the distribution used. In this overload, since the type of the samples cannot be deduced, the samples are of type <code class="computeroutput">double</code> and the distribution is uniform real in [0, 1).</p></li>
54<li class="listitem"><p><code class="computeroutput">seed:</code> the seed for generating the values</p></li>
55<li class="listitem"><p><code class="computeroutput">engine:</code> the random number generator engine</p></li>
56</ul></div>
57<p>
58</p>
59</li>
60</ul></div>
61<p>
62</p>
63<p>The function returns an object that implements the dataset API. </p>
64<div class="note"><table border="0" summary="Note">
65<tr>
66<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../../../../doc/src/images/note.png"></td>
67<th align="left">Note</th>
68</tr>
69<tr><td align="left" valign="top"><p>This function is available only for C++11 capable compilers. </p></td></tr>
70</table></div>
71<p>
72</p>
73</div>
74</div>
75<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
76<td align="left"></td>
77<td align="right"><div class="copyright-footer">Copyright © 2001-2020 Boost.Test contributors<p>
78        Distributed under the Boost Software License, Version 1.0. (See accompanying
79        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
80      </p>
81</div></td>
82</tr></table>
83<hr>
84<div class="spirit-nav">
85<a accesskey="p" href="monomorphic/random_t.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../header/boost/test/data/monomorphic/generators/random_hpp.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../../header/boost/test/data/monomorphic/generators/xrange_hpp.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
86</div>
87</body>
88</html>
89