http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d1b3113a/commons-rng-core/site-content/.svn/pristine/3e/3ec534f9bb4bba36fa59fc27d127de712f0e1d17.svn-base ---------------------------------------------------------------------- diff --git a/commons-rng-core/site-content/.svn/pristine/3e/3ec534f9bb4bba36fa59fc27d127de712f0e1d17.svn-base b/commons-rng-core/site-content/.svn/pristine/3e/3ec534f9bb4bba36fa59fc27d127de712f0e1d17.svn-base new file mode 100644 index 0000000..8a1cca0 --- /dev/null +++ b/commons-rng-core/site-content/.svn/pristine/3e/3ec534f9bb4bba36fa59fc27d127de712f0e1d17.svn-base @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>Well44497b.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Commons Rng</a> > <a href="index.source.html" class="el_package">org.apache.commons.rng.internal.source32</a> > <span class="el_source">Well44497b.java</span>< /div><h1>Well44497b.java</h1><pre class="source lang-java linenums">/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.rng.internal.source32; + +/** + * This class implements the WELL44497b pseudo-random number generator + * from Fran&ccedil;ois Panneton, Pierre L'Ecuyer and Makoto Matsumoto. + * <p> + * This generator is described in a paper by Fran&ccedil;ois Panneton, + * Pierre L'Ecuyer and Makoto Matsumoto + * <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng.pdf"> + * Improved Long-Period Generators Based on Linear Recurrences Modulo 2</a> + * ACM Transactions on Mathematical Software, 32, 1 (2006). + * The errata for the paper are in + * <a href="http://www.iro.umontreal.ca/~lecuyer/myftp/papers/wellrng-errata.txt">wellrng-errata.txt</a>. + * </p> + * + * @see <a href="http://www.iro.umontreal.ca/~panneton/WELLRNG.html">WELL Random number generator</a> + * @since 1.0 + */ +public class Well44497b extends Well44497a { + /** + * Creates a new random number generator. + * + * @param seed Initial seed. + */ + public Well44497b(int[] seed) { +<span class="fc" id="L42"> super(seed);</span> +<span class="fc" id="L43"> }</span> + + /** {@inheritDoc} */ + @Override + public int next() { +<span class="fc" id="L48"> int z4 = super.next();</span> + + // Matsumoto-Kurita tempering to get a maximally equidistributed generator. +<span class="fc" id="L51"> z4 ^= (z4 << 7) & 0x93dd1400;</span> +<span class="fc" id="L52"> z4 ^= (z4 << 15) & 0xfa118000;</span> + +<span class="fc" id="L54"> return z4;</span> + } +} +</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.5.201505241946</span></div></body></html> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d1b3113a/commons-rng-core/site-content/.svn/pristine/3e/3ef0185bc05d7d15455cc5d4fb895d58e1b3be22.svn-base ---------------------------------------------------------------------- diff --git a/commons-rng-core/site-content/.svn/pristine/3e/3ef0185bc05d7d15455cc5d4fb895d58e1b3be22.svn-base b/commons-rng-core/site-content/.svn/pristine/3e/3ef0185bc05d7d15455cc5d4fb895d58e1b3be22.svn-base new file mode 100644 index 0000000..fa4a10d --- /dev/null +++ b/commons-rng-core/site-content/.svn/pristine/3e/3ef0185bc05d7d15455cc5d4fb895d58e1b3be22.svn-base @@ -0,0 +1,54 @@ + +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xml:lang="en" lang="en"> + <head> + <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> + <title>Apache Commons Rng 1.0-SNAPSHOT Reference Package org.apache.commons.rng.internal.source32</title> + <link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="style" /> + </head> + <body> + + <h3> + <a href="package-summary.html" target="classFrame">org.apache.commons.rng.internal.source32</a> + </h3> + + <h3>Classes</h3> + + <ul> + <li> + <a href="ISAACRandomTest.html" target="classFrame">ISAACRandomTest</a> + </li> + <li> + <a href="JDKRandomTest.html" target="classFrame">JDKRandomTest</a> + </li> + <li> + <a href="KISSRandomTest.html" target="classFrame">KISSRandomTest</a> + </li> + <li> + <a href="MersenneTwisterTest.html" target="classFrame">MersenneTwisterTest</a> + </li> + <li> + <a href="MultiplyWithCarry256Test.html" target="classFrame">MultiplyWithCarry256Test</a> + </li> + <li> + <a href="Well1024aTest.html" target="classFrame">Well1024aTest</a> + </li> + <li> + <a href="Well19937aTest.html" target="classFrame">Well19937aTest</a> + </li> + <li> + <a href="Well19937cTest.html" target="classFrame">Well19937cTest</a> + </li> + <li> + <a href="Well44497aTest.html" target="classFrame">Well44497aTest</a> + </li> + <li> + <a href="Well44497bTest.html" target="classFrame">Well44497bTest</a> + </li> + <li> + <a href="Well512aTest.html" target="classFrame">Well512aTest</a> + </li> + </ul> + + </body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d1b3113a/commons-rng-core/site-content/.svn/pristine/3f/3f59fee2e85d37199a19a9151d7d1fae28f2e4ee.svn-base ---------------------------------------------------------------------- diff --git a/commons-rng-core/site-content/.svn/pristine/3f/3f59fee2e85d37199a19a9151d7d1fae28f2e4ee.svn-base b/commons-rng-core/site-content/.svn/pristine/3f/3f59fee2e85d37199a19a9151d7d1fae28f2e4ee.svn-base new file mode 100644 index 0000000..d59ab20 --- /dev/null +++ b/commons-rng-core/site-content/.svn/pristine/3f/3f59fee2e85d37199a19a9151d7d1fae28f2e4ee.svn-base @@ -0,0 +1,172 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head><meta http-equiv="content-type" content="text/html; charset=UTF-8" /> +<title>ProvidersList xref</title> +<link type="text/css" rel="stylesheet" href="../../../../stylesheet.css" /> +</head> +<body> +<div id="overview"><a href="../../../../../testapidocs/org/apache/commons/rng/ProvidersList.html">View Javadoc</a></div><pre> +<a class="jxr_linenumber" name="L1" href="#L1">1</a> <em class="jxr_comment">/*</em> +<a class="jxr_linenumber" name="L2" href="#L2">2</a> <em class="jxr_comment"> * Licensed to the Apache Software Foundation (ASF) under one or more</em> +<a class="jxr_linenumber" name="L3" href="#L3">3</a> <em class="jxr_comment"> * contributor license agreements. See the NOTICE file distributed with</em> +<a class="jxr_linenumber" name="L4" href="#L4">4</a> <em class="jxr_comment"> * this work for additional information regarding copyright ownership.</em> +<a class="jxr_linenumber" name="L5" href="#L5">5</a> <em class="jxr_comment"> * The ASF licenses this file to You under the Apache License, Version 2.0</em> +<a class="jxr_linenumber" name="L6" href="#L6">6</a> <em class="jxr_comment"> * (the "License"); you may not use this file except in compliance with</em> +<a class="jxr_linenumber" name="L7" href="#L7">7</a> <em class="jxr_comment"> * the License. You may obtain a copy of the License at</em> +<a class="jxr_linenumber" name="L8" href="#L8">8</a> <em class="jxr_comment"> *</em> +<a class="jxr_linenumber" name="L9" href="#L9">9</a> <em class="jxr_comment"> * <a href="http://www.apache.org/licenses/LICENSE-2." target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.</a>0</em> +<a class="jxr_linenumber" name="L10" href="#L10">10</a> <em class="jxr_comment"> *</em> +<a class="jxr_linenumber" name="L11" href="#L11">11</a> <em class="jxr_comment"> * Unless required by applicable law or agreed to in writing, software</em> +<a class="jxr_linenumber" name="L12" href="#L12">12</a> <em class="jxr_comment"> * distributed under the License is distributed on an "AS IS" BASIS,</em> +<a class="jxr_linenumber" name="L13" href="#L13">13</a> <em class="jxr_comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</em> +<a class="jxr_linenumber" name="L14" href="#L14">14</a> <em class="jxr_comment"> * See the License for the specific language governing permissions and</em> +<a class="jxr_linenumber" name="L15" href="#L15">15</a> <em class="jxr_comment"> * limitations under the License.</em> +<a class="jxr_linenumber" name="L16" href="#L16">16</a> <em class="jxr_comment"> */</em> +<a class="jxr_linenumber" name="L17" href="#L17">17</a> <strong class="jxr_keyword">package</strong> org.apache.commons.rng; +<a class="jxr_linenumber" name="L18" href="#L18">18</a> +<a class="jxr_linenumber" name="L19" href="#L19">19</a> <strong class="jxr_keyword">import</strong> java.util.Arrays; +<a class="jxr_linenumber" name="L20" href="#L20">20</a> <strong class="jxr_keyword">import</strong> java.util.List; +<a class="jxr_linenumber" name="L21" href="#L21">21</a> <strong class="jxr_keyword">import</strong> java.util.ArrayList; +<a class="jxr_linenumber" name="L22" href="#L22">22</a> <strong class="jxr_keyword">import</strong> java.util.Collections; +<a class="jxr_linenumber" name="L23" href="#L23">23</a> +<a class="jxr_linenumber" name="L24" href="#L24">24</a> <em class="jxr_javadoccomment">/**</em> +<a class="jxr_linenumber" name="L25" href="#L25">25</a> <em class="jxr_javadoccomment"> * The purpose of this class is to provide the list of all generators</em> +<a class="jxr_linenumber" name="L26" href="#L26">26</a> <em class="jxr_javadoccomment"> * implemented in the library.</em> +<a class="jxr_linenumber" name="L27" href="#L27">27</a> <em class="jxr_javadoccomment"> * The list must be updated with each new RNG implementation.</em> +<a class="jxr_linenumber" name="L28" href="#L28">28</a> <em class="jxr_javadoccomment"> *</em> +<a class="jxr_linenumber" name="L29" href="#L29">29</a> <em class="jxr_javadoccomment"> * @see #list()</em> +<a class="jxr_linenumber" name="L30" href="#L30">30</a> <em class="jxr_javadoccomment"> * @see #list32()</em> +<a class="jxr_linenumber" name="L31" href="#L31">31</a> <em class="jxr_javadoccomment"> * @see #list64()</em> +<a class="jxr_linenumber" name="L32" href="#L32">32</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L33" href="#L33">33</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../org/apache/commons/rng/ProvidersList.html">ProvidersList</a> { +<a class="jxr_linenumber" name="L34" href="#L34">34</a> <em class="jxr_javadoccomment">/** List of all RNGs implemented in the library. */</em> +<a class="jxr_linenumber" name="L35" href="#L35">35</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> List<Data[]> LIST = <strong class="jxr_keyword">new</strong> ArrayList<Data[]>(); +<a class="jxr_linenumber" name="L36" href="#L36">36</a> <em class="jxr_javadoccomment">/** List of 32-bits based RNGs. */</em> +<a class="jxr_linenumber" name="L37" href="#L37">37</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> List<Data[]> LIST32 = <strong class="jxr_keyword">new</strong> ArrayList<Data[]>(); +<a class="jxr_linenumber" name="L38" href="#L38">38</a> <em class="jxr_javadoccomment">/** List of 64-bits based RNGs. */</em> +<a class="jxr_linenumber" name="L39" href="#L39">39</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> List<Data[]> LIST64 = <strong class="jxr_keyword">new</strong> ArrayList<Data[]>(); +<a class="jxr_linenumber" name="L40" href="#L40">40</a> +<a class="jxr_linenumber" name="L41" href="#L41">41</a> <strong class="jxr_keyword">static</strong> { +<a class="jxr_linenumber" name="L42" href="#L42">42</a> <strong class="jxr_keyword">try</strong> { +<a class="jxr_linenumber" name="L43" href="#L43">43</a> <em class="jxr_comment">// "int"-based RNGs.</em> +<a class="jxr_linenumber" name="L44" href="#L44">44</a> add(LIST32, RandomSource.JDK, -122333444455555L); +<a class="jxr_linenumber" name="L45" href="#L45">45</a> add(LIST32, RandomSource.MT, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { -123, -234, -345 }); +<a class="jxr_linenumber" name="L46" href="#L46">46</a> add(LIST32, RandomSource.WELL_512_A, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { -23, -34, -45 }); +<a class="jxr_linenumber" name="L47" href="#L47">47</a> add(LIST32, RandomSource.WELL_1024_A, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { -1234, -2345, -3456 }); +<a class="jxr_linenumber" name="L48" href="#L48">48</a> add(LIST32, RandomSource.WELL_19937_A, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { -2123, -3234, -4345 }); +<a class="jxr_linenumber" name="L49" href="#L49">49</a> add(LIST32, RandomSource.WELL_19937_C, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { -123, -234, -345, -456 }); +<a class="jxr_linenumber" name="L50" href="#L50">50</a> add(LIST32, RandomSource.WELL_44497_A, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { -12345, -23456, -34567 }); +<a class="jxr_linenumber" name="L51" href="#L51">51</a> add(LIST32, RandomSource.WELL_44497_B, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { 123, 234, 345 }); +<a class="jxr_linenumber" name="L52" href="#L52">52</a> add(LIST32, RandomSource.ISAAC, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { 123, -234, 345, -456 }); +<a class="jxr_linenumber" name="L53" href="#L53">53</a> add(LIST32, RandomSource.MWC_256, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { 12, -1234, -3456, 45678 }); +<a class="jxr_linenumber" name="L54" href="#L54">54</a> add(LIST32, RandomSource.KISS, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">int</strong>[] { 12, 1234, 23456, 345678 }); +<a class="jxr_linenumber" name="L55" href="#L55">55</a> <em class="jxr_comment">// ... add more here.</em> +<a class="jxr_linenumber" name="L56" href="#L56">56</a> +<a class="jxr_linenumber" name="L57" href="#L57">57</a> <em class="jxr_comment">// "long"-based RNGs.</em> +<a class="jxr_linenumber" name="L58" href="#L58">58</a> add(LIST64, RandomSource.SPLIT_MIX_64, -988777666655555L); +<a class="jxr_linenumber" name="L59" href="#L59">59</a> add(LIST64, RandomSource.XOR_SHIFT_1024_S, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">long</strong>[] { 123456L, 234567L, -345678L }); +<a class="jxr_linenumber" name="L60" href="#L60">60</a> add(LIST64, RandomSource.TWO_CMRES, 55443322); +<a class="jxr_linenumber" name="L61" href="#L61">61</a> add(LIST64, RandomSource.TWO_CMRES_SELECT, -987654321, 5, 8); +<a class="jxr_linenumber" name="L62" href="#L62">62</a> add(LIST64, RandomSource.MT_64, <strong class="jxr_keyword">new</strong> <strong class="jxr_keyword">long</strong>[] { 1234567L, 2345678L, -3456789L }); +<a class="jxr_linenumber" name="L63" href="#L63">63</a> <em class="jxr_comment">// ... add more here.</em> +<a class="jxr_linenumber" name="L64" href="#L64">64</a> +<a class="jxr_linenumber" name="L65" href="#L65">65</a> <em class="jxr_comment">// Do not modify the remaining statements.</em> +<a class="jxr_linenumber" name="L66" href="#L66">66</a> <em class="jxr_comment">// Complete list.</em> +<a class="jxr_linenumber" name="L67" href="#L67">67</a> LIST.addAll(LIST32); +<a class="jxr_linenumber" name="L68" href="#L68">68</a> LIST.addAll(LIST64); +<a class="jxr_linenumber" name="L69" href="#L69">69</a> } <strong class="jxr_keyword">catch</strong> (Exception e) { +<a class="jxr_linenumber" name="L70" href="#L70">70</a> System.err.println(<span class="jxr_string">"Unexpected exception while creating the list of generators: "</span> + e); +<a class="jxr_linenumber" name="L71" href="#L71">71</a> e.printStackTrace(System.err); +<a class="jxr_linenumber" name="L72" href="#L72">72</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> RuntimeException(e); +<a class="jxr_linenumber" name="L73" href="#L73">73</a> } +<a class="jxr_linenumber" name="L74" href="#L74">74</a> } +<a class="jxr_linenumber" name="L75" href="#L75">75</a> +<a class="jxr_linenumber" name="L76" href="#L76">76</a> <em class="jxr_javadoccomment">/**</em> +<a class="jxr_linenumber" name="L77" href="#L77">77</a> <em class="jxr_javadoccomment"> * Class contains only static methods.</em> +<a class="jxr_linenumber" name="L78" href="#L78">78</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L79" href="#L79">79</a> <strong class="jxr_keyword">private</strong> <a href="../../../../org/apache/commons/rng/ProvidersList.html">ProvidersList</a>() {} +<a class="jxr_linenumber" name="L80" href="#L80">80</a> +<a class="jxr_linenumber" name="L81" href="#L81">81</a> <em class="jxr_javadoccomment">/**</em> +<a class="jxr_linenumber" name="L82" href="#L82">82</a> <em class="jxr_javadoccomment"> * Helper to statisfy Junit requirement that each parameter set contains</em> +<a class="jxr_linenumber" name="L83" href="#L83">83</a> <em class="jxr_javadoccomment"> * the same number of objects.</em> +<a class="jxr_linenumber" name="L84" href="#L84">84</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L85" href="#L85">85</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">void</strong> add(List<Data[]> list, +<a class="jxr_linenumber" name="L86" href="#L86">86</a> RandomSource source, +<a class="jxr_linenumber" name="L87" href="#L87">87</a> Object ... data) { +<a class="jxr_linenumber" name="L88" href="#L88">88</a> <strong class="jxr_keyword">final</strong> RandomSource rng = source; +<a class="jxr_linenumber" name="L89" href="#L89">89</a> <strong class="jxr_keyword">final</strong> Object seed = data.length > 0 ? data[0] : <strong class="jxr_keyword">null</strong>; +<a class="jxr_linenumber" name="L90" href="#L90">90</a> <strong class="jxr_keyword">final</strong> Object[] args = data.length > 1 ? Arrays.copyOfRange(data, 1, data.length) : <strong class="jxr_keyword">null</strong>; +<a class="jxr_linenumber" name="L91" href="#L91">91</a> +<a class="jxr_linenumber" name="L92" href="#L92">92</a> list.add(<strong class="jxr_keyword">new</strong> <a href="../../../../org/apache/commons/rng/ProvidersList.html">Data</a>[] { <strong class="jxr_keyword">new</strong> Data(rng, seed, args) }); +<a class="jxr_linenumber" name="L93" href="#L93">93</a> } +<a class="jxr_linenumber" name="L94" href="#L94">94</a> +<a class="jxr_linenumber" name="L95" href="#L95">95</a> <em class="jxr_javadoccomment">/**</em> +<a class="jxr_linenumber" name="L96" href="#L96">96</a> <em class="jxr_javadoccomment"> * Subclasses that are "parametric" tests can forward the call to</em> +<a class="jxr_linenumber" name="L97" href="#L97">97</a> <em class="jxr_javadoccomment"> * the "@Parameters"-annotated method to this method.</em> +<a class="jxr_linenumber" name="L98" href="#L98">98</a> <em class="jxr_javadoccomment"> *</em> +<a class="jxr_linenumber" name="L99" href="#L99">99</a> <em class="jxr_javadoccomment"> * @return the list of all generators.</em> +<a class="jxr_linenumber" name="L100" href="#L100">100</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L101" href="#L101">101</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> Iterable<Data[]> list() { +<a class="jxr_linenumber" name="L102" href="#L102">102</a> <strong class="jxr_keyword">return</strong> Collections.unmodifiableList(LIST); +<a class="jxr_linenumber" name="L103" href="#L103">103</a> } +<a class="jxr_linenumber" name="L104" href="#L104">104</a> +<a class="jxr_linenumber" name="L105" href="#L105">105</a> <em class="jxr_javadoccomment">/**</em> +<a class="jxr_linenumber" name="L106" href="#L106">106</a> <em class="jxr_javadoccomment"> * Subclasses that are "parametric" tests can forward the call to</em> +<a class="jxr_linenumber" name="L107" href="#L107">107</a> <em class="jxr_javadoccomment"> * the "@Parameters"-annotated method to this method.</em> +<a class="jxr_linenumber" name="L108" href="#L108">108</a> <em class="jxr_javadoccomment"> *</em> +<a class="jxr_linenumber" name="L109" href="#L109">109</a> <em class="jxr_javadoccomment"> * @return the list of 32-bits based generators.</em> +<a class="jxr_linenumber" name="L110" href="#L110">110</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L111" href="#L111">111</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> Iterable<Data[]> list32() { +<a class="jxr_linenumber" name="L112" href="#L112">112</a> <strong class="jxr_keyword">return</strong> Collections.unmodifiableList(LIST32); +<a class="jxr_linenumber" name="L113" href="#L113">113</a> } +<a class="jxr_linenumber" name="L114" href="#L114">114</a> +<a class="jxr_linenumber" name="L115" href="#L115">115</a> <em class="jxr_javadoccomment">/**</em> +<a class="jxr_linenumber" name="L116" href="#L116">116</a> <em class="jxr_javadoccomment"> * Subclasses that are "parametric" tests can forward the call to</em> +<a class="jxr_linenumber" name="L117" href="#L117">117</a> <em class="jxr_javadoccomment"> * the "@Parameters"-annotated method to this method.</em> +<a class="jxr_linenumber" name="L118" href="#L118">118</a> <em class="jxr_javadoccomment"> *</em> +<a class="jxr_linenumber" name="L119" href="#L119">119</a> <em class="jxr_javadoccomment"> * @return the list of 32-bits based generators.</em> +<a class="jxr_linenumber" name="L120" href="#L120">120</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L121" href="#L121">121</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> Iterable<Data[]> list64() { +<a class="jxr_linenumber" name="L122" href="#L122">122</a> <strong class="jxr_keyword">return</strong> Collections.unmodifiableList(LIST64); +<a class="jxr_linenumber" name="L123" href="#L123">123</a> } +<a class="jxr_linenumber" name="L124" href="#L124">124</a> +<a class="jxr_linenumber" name="L125" href="#L125">125</a> <em class="jxr_javadoccomment">/**</em> +<a class="jxr_linenumber" name="L126" href="#L126">126</a> <em class="jxr_javadoccomment"> * Helper.</em> +<a class="jxr_linenumber" name="L127" href="#L127">127</a> <em class="jxr_javadoccomment"> * Better not to mix Junit assumptions of the usage of "Object[]".</em> +<a class="jxr_linenumber" name="L128" href="#L128">128</a> <em class="jxr_javadoccomment"> */</em> +<a class="jxr_linenumber" name="L129" href="#L129">129</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../org/apache/commons/rng/ProvidersList.html">Data</a> { +<a class="jxr_linenumber" name="L130" href="#L130">130</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> RandomSource source; +<a class="jxr_linenumber" name="L131" href="#L131">131</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Object seed; +<a class="jxr_linenumber" name="L132" href="#L132">132</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Object[] args; +<a class="jxr_linenumber" name="L133" href="#L133">133</a> +<a class="jxr_linenumber" name="L134" href="#L134">134</a> <strong class="jxr_keyword">public</strong> <a href="../../../../org/apache/commons/rng/ProvidersList.html">Data</a>(RandomSource source, +<a class="jxr_linenumber" name="L135" href="#L135">135</a> Object seed, +<a class="jxr_linenumber" name="L136" href="#L136">136</a> Object[] args) { +<a class="jxr_linenumber" name="L137" href="#L137">137</a> <strong class="jxr_keyword">this</strong>.source = source; +<a class="jxr_linenumber" name="L138" href="#L138">138</a> <strong class="jxr_keyword">this</strong>.seed = seed; +<a class="jxr_linenumber" name="L139" href="#L139">139</a> <strong class="jxr_keyword">this</strong>.args = args; +<a class="jxr_linenumber" name="L140" href="#L140">140</a> } +<a class="jxr_linenumber" name="L141" href="#L141">141</a> +<a class="jxr_linenumber" name="L142" href="#L142">142</a> <strong class="jxr_keyword">public</strong> RandomSource getSource() { +<a class="jxr_linenumber" name="L143" href="#L143">143</a> <strong class="jxr_keyword">return</strong> source; +<a class="jxr_linenumber" name="L144" href="#L144">144</a> } +<a class="jxr_linenumber" name="L145" href="#L145">145</a> +<a class="jxr_linenumber" name="L146" href="#L146">146</a> <strong class="jxr_keyword">public</strong> Object getSeed() { +<a class="jxr_linenumber" name="L147" href="#L147">147</a> <strong class="jxr_keyword">return</strong> seed; +<a class="jxr_linenumber" name="L148" href="#L148">148</a> } +<a class="jxr_linenumber" name="L149" href="#L149">149</a> +<a class="jxr_linenumber" name="L150" href="#L150">150</a> <strong class="jxr_keyword">public</strong> Object[] getArgs() { +<a class="jxr_linenumber" name="L151" href="#L151">151</a> <strong class="jxr_keyword">return</strong> args == <strong class="jxr_keyword">null</strong> ? <strong class="jxr_keyword">null</strong> : Arrays.copyOf(args, args.length); +<a class="jxr_linenumber" name="L152" href="#L152">152</a> } +<a class="jxr_linenumber" name="L153" href="#L153">153</a> +<a class="jxr_linenumber" name="L154" href="#L154">154</a> @Override +<a class="jxr_linenumber" name="L155" href="#L155">155</a> <strong class="jxr_keyword">public</strong> String toString() { +<a class="jxr_linenumber" name="L156" href="#L156">156</a> <strong class="jxr_keyword">return</strong> source.toString() + <span class="jxr_string">" seed="</span> + seed + <span class="jxr_string">" args="</span> + Arrays.toString(args); +<a class="jxr_linenumber" name="L157" href="#L157">157</a> } +<a class="jxr_linenumber" name="L158" href="#L158">158</a> } +<a class="jxr_linenumber" name="L159" href="#L159">159</a> } +</pre> +<hr/> +<div id="footer">Copyright © 2016 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</div> +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d1b3113a/commons-rng-core/site-content/.svn/pristine/3f/3fd8924eada0f4ffdfea7775f16e647caef4a96c.svn-base ---------------------------------------------------------------------- diff --git a/commons-rng-core/site-content/.svn/pristine/3f/3fd8924eada0f4ffdfea7775f16e647caef4a96c.svn-base b/commons-rng-core/site-content/.svn/pristine/3f/3fd8924eada0f4ffdfea7775f16e647caef4a96c.svn-base new file mode 100644 index 0000000..a59c10c --- /dev/null +++ b/commons-rng-core/site-content/.svn/pristine/3f/3fd8924eada0f4ffdfea7775f16e647caef4a96c.svn-base @@ -0,0 +1,370 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html lang="en"> +<head> +<title>Source code</title> +<link rel="stylesheet" type="text/css" href="../../../../../../../stylesheet.css" title="Style"> +</head> +<body> +<div class="sourceContainer"> +<pre><span class="sourceLineNo">001</span>/*<a name="line.1"></a> +<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a> +<span class="sourceLineNo">003</span> * contributor license agreements. See the NOTICE file distributed with<a name="line.3"></a> +<span class="sourceLineNo">004</span> * this work for additional information regarding copyright ownership.<a name="line.4"></a> +<span class="sourceLineNo">005</span> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a> +<span class="sourceLineNo">006</span> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a> +<span class="sourceLineNo">007</span> * the License. You may obtain a copy of the License at<a name="line.7"></a> +<span class="sourceLineNo">008</span> *<a name="line.8"></a> +<span class="sourceLineNo">009</span> * http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a> +<span class="sourceLineNo">010</span> *<a name="line.10"></a> +<span class="sourceLineNo">011</span> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a> +<span class="sourceLineNo">012</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a> +<span class="sourceLineNo">013</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a> +<span class="sourceLineNo">014</span> * See the License for the specific language governing permissions and<a name="line.14"></a> +<span class="sourceLineNo">015</span> * limitations under the License.<a name="line.15"></a> +<span class="sourceLineNo">016</span> */<a name="line.16"></a> +<span class="sourceLineNo">017</span>package org.apache.commons.rng.internal.util;<a name="line.17"></a> +<span class="sourceLineNo">018</span><a name="line.18"></a> +<span class="sourceLineNo">019</span>import org.apache.commons.rng.internal.source32.RandomIntSource;<a name="line.19"></a> +<span class="sourceLineNo">020</span>import org.apache.commons.rng.internal.source32.Well44497b;<a name="line.20"></a> +<span class="sourceLineNo">021</span>import org.apache.commons.rng.internal.source64.RandomLongSource;<a name="line.21"></a> +<span class="sourceLineNo">022</span>import org.apache.commons.rng.internal.source64.SplitMix64;<a name="line.22"></a> +<span class="sourceLineNo">023</span><a name="line.23"></a> +<span class="sourceLineNo">024</span>/**<a name="line.24"></a> +<span class="sourceLineNo">025</span> * Utilities related to seeding.<a name="line.25"></a> +<span class="sourceLineNo">026</span> *<a name="line.26"></a> +<span class="sourceLineNo">027</span> * <p><a name="line.27"></a> +<span class="sourceLineNo">028</span> * This class provides methods to generate random seeds (single values<a name="line.28"></a> +<span class="sourceLineNo">029</span> * or arrays of values, of {@code int} or {@code long} types) that can<a name="line.29"></a> +<span class="sourceLineNo">030</span> * be passed to the {@link org.apache.commons.rng.RandomSource<a name="line.30"></a> +<span class="sourceLineNo">031</span> * methods that create a generator instance}.<a name="line.31"></a> +<span class="sourceLineNo">032</span> * <br><a name="line.32"></a> +<span class="sourceLineNo">033</span> * Although the seed-generating methods defined in this class will likely<a name="line.33"></a> +<span class="sourceLineNo">034</span> * return different values for all calls, there is no guarantee that the<a name="line.34"></a> +<span class="sourceLineNo">035</span> * produced seed will result always in a "good" sequence of numbers (even<a name="line.35"></a> +<span class="sourceLineNo">036</span> * if the generator initialized with that seed is good).<a name="line.36"></a> +<span class="sourceLineNo">037</span> * <br><a name="line.37"></a> +<span class="sourceLineNo">038</span> * There is <i>no guarantee</i> that sequences will not overlap.<a name="line.38"></a> +<span class="sourceLineNo">039</span> * </p><a name="line.39"></a> +<span class="sourceLineNo">040</span> *<a name="line.40"></a> +<span class="sourceLineNo">041</span> * @since 1.0<a name="line.41"></a> +<span class="sourceLineNo">042</span> */<a name="line.42"></a> +<span class="sourceLineNo">043</span>public class SeedFactory {<a name="line.43"></a> +<span class="sourceLineNo">044</span> /** Generator with a long period. */<a name="line.44"></a> +<span class="sourceLineNo">045</span> private static final RandomIntSource SEED_GENERATOR;<a name="line.45"></a> +<span class="sourceLineNo">046</span><a name="line.46"></a> +<span class="sourceLineNo">047</span> static {<a name="line.47"></a> +<span class="sourceLineNo">048</span> // Another RNG for initializing the "SEED_GENERATOR".<a name="line.48"></a> +<span class="sourceLineNo">049</span> final long t = System.currentTimeMillis();<a name="line.49"></a> +<span class="sourceLineNo">050</span> final int h = System.identityHashCode(Runtime.getRuntime());<a name="line.50"></a> +<span class="sourceLineNo">051</span> final SplitMix64 rng = new SplitMix64(t ^ NumberFactory.makeLong(h, ~h));<a name="line.51"></a> +<span class="sourceLineNo">052</span><a name="line.52"></a> +<span class="sourceLineNo">053</span> final int blockCount = 1391; // Size of the state array of "Well44497b".<a name="line.53"></a> +<span class="sourceLineNo">054</span> SEED_GENERATOR = new Well44497b(createIntArray(blockCount, rng));<a name="line.54"></a> +<span class="sourceLineNo">055</span> }<a name="line.55"></a> +<span class="sourceLineNo">056</span><a name="line.56"></a> +<span class="sourceLineNo">057</span> /**<a name="line.57"></a> +<span class="sourceLineNo">058</span> * Class contains only static methods.<a name="line.58"></a> +<span class="sourceLineNo">059</span> */<a name="line.59"></a> +<span class="sourceLineNo">060</span> private SeedFactory() {}<a name="line.60"></a> +<span class="sourceLineNo">061</span><a name="line.61"></a> +<span class="sourceLineNo">062</span> /**<a name="line.62"></a> +<span class="sourceLineNo">063</span> * Creates a number for use as a seed.<a name="line.63"></a> +<span class="sourceLineNo">064</span> *<a name="line.64"></a> +<span class="sourceLineNo">065</span> * @return a random number.<a name="line.65"></a> +<span class="sourceLineNo">066</span> */<a name="line.66"></a> +<span class="sourceLineNo">067</span> public static int createInt() {<a name="line.67"></a> +<span class="sourceLineNo">068</span> return createInt(SEED_GENERATOR, System.identityHashCode(new Object()));<a name="line.68"></a> +<span class="sourceLineNo">069</span> }<a name="line.69"></a> +<span class="sourceLineNo">070</span><a name="line.70"></a> +<span class="sourceLineNo">071</span> /**<a name="line.71"></a> +<span class="sourceLineNo">072</span> * Creates a number for use as a seed.<a name="line.72"></a> +<span class="sourceLineNo">073</span> *<a name="line.73"></a> +<span class="sourceLineNo">074</span> * @return a random number.<a name="line.74"></a> +<span class="sourceLineNo">075</span> */<a name="line.75"></a> +<span class="sourceLineNo">076</span> public static long createLong() {<a name="line.76"></a> +<span class="sourceLineNo">077</span> return createLong(SEED_GENERATOR, System.identityHashCode(new Object()));<a name="line.77"></a> +<span class="sourceLineNo">078</span> }<a name="line.78"></a> +<span class="sourceLineNo">079</span><a name="line.79"></a> +<span class="sourceLineNo">080</span> /**<a name="line.80"></a> +<span class="sourceLineNo">081</span> * Creates an array of numbers for use as a seed.<a name="line.81"></a> +<span class="sourceLineNo">082</span> *<a name="line.82"></a> +<span class="sourceLineNo">083</span> * @param n Size of the array to create.<a name="line.83"></a> +<span class="sourceLineNo">084</span> * @return an array of {@code n} random numbers.<a name="line.84"></a> +<span class="sourceLineNo">085</span> */<a name="line.85"></a> +<span class="sourceLineNo">086</span> public static int[] createIntArray(int n) {<a name="line.86"></a> +<span class="sourceLineNo">087</span> return createIntArray(n, SEED_GENERATOR, new Object());<a name="line.87"></a> +<span class="sourceLineNo">088</span> }<a name="line.88"></a> +<span class="sourceLineNo">089</span><a name="line.89"></a> +<span class="sourceLineNo">090</span> /**<a name="line.90"></a> +<span class="sourceLineNo">091</span> * Creates an array of numbers for use as a seed.<a name="line.91"></a> +<span class="sourceLineNo">092</span> *<a name="line.92"></a> +<span class="sourceLineNo">093</span> * @param n Size of the array to create.<a name="line.93"></a> +<span class="sourceLineNo">094</span> * @return an array of {@code n} random numbers.<a name="line.94"></a> +<span class="sourceLineNo">095</span> */<a name="line.95"></a> +<span class="sourceLineNo">096</span> public static long[] createLongArray(int n) {<a name="line.96"></a> +<span class="sourceLineNo">097</span> return createLongArray(n, SEED_GENERATOR, new Object());<a name="line.97"></a> +<span class="sourceLineNo">098</span> }<a name="line.98"></a> +<span class="sourceLineNo">099</span><a name="line.99"></a> +<span class="sourceLineNo">100</span> /**<a name="line.100"></a> +<span class="sourceLineNo">101</span> * Simple filling procedure.<a name="line.101"></a> +<span class="sourceLineNo">102</span> * It will<a name="line.102"></a> +<span class="sourceLineNo">103</span> * <ol><a name="line.103"></a> +<span class="sourceLineNo">104</span> * <li><a name="line.104"></a> +<span class="sourceLineNo">105</span> * fill the beginning of {@code state} by copying<a name="line.105"></a> +<span class="sourceLineNo">106</span> * {@code min(seed.length, state.length)} elements from<a name="line.106"></a> +<span class="sourceLineNo">107</span> * {@code seed},<a name="line.107"></a> +<span class="sourceLineNo">108</span> * </li><a name="line.108"></a> +<span class="sourceLineNo">109</span> * <li><a name="line.109"></a> +<span class="sourceLineNo">110</span> * set all remaining elements of {@code state} with non-zero<a name="line.110"></a> +<span class="sourceLineNo">111</span> * values (even if {@code seed.length < state.length}).<a name="line.111"></a> +<span class="sourceLineNo">112</span> * </li><a name="line.112"></a> +<span class="sourceLineNo">113</span> * </ol><a name="line.113"></a> +<span class="sourceLineNo">114</span> *<a name="line.114"></a> +<span class="sourceLineNo">115</span> * @param state State. Must be allocated.<a name="line.115"></a> +<span class="sourceLineNo">116</span> * @param seed Seed. Cannot be null.<a name="line.116"></a> +<span class="sourceLineNo">117</span> */<a name="line.117"></a> +<span class="sourceLineNo">118</span> public static void fillState(int[] state,<a name="line.118"></a> +<span class="sourceLineNo">119</span> int[] seed) {<a name="line.119"></a> +<span class="sourceLineNo">120</span> final int stateSize = state.length;<a name="line.120"></a> +<span class="sourceLineNo">121</span> final int seedSize = seed.length;<a name="line.121"></a> +<span class="sourceLineNo">122</span> System.arraycopy(seed, 0, state, 0, Math.min(seedSize, stateSize));<a name="line.122"></a> +<span class="sourceLineNo">123</span><a name="line.123"></a> +<span class="sourceLineNo">124</span> if (seedSize < stateSize) {<a name="line.124"></a> +<span class="sourceLineNo">125</span> for (int i = seedSize; i < stateSize; i++) {<a name="line.125"></a> +<span class="sourceLineNo">126</span> state[i] = 26021969 * i;<a name="line.126"></a> +<span class="sourceLineNo">127</span> }<a name="line.127"></a> +<span class="sourceLineNo">128</span> for (int i = stateSize - 1; i > seedSize; i--) {<a name="line.128"></a> +<span class="sourceLineNo">129</span> state[i] ^= state[stateSize - i - 1];<a name="line.129"></a> +<span class="sourceLineNo">130</span> }<a name="line.130"></a> +<span class="sourceLineNo">131</span><a name="line.131"></a> +<span class="sourceLineNo">132</span> state[seedSize] = 0x80000000; // Ensuring non-zero initial array.<a name="line.132"></a> +<span class="sourceLineNo">133</span> }<a name="line.133"></a> +<span class="sourceLineNo">134</span> }<a name="line.134"></a> +<span class="sourceLineNo">135</span><a name="line.135"></a> +<span class="sourceLineNo">136</span> /**<a name="line.136"></a> +<span class="sourceLineNo">137</span> * Creates an array of numbers for use as a seed.<a name="line.137"></a> +<span class="sourceLineNo">138</span> *<a name="line.138"></a> +<span class="sourceLineNo">139</span> * @param n Size of the array to create.<a name="line.139"></a> +<span class="sourceLineNo">140</span> * @param source Source of randomness.<a name="line.140"></a> +<span class="sourceLineNo">141</span> * @return an array of {@code n} random numbers drawn from the<a name="line.141"></a> +<span class="sourceLineNo">142</span> * {@code source}.<a name="line.142"></a> +<span class="sourceLineNo">143</span> */<a name="line.143"></a> +<span class="sourceLineNo">144</span> static long[] createLongArray(int n,<a name="line.144"></a> +<span class="sourceLineNo">145</span> RandomIntSource source) {<a name="line.145"></a> +<span class="sourceLineNo">146</span> return createLongArray(n, source, null);<a name="line.146"></a> +<span class="sourceLineNo">147</span> }<a name="line.147"></a> +<span class="sourceLineNo">148</span><a name="line.148"></a> +<span class="sourceLineNo">149</span> /**<a name="line.149"></a> +<span class="sourceLineNo">150</span> * Creates an array of numbers for use as a seed.<a name="line.150"></a> +<span class="sourceLineNo">151</span> *<a name="line.151"></a> +<span class="sourceLineNo">152</span> * @param n Size of the array to create.<a name="line.152"></a> +<span class="sourceLineNo">153</span> * @param source Source of randomness.<a name="line.153"></a> +<span class="sourceLineNo">154</span> * @return an array of {@code n} random numbers drawn from the<a name="line.154"></a> +<span class="sourceLineNo">155</span> * {@code source}.<a name="line.155"></a> +<span class="sourceLineNo">156</span> */<a name="line.156"></a> +<span class="sourceLineNo">157</span> static int[] createIntArray(int n,<a name="line.157"></a> +<span class="sourceLineNo">158</span> RandomLongSource source) {<a name="line.158"></a> +<span class="sourceLineNo">159</span> return createIntArray(n, source, null);<a name="line.159"></a> +<span class="sourceLineNo">160</span> }<a name="line.160"></a> +<span class="sourceLineNo">161</span><a name="line.161"></a> +<span class="sourceLineNo">162</span> /**<a name="line.162"></a> +<span class="sourceLineNo">163</span> * Creates an array of numbers for use as a seed.<a name="line.163"></a> +<span class="sourceLineNo">164</span> *<a name="line.164"></a> +<span class="sourceLineNo">165</span> * @param n Size of the array to create.<a name="line.165"></a> +<span class="sourceLineNo">166</span> * @param source Source of randomness.<a name="line.166"></a> +<span class="sourceLineNo">167</span> * @return an array of {@code n} random numbers drawn from the<a name="line.167"></a> +<span class="sourceLineNo">168</span> * {@code source}.<a name="line.168"></a> +<span class="sourceLineNo">169</span> */<a name="line.169"></a> +<span class="sourceLineNo">170</span> static int[] createIntArray(int n,<a name="line.170"></a> +<span class="sourceLineNo">171</span> RandomIntSource source) {<a name="line.171"></a> +<span class="sourceLineNo">172</span> return createIntArray(n, source, null);<a name="line.172"></a> +<span class="sourceLineNo">173</span> }<a name="line.173"></a> +<span class="sourceLineNo">174</span><a name="line.174"></a> +<span class="sourceLineNo">175</span> /**<a name="line.175"></a> +<span class="sourceLineNo">176</span> * Creates an array of numbers for use as a seed.<a name="line.176"></a> +<span class="sourceLineNo">177</span> *<a name="line.177"></a> +<span class="sourceLineNo">178</span> * @param n Size of the array to create.<a name="line.178"></a> +<span class="sourceLineNo">179</span> * @param source Source of randomness.<a name="line.179"></a> +<span class="sourceLineNo">180</span> * @param h Arbitrary object whose {@link System#identityHashCode(Object)<a name="line.180"></a> +<span class="sourceLineNo">181</span> * hash code} will be combined with the next number drawn from<a name="line.181"></a> +<span class="sourceLineNo">182</span> * the {@code source}.<a name="line.182"></a> +<span class="sourceLineNo">183</span> * @return an array of {@code n} random numbers.<a name="line.183"></a> +<span class="sourceLineNo">184</span> */<a name="line.184"></a> +<span class="sourceLineNo">185</span> private static long[] createLongArray(int n,<a name="line.185"></a> +<span class="sourceLineNo">186</span> RandomIntSource source,<a name="line.186"></a> +<span class="sourceLineNo">187</span> Object h) {<a name="line.187"></a> +<span class="sourceLineNo">188</span> final long[] array = new long[n];<a name="line.188"></a> +<span class="sourceLineNo">189</span><a name="line.189"></a> +<span class="sourceLineNo">190</span> final int hash = System.identityHashCode(h);<a name="line.190"></a> +<span class="sourceLineNo">191</span> for (int i = 0; i < n; i++) {<a name="line.191"></a> +<span class="sourceLineNo">192</span> array[i] = createLong(source, hash);<a name="line.192"></a> +<span class="sourceLineNo">193</span> }<a name="line.193"></a> +<span class="sourceLineNo">194</span><a name="line.194"></a> +<span class="sourceLineNo">195</span> return array;<a name="line.195"></a> +<span class="sourceLineNo">196</span> }<a name="line.196"></a> +<span class="sourceLineNo">197</span><a name="line.197"></a> +<span class="sourceLineNo">198</span> /**<a name="line.198"></a> +<span class="sourceLineNo">199</span> * Creates an array of numbers for use as a seed.<a name="line.199"></a> +<span class="sourceLineNo">200</span> *<a name="line.200"></a> +<span class="sourceLineNo">201</span> * @param n Size of the array to create.<a name="line.201"></a> +<span class="sourceLineNo">202</span> * @param source Source of randomness.<a name="line.202"></a> +<span class="sourceLineNo">203</span> * @param h Arbitrary object whose {@link System#identityHashCode(Object)<a name="line.203"></a> +<span class="sourceLineNo">204</span> * hash code} will be combined with the next number drawn from<a name="line.204"></a> +<span class="sourceLineNo">205</span> * the {@code source}.<a name="line.205"></a> +<span class="sourceLineNo">206</span> * @return an array of {@code n} random numbers.<a name="line.206"></a> +<span class="sourceLineNo">207</span> */<a name="line.207"></a> +<span class="sourceLineNo">208</span> private static int[] createIntArray(int n,<a name="line.208"></a> +<span class="sourceLineNo">209</span> RandomLongSource source,<a name="line.209"></a> +<span class="sourceLineNo">210</span> Object h) {<a name="line.210"></a> +<span class="sourceLineNo">211</span> final int[] array = new int[n];<a name="line.211"></a> +<span class="sourceLineNo">212</span><a name="line.212"></a> +<span class="sourceLineNo">213</span> final int hash = System.identityHashCode(h);<a name="line.213"></a> +<span class="sourceLineNo">214</span> for (int i = 0; i < n; i += 2) {<a name="line.214"></a> +<span class="sourceLineNo">215</span> final long v = createLong(source, hash);<a name="line.215"></a> +<span class="sourceLineNo">216</span><a name="line.216"></a> +<span class="sourceLineNo">217</span> array[i] = NumberFactory.extractHi(v);<a name="line.217"></a> +<span class="sourceLineNo">218</span><a name="line.218"></a> +<span class="sourceLineNo">219</span> if (i + 1 < n) {<a name="line.219"></a> +<span class="sourceLineNo">220</span> array[i + 1] = NumberFactory.extractLo(v);<a name="line.220"></a> +<span class="sourceLineNo">221</span> }<a name="line.221"></a> +<span class="sourceLineNo">222</span> }<a name="line.222"></a> +<span class="sourceLineNo">223</span><a name="line.223"></a> +<span class="sourceLineNo">224</span> return array;<a name="line.224"></a> +<span class="sourceLineNo">225</span> }<a name="line.225"></a> +<span class="sourceLineNo">226</span><a name="line.226"></a> +<span class="sourceLineNo">227</span> /**<a name="line.227"></a> +<span class="sourceLineNo">228</span> * Creates an array of numbers for use as a seed.<a name="line.228"></a> +<span class="sourceLineNo">229</span> *<a name="line.229"></a> +<span class="sourceLineNo">230</span> * @param n Size of the array to create.<a name="line.230"></a> +<span class="sourceLineNo">231</span> * @param source Source of randomness.<a name="line.231"></a> +<span class="sourceLineNo">232</span> * @param h Arbitrary object whose {@link System#identityHashCode(Object)<a name="line.232"></a> +<span class="sourceLineNo">233</span> * hash code} will be combined with the next number drawn from<a name="line.233"></a> +<span class="sourceLineNo">234</span> * the {@code source}.<a name="line.234"></a> +<span class="sourceLineNo">235</span> * @return an array of {@code n} random numbers.<a name="line.235"></a> +<span class="sourceLineNo">236</span> */<a name="line.236"></a> +<span class="sourceLineNo">237</span> private static int[] createIntArray(int n,<a name="line.237"></a> +<span class="sourceLineNo">238</span> RandomIntSource source,<a name="line.238"></a> +<span class="sourceLineNo">239</span> Object h) {<a name="line.239"></a> +<span class="sourceLineNo">240</span> final int[] array = new int[n];<a name="line.240"></a> +<span class="sourceLineNo">241</span><a name="line.241"></a> +<span class="sourceLineNo">242</span> final int hash = System.identityHashCode(h);<a name="line.242"></a> +<span class="sourceLineNo">243</span> for (int i = 0; i < n; i++) {<a name="line.243"></a> +<span class="sourceLineNo">244</span> array[i] = createInt(source, hash);<a name="line.244"></a> +<span class="sourceLineNo">245</span> }<a name="line.245"></a> +<span class="sourceLineNo">246</span><a name="line.246"></a> +<span class="sourceLineNo">247</span> return array;<a name="line.247"></a> +<span class="sourceLineNo">248</span> }<a name="line.248"></a> +<span class="sourceLineNo">249</span><a name="line.249"></a> +<span class="sourceLineNo">250</span> /**<a name="line.250"></a> +<span class="sourceLineNo">251</span> * Creates a random number by performing an "xor" between the<a name="line.251"></a> +<span class="sourceLineNo">252</span> * next value in the sequence of the {@code source} and the<a name="line.252"></a> +<span class="sourceLineNo">253</span> * given {@code number}.<a name="line.253"></a> +<span class="sourceLineNo">254</span> *<a name="line.254"></a> +<span class="sourceLineNo">255</span> * @param source Source of randomness.<a name="line.255"></a> +<span class="sourceLineNo">256</span> * @param number Arbitrary number.<a name="line.256"></a> +<span class="sourceLineNo">257</span> * @return a random number.<a name="line.257"></a> +<span class="sourceLineNo">258</span> */<a name="line.258"></a> +<span class="sourceLineNo">259</span> private static long createLong(RandomLongSource source,<a name="line.259"></a> +<span class="sourceLineNo">260</span> int number) {<a name="line.260"></a> +<span class="sourceLineNo">261</span> synchronized (source) {<a name="line.261"></a> +<span class="sourceLineNo">262</span> return source.next() ^ NumberFactory.makeLong(number, number);<a name="line.262"></a> +<span class="sourceLineNo">263</span> }<a name="line.263"></a> +<span class="sourceLineNo">264</span> }<a name="line.264"></a> +<span class="sourceLineNo">265</span><a name="line.265"></a> +<span class="sourceLineNo">266</span> /**<a name="line.266"></a> +<span class="sourceLineNo">267</span> * Creates a random number by performing an "xor" between the<a name="line.267"></a> +<span class="sourceLineNo">268</span> * the next value in the sequence of the {@code source} and the<a name="line.268"></a> +<span class="sourceLineNo">269</span> * given {@code number}.<a name="line.269"></a> +<span class="sourceLineNo">270</span> *<a name="line.270"></a> +<span class="sourceLineNo">271</span> * @param source Source of randomness.<a name="line.271"></a> +<span class="sourceLineNo">272</span> * @param number Arbitrary number.<a name="line.272"></a> +<span class="sourceLineNo">273</span> * @return a random number.<a name="line.273"></a> +<span class="sourceLineNo">274</span> */<a name="line.274"></a> +<span class="sourceLineNo">275</span> private static long createLong(RandomIntSource source,<a name="line.275"></a> +<span class="sourceLineNo">276</span> int number) {<a name="line.276"></a> +<span class="sourceLineNo">277</span> synchronized (source) {<a name="line.277"></a> +<span class="sourceLineNo">278</span> return NumberFactory.makeLong(source.next() ^ number,<a name="line.278"></a> +<span class="sourceLineNo">279</span> source.next() ^ number);<a name="line.279"></a> +<span class="sourceLineNo">280</span> }<a name="line.280"></a> +<span class="sourceLineNo">281</span> }<a name="line.281"></a> +<span class="sourceLineNo">282</span><a name="line.282"></a> +<span class="sourceLineNo">283</span> /**<a name="line.283"></a> +<span class="sourceLineNo">284</span> * Creates a random number by performing an "xor" between the<a name="line.284"></a> +<span class="sourceLineNo">285</span> * next value in the sequence of the {@code source} and the<a name="line.285"></a> +<span class="sourceLineNo">286</span> * given {@code number}.<a name="line.286"></a> +<span class="sourceLineNo">287</span> *<a name="line.287"></a> +<span class="sourceLineNo">288</span> * @param source Source of randomness.<a name="line.288"></a> +<span class="sourceLineNo">289</span> * @param number Arbitrary number.<a name="line.289"></a> +<span class="sourceLineNo">290</span> * @return a random number.<a name="line.290"></a> +<span class="sourceLineNo">291</span> */<a name="line.291"></a> +<span class="sourceLineNo">292</span> private static int createInt(RandomIntSource source,<a name="line.292"></a> +<span class="sourceLineNo">293</span> int number) {<a name="line.293"></a> +<span class="sourceLineNo">294</span> synchronized (source) {<a name="line.294"></a> +<span class="sourceLineNo">295</span> return source.next() ^ number;<a name="line.295"></a> +<span class="sourceLineNo">296</span> }<a name="line.296"></a> +<span class="sourceLineNo">297</span> }<a name="line.297"></a> +<span class="sourceLineNo">298</span>}<a name="line.298"></a> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +</pre> +</div> +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/commons-rng/blob/d1b3113a/commons-rng-core/site-content/.svn/pristine/3f/3fdc1e63b4e159768aebcc024dfb2dfd7d92d7b8.svn-base ---------------------------------------------------------------------- diff --git a/commons-rng-core/site-content/.svn/pristine/3f/3fdc1e63b4e159768aebcc024dfb2dfd7d92d7b8.svn-base b/commons-rng-core/site-content/.svn/pristine/3f/3fdc1e63b4e159768aebcc024dfb2dfd7d92d7b8.svn-base new file mode 100644 index 0000000..9ccdbc2 --- /dev/null +++ b/commons-rng-core/site-content/.svn/pristine/3f/3fdc1e63b4e159768aebcc024dfb2dfd7d92d7b8.svn-base @@ -0,0 +1,232 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- NewPage --> +<html lang="en"> +<head> +<!-- Generated by javadoc --> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>API Help (Apache Commons Rng 1.0-SNAPSHOT API)</title> +<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style"> +<script type="text/javascript" src="script.js"></script> +</head> +<body> +<script type="text/javascript"><!-- + try { + if (location.href.indexOf('is-external=true') == -1) { + parent.document.title="API Help (Apache Commons Rng 1.0-SNAPSHOT API)"; + } + } + catch(err) { + } +//--> +</script> +<noscript> +<div>JavaScript is disabled on your browser.</div> +</noscript> +<!-- ========= START OF TOP NAVBAR ======= --> +<div class="topNav"><a name="navbar.top"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.top.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="overview-summary.html">Overview</a></li> +<li>Package</li> +<li>Class</li> +<li>Use</li> +<li><a href="overview-tree.html">Tree</a></li> +<li><a href="deprecated-list.html">Deprecated</a></li> +<li><a href="index-all.html">Index</a></li> +<li class="navBarCell1Rev">Help</li> +</ul> +<div class="aboutLanguage"><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></div> +</div> +<div class="subNav"> +<ul class="navList"> +<li>Prev</li> +<li>Next</li> +</ul> +<ul class="navList"> +<li><a href="index.html?help-doc.html" target="_top">Frames</a></li> +<li><a href="help-doc.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_top"> +<li><a href="allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_top"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.top"> +<!-- --> +</a></div> +<!-- ========= END OF TOP NAVBAR ========= --> +<div class="header"> +<h1 class="title">How This API Document Is Organized</h1> +<div class="subTitle">This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.</div> +</div> +<div class="contentContainer"> +<ul class="blockList"> +<li class="blockList"> +<h2>Overview</h2> +<p>The <a href="overview-summary.html">Overview</a> page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.</p> +</li> +<li class="blockList"> +<h2>Package</h2> +<p>Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:</p> +<ul> +<li>Interfaces (italic)</li> +<li>Classes</li> +<li>Enums</li> +<li>Exceptions</li> +<li>Errors</li> +<li>Annotation Types</li> +</ul> +</li> +<li class="blockList"> +<h2>Class/Interface</h2> +<p>Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:</p> +<ul> +<li>Class inheritance diagram</li> +<li>Direct Subclasses</li> +<li>All Known Subinterfaces</li> +<li>All Known Implementing Classes</li> +<li>Class/interface declaration</li> +<li>Class/interface description</li> +</ul> +<ul> +<li>Nested Class Summary</li> +<li>Field Summary</li> +<li>Constructor Summary</li> +<li>Method Summary</li> +</ul> +<ul> +<li>Field Detail</li> +<li>Constructor Detail</li> +<li>Method Detail</li> +</ul> +<p>Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.</p> +</li> +<li class="blockList"> +<h2>Annotation Type</h2> +<p>Each annotation type has its own separate page with the following sections:</p> +<ul> +<li>Annotation Type declaration</li> +<li>Annotation Type description</li> +<li>Required Element Summary</li> +<li>Optional Element Summary</li> +<li>Element Detail</li> +</ul> +</li> +<li class="blockList"> +<h2>Enum</h2> +<p>Each enum has its own separate page with the following sections:</p> +<ul> +<li>Enum declaration</li> +<li>Enum description</li> +<li>Enum Constant Summary</li> +<li>Enum Constant Detail</li> +</ul> +</li> +<li class="blockList"> +<h2>Use</h2> +<p>Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.</p> +</li> +<li class="blockList"> +<h2>Tree (Class Hierarchy)</h2> +<p>There is a <a href="overview-tree.html">Class Hierarchy</a> page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with <code>java.lang.Object</code>. The interfaces do not inherit from <code>java.lang.Object</code>.</p> +<ul> +<li>When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.</li> +<li>When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.</li> +</ul> +</li> +<li class="blockList"> +<h2>Deprecated API</h2> +<p>The <a href="deprecated-list.html">Deprecated API</a> page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.</p> +</li> +<li class="blockList"> +<h2>Index</h2> +<p>The <a href="index-all.html">Index</a> contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.</p> +</li> +<li class="blockList"> +<h2>Prev/Next</h2> +<p>These links take you to the next or previous class, interface, package, or related page.</p> +</li> +<li class="blockList"> +<h2>Frames/No Frames</h2> +<p>These links show and hide the HTML frames. All pages are available with or without frames.</p> +</li> +<li class="blockList"> +<h2>All Classes</h2> +<p>The <a href="allclasses-noframe.html">All Classes</a> link shows all classes and interfaces except non-static nested types.</p> +</li> +<li class="blockList"> +<h2>Serialized Form</h2> +<p>Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.</p> +</li> +<li class="blockList"> +<h2>Constant Field Values</h2> +<p>The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.</p> +</li> +</ul> +<span class="emphasizedPhrase">This help file applies to API documentation generated using the standard doclet.</span></div> +<!-- ======= START OF BOTTOM NAVBAR ====== --> +<div class="bottomNav"><a name="navbar.bottom"> +<!-- --> +</a> +<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> +<a name="navbar.bottom.firstrow"> +<!-- --> +</a> +<ul class="navList" title="Navigation"> +<li><a href="overview-summary.html">Overview</a></li> +<li>Package</li> +<li>Class</li> +<li>Use</li> +<li><a href="overview-tree.html">Tree</a></li> +<li><a href="deprecated-list.html">Deprecated</a></li> +<li><a href="index-all.html">Index</a></li> +<li class="navBarCell1Rev">Help</li> +</ul> +<div class="aboutLanguage"><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script></div> +</div> +<div class="subNav"> +<ul class="navList"> +<li>Prev</li> +<li>Next</li> +</ul> +<ul class="navList"> +<li><a href="index.html?help-doc.html" target="_top">Frames</a></li> +<li><a href="help-doc.html" target="_top">No Frames</a></li> +</ul> +<ul class="navList" id="allclasses_navbar_bottom"> +<li><a href="allclasses-noframe.html">All Classes</a></li> +</ul> +<div> +<script type="text/javascript"><!-- + allClassesLink = document.getElementById("allclasses_navbar_bottom"); + if(window==top) { + allClassesLink.style.display = "block"; + } + else { + allClassesLink.style.display = "none"; + } + //--> +</script> +</div> +<a name="skip.navbar.bottom"> +<!-- --> +</a></div> +<!-- ======== END OF BOTTOM NAVBAR ======= --> +<p class="legalCopy"><small>Copyright © 2016 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p> +</body> +</html> \ No newline at end of file