commons-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r995697 [3/14] - in /websites/production/commons/content/proper/commons-rng: ./ apidocs/ apidocs/org/apache/commons/rng/ apidocs/org/apache/commons/rng/class-use/ apidocs/org/apache/commons/rng/internal/ apidocs/org/apache/commons/rng/inter...
Date Mon, 22 Aug 2016 22:01:59 GMT
Modified: websites/production/commons/content/proper/commons-rng/apidocs/src-html/org/apache/commons/rng/RandomSource.State.html
==============================================================================
--- websites/production/commons/content/proper/commons-rng/apidocs/src-html/org/apache/commons/rng/RandomSource.State.html (original)
+++ websites/production/commons/content/proper/commons-rng/apidocs/src-html/org/apache/commons/rng/RandomSource.State.html Mon Aug 22 22:01:58 2016
@@ -24,404 +24,432 @@
 <span class="sourceLineNo">016</span> */<a name="line.16"></a>
 <span class="sourceLineNo">017</span>package org.apache.commons.rng;<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.ProviderBuilder;<a name="line.19"></a>
-<span class="sourceLineNo">020</span>import org.apache.commons.rng.internal.BaseProvider;<a name="line.20"></a>
-<span class="sourceLineNo">021</span>import org.apache.commons.rng.internal.util.SeedFactory;<a name="line.21"></a>
-<span class="sourceLineNo">022</span>import org.apache.commons.rng.internal.source64.TwoCmres;<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> * This class provides the API for creating generators of random numbers.<a name="line.25"></a>
-<span class="sourceLineNo">026</span> * &lt;p&gt;<a name="line.26"></a>
-<span class="sourceLineNo">027</span> * Usage examples:<a name="line.27"></a>
-<span class="sourceLineNo">028</span> * &lt;pre&gt;&lt;code&gt;<a name="line.28"></a>
-<span class="sourceLineNo">029</span> *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT);<a name="line.29"></a>
-<span class="sourceLineNo">030</span> * &lt;/code&gt;&lt;/pre&gt;<a name="line.30"></a>
-<span class="sourceLineNo">031</span> * or<a name="line.31"></a>
-<span class="sourceLineNo">032</span> * &lt;pre&gt;&lt;code&gt;<a name="line.32"></a>
-<span class="sourceLineNo">033</span> *  final int[] seed = new int[] { 196, 9, 0, 226 };<a name="line.33"></a>
-<span class="sourceLineNo">034</span> *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed);<a name="line.34"></a>
-<span class="sourceLineNo">035</span> * &lt;/code&gt;&lt;/pre&gt;<a name="line.35"></a>
-<span class="sourceLineNo">036</span> * or<a name="line.36"></a>
-<span class="sourceLineNo">037</span> * &lt;pre&gt;&lt;code&gt;<a name="line.37"></a>
-<span class="sourceLineNo">038</span> *  final int[] seed = RandomSource.createIntArray(256);<a name="line.38"></a>
-<span class="sourceLineNo">039</span> *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed);<a name="line.39"></a>
-<span class="sourceLineNo">040</span> * &lt;/code&gt;&lt;/pre&gt;<a name="line.40"></a>
-<span class="sourceLineNo">041</span> * where the first argument to method {@code create} is the identifier<a name="line.41"></a>
-<span class="sourceLineNo">042</span> * of the generator's concrete implementation, and the second the is the<a name="line.42"></a>
-<span class="sourceLineNo">043</span> * (optional) seed.<a name="line.43"></a>
-<span class="sourceLineNo">044</span> * &lt;br&gt;<a name="line.44"></a>
-<span class="sourceLineNo">045</span> * In the first form, a random seed will be {@link SeedFactory generated<a name="line.45"></a>
-<span class="sourceLineNo">046</span> * automatically}; in the second form, a fixed seed is used; a random seed<a name="line.46"></a>
-<span class="sourceLineNo">047</span> * is explicitly generated in the third form.<a name="line.47"></a>
-<span class="sourceLineNo">048</span> * &lt;/p&gt;<a name="line.48"></a>
-<span class="sourceLineNo">049</span> *<a name="line.49"></a>
-<span class="sourceLineNo">050</span> * &lt;p&gt;<a name="line.50"></a>
-<span class="sourceLineNo">051</span> * Seeding is the procedure by which a value (or set of values) is<a name="line.51"></a>
-<span class="sourceLineNo">052</span> * used to &lt;i&gt;initialize&lt;/i&gt; a generator instance.<a name="line.52"></a>
-<span class="sourceLineNo">053</span> * The requirement that a given seed will always result in the same<a name="line.53"></a>
-<span class="sourceLineNo">054</span> * internal state allows to create different instances of a generator<a name="line.54"></a>
-<span class="sourceLineNo">055</span> * that will produce the same sequence of pseudo-random numbers.<a name="line.55"></a>
-<span class="sourceLineNo">056</span> * &lt;/p&gt;<a name="line.56"></a>
-<span class="sourceLineNo">057</span> *<a name="line.57"></a>
-<span class="sourceLineNo">058</span> * &lt;p&gt;<a name="line.58"></a>
-<span class="sourceLineNo">059</span> * The type of data used as a seed depends on the concrete implementation<a name="line.59"></a>
-<span class="sourceLineNo">060</span> * as some types may not provide enough information to fully initialize<a name="line.60"></a>
-<span class="sourceLineNo">061</span> * the generator's internal state.<a name="line.61"></a>
-<span class="sourceLineNo">062</span> * &lt;br&gt;<a name="line.62"></a>
-<span class="sourceLineNo">063</span> * The reference algorithm's seeding procedure (if provided) operates<a name="line.63"></a>
-<span class="sourceLineNo">064</span> * on a value of a (single) &lt;i&gt;native&lt;/i&gt; type:<a name="line.64"></a>
-<span class="sourceLineNo">065</span> * Each concrete implementation's constructor creates an instance using<a name="line.65"></a>
-<span class="sourceLineNo">066</span> * the native type whose information contents is used to set the<a name="line.66"></a>
-<span class="sourceLineNo">067</span> * internal state.<a name="line.67"></a>
-<span class="sourceLineNo">068</span> * &lt;br&gt;<a name="line.68"></a>
-<span class="sourceLineNo">069</span> * When the seed value passed by the caller is of the native type, it is<a name="line.69"></a>
-<span class="sourceLineNo">070</span> * expected that the sequences produced will be identical to those<a name="line.70"></a>
-<span class="sourceLineNo">071</span> * produced by other implementations of the same reference algorithm.<a name="line.71"></a>
-<span class="sourceLineNo">072</span> * &lt;br&gt;<a name="line.72"></a>
-<span class="sourceLineNo">073</span> * However, when the seed value passed by the caller is not of the native<a name="line.73"></a>
-<span class="sourceLineNo">074</span> * type, a transformation is performed by this library and the resulting<a name="line.74"></a>
-<span class="sourceLineNo">075</span> * native type value will &lt;i&gt;not&lt;/i&gt; contain more information than the<a name="line.75"></a>
-<span class="sourceLineNo">076</span> * original seed value.<a name="line.76"></a>
-<span class="sourceLineNo">077</span> * If the algorithm's native type is "simpler" than the type passed by<a name="line.77"></a>
-<span class="sourceLineNo">078</span> * the caller, then some (unused) information will even be lost.<a name="line.78"></a>
-<span class="sourceLineNo">079</span> * &lt;br&gt;<a name="line.79"></a>
-<span class="sourceLineNo">080</span> * The transformation from non-native to native seed type is arbitrary,<a name="line.80"></a>
-<span class="sourceLineNo">081</span> * as long as it does not reduce the amount of information required by<a name="line.81"></a>
-<span class="sourceLineNo">082</span> * the algorithm to initialize its state.<a name="line.82"></a>
-<span class="sourceLineNo">083</span> * The consequence of the transformation is that sequences produced<a name="line.83"></a>
-<span class="sourceLineNo">084</span> * by this library may &lt;i&gt;not&lt;/i&gt; be the same as the sequences produced<a name="line.84"></a>
-<span class="sourceLineNo">085</span> * by other implementations of the same algorithm!<a name="line.85"></a>
-<span class="sourceLineNo">086</span> * &lt;/p&gt;<a name="line.86"></a>
-<span class="sourceLineNo">087</span> *<a name="line.87"></a>
-<span class="sourceLineNo">088</span> * &lt;p&gt;<a name="line.88"></a>
-<span class="sourceLineNo">089</span> * This class provides methods to generate random seeds (single values<a name="line.89"></a>
-<span class="sourceLineNo">090</span> * or arrays of values, of {@code int} or {@code long} types) that can<a name="line.90"></a>
-<span class="sourceLineNo">091</span> * be passed to the {@link RandomSource#create(RandomSource,Object,Object[])<a name="line.91"></a>
-<span class="sourceLineNo">092</span> * generators factory method}.<a name="line.92"></a>
-<span class="sourceLineNo">093</span> * &lt;br&gt;<a name="line.93"></a>
-<span class="sourceLineNo">094</span> * Although the seed-generating methods defined in this class will likely<a name="line.94"></a>
-<span class="sourceLineNo">095</span> * return different values each time they are called, there is no guarantee<a name="line.95"></a>
-<span class="sourceLineNo">096</span> * that the resulting "seed" will always generate a &lt;i&gt;good&lt;/i&gt; (i.e.<a name="line.96"></a>
-<span class="sourceLineNo">097</span> * sufficiently uniformly random for the intended purpose) sequence of<a name="line.97"></a>
-<span class="sourceLineNo">098</span> * numbers, even if the generator is good!<a name="line.98"></a>
-<span class="sourceLineNo">099</span> * The only way to ensure that the selected seed will make the generator<a name="line.99"></a>
-<span class="sourceLineNo">100</span> * produce a good sequence is to submit that sequence to a series of<a name="line.100"></a>
-<span class="sourceLineNo">101</span> * stringent tests, as provided by tools such as<a name="line.101"></a>
-<span class="sourceLineNo">102</span> * &lt;a href="http://www.phy.duke.edu/~rgb/General/dieharder.php"&gt;dieharder&lt;/a&gt;<a name="line.102"></a>
-<span class="sourceLineNo">103</span> * or &lt;a href="http://simul.iro.umontreal.ca/testu01/tu01.html"&gt;TestU01&lt;/a&gt;.<a name="line.103"></a>
-<span class="sourceLineNo">104</span> * &lt;/p&gt;<a name="line.104"></a>
-<span class="sourceLineNo">105</span> *<a name="line.105"></a>
-<span class="sourceLineNo">106</span> * &lt;p&gt;<a name="line.106"></a>
-<span class="sourceLineNo">107</span> * The current implementations have no provision for producing non-overlapping<a name="line.107"></a>
-<span class="sourceLineNo">108</span> * sequences.<a name="line.108"></a>
-<span class="sourceLineNo">109</span> * For parallel applications, a possible workaround is that each thread uses<a name="line.109"></a>
-<span class="sourceLineNo">110</span> * a generator of a different type (see {@link #TWO_CMRES_SELECT}).<a name="line.110"></a>
-<span class="sourceLineNo">111</span> * &lt;/p&gt;<a name="line.111"></a>
-<span class="sourceLineNo">112</span> *<a name="line.112"></a>
-<span class="sourceLineNo">113</span> * &lt;p&gt;<a name="line.113"></a>
-<span class="sourceLineNo">114</span> * &lt;b&gt;Note:&lt;/b&gt;<a name="line.114"></a>
-<span class="sourceLineNo">115</span> * Seeding is not equivalent to restoring the internal state of an<a name="line.115"></a>
-<span class="sourceLineNo">116</span> * &lt;i&gt;already initialized&lt;/i&gt; generator.<a name="line.116"></a>
-<span class="sourceLineNo">117</span> * Indeed, generators can have a state that is more complex than the<a name="line.117"></a>
-<span class="sourceLineNo">118</span> * seed, and seeding is thus a transformation (from seed to state).<a name="line.118"></a>
-<span class="sourceLineNo">119</span> * Implementations do not provide the inverse transformation (from<a name="line.119"></a>
-<span class="sourceLineNo">120</span> * state to seed), hence it is not generally possible to know the seed<a name="line.120"></a>
-<span class="sourceLineNo">121</span> * that would initialize a new generator instance to the current state<a name="line.121"></a>
-<span class="sourceLineNo">122</span> * of another instance.<a name="line.122"></a>
-<span class="sourceLineNo">123</span> * Reseeding is also inefficient if the purpose is to continue the<a name="line.123"></a>
-<span class="sourceLineNo">124</span> * same sequence where another instance left off, as it would require<a name="line.124"></a>
-<span class="sourceLineNo">125</span> * to "replay" all the calls performed by that other instance (and it<a name="line.125"></a>
-<span class="sourceLineNo">126</span> * would require to know the number of calls to the primary source of<a name="line.126"></a>
-<span class="sourceLineNo">127</span> * randomness, which is also not usually accessible).<a name="line.127"></a>
-<span class="sourceLineNo">128</span> * &lt;br&gt;<a name="line.128"></a>
-<span class="sourceLineNo">129</span> * This factory thus provides a method for<a name="line.129"></a>
-<span class="sourceLineNo">130</span> * {@link #saveState(UniformRandomProvider) saving} the internal<a name="line.130"></a>
-<span class="sourceLineNo">131</span> * state of a generator.<a name="line.131"></a>
-<span class="sourceLineNo">132</span> * The state is encapsulated in an {@link State "opaque object"} to be<a name="line.132"></a>
-<span class="sourceLineNo">133</span> * used for {@link #restoreState(UniformRandomProvider,State) restoring}<a name="line.133"></a>
-<span class="sourceLineNo">134</span> * a generator (of the same type) to an identical state (e.g. to allow<a name="line.134"></a>
-<span class="sourceLineNo">135</span> * persistent storage, or to continue a sequence from where the original<a name="line.135"></a>
-<span class="sourceLineNo">136</span> * instance left off).<a name="line.136"></a>
-<span class="sourceLineNo">137</span> * &lt;/p&gt;<a name="line.137"></a>
-<span class="sourceLineNo">138</span> *<a name="line.138"></a>
-<span class="sourceLineNo">139</span> * @since 1.0<a name="line.139"></a>
-<span class="sourceLineNo">140</span> */<a name="line.140"></a>
-<span class="sourceLineNo">141</span>public enum RandomSource {<a name="line.141"></a>
-<span class="sourceLineNo">142</span>    /**<a name="line.142"></a>
-<span class="sourceLineNo">143</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.JDKRandom}.<a name="line.143"></a>
-<span class="sourceLineNo">144</span>     * Native seed type: {@code Long}.<a name="line.144"></a>
-<span class="sourceLineNo">145</span>     */<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    JDK(ProviderBuilder.RandomSourceInternal.JDK),<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    /**<a name="line.147"></a>
-<span class="sourceLineNo">148</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well512a}.<a name="line.148"></a>
-<span class="sourceLineNo">149</span>     * Native seed type: {@code int[]}.<a name="line.149"></a>
-<span class="sourceLineNo">150</span>     */<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    WELL_512_A(ProviderBuilder.RandomSourceInternal.WELL_512_A),<a name="line.151"></a>
-<span class="sourceLineNo">152</span>    /**<a name="line.152"></a>
-<span class="sourceLineNo">153</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well1024a}.<a name="line.153"></a>
-<span class="sourceLineNo">154</span>     * Native seed type: {@code int[]}.<a name="line.154"></a>
-<span class="sourceLineNo">155</span>     */<a name="line.155"></a>
-<span class="sourceLineNo">156</span>    WELL_1024_A(ProviderBuilder.RandomSourceInternal.WELL_1024_A),<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    /**<a name="line.157"></a>
-<span class="sourceLineNo">158</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well19937a}.<a name="line.158"></a>
-<span class="sourceLineNo">159</span>     * Native seed type: {@code int[]}.<a name="line.159"></a>
-<span class="sourceLineNo">160</span>     */<a name="line.160"></a>
-<span class="sourceLineNo">161</span>    WELL_19937_A(ProviderBuilder.RandomSourceInternal.WELL_19937_A),<a name="line.161"></a>
-<span class="sourceLineNo">162</span>    /**<a name="line.162"></a>
-<span class="sourceLineNo">163</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well19937c}.<a name="line.163"></a>
-<span class="sourceLineNo">164</span>     * Native seed type: {@code int[]}.<a name="line.164"></a>
-<span class="sourceLineNo">165</span>     */<a name="line.165"></a>
-<span class="sourceLineNo">166</span>    WELL_19937_C(ProviderBuilder.RandomSourceInternal.WELL_19937_C),<a name="line.166"></a>
-<span class="sourceLineNo">167</span>    /**<a name="line.167"></a>
-<span class="sourceLineNo">168</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well44497a}.<a name="line.168"></a>
-<span class="sourceLineNo">169</span>     * Native seed type: {@code int[]}.<a name="line.169"></a>
-<span class="sourceLineNo">170</span>     */<a name="line.170"></a>
-<span class="sourceLineNo">171</span>    WELL_44497_A(ProviderBuilder.RandomSourceInternal.WELL_44497_A),<a name="line.171"></a>
-<span class="sourceLineNo">172</span>    /**<a name="line.172"></a>
-<span class="sourceLineNo">173</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well44497b}.<a name="line.173"></a>
-<span class="sourceLineNo">174</span>     * Native seed type: {@code int[]}.<a name="line.174"></a>
-<span class="sourceLineNo">175</span>     */<a name="line.175"></a>
-<span class="sourceLineNo">176</span>    WELL_44497_B(ProviderBuilder.RandomSourceInternal.WELL_44497_B),<a name="line.176"></a>
-<span class="sourceLineNo">177</span>    /**<a name="line.177"></a>
-<span class="sourceLineNo">178</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.MersenneTwister}.<a name="line.178"></a>
-<span class="sourceLineNo">179</span>     * Native seed type: {@code int[]}.<a name="line.179"></a>
-<span class="sourceLineNo">180</span>     */<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    MT(ProviderBuilder.RandomSourceInternal.MT),<a name="line.181"></a>
-<span class="sourceLineNo">182</span>    /**<a name="line.182"></a>
-<span class="sourceLineNo">183</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.ISAACRandom}.<a name="line.183"></a>
-<span class="sourceLineNo">184</span>     * Native seed type: {@code int[]}.<a name="line.184"></a>
-<span class="sourceLineNo">185</span>     */<a name="line.185"></a>
-<span class="sourceLineNo">186</span>    ISAAC(ProviderBuilder.RandomSourceInternal.ISAAC),<a name="line.186"></a>
-<span class="sourceLineNo">187</span>    /**<a name="line.187"></a>
-<span class="sourceLineNo">188</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.SplitMix64}.<a name="line.188"></a>
-<span class="sourceLineNo">189</span>     * Native seed type: {@code Long}.<a name="line.189"></a>
-<span class="sourceLineNo">190</span>     */<a name="line.190"></a>
-<span class="sourceLineNo">191</span>    SPLIT_MIX_64(ProviderBuilder.RandomSourceInternal.SPLIT_MIX_64),<a name="line.191"></a>
-<span class="sourceLineNo">192</span>    /**<a name="line.192"></a>
-<span class="sourceLineNo">193</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.XorShift1024Star}.<a name="line.193"></a>
-<span class="sourceLineNo">194</span>     * Native seed type: {@code long[]}.<a name="line.194"></a>
-<span class="sourceLineNo">195</span>     */<a name="line.195"></a>
-<span class="sourceLineNo">196</span>    XOR_SHIFT_1024_S(ProviderBuilder.RandomSourceInternal.XOR_SHIFT_1024_S),<a name="line.196"></a>
-<span class="sourceLineNo">197</span>    /**<a name="line.197"></a>
-<span class="sourceLineNo">198</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.TwoCmres}.<a name="line.198"></a>
-<span class="sourceLineNo">199</span>     * Native seed type: {@code Integer}.<a name="line.199"></a>
-<span class="sourceLineNo">200</span>     */<a name="line.200"></a>
-<span class="sourceLineNo">201</span>    TWO_CMRES(ProviderBuilder.RandomSourceInternal.TWO_CMRES),<a name="line.201"></a>
-<span class="sourceLineNo">202</span>    /**<a name="line.202"></a>
-<span class="sourceLineNo">203</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.TwoCmres},<a name="line.203"></a>
-<span class="sourceLineNo">204</span>     * with explicit selection of the two subcycle generators.<a name="line.204"></a>
-<span class="sourceLineNo">205</span>     * Native seed type: {@code Integer}.<a name="line.205"></a>
-<span class="sourceLineNo">206</span>     */<a name="line.206"></a>
-<span class="sourceLineNo">207</span>    TWO_CMRES_SELECT(ProviderBuilder.RandomSourceInternal.TWO_CMRES_SELECT),<a name="line.207"></a>
-<span class="sourceLineNo">208</span>    /**<a name="line.208"></a>
-<span class="sourceLineNo">209</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.MersenneTwister64}.<a name="line.209"></a>
-<span class="sourceLineNo">210</span>     * Native seed type: {@code long[]}.<a name="line.210"></a>
-<span class="sourceLineNo">211</span>     */<a name="line.211"></a>
-<span class="sourceLineNo">212</span>    MT_64(ProviderBuilder.RandomSourceInternal.MT_64);<a name="line.212"></a>
-<span class="sourceLineNo">213</span><a name="line.213"></a>
-<span class="sourceLineNo">214</span>    /** Internal identifier. */<a name="line.214"></a>
-<span class="sourceLineNo">215</span>    private final ProviderBuilder.RandomSourceInternal internalIdentifier;<a name="line.215"></a>
-<span class="sourceLineNo">216</span><a name="line.216"></a>
-<span class="sourceLineNo">217</span>    /**<a name="line.217"></a>
-<span class="sourceLineNo">218</span>     * @param id Internal identifier.<a name="line.218"></a>
-<span class="sourceLineNo">219</span>     */<a name="line.219"></a>
-<span class="sourceLineNo">220</span>    RandomSource(ProviderBuilder.RandomSourceInternal id) {<a name="line.220"></a>
-<span class="sourceLineNo">221</span>        internalIdentifier = id;<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>    /**<a name="line.224"></a>
-<span class="sourceLineNo">225</span>     * @return the internal identifier.<a name="line.225"></a>
-<span class="sourceLineNo">226</span>     */<a name="line.226"></a>
-<span class="sourceLineNo">227</span>    ProviderBuilder.RandomSourceInternal getInternalIdentifier() {<a name="line.227"></a>
-<span class="sourceLineNo">228</span>        return internalIdentifier;<a name="line.228"></a>
-<span class="sourceLineNo">229</span>    }<a name="line.229"></a>
-<span class="sourceLineNo">230</span><a name="line.230"></a>
-<span class="sourceLineNo">231</span>    /**<a name="line.231"></a>
-<span class="sourceLineNo">232</span>     * Checks whether the type of given {@code seed} is the native type<a name="line.232"></a>
-<span class="sourceLineNo">233</span>     * of the implementation.<a name="line.233"></a>
-<span class="sourceLineNo">234</span>     *<a name="line.234"></a>
-<span class="sourceLineNo">235</span>     * @param seed Seed value.<a name="line.235"></a>
-<span class="sourceLineNo">236</span>     * @return {@code true} if the type of {@code seed} is the native<a name="line.236"></a>
-<span class="sourceLineNo">237</span>     * type for this RNG source.<a name="line.237"></a>
-<span class="sourceLineNo">238</span>     */<a name="line.238"></a>
-<span class="sourceLineNo">239</span>    public boolean isNativeSeed(Object seed) {<a name="line.239"></a>
-<span class="sourceLineNo">240</span>        return internalIdentifier.isNativeSeed(seed);<a name="line.240"></a>
-<span class="sourceLineNo">241</span>    }<a name="line.241"></a>
+<span class="sourceLineNo">019</span>import java.util.Arrays;<a name="line.19"></a>
+<span class="sourceLineNo">020</span>import org.apache.commons.rng.internal.ProviderBuilder;<a name="line.20"></a>
+<span class="sourceLineNo">021</span>import org.apache.commons.rng.internal.BaseProvider;<a name="line.21"></a>
+<span class="sourceLineNo">022</span>import org.apache.commons.rng.internal.util.SeedFactory;<a name="line.22"></a>
+<span class="sourceLineNo">023</span>import org.apache.commons.rng.internal.source64.TwoCmres;<a name="line.23"></a>
+<span class="sourceLineNo">024</span><a name="line.24"></a>
+<span class="sourceLineNo">025</span>/**<a name="line.25"></a>
+<span class="sourceLineNo">026</span> * This class provides the API for creating generators of random numbers.<a name="line.26"></a>
+<span class="sourceLineNo">027</span> * &lt;p&gt;<a name="line.27"></a>
+<span class="sourceLineNo">028</span> * Usage examples:<a name="line.28"></a>
+<span class="sourceLineNo">029</span> * &lt;pre&gt;&lt;code&gt;<a name="line.29"></a>
+<span class="sourceLineNo">030</span> *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT);<a name="line.30"></a>
+<span class="sourceLineNo">031</span> * &lt;/code&gt;&lt;/pre&gt;<a name="line.31"></a>
+<span class="sourceLineNo">032</span> * or<a name="line.32"></a>
+<span class="sourceLineNo">033</span> * &lt;pre&gt;&lt;code&gt;<a name="line.33"></a>
+<span class="sourceLineNo">034</span> *  final int[] seed = new int[] { 196, 9, 0, 226 };<a name="line.34"></a>
+<span class="sourceLineNo">035</span> *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed);<a name="line.35"></a>
+<span class="sourceLineNo">036</span> * &lt;/code&gt;&lt;/pre&gt;<a name="line.36"></a>
+<span class="sourceLineNo">037</span> * or<a name="line.37"></a>
+<span class="sourceLineNo">038</span> * &lt;pre&gt;&lt;code&gt;<a name="line.38"></a>
+<span class="sourceLineNo">039</span> *  final int[] seed = RandomSource.createIntArray(256);<a name="line.39"></a>
+<span class="sourceLineNo">040</span> *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed);<a name="line.40"></a>
+<span class="sourceLineNo">041</span> * &lt;/code&gt;&lt;/pre&gt;<a name="line.41"></a>
+<span class="sourceLineNo">042</span> * where the first argument to method {@code create} is the identifier<a name="line.42"></a>
+<span class="sourceLineNo">043</span> * of the generator's concrete implementation, and the second the is the<a name="line.43"></a>
+<span class="sourceLineNo">044</span> * (optional) seed.<a name="line.44"></a>
+<span class="sourceLineNo">045</span> * &lt;br&gt;<a name="line.45"></a>
+<span class="sourceLineNo">046</span> * In the first form, a random seed will be {@link SeedFactory generated<a name="line.46"></a>
+<span class="sourceLineNo">047</span> * automatically}; in the second form, a fixed seed is used; a random seed<a name="line.47"></a>
+<span class="sourceLineNo">048</span> * is explicitly generated in the third form.<a name="line.48"></a>
+<span class="sourceLineNo">049</span> * &lt;/p&gt;<a name="line.49"></a>
+<span class="sourceLineNo">050</span> *<a name="line.50"></a>
+<span class="sourceLineNo">051</span> * &lt;p&gt;<a name="line.51"></a>
+<span class="sourceLineNo">052</span> * Seeding is the procedure by which a value (or set of values) is<a name="line.52"></a>
+<span class="sourceLineNo">053</span> * used to &lt;i&gt;initialize&lt;/i&gt; a generator instance.<a name="line.53"></a>
+<span class="sourceLineNo">054</span> * The requirement that a given seed will always result in the same<a name="line.54"></a>
+<span class="sourceLineNo">055</span> * internal state allows to create different instances of a generator<a name="line.55"></a>
+<span class="sourceLineNo">056</span> * that will produce the same sequence of pseudo-random numbers.<a name="line.56"></a>
+<span class="sourceLineNo">057</span> * &lt;/p&gt;<a name="line.57"></a>
+<span class="sourceLineNo">058</span> *<a name="line.58"></a>
+<span class="sourceLineNo">059</span> * &lt;p&gt;<a name="line.59"></a>
+<span class="sourceLineNo">060</span> * The type of data used as a seed depends on the concrete implementation<a name="line.60"></a>
+<span class="sourceLineNo">061</span> * as some types may not provide enough information to fully initialize<a name="line.61"></a>
+<span class="sourceLineNo">062</span> * the generator's internal state.<a name="line.62"></a>
+<span class="sourceLineNo">063</span> * &lt;br&gt;<a name="line.63"></a>
+<span class="sourceLineNo">064</span> * The reference algorithm's seeding procedure (if provided) operates<a name="line.64"></a>
+<span class="sourceLineNo">065</span> * on a value of a (single) &lt;i&gt;native&lt;/i&gt; type:<a name="line.65"></a>
+<span class="sourceLineNo">066</span> * Each concrete implementation's constructor creates an instance using<a name="line.66"></a>
+<span class="sourceLineNo">067</span> * the native type whose information contents is used to set the<a name="line.67"></a>
+<span class="sourceLineNo">068</span> * internal state.<a name="line.68"></a>
+<span class="sourceLineNo">069</span> * &lt;br&gt;<a name="line.69"></a>
+<span class="sourceLineNo">070</span> * When the seed value passed by the caller is of the native type, it is<a name="line.70"></a>
+<span class="sourceLineNo">071</span> * expected that the sequences produced will be identical to those<a name="line.71"></a>
+<span class="sourceLineNo">072</span> * produced by other implementations of the same reference algorithm.<a name="line.72"></a>
+<span class="sourceLineNo">073</span> * &lt;br&gt;<a name="line.73"></a>
+<span class="sourceLineNo">074</span> * However, when the seed value passed by the caller is not of the native<a name="line.74"></a>
+<span class="sourceLineNo">075</span> * type, a transformation is performed by this library and the resulting<a name="line.75"></a>
+<span class="sourceLineNo">076</span> * native type value will &lt;i&gt;not&lt;/i&gt; contain more information than the<a name="line.76"></a>
+<span class="sourceLineNo">077</span> * original seed value.<a name="line.77"></a>
+<span class="sourceLineNo">078</span> * If the algorithm's native type is "simpler" than the type passed by<a name="line.78"></a>
+<span class="sourceLineNo">079</span> * the caller, then some (unused) information will even be lost.<a name="line.79"></a>
+<span class="sourceLineNo">080</span> * &lt;br&gt;<a name="line.80"></a>
+<span class="sourceLineNo">081</span> * The transformation from non-native to native seed type is arbitrary,<a name="line.81"></a>
+<span class="sourceLineNo">082</span> * as long as it does not reduce the amount of information required by<a name="line.82"></a>
+<span class="sourceLineNo">083</span> * the algorithm to initialize its state.<a name="line.83"></a>
+<span class="sourceLineNo">084</span> * The consequence of the transformation is that sequences produced<a name="line.84"></a>
+<span class="sourceLineNo">085</span> * by this library may &lt;i&gt;not&lt;/i&gt; be the same as the sequences produced<a name="line.85"></a>
+<span class="sourceLineNo">086</span> * by other implementations of the same algorithm!<a name="line.86"></a>
+<span class="sourceLineNo">087</span> * &lt;/p&gt;<a name="line.87"></a>
+<span class="sourceLineNo">088</span> *<a name="line.88"></a>
+<span class="sourceLineNo">089</span> * &lt;p&gt;<a name="line.89"></a>
+<span class="sourceLineNo">090</span> * This class provides methods to generate random seeds (single values<a name="line.90"></a>
+<span class="sourceLineNo">091</span> * or arrays of values, of {@code int} or {@code long} types) that can<a name="line.91"></a>
+<span class="sourceLineNo">092</span> * be passed to the {@link RandomSource#create(RandomSource,Object,Object[])<a name="line.92"></a>
+<span class="sourceLineNo">093</span> * generators factory method}.<a name="line.93"></a>
+<span class="sourceLineNo">094</span> * &lt;br&gt;<a name="line.94"></a>
+<span class="sourceLineNo">095</span> * Although the seed-generating methods defined in this class will likely<a name="line.95"></a>
+<span class="sourceLineNo">096</span> * return different values each time they are called, there is no guarantee<a name="line.96"></a>
+<span class="sourceLineNo">097</span> * that the resulting "seed" will always generate a &lt;i&gt;good&lt;/i&gt; (i.e.<a name="line.97"></a>
+<span class="sourceLineNo">098</span> * sufficiently uniformly random for the intended purpose) sequence of<a name="line.98"></a>
+<span class="sourceLineNo">099</span> * numbers, even if the generator is good!<a name="line.99"></a>
+<span class="sourceLineNo">100</span> * The only way to ensure that the selected seed will make the generator<a name="line.100"></a>
+<span class="sourceLineNo">101</span> * produce a good sequence is to submit that sequence to a series of<a name="line.101"></a>
+<span class="sourceLineNo">102</span> * stringent tests, as provided by tools such as<a name="line.102"></a>
+<span class="sourceLineNo">103</span> * &lt;a href="http://www.phy.duke.edu/~rgb/General/dieharder.php"&gt;dieharder&lt;/a&gt;<a name="line.103"></a>
+<span class="sourceLineNo">104</span> * or &lt;a href="http://simul.iro.umontreal.ca/testu01/tu01.html"&gt;TestU01&lt;/a&gt;.<a name="line.104"></a>
+<span class="sourceLineNo">105</span> * &lt;/p&gt;<a name="line.105"></a>
+<span class="sourceLineNo">106</span> *<a name="line.106"></a>
+<span class="sourceLineNo">107</span> * &lt;p&gt;<a name="line.107"></a>
+<span class="sourceLineNo">108</span> * The current implementations have no provision for producing non-overlapping<a name="line.108"></a>
+<span class="sourceLineNo">109</span> * sequences.<a name="line.109"></a>
+<span class="sourceLineNo">110</span> * For parallel applications, a possible workaround is that each thread uses<a name="line.110"></a>
+<span class="sourceLineNo">111</span> * a generator of a different type (see {@link #TWO_CMRES_SELECT}).<a name="line.111"></a>
+<span class="sourceLineNo">112</span> * &lt;/p&gt;<a name="line.112"></a>
+<span class="sourceLineNo">113</span> *<a name="line.113"></a>
+<span class="sourceLineNo">114</span> * &lt;p&gt;<a name="line.114"></a>
+<span class="sourceLineNo">115</span> * &lt;b&gt;Note:&lt;/b&gt;<a name="line.115"></a>
+<span class="sourceLineNo">116</span> * Seeding is not equivalent to restoring the internal state of an<a name="line.116"></a>
+<span class="sourceLineNo">117</span> * &lt;i&gt;already initialized&lt;/i&gt; generator.<a name="line.117"></a>
+<span class="sourceLineNo">118</span> * Indeed, generators can have a state that is more complex than the<a name="line.118"></a>
+<span class="sourceLineNo">119</span> * seed, and seeding is thus a transformation (from seed to state).<a name="line.119"></a>
+<span class="sourceLineNo">120</span> * Implementations do not provide the inverse transformation (from<a name="line.120"></a>
+<span class="sourceLineNo">121</span> * state to seed), hence it is not generally possible to know the seed<a name="line.121"></a>
+<span class="sourceLineNo">122</span> * that would initialize a new generator instance to the current state<a name="line.122"></a>
+<span class="sourceLineNo">123</span> * of another instance.<a name="line.123"></a>
+<span class="sourceLineNo">124</span> * Reseeding is also inefficient if the purpose is to continue the<a name="line.124"></a>
+<span class="sourceLineNo">125</span> * same sequence where another instance left off, as it would require<a name="line.125"></a>
+<span class="sourceLineNo">126</span> * to "replay" all the calls performed by that other instance (and it<a name="line.126"></a>
+<span class="sourceLineNo">127</span> * would require to know the number of calls to the primary source of<a name="line.127"></a>
+<span class="sourceLineNo">128</span> * randomness, which is also not usually accessible).<a name="line.128"></a>
+<span class="sourceLineNo">129</span> * &lt;br&gt;<a name="line.129"></a>
+<span class="sourceLineNo">130</span> * This factory thus provides a method for<a name="line.130"></a>
+<span class="sourceLineNo">131</span> * {@link #saveState(UniformRandomProvider) saving} the internal<a name="line.131"></a>
+<span class="sourceLineNo">132</span> * state of a generator.<a name="line.132"></a>
+<span class="sourceLineNo">133</span> * The state is wrapped in an {@link SourceState "opaque object"} to be<a name="line.133"></a>
+<span class="sourceLineNo">134</span> * used for {@link #restoreState(UniformRandomProvider,SourceState) restoring}<a name="line.134"></a>
+<span class="sourceLineNo">135</span> * a generator (of the same type) to an identical state (e.g. to allow<a name="line.135"></a>
+<span class="sourceLineNo">136</span> * persistent storage, or to continue a sequence from where the original<a name="line.136"></a>
+<span class="sourceLineNo">137</span> * instance left off).<a name="line.137"></a>
+<span class="sourceLineNo">138</span> * &lt;/p&gt;<a name="line.138"></a>
+<span class="sourceLineNo">139</span> *<a name="line.139"></a>
+<span class="sourceLineNo">140</span> * @since 1.0<a name="line.140"></a>
+<span class="sourceLineNo">141</span> */<a name="line.141"></a>
+<span class="sourceLineNo">142</span>public enum RandomSource {<a name="line.142"></a>
+<span class="sourceLineNo">143</span>    /**<a name="line.143"></a>
+<span class="sourceLineNo">144</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.JDKRandom}.<a name="line.144"></a>
+<span class="sourceLineNo">145</span>     * Native seed type: {@code Long}.<a name="line.145"></a>
+<span class="sourceLineNo">146</span>     */<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    JDK(ProviderBuilder.RandomSourceInternal.JDK),<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    /**<a name="line.148"></a>
+<span class="sourceLineNo">149</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well512a}.<a name="line.149"></a>
+<span class="sourceLineNo">150</span>     * Native seed type: {@code int[]}.<a name="line.150"></a>
+<span class="sourceLineNo">151</span>     */<a name="line.151"></a>
+<span class="sourceLineNo">152</span>    WELL_512_A(ProviderBuilder.RandomSourceInternal.WELL_512_A),<a name="line.152"></a>
+<span class="sourceLineNo">153</span>    /**<a name="line.153"></a>
+<span class="sourceLineNo">154</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well1024a}.<a name="line.154"></a>
+<span class="sourceLineNo">155</span>     * Native seed type: {@code int[]}.<a name="line.155"></a>
+<span class="sourceLineNo">156</span>     */<a name="line.156"></a>
+<span class="sourceLineNo">157</span>    WELL_1024_A(ProviderBuilder.RandomSourceInternal.WELL_1024_A),<a name="line.157"></a>
+<span class="sourceLineNo">158</span>    /**<a name="line.158"></a>
+<span class="sourceLineNo">159</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well19937a}.<a name="line.159"></a>
+<span class="sourceLineNo">160</span>     * Native seed type: {@code int[]}.<a name="line.160"></a>
+<span class="sourceLineNo">161</span>     */<a name="line.161"></a>
+<span class="sourceLineNo">162</span>    WELL_19937_A(ProviderBuilder.RandomSourceInternal.WELL_19937_A),<a name="line.162"></a>
+<span class="sourceLineNo">163</span>    /**<a name="line.163"></a>
+<span class="sourceLineNo">164</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well19937c}.<a name="line.164"></a>
+<span class="sourceLineNo">165</span>     * Native seed type: {@code int[]}.<a name="line.165"></a>
+<span class="sourceLineNo">166</span>     */<a name="line.166"></a>
+<span class="sourceLineNo">167</span>    WELL_19937_C(ProviderBuilder.RandomSourceInternal.WELL_19937_C),<a name="line.167"></a>
+<span class="sourceLineNo">168</span>    /**<a name="line.168"></a>
+<span class="sourceLineNo">169</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well44497a}.<a name="line.169"></a>
+<span class="sourceLineNo">170</span>     * Native seed type: {@code int[]}.<a name="line.170"></a>
+<span class="sourceLineNo">171</span>     */<a name="line.171"></a>
+<span class="sourceLineNo">172</span>    WELL_44497_A(ProviderBuilder.RandomSourceInternal.WELL_44497_A),<a name="line.172"></a>
+<span class="sourceLineNo">173</span>    /**<a name="line.173"></a>
+<span class="sourceLineNo">174</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.Well44497b}.<a name="line.174"></a>
+<span class="sourceLineNo">175</span>     * Native seed type: {@code int[]}.<a name="line.175"></a>
+<span class="sourceLineNo">176</span>     */<a name="line.176"></a>
+<span class="sourceLineNo">177</span>    WELL_44497_B(ProviderBuilder.RandomSourceInternal.WELL_44497_B),<a name="line.177"></a>
+<span class="sourceLineNo">178</span>    /**<a name="line.178"></a>
+<span class="sourceLineNo">179</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.MersenneTwister}.<a name="line.179"></a>
+<span class="sourceLineNo">180</span>     * Native seed type: {@code int[]}.<a name="line.180"></a>
+<span class="sourceLineNo">181</span>     */<a name="line.181"></a>
+<span class="sourceLineNo">182</span>    MT(ProviderBuilder.RandomSourceInternal.MT),<a name="line.182"></a>
+<span class="sourceLineNo">183</span>    /**<a name="line.183"></a>
+<span class="sourceLineNo">184</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source32.ISAACRandom}.<a name="line.184"></a>
+<span class="sourceLineNo">185</span>     * Native seed type: {@code int[]}.<a name="line.185"></a>
+<span class="sourceLineNo">186</span>     */<a name="line.186"></a>
+<span class="sourceLineNo">187</span>    ISAAC(ProviderBuilder.RandomSourceInternal.ISAAC),<a name="line.187"></a>
+<span class="sourceLineNo">188</span>    /**<a name="line.188"></a>
+<span class="sourceLineNo">189</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.SplitMix64}.<a name="line.189"></a>
+<span class="sourceLineNo">190</span>     * Native seed type: {@code Long}.<a name="line.190"></a>
+<span class="sourceLineNo">191</span>     */<a name="line.191"></a>
+<span class="sourceLineNo">192</span>    SPLIT_MIX_64(ProviderBuilder.RandomSourceInternal.SPLIT_MIX_64),<a name="line.192"></a>
+<span class="sourceLineNo">193</span>    /**<a name="line.193"></a>
+<span class="sourceLineNo">194</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.XorShift1024Star}.<a name="line.194"></a>
+<span class="sourceLineNo">195</span>     * Native seed type: {@code long[]}.<a name="line.195"></a>
+<span class="sourceLineNo">196</span>     */<a name="line.196"></a>
+<span class="sourceLineNo">197</span>    XOR_SHIFT_1024_S(ProviderBuilder.RandomSourceInternal.XOR_SHIFT_1024_S),<a name="line.197"></a>
+<span class="sourceLineNo">198</span>    /**<a name="line.198"></a>
+<span class="sourceLineNo">199</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.TwoCmres}.<a name="line.199"></a>
+<span class="sourceLineNo">200</span>     * Native seed type: {@code Integer}.<a name="line.200"></a>
+<span class="sourceLineNo">201</span>     */<a name="line.201"></a>
+<span class="sourceLineNo">202</span>    TWO_CMRES(ProviderBuilder.RandomSourceInternal.TWO_CMRES),<a name="line.202"></a>
+<span class="sourceLineNo">203</span>    /**<a name="line.203"></a>
+<span class="sourceLineNo">204</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.TwoCmres},<a name="line.204"></a>
+<span class="sourceLineNo">205</span>     * with explicit selection of the two subcycle generators.<a name="line.205"></a>
+<span class="sourceLineNo">206</span>     * Native seed type: {@code Integer}.<a name="line.206"></a>
+<span class="sourceLineNo">207</span>     */<a name="line.207"></a>
+<span class="sourceLineNo">208</span>    TWO_CMRES_SELECT(ProviderBuilder.RandomSourceInternal.TWO_CMRES_SELECT),<a name="line.208"></a>
+<span class="sourceLineNo">209</span>    /**<a name="line.209"></a>
+<span class="sourceLineNo">210</span>     * Source of randomness is {@link org.apache.commons.rng.internal.source64.MersenneTwister64}.<a name="line.210"></a>
+<span class="sourceLineNo">211</span>     * Native seed type: {@code long[]}.<a name="line.211"></a>
+<span class="sourceLineNo">212</span>     */<a name="line.212"></a>
+<span class="sourceLineNo">213</span>    MT_64(ProviderBuilder.RandomSourceInternal.MT_64);<a name="line.213"></a>
+<span class="sourceLineNo">214</span><a name="line.214"></a>
+<span class="sourceLineNo">215</span>    /** Internal identifier. */<a name="line.215"></a>
+<span class="sourceLineNo">216</span>    private final ProviderBuilder.RandomSourceInternal internalIdentifier;<a name="line.216"></a>
+<span class="sourceLineNo">217</span><a name="line.217"></a>
+<span class="sourceLineNo">218</span>    /**<a name="line.218"></a>
+<span class="sourceLineNo">219</span>     * Wraps the internal state of a {@link UniformRandomProvider}.<a name="line.219"></a>
+<span class="sourceLineNo">220</span>     * Its purpose is to store all the data needed to recover the same<a name="line.220"></a>
+<span class="sourceLineNo">221</span>     * state in order to restart a sequence where it left off.<a name="line.221"></a>
+<span class="sourceLineNo">222</span>     * External code should not to modify the data contained in instances<a name="line.222"></a>
+<span class="sourceLineNo">223</span>     * of this class.<a name="line.223"></a>
+<span class="sourceLineNo">224</span>     */<a name="line.224"></a>
+<span class="sourceLineNo">225</span>    public static class State {<a name="line.225"></a>
+<span class="sourceLineNo">226</span>        /** Internal state. */<a name="line.226"></a>
+<span class="sourceLineNo">227</span>        private final byte[] state;<a name="line.227"></a>
+<span class="sourceLineNo">228</span><a name="line.228"></a>
+<span class="sourceLineNo">229</span>        /**<a name="line.229"></a>
+<span class="sourceLineNo">230</span>         * Initializes an instance.<a name="line.230"></a>
+<span class="sourceLineNo">231</span>         * The contents of the {@code state} argument is unspecified, and is<a name="line.231"></a>
+<span class="sourceLineNo">232</span>         * guaranteed to be valid only if it was generated by implementations<a name="line.232"></a>
+<span class="sourceLineNo">233</span>         * provided by this library.<a name="line.233"></a>
+<span class="sourceLineNo">234</span>         *<a name="line.234"></a>
+<span class="sourceLineNo">235</span>         * @param state Mapping of all the data which an implementation of<a name="line.235"></a>
+<span class="sourceLineNo">236</span>         * {@link UniformRandomProvider} needs in order to reset its internal<a name="line.236"></a>
+<span class="sourceLineNo">237</span>         * state.<a name="line.237"></a>
+<span class="sourceLineNo">238</span>         */<a name="line.238"></a>
+<span class="sourceLineNo">239</span>        public State(byte[] state) {<a name="line.239"></a>
+<span class="sourceLineNo">240</span>            this.state = Arrays.copyOf(state, state.length);<a name="line.240"></a>
+<span class="sourceLineNo">241</span>        }<a name="line.241"></a>
 <span class="sourceLineNo">242</span><a name="line.242"></a>
-<span class="sourceLineNo">243</span>    /**<a name="line.243"></a>
-<span class="sourceLineNo">244</span>     * Marker interface used to define the "save" and "restore"<a name="line.244"></a>
-<span class="sourceLineNo">245</span>     * functionality of the generators.<a name="line.245"></a>
-<span class="sourceLineNo">246</span>     */<a name="line.246"></a>
-<span class="sourceLineNo">247</span>    public interface State {}<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>     * Creates a random number generator with a random seed.<a name="line.250"></a>
-<span class="sourceLineNo">251</span>     *<a name="line.251"></a>
-<span class="sourceLineNo">252</span>     * &lt;p&gt;<a name="line.252"></a>
-<span class="sourceLineNo">253</span>     * Example of usage:<a name="line.253"></a>
-<span class="sourceLineNo">254</span>     * &lt;pre&gt;&lt;code&gt;<a name="line.254"></a>
-<span class="sourceLineNo">255</span>     *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT);<a name="line.255"></a>
-<span class="sourceLineNo">256</span>     * &lt;/code&gt;&lt;/pre&gt;<a name="line.256"></a>
-<span class="sourceLineNo">257</span>     * &lt;/p&gt;<a name="line.257"></a>
-<span class="sourceLineNo">258</span>     *<a name="line.258"></a>
-<span class="sourceLineNo">259</span>     * @param source RNG type.<a name="line.259"></a>
-<span class="sourceLineNo">260</span>     * @return the RNG.<a name="line.260"></a>
-<span class="sourceLineNo">261</span>     */<a name="line.261"></a>
-<span class="sourceLineNo">262</span>    public static UniformRandomProvider create(RandomSource source) {<a name="line.262"></a>
-<span class="sourceLineNo">263</span>        return create(source, null);<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 generator with the given {@code seed}.<a name="line.267"></a>
+<span class="sourceLineNo">243</span>        /**<a name="line.243"></a>
+<span class="sourceLineNo">244</span>         * @return the internal state.<a name="line.244"></a>
+<span class="sourceLineNo">245</span>         */<a name="line.245"></a>
+<span class="sourceLineNo">246</span>        public byte[] getState() {<a name="line.246"></a>
+<span class="sourceLineNo">247</span>            return Arrays.copyOf(state, state.length);<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>    /**<a name="line.251"></a>
+<span class="sourceLineNo">252</span>     * @param id Internal identifier.<a name="line.252"></a>
+<span class="sourceLineNo">253</span>     */<a name="line.253"></a>
+<span class="sourceLineNo">254</span>    RandomSource(ProviderBuilder.RandomSourceInternal id) {<a name="line.254"></a>
+<span class="sourceLineNo">255</span>        internalIdentifier = id;<a name="line.255"></a>
+<span class="sourceLineNo">256</span>    }<a name="line.256"></a>
+<span class="sourceLineNo">257</span><a name="line.257"></a>
+<span class="sourceLineNo">258</span>    /**<a name="line.258"></a>
+<span class="sourceLineNo">259</span>     * @return the internal identifier.<a name="line.259"></a>
+<span class="sourceLineNo">260</span>     */<a name="line.260"></a>
+<span class="sourceLineNo">261</span>    ProviderBuilder.RandomSourceInternal getInternalIdentifier() {<a name="line.261"></a>
+<span class="sourceLineNo">262</span>        return internalIdentifier;<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>     * Checks whether the type of given {@code seed} is the native type<a name="line.266"></a>
+<span class="sourceLineNo">267</span>     * of the implementation.<a name="line.267"></a>
 <span class="sourceLineNo">268</span>     *<a name="line.268"></a>
-<span class="sourceLineNo">269</span>     * &lt;p&gt;<a name="line.269"></a>
-<span class="sourceLineNo">270</span>     * Example of usage:<a name="line.270"></a>
-<span class="sourceLineNo">271</span>     * &lt;pre&gt;&lt;code&gt;<a name="line.271"></a>
-<span class="sourceLineNo">272</span>     *  UniformRandomProvider rng = RandomSource.create(RandomSource.TWO_CMRES_SELECT, 26219, 6, 9);<a name="line.272"></a>
-<span class="sourceLineNo">273</span>     * &lt;/code&gt;&lt;/pre&gt;<a name="line.273"></a>
-<span class="sourceLineNo">274</span>     * &lt;/p&gt;<a name="line.274"></a>
-<span class="sourceLineNo">275</span>     *<a name="line.275"></a>
-<span class="sourceLineNo">276</span>     * &lt;p&gt;<a name="line.276"></a>
-<span class="sourceLineNo">277</span>     * Valid types for the {@code seed} are:<a name="line.277"></a>
-<span class="sourceLineNo">278</span>     *  &lt;ul&gt;<a name="line.278"></a>
-<span class="sourceLineNo">279</span>     *   &lt;li&gt;{@code Integer} (or {@code int})&lt;/li&gt;<a name="line.279"></a>
-<span class="sourceLineNo">280</span>     *   &lt;li&gt;{@code Long} (or {@code long})&lt;/li&gt;<a name="line.280"></a>
-<span class="sourceLineNo">281</span>     *   &lt;li&gt;{@code int[]}&lt;/li&gt;<a name="line.281"></a>
-<span class="sourceLineNo">282</span>     *   &lt;li&gt;{@code long[]}&lt;/li&gt;<a name="line.282"></a>
-<span class="sourceLineNo">283</span>     *  &lt;/ul&gt;<a name="line.283"></a>
-<span class="sourceLineNo">284</span>     * &lt;/p&gt;<a name="line.284"></a>
-<span class="sourceLineNo">285</span>     *<a name="line.285"></a>
-<span class="sourceLineNo">286</span>     * &lt;p&gt;<a name="line.286"></a>
-<span class="sourceLineNo">287</span>     * Notes:<a name="line.287"></a>
-<span class="sourceLineNo">288</span>     * &lt;ul&gt;<a name="line.288"></a>
-<span class="sourceLineNo">289</span>     *  &lt;li&gt;<a name="line.289"></a>
-<span class="sourceLineNo">290</span>     *   When the seed type passed as argument is more complex (i.e. more<a name="line.290"></a>
-<span class="sourceLineNo">291</span>     *   bits can be independently chosen) than the generator's<a name="line.291"></a>
-<span class="sourceLineNo">292</span>     *   {@link #isNativeSeed(Object) native type}, the conversion of a<a name="line.292"></a>
-<span class="sourceLineNo">293</span>     *   set of different seeds will necessarily result in the same value<a name="line.293"></a>
-<span class="sourceLineNo">294</span>     *   of the native seed type.<a name="line.294"></a>
-<span class="sourceLineNo">295</span>     *  &lt;/li&gt;<a name="line.295"></a>
-<span class="sourceLineNo">296</span>     *  &lt;li&gt;<a name="line.296"></a>
-<span class="sourceLineNo">297</span>     *   When the native seed type is an array, the same remark applies<a name="line.297"></a>
-<span class="sourceLineNo">298</span>     *   when the array contains more bits than the state of the generator.<a name="line.298"></a>
-<span class="sourceLineNo">299</span>     *  &lt;/li&gt;<a name="line.299"></a>
-<span class="sourceLineNo">300</span>     *  &lt;li&gt;<a name="line.300"></a>
-<span class="sourceLineNo">301</span>     *   When the native seed type is an array and the {@code seed} is<a name="line.301"></a>
-<span class="sourceLineNo">302</span>     *   {@code null}, the size of the generated array will be 128.<a name="line.302"></a>
-<span class="sourceLineNo">303</span>     *  &lt;/li&gt;<a name="line.303"></a>
-<span class="sourceLineNo">304</span>     * &lt;/ul&gt;<a name="line.304"></a>
-<span class="sourceLineNo">305</span>     * &lt;/p&gt;<a name="line.305"></a>
-<span class="sourceLineNo">306</span>     *<a name="line.306"></a>
-<span class="sourceLineNo">307</span>     * @param source RNG type.<a name="line.307"></a>
-<span class="sourceLineNo">308</span>     * @param seed Seed value.  It can be {@code null} (in which case a<a name="line.308"></a>
-<span class="sourceLineNo">309</span>     * random value will be used).<a name="line.309"></a>
-<span class="sourceLineNo">310</span>     * @param data Additional arguments to the implementation's constructor.<a name="line.310"></a>
-<span class="sourceLineNo">311</span>     * Please refer to the documentation of each specific implementation.<a name="line.311"></a>
-<span class="sourceLineNo">312</span>     * @return the RNG.<a name="line.312"></a>
-<span class="sourceLineNo">313</span>     * @throws UnsupportedOperationException if the type of the {@code seed}<a name="line.313"></a>
-<span class="sourceLineNo">314</span>     * is invalid.<a name="line.314"></a>
-<span class="sourceLineNo">315</span>     * @throws IllegalStateException if data is missing to initialize the<a name="line.315"></a>
-<span class="sourceLineNo">316</span>     * generator implemented by the given {@code source}.<a name="line.316"></a>
-<span class="sourceLineNo">317</span>     */<a name="line.317"></a>
-<span class="sourceLineNo">318</span>    public static UniformRandomProvider create(RandomSource source,<a name="line.318"></a>
-<span class="sourceLineNo">319</span>                                               Object seed,<a name="line.319"></a>
-<span class="sourceLineNo">320</span>                                               Object ... data) {<a name="line.320"></a>
-<span class="sourceLineNo">321</span>        return ProviderBuilder.create(source.getInternalIdentifier(), seed, data);<a name="line.321"></a>
-<span class="sourceLineNo">322</span>    }<a name="line.322"></a>
-<span class="sourceLineNo">323</span><a name="line.323"></a>
-<span class="sourceLineNo">324</span>    /**<a name="line.324"></a>
-<span class="sourceLineNo">325</span>     * Gets the number of elements of the set of "subcycle" generators from<a name="line.325"></a>
-<span class="sourceLineNo">326</span>     * which two can be selected in order to create a {@link TwoCmres} RNG.<a name="line.326"></a>
-<span class="sourceLineNo">327</span>     *<a name="line.327"></a>
-<span class="sourceLineNo">328</span>     * @return the number of implemented subcycle generators.<a name="line.328"></a>
-<span class="sourceLineNo">329</span>     */<a name="line.329"></a>
-<span class="sourceLineNo">330</span>    public static int numberOfCmresGenerators() {<a name="line.330"></a>
-<span class="sourceLineNo">331</span>        return TwoCmres.numberOfSubcycleGenerators();<a name="line.331"></a>
-<span class="sourceLineNo">332</span>    }<a name="line.332"></a>
-<span class="sourceLineNo">333</span><a name="line.333"></a>
-<span class="sourceLineNo">334</span>    /**<a name="line.334"></a>
-<span class="sourceLineNo">335</span>     * Saves the state of a RNG.<a name="line.335"></a>
-<span class="sourceLineNo">336</span>     *<a name="line.336"></a>
-<span class="sourceLineNo">337</span>     * @param provider Provider.<a name="line.337"></a>
-<span class="sourceLineNo">338</span>     * @return the current state of the given {@code provider}.<a name="line.338"></a>
-<span class="sourceLineNo">339</span>     * @throws UnsupportedOperationException if the {@code provider} is<a name="line.339"></a>
-<span class="sourceLineNo">340</span>     * not an object created by this factory or the underlying source of<a name="line.340"></a>
-<span class="sourceLineNo">341</span>     * randomness does not support this functionality.<a name="line.341"></a>
-<span class="sourceLineNo">342</span>     *<a name="line.342"></a>
-<span class="sourceLineNo">343</span>     * @see #restoreState(UniformRandomProvider,RandomSource.State)<a name="line.343"></a>
-<span class="sourceLineNo">344</span>     */<a name="line.344"></a>
-<span class="sourceLineNo">345</span>    public static State saveState(UniformRandomProvider provider) {<a name="line.345"></a>
-<span class="sourceLineNo">346</span>        if (!(provider instanceof BaseProvider)) {<a name="line.346"></a>
-<span class="sourceLineNo">347</span>            throw new UnsupportedOperationException();<a name="line.347"></a>
-<span class="sourceLineNo">348</span>        } else {<a name="line.348"></a>
-<span class="sourceLineNo">349</span>            return ((BaseProvider) provider).getState();<a name="line.349"></a>
-<span class="sourceLineNo">350</span>        }<a name="line.350"></a>
-<span class="sourceLineNo">351</span>    }<a name="line.351"></a>
-<span class="sourceLineNo">352</span><a name="line.352"></a>
-<span class="sourceLineNo">353</span>    /**<a name="line.353"></a>
-<span class="sourceLineNo">354</span>     * Restores the state of a RNG.<a name="line.354"></a>
+<span class="sourceLineNo">269</span>     * @param seed Seed value.<a name="line.269"></a>
+<span class="sourceLineNo">270</span>     * @return {@code true} if the type of {@code seed} is the native<a name="line.270"></a>
+<span class="sourceLineNo">271</span>     * type for this RNG source.<a name="line.271"></a>
+<span class="sourceLineNo">272</span>     */<a name="line.272"></a>
+<span class="sourceLineNo">273</span>    public boolean isNativeSeed(Object seed) {<a name="line.273"></a>
+<span class="sourceLineNo">274</span>        return internalIdentifier.isNativeSeed(seed);<a name="line.274"></a>
+<span class="sourceLineNo">275</span>    }<a name="line.275"></a>
+<span class="sourceLineNo">276</span><a name="line.276"></a>
+<span class="sourceLineNo">277</span>    /**<a name="line.277"></a>
+<span class="sourceLineNo">278</span>     * Creates a random number generator with a random seed.<a name="line.278"></a>
+<span class="sourceLineNo">279</span>     *<a name="line.279"></a>
+<span class="sourceLineNo">280</span>     * &lt;p&gt;<a name="line.280"></a>
+<span class="sourceLineNo">281</span>     * Example of usage:<a name="line.281"></a>
+<span class="sourceLineNo">282</span>     * &lt;pre&gt;&lt;code&gt;<a name="line.282"></a>
+<span class="sourceLineNo">283</span>     *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT);<a name="line.283"></a>
+<span class="sourceLineNo">284</span>     * &lt;/code&gt;&lt;/pre&gt;<a name="line.284"></a>
+<span class="sourceLineNo">285</span>     * &lt;/p&gt;<a name="line.285"></a>
+<span class="sourceLineNo">286</span>     *<a name="line.286"></a>
+<span class="sourceLineNo">287</span>     * @param source RNG type.<a name="line.287"></a>
+<span class="sourceLineNo">288</span>     * @return the RNG.<a name="line.288"></a>
+<span class="sourceLineNo">289</span>     */<a name="line.289"></a>
+<span class="sourceLineNo">290</span>    public static UniformRandomProvider create(RandomSource source) {<a name="line.290"></a>
+<span class="sourceLineNo">291</span>        return create(source, null);<a name="line.291"></a>
+<span class="sourceLineNo">292</span>    }<a name="line.292"></a>
+<span class="sourceLineNo">293</span><a name="line.293"></a>
+<span class="sourceLineNo">294</span>    /**<a name="line.294"></a>
+<span class="sourceLineNo">295</span>     * Creates a random number generator with the given {@code seed}.<a name="line.295"></a>
+<span class="sourceLineNo">296</span>     *<a name="line.296"></a>
+<span class="sourceLineNo">297</span>     * &lt;p&gt;<a name="line.297"></a>
+<span class="sourceLineNo">298</span>     * Example of usage:<a name="line.298"></a>
+<span class="sourceLineNo">299</span>     * &lt;pre&gt;&lt;code&gt;<a name="line.299"></a>
+<span class="sourceLineNo">300</span>     *  UniformRandomProvider rng = RandomSource.create(RandomSource.TWO_CMRES_SELECT, 26219, 6, 9);<a name="line.300"></a>
+<span class="sourceLineNo">301</span>     * &lt;/code&gt;&lt;/pre&gt;<a name="line.301"></a>
+<span class="sourceLineNo">302</span>     * &lt;/p&gt;<a name="line.302"></a>
+<span class="sourceLineNo">303</span>     *<a name="line.303"></a>
+<span class="sourceLineNo">304</span>     * &lt;p&gt;<a name="line.304"></a>
+<span class="sourceLineNo">305</span>     * Valid types for the {@code seed} are:<a name="line.305"></a>
+<span class="sourceLineNo">306</span>     *  &lt;ul&gt;<a name="line.306"></a>
+<span class="sourceLineNo">307</span>     *   &lt;li&gt;{@code Integer} (or {@code int})&lt;/li&gt;<a name="line.307"></a>
+<span class="sourceLineNo">308</span>     *   &lt;li&gt;{@code Long} (or {@code long})&lt;/li&gt;<a name="line.308"></a>
+<span class="sourceLineNo">309</span>     *   &lt;li&gt;{@code int[]}&lt;/li&gt;<a name="line.309"></a>
+<span class="sourceLineNo">310</span>     *   &lt;li&gt;{@code long[]}&lt;/li&gt;<a name="line.310"></a>
+<span class="sourceLineNo">311</span>     *  &lt;/ul&gt;<a name="line.311"></a>
+<span class="sourceLineNo">312</span>     * &lt;/p&gt;<a name="line.312"></a>
+<span class="sourceLineNo">313</span>     *<a name="line.313"></a>
+<span class="sourceLineNo">314</span>     * &lt;p&gt;<a name="line.314"></a>
+<span class="sourceLineNo">315</span>     * Notes:<a name="line.315"></a>
+<span class="sourceLineNo">316</span>     * &lt;ul&gt;<a name="line.316"></a>
+<span class="sourceLineNo">317</span>     *  &lt;li&gt;<a name="line.317"></a>
+<span class="sourceLineNo">318</span>     *   When the seed type passed as argument is more complex (i.e. more<a name="line.318"></a>
+<span class="sourceLineNo">319</span>     *   bits can be independently chosen) than the generator's<a name="line.319"></a>
+<span class="sourceLineNo">320</span>     *   {@link #isNativeSeed(Object) native type}, the conversion of a<a name="line.320"></a>
+<span class="sourceLineNo">321</span>     *   set of different seeds will necessarily result in the same value<a name="line.321"></a>
+<span class="sourceLineNo">322</span>     *   of the native seed type.<a name="line.322"></a>
+<span class="sourceLineNo">323</span>     *  &lt;/li&gt;<a name="line.323"></a>
+<span class="sourceLineNo">324</span>     *  &lt;li&gt;<a name="line.324"></a>
+<span class="sourceLineNo">325</span>     *   When the native seed type is an array, the same remark applies<a name="line.325"></a>
+<span class="sourceLineNo">326</span>     *   when the array contains more bits than the state of the generator.<a name="line.326"></a>
+<span class="sourceLineNo">327</span>     *  &lt;/li&gt;<a name="line.327"></a>
+<span class="sourceLineNo">328</span>     *  &lt;li&gt;<a name="line.328"></a>
+<span class="sourceLineNo">329</span>     *   When the native seed type is an array and the {@code seed} is<a name="line.329"></a>
+<span class="sourceLineNo">330</span>     *   {@code null}, the size of the generated array will be 128.<a name="line.330"></a>
+<span class="sourceLineNo">331</span>     *  &lt;/li&gt;<a name="line.331"></a>
+<span class="sourceLineNo">332</span>     * &lt;/ul&gt;<a name="line.332"></a>
+<span class="sourceLineNo">333</span>     * &lt;/p&gt;<a name="line.333"></a>
+<span class="sourceLineNo">334</span>     *<a name="line.334"></a>
+<span class="sourceLineNo">335</span>     * @param source RNG type.<a name="line.335"></a>
+<span class="sourceLineNo">336</span>     * @param seed Seed value.  It can be {@code null} (in which case a<a name="line.336"></a>
+<span class="sourceLineNo">337</span>     * random value will be used).<a name="line.337"></a>
+<span class="sourceLineNo">338</span>     * @param data Additional arguments to the implementation's constructor.<a name="line.338"></a>
+<span class="sourceLineNo">339</span>     * Please refer to the documentation of each specific implementation.<a name="line.339"></a>
+<span class="sourceLineNo">340</span>     * @return the RNG.<a name="line.340"></a>
+<span class="sourceLineNo">341</span>     * @throws UnsupportedOperationException if the type of the {@code seed}<a name="line.341"></a>
+<span class="sourceLineNo">342</span>     * is invalid.<a name="line.342"></a>
+<span class="sourceLineNo">343</span>     * @throws IllegalStateException if data is missing to initialize the<a name="line.343"></a>
+<span class="sourceLineNo">344</span>     * generator implemented by the given {@code source}.<a name="line.344"></a>
+<span class="sourceLineNo">345</span>     */<a name="line.345"></a>
+<span class="sourceLineNo">346</span>    public static UniformRandomProvider create(RandomSource source,<a name="line.346"></a>
+<span class="sourceLineNo">347</span>                                               Object seed,<a name="line.347"></a>
+<span class="sourceLineNo">348</span>                                               Object ... data) {<a name="line.348"></a>
+<span class="sourceLineNo">349</span>        return ProviderBuilder.create(source.getInternalIdentifier(), seed, data);<a name="line.349"></a>
+<span class="sourceLineNo">350</span>    }<a name="line.350"></a>
+<span class="sourceLineNo">351</span><a name="line.351"></a>
+<span class="sourceLineNo">352</span>    /**<a name="line.352"></a>
+<span class="sourceLineNo">353</span>     * Gets the number of elements of the set of "subcycle" generators from<a name="line.353"></a>
+<span class="sourceLineNo">354</span>     * which two can be selected in order to create a {@link TwoCmres} RNG.<a name="line.354"></a>
 <span class="sourceLineNo">355</span>     *<a name="line.355"></a>
-<span class="sourceLineNo">356</span>     * @param provider Provider.<a name="line.356"></a>
-<span class="sourceLineNo">357</span>     * @param state State which the {@code provider} will be set to.<a name="line.357"></a>
-<span class="sourceLineNo">358</span>     * This parameter must have been obtained by a call to<a name="line.358"></a>
-<span class="sourceLineNo">359</span>     * {@link #saveState(UniformRandomProvider) saveState(rng)}<a name="line.359"></a>
-<span class="sourceLineNo">360</span>     * where {@code rng} is either the same object as {@code provider},<a name="line.360"></a>
-<span class="sourceLineNo">361</span>     * or an object of the exact same class.<a name="line.361"></a>
-<span class="sourceLineNo">362</span>     * @throws UnsupportedOperationException if the {@code provider} is<a name="line.362"></a>
-<span class="sourceLineNo">363</span>     * not an object created by this factory or the underlying source of<a name="line.363"></a>
-<span class="sourceLineNo">364</span>     * randomness does not support this functionality.<a name="line.364"></a>
-<span class="sourceLineNo">365</span>     * @throws IllegalArgumentException if it was detected that the<a name="line.365"></a>
-<span class="sourceLineNo">366</span>     * {@code state} is incompatible with the given {@code provider}.<a name="line.366"></a>
-<span class="sourceLineNo">367</span>     *<a name="line.367"></a>
-<span class="sourceLineNo">368</span>     * @see #saveState(UniformRandomProvider)<a name="line.368"></a>
-<span class="sourceLineNo">369</span>     */<a name="line.369"></a>
-<span class="sourceLineNo">370</span>    public static void restoreState(UniformRandomProvider provider,<a name="line.370"></a>
-<span class="sourceLineNo">371</span>                                    State state) {<a name="line.371"></a>
-<span class="sourceLineNo">372</span>        if (!(provider instanceof BaseProvider)) {<a name="line.372"></a>
-<span class="sourceLineNo">373</span>            throw new UnsupportedOperationException();<a name="line.373"></a>
-<span class="sourceLineNo">374</span>        } else {<a name="line.374"></a>
-<span class="sourceLineNo">375</span>            ((BaseProvider) provider).setState(state);<a name="line.375"></a>
-<span class="sourceLineNo">376</span>        }<a name="line.376"></a>
-<span class="sourceLineNo">377</span>    }<a name="line.377"></a>
-<span class="sourceLineNo">378</span><a name="line.378"></a>
-<span class="sourceLineNo">379</span>    /**<a name="line.379"></a>
-<span class="sourceLineNo">380</span>     * Creates a number for use as a seed.<a name="line.380"></a>
-<span class="sourceLineNo">381</span>     *<a name="line.381"></a>
-<span class="sourceLineNo">382</span>     * @return a random number.<a name="line.382"></a>
-<span class="sourceLineNo">383</span>     */<a name="line.383"></a>
-<span class="sourceLineNo">384</span>    public static int createInt() {<a name="line.384"></a>
-<span class="sourceLineNo">385</span>        return SeedFactory.createInt();<a name="line.385"></a>
-<span class="sourceLineNo">386</span>    }<a name="line.386"></a>
-<span class="sourceLineNo">387</span><a name="line.387"></a>
-<span class="sourceLineNo">388</span>    /**<a name="line.388"></a>
-<span class="sourceLineNo">389</span>     * Creates a number for use as a seed.<a name="line.389"></a>
-<span class="sourceLineNo">390</span>     *<a name="line.390"></a>
-<span class="sourceLineNo">391</span>     * @return a random number.<a name="line.391"></a>
-<span class="sourceLineNo">392</span>     */<a name="line.392"></a>
-<span class="sourceLineNo">393</span>    public static long createLong() {<a name="line.393"></a>
-<span class="sourceLineNo">394</span>        return SeedFactory.createLong();<a name="line.394"></a>
-<span class="sourceLineNo">395</span>    }<a name="line.395"></a>
-<span class="sourceLineNo">396</span><a name="line.396"></a>
-<span class="sourceLineNo">397</span>    /**<a name="line.397"></a>
-<span class="sourceLineNo">398</span>     * Creates an array of numbers for use as a seed.<a name="line.398"></a>
-<span class="sourceLineNo">399</span>     *<a name="line.399"></a>
-<span class="sourceLineNo">400</span>     * @param n Size of the array to create.<a name="line.400"></a>
-<span class="sourceLineNo">401</span>     * @return an array of {@code n} random numbers.<a name="line.401"></a>
-<span class="sourceLineNo">402</span>     */<a name="line.402"></a>
-<span class="sourceLineNo">403</span>    public static int[] createIntArray(int n) {<a name="line.403"></a>
-<span class="sourceLineNo">404</span>        return SeedFactory.createIntArray(n);<a name="line.404"></a>
+<span class="sourceLineNo">356</span>     * @return the number of implemented subcycle generators.<a name="line.356"></a>
+<span class="sourceLineNo">357</span>     */<a name="line.357"></a>
+<span class="sourceLineNo">358</span>    public static int numberOfCmresGenerators() {<a name="line.358"></a>
+<span class="sourceLineNo">359</span>        return TwoCmres.numberOfSubcycleGenerators();<a name="line.359"></a>
+<span class="sourceLineNo">360</span>    }<a name="line.360"></a>
+<span class="sourceLineNo">361</span><a name="line.361"></a>
+<span class="sourceLineNo">362</span>    /**<a name="line.362"></a>
+<span class="sourceLineNo">363</span>     * Saves the state of a RNG.<a name="line.363"></a>
+<span class="sourceLineNo">364</span>     *<a name="line.364"></a>
+<span class="sourceLineNo">365</span>     * @param provider Provider.<a name="line.365"></a>
+<span class="sourceLineNo">366</span>     * @return the current state of the given {@code provider}.<a name="line.366"></a>
+<span class="sourceLineNo">367</span>     * @throws UnsupportedOperationException if the {@code provider} is<a name="line.367"></a>
+<span class="sourceLineNo">368</span>     * not an object created by this factory or the underlying source of<a name="line.368"></a>
+<span class="sourceLineNo">369</span>     * randomness does not support this functionality.<a name="line.369"></a>
+<span class="sourceLineNo">370</span>     *<a name="line.370"></a>
+<span class="sourceLineNo">371</span>     * @see #restoreState(UniformRandomProvider,State)<a name="line.371"></a>
+<span class="sourceLineNo">372</span>     */<a name="line.372"></a>
+<span class="sourceLineNo">373</span>    public static State saveState(UniformRandomProvider provider) {<a name="line.373"></a>
+<span class="sourceLineNo">374</span>        if (!(provider instanceof BaseProvider)) {<a name="line.374"></a>
+<span class="sourceLineNo">375</span>            throw new UnsupportedOperationException();<a name="line.375"></a>
+<span class="sourceLineNo">376</span>        } else {<a name="line.376"></a>
+<span class="sourceLineNo">377</span>            return new State(((BaseProvider) provider).getState());<a name="line.377"></a>
+<span class="sourceLineNo">378</span>        }<a name="line.378"></a>
+<span class="sourceLineNo">379</span>    }<a name="line.379"></a>
+<span class="sourceLineNo">380</span><a name="line.380"></a>
+<span class="sourceLineNo">381</span>    /**<a name="line.381"></a>
+<span class="sourceLineNo">382</span>     * Restores the state of a RNG.<a name="line.382"></a>
+<span class="sourceLineNo">383</span>     *<a name="line.383"></a>
+<span class="sourceLineNo">384</span>     * @param provider Provider.<a name="line.384"></a>
+<span class="sourceLineNo">385</span>     * @param state State which the {@code provider} will be set to.<a name="line.385"></a>
+<span class="sourceLineNo">386</span>     * This parameter must have been obtained by a call to<a name="line.386"></a>
+<span class="sourceLineNo">387</span>     * {@link #saveState(UniformRandomProvider) saveState(rng)}<a name="line.387"></a>
+<span class="sourceLineNo">388</span>     * where {@code rng} is either the same object as {@code provider},<a name="line.388"></a>
+<span class="sourceLineNo">389</span>     * or an object of the exact same class.<a name="line.389"></a>
+<span class="sourceLineNo">390</span>     * @throws UnsupportedOperationException if the {@code provider} is<a name="line.390"></a>
+<span class="sourceLineNo">391</span>     * not an object created by this factory or the underlying source of<a name="line.391"></a>
+<span class="sourceLineNo">392</span>     * randomness does not support this functionality.<a name="line.392"></a>
+<span class="sourceLineNo">393</span>     * @throws IllegalArgumentException if it was detected that the<a name="line.393"></a>
+<span class="sourceLineNo">394</span>     * {@code state} is incompatible with the given {@code provider}.<a name="line.394"></a>
+<span class="sourceLineNo">395</span>     *<a name="line.395"></a>
+<span class="sourceLineNo">396</span>     * @see #saveState(UniformRandomProvider)<a name="line.396"></a>
+<span class="sourceLineNo">397</span>     */<a name="line.397"></a>
+<span class="sourceLineNo">398</span>    public static void restoreState(UniformRandomProvider provider,<a name="line.398"></a>
+<span class="sourceLineNo">399</span>                                    State state) {<a name="line.399"></a>
+<span class="sourceLineNo">400</span>        if (!(provider instanceof BaseProvider)) {<a name="line.400"></a>
+<span class="sourceLineNo">401</span>            throw new UnsupportedOperationException();<a name="line.401"></a>
+<span class="sourceLineNo">402</span>        } else {<a name="line.402"></a>
+<span class="sourceLineNo">403</span>            ((BaseProvider) provider).setState(state.getState());<a name="line.403"></a>
+<span class="sourceLineNo">404</span>        }<a name="line.404"></a>
 <span class="sourceLineNo">405</span>    }<a name="line.405"></a>
 <span class="sourceLineNo">406</span><a name="line.406"></a>
 <span class="sourceLineNo">407</span>    /**<a name="line.407"></a>
-<span class="sourceLineNo">408</span>     * Creates an array of numbers for use as a seed.<a name="line.408"></a>
+<span class="sourceLineNo">408</span>     * Creates a number for use as a seed.<a name="line.408"></a>
 <span class="sourceLineNo">409</span>     *<a name="line.409"></a>
-<span class="sourceLineNo">410</span>     * @param n Size of the array to create.<a name="line.410"></a>
-<span class="sourceLineNo">411</span>     * @return an array of {@code n} random numbers.<a name="line.411"></a>
-<span class="sourceLineNo">412</span>     */<a name="line.412"></a>
-<span class="sourceLineNo">413</span>    public static long[] createLongArray(int n) {<a name="line.413"></a>
-<span class="sourceLineNo">414</span>        return SeedFactory.createLongArray(n);<a name="line.414"></a>
-<span class="sourceLineNo">415</span>    }<a name="line.415"></a>
-<span class="sourceLineNo">416</span>}<a name="line.416"></a>
+<span class="sourceLineNo">410</span>     * @return a random number.<a name="line.410"></a>
+<span class="sourceLineNo">411</span>     */<a name="line.411"></a>
+<span class="sourceLineNo">412</span>    public static int createInt() {<a name="line.412"></a>
+<span class="sourceLineNo">413</span>        return SeedFactory.createInt();<a name="line.413"></a>
+<span class="sourceLineNo">414</span>    }<a name="line.414"></a>
+<span class="sourceLineNo">415</span><a name="line.415"></a>
+<span class="sourceLineNo">416</span>    /**<a name="line.416"></a>
+<span class="sourceLineNo">417</span>     * Creates a number for use as a seed.<a name="line.417"></a>
+<span class="sourceLineNo">418</span>     *<a name="line.418"></a>
+<span class="sourceLineNo">419</span>     * @return a random number.<a name="line.419"></a>
+<span class="sourceLineNo">420</span>     */<a name="line.420"></a>
+<span class="sourceLineNo">421</span>    public static long createLong() {<a name="line.421"></a>
+<span class="sourceLineNo">422</span>        return SeedFactory.createLong();<a name="line.422"></a>
+<span class="sourceLineNo">423</span>    }<a name="line.423"></a>
+<span class="sourceLineNo">424</span><a name="line.424"></a>
+<span class="sourceLineNo">425</span>    /**<a name="line.425"></a>
+<span class="sourceLineNo">426</span>     * Creates an array of numbers for use as a seed.<a name="line.426"></a>
+<span class="sourceLineNo">427</span>     *<a name="line.427"></a>
+<span class="sourceLineNo">428</span>     * @param n Size of the array to create.<a name="line.428"></a>
+<span class="sourceLineNo">429</span>     * @return an array of {@code n} random numbers.<a name="line.429"></a>
+<span class="sourceLineNo">430</span>     */<a name="line.430"></a>
+<span class="sourceLineNo">431</span>    public static int[] createIntArray(int n) {<a name="line.431"></a>
+<span class="sourceLineNo">432</span>        return SeedFactory.createIntArray(n);<a name="line.432"></a>
+<span class="sourceLineNo">433</span>    }<a name="line.433"></a>
+<span class="sourceLineNo">434</span><a name="line.434"></a>
+<span class="sourceLineNo">435</span>    /**<a name="line.435"></a>
+<span class="sourceLineNo">436</span>     * Creates an array of numbers for use as a seed.<a name="line.436"></a>
+<span class="sourceLineNo">437</span>     *<a name="line.437"></a>
+<span class="sourceLineNo">438</span>     * @param n Size of the array to create.<a name="line.438"></a>
+<span class="sourceLineNo">439</span>     * @return an array of {@code n} random numbers.<a name="line.439"></a>
+<span class="sourceLineNo">440</span>     */<a name="line.440"></a>
+<span class="sourceLineNo">441</span>    public static long[] createLongArray(int n) {<a name="line.441"></a>
+<span class="sourceLineNo">442</span>        return SeedFactory.createLongArray(n);<a name="line.442"></a>
+<span class="sourceLineNo">443</span>    }<a name="line.443"></a>
+<span class="sourceLineNo">444</span>}<a name="line.444"></a>
 
 
 



Mime
View raw message