001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.rng.simple;
018
019import java.util.stream.DoubleStream;
020import java.util.stream.IntStream;
021import java.util.stream.LongStream;
022import org.apache.commons.rng.UniformRandomProvider;
023import org.apache.commons.rng.RestorableUniformRandomProvider;
024import org.apache.commons.rng.simple.internal.ProviderBuilder;
025import org.apache.commons.rng.simple.internal.SeedFactory;
026
027/**
028 * This class provides the API for creating generators of random numbers.
029 *
030 * <p>Usage examples:</p>
031 * <pre><code>
032 *  UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create();
033 * </code></pre>
034 * or
035 * <pre><code>
036 *  final int[] seed = new int[] { 196, 9, 0, 226 };
037 *  UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create(seed);
038 * </code></pre>
039 * or
040 * <pre><code>
041 *  final int[] seed = RandomSource.createIntArray(256);
042 *  UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create(seed);
043 * </code></pre>
044 * where the enum value is the identifier of the generator's concrete
045 * implementation, and the argument to method {@code create} is the
046 * (optional) seed.
047 *
048 * <p>
049 * In the first form, a random seed will be {@link SeedFactory generated
050 * automatically}; in the second form, a fixed seed is used; a random seed
051 * is explicitly generated in the third form.
052 * </p>
053 *
054 * <h2>Seeding</h2>
055 * <p>
056 * Seeding is the procedure by which a value (or set of values) is
057 * used to <i>initialize</i> a generator instance.
058 * The requirement that a given seed will always result in the same
059 * internal state allows to create different instances of a generator
060 * that will produce the same sequence of pseudo-random numbers.
061 * </p>
062 *
063 * <p>
064 * The type of data used as a seed depends on the concrete implementation
065 * as some types may not provide enough information to fully initialize
066 * the generator's internal state.
067 * <br>
068 * The reference algorithm's seeding procedure (if provided) operates
069 * on a value of a (single) <i>native</i> type:
070 * Each concrete implementation's constructor creates an instance using
071 * the native type whose information contents is used to set the
072 * internal state.
073 * <br>
074 * When the seed value passed by the caller is of the native type, it is
075 * expected that the sequences produced will be identical to those
076 * produced by other implementations of the same reference algorithm.
077 * <br>
078 * However, when the seed value passed by the caller is not of the native
079 * type, a transformation is performed by this library and the resulting
080 * native type value will <i>not</i> contain more information than the
081 * original seed value.
082 * If the algorithm's native type is "simpler" than the type passed by
083 * the caller, then some (unused) information will even be lost.
084 * <br>
085 * The transformation from non-native to native seed type is arbitrary,
086 * as long as it does not reduce the amount of information required by
087 * the algorithm to initialize its state.
088 * The consequence of the transformation is that sequences produced
089 * by this library may <i>not</i> be the same as the sequences produced
090 * by other implementations of the same algorithm!
091 * </p>
092 *
093 * <p>
094 * For each algorithm, the Javadoc mentions the "ideal" size of the seed,
095 * meaning the number of {@code int} or {@code long} values that is neither
096 * too large (i.e. some of the seed is useless) or too small (i.e. an
097 * internal procedure will fill the state with redundant information
098 * computed from the given seed).
099 * </p>
100 *
101 * <p>
102 * Note that some algorithms are inherently sensitive to having too low
103 * diversity in their initial state.
104 * For example, it is often a bad idea to use a seed that is mostly
105 * composed of zeroes, or of repeated values.
106 * </p>
107 *
108 * <p>
109 * This class provides methods to generate random seeds (single values
110 * or arrays of values, of {@code int} or {@code long} types) that can
111 * be passed to the {@link RandomSource#create(Object,Object[])
112 * generator's factory method}.
113 * </p>
114 * <p>
115 * Although the seed-generating methods defined in this class will likely
116 * return different values each time they are called, there is no guarantee:
117 * </p>
118 * <ul>
119 *  <li>
120 *   In any sub-sequence, it is <a href="https://en.wikipedia.org/wiki/Birthday_problem">
121 *   expected</a> that the same numbers can occur, with a probability getting
122 *   higher as the range of allowed values is smaller and the sequence becomes
123 *   longer.
124 *  </li>
125 *  <li>
126 *   It possible that the resulting "seed" will not be <i>good</i> (i.e.
127 *   it will not generate a sufficiently uniformly random sequence for the
128 *   intended purpose), even if the generator is good!
129 *   The only way to ensure that the selected seed will make the generator
130 *   produce a good sequence is to submit that sequence to a series of
131 *   stringent tests, as provided by tools such as
132 *   <a href="https://www.phy.duke.edu/~rgb/General/dieharder.php">dieharder</a>
133 *   or <a href="https://simul.iro.umontreal.ca/testu01/tu01.html">TestU01</a>.
134 *  </li>
135 * </ul>
136 *
137 * <p>
138 * <b>Note:</b>
139 * Seeding is not equivalent to restoring the internal state of an
140 * <i>already initialized</i> generator.
141 * Indeed, generators can have a state that is more complex than the
142 * seed, and seeding is thus a transformation (from seed to state).
143 * Implementations do not provide the inverse transformation (from
144 * state to seed), hence it is not generally possible to know the seed
145 * that would initialize a new generator instance to the current state
146 * of another instance.
147 * Reseeding is also inefficient if the purpose is to continue the
148 * same sequence where another instance left off, as it would require
149 * to "replay" all the calls performed by that other instance (and it
150 * would require to know the number of calls to the primary source of
151 * randomness, which is also not usually accessible).
152 * </p>
153 *
154 * <h2>Parallel applications</h2>
155 * <p>
156 * For parallel applications, some implementations have provision for producing
157 * non-overlapping sequences by copying the generator and then advancing a large number
158 * of steps in the generator sequence. Repeated jumps can create a series of
159 * child generators that will output non-overlapping sequences over a specified number
160 * of outputs. These implementations are identified using the {@link #isJumpable()},
161 * {@link #isLongJumpable()} and {@link #isArbitrarilyJumpable()} methods.
162 * </p>
163 * <pre><code>
164 *  RandomSource source = RandomSource.XO_RO_SHI_RO_128_SS; // Known to be jumpable.
165 *
166 *  JumpableUniformRandomProvider jumpable = (JumpableUniformRandomProvider) source.create();
167 *
168 *  // For use in parallel
169 *  UniformRandomProvider[] rngs = new UniformRandomProvider[10];
170 *  for (int i = 0; i &lt; rngs.length; i++) {
171 *      rngs[i] = jumpable.jump();
172 *  }
173 * </code></pre>
174 * <p>
175 * For implementations that have no provision for producing non-overlapping
176 * sequences, a possible workaround is that each thread uses
177 * a generator of a different type (see {@link #TWO_CMRES_SELECT}).
178 * </p>
179 *
180 * @since 1.0
181 */
182public enum RandomSource {
183    /**
184     * Source of randomness is {@link org.apache.commons.rng.core.source32.JDKRandom}.
185     * <ul>
186     *  <li>Native seed type: {@code Long}.</li>
187     * </ul>
188     */
189    JDK(ProviderBuilder.RandomSourceInternal.JDK),
190    /**
191     * Source of randomness is {@link org.apache.commons.rng.core.source32.Well512a}.
192     * <ul>
193     *  <li>Native seed type: {@code int[]}.</li>
194     *  <li>Native seed size: 16.</li>
195     * </ul>
196     */
197    WELL_512_A(ProviderBuilder.RandomSourceInternal.WELL_512_A),
198    /**
199     * Source of randomness is {@link org.apache.commons.rng.core.source32.Well1024a}.
200     * <ul>
201     *  <li>Native seed type: {@code int[]}.</li>
202     *  <li>Native seed size: 32.</li>
203     * </ul>
204     */
205    WELL_1024_A(ProviderBuilder.RandomSourceInternal.WELL_1024_A),
206    /**
207     * Source of randomness is {@link org.apache.commons.rng.core.source32.Well19937a}.
208     * <ul>
209     *  <li>Native seed type: {@code int[]}.</li>
210     *  <li>Native seed size: 624.</li>
211     * </ul>
212     */
213    WELL_19937_A(ProviderBuilder.RandomSourceInternal.WELL_19937_A),
214    /**
215     * Source of randomness is {@link org.apache.commons.rng.core.source32.Well19937c}.
216     * <ul>
217     *  <li>Native seed type: {@code int[]}.</li>
218     *  <li>Native seed size: 624.</li>
219     * </ul>
220     */
221    WELL_19937_C(ProviderBuilder.RandomSourceInternal.WELL_19937_C),
222    /**
223     * Source of randomness is {@link org.apache.commons.rng.core.source32.Well44497a}.
224     * <ul>
225     *  <li>Native seed type: {@code int[]}.</li>
226     *  <li>Native seed size: 1391.</li>
227     * </ul>
228     */
229    WELL_44497_A(ProviderBuilder.RandomSourceInternal.WELL_44497_A),
230    /**
231     * Source of randomness is {@link org.apache.commons.rng.core.source32.Well44497b}.
232     * <ul>
233     *  <li>Native seed type: {@code int[]}.</li>
234     *  <li>Native seed size: 1391.</li>
235     * </ul>
236     */
237    WELL_44497_B(ProviderBuilder.RandomSourceInternal.WELL_44497_B),
238    /**
239     * Source of randomness is {@link org.apache.commons.rng.core.source32.MersenneTwister}.
240     * <ul>
241     *  <li>Native seed type: {@code int[]}.</li>
242     *  <li>Native seed size: 624.</li>
243     * </ul>
244     */
245    MT(ProviderBuilder.RandomSourceInternal.MT),
246    /**
247     * Source of randomness is {@link org.apache.commons.rng.core.source32.ISAACRandom}.
248     * <ul>
249     *  <li>Native seed type: {@code int[]}.</li>
250     *  <li>Native seed size: 256.</li>
251     * </ul>
252     */
253    ISAAC(ProviderBuilder.RandomSourceInternal.ISAAC),
254    /**
255     * Source of randomness is {@link org.apache.commons.rng.core.source64.SplitMix64}.
256     * <ul>
257     *  <li>Native seed type: {@code Long}.</li>
258     * </ul>
259     */
260    SPLIT_MIX_64(ProviderBuilder.RandomSourceInternal.SPLIT_MIX_64),
261    /**
262     * Source of randomness is {@link org.apache.commons.rng.core.source64.XorShift1024Star}.
263     * <ul>
264     *  <li>Native seed type: {@code long[]}.</li>
265     *  <li>Native seed size: 16.</li>
266     * </ul>
267     *
268     * @deprecated Since 1.3, where it is recommended to use {@code XOR_SHIFT_1024_S_PHI}
269     * instead due to its slightly better (more uniform) output. {@code XOR_SHIFT_1024_S}
270     * is still quite usable but both are variants of the same algorithm and maintain their
271     * internal state identically. Their outputs are correlated and the two should not be
272     * used together when independent sequences are assumed.
273     */
274    @Deprecated
275    XOR_SHIFT_1024_S(ProviderBuilder.RandomSourceInternal.XOR_SHIFT_1024_S),
276    /**
277     * Source of randomness is {@link org.apache.commons.rng.core.source64.TwoCmres}.
278     * This generator is equivalent to {@link #TWO_CMRES_SELECT} with the choice of the
279     * pair {@code (0, 1)} for the two subcycle generators.
280     * <ul>
281     *  <li>Native seed type: {@code Integer}.</li>
282     * </ul>
283     */
284    TWO_CMRES(ProviderBuilder.RandomSourceInternal.TWO_CMRES),
285    /**
286     * Source of randomness is {@link org.apache.commons.rng.core.source64.TwoCmres},
287     * with explicit selection of the two subcycle generators.
288     * The selection of the subcycle generator is by passing its index in the internal
289     * table, a value between 0 (included) and 13 (included).
290     * The two indices must be different.
291     * Different choices of an ordered pair of indices create independent generators.
292     * <ul>
293     *  <li>Native seed type: {@code Integer}.</li>
294     * </ul>
295     */
296    TWO_CMRES_SELECT(ProviderBuilder.RandomSourceInternal.TWO_CMRES_SELECT),
297    /**
298     * Source of randomness is {@link org.apache.commons.rng.core.source64.MersenneTwister64}.
299     * <ul>
300     *  <li>Native seed type: {@code long[]}.</li>
301     *  <li>Native seed size: 312.</li>
302     * </ul>
303     */
304    MT_64(ProviderBuilder.RandomSourceInternal.MT_64),
305    /**
306     * Source of randomness is {@link org.apache.commons.rng.core.source32.MultiplyWithCarry256}.
307     * <ul>
308     *  <li>Native seed type: {@code int[]}.</li>
309     *  <li>Native seed size: 257.</li>
310     * </ul>
311     */
312    MWC_256(ProviderBuilder.RandomSourceInternal.MWC_256),
313    /**
314     * Source of randomness is {@link org.apache.commons.rng.core.source32.KISSRandom}.
315     * <ul>
316     *  <li>Native seed type: {@code int[]}.</li>
317     *  <li>Native seed size: 4.</li>
318     * </ul>
319     */
320    KISS(ProviderBuilder.RandomSourceInternal.KISS),
321    /**
322     * Source of randomness is {@link org.apache.commons.rng.core.source64.XorShift1024StarPhi}.
323     * <ul>
324     *  <li>Native seed type: {@code long[]}.</li>
325     *  <li>Native seed size: 16.</li>
326     * </ul>
327     * @since 1.3
328     */
329    XOR_SHIFT_1024_S_PHI(ProviderBuilder.RandomSourceInternal.XOR_SHIFT_1024_S_PHI),
330    /**
331     * Source of randomness is {@link org.apache.commons.rng.core.source32.XoRoShiRo64Star}.
332     * <ul>
333     *  <li>Native seed type: {@code int[]}.</li>
334     *  <li>Native seed size: 2.</li>
335     * </ul>
336     * @since 1.3
337     */
338    XO_RO_SHI_RO_64_S(ProviderBuilder.RandomSourceInternal.XO_RO_SHI_RO_64_S),
339    /**
340     * Source of randomness is {@link org.apache.commons.rng.core.source32.XoRoShiRo64StarStar}.
341     * <ul>
342     *  <li>Native seed type: {@code int[]}.</li>
343     *  <li>Native seed size: 2.</li>
344     * </ul>
345     * @since 1.3
346     */
347    XO_RO_SHI_RO_64_SS(ProviderBuilder.RandomSourceInternal.XO_RO_SHI_RO_64_SS),
348    /**
349     * Source of randomness is {@link org.apache.commons.rng.core.source32.XoShiRo128Plus}.
350     * <ul>
351     *  <li>Native seed type: {@code int[]}.</li>
352     *  <li>Native seed size: 4.</li>
353     * </ul>
354     * @since 1.3
355     */
356    XO_SHI_RO_128_PLUS(ProviderBuilder.RandomSourceInternal.XO_SHI_RO_128_PLUS),
357    /**
358     * Source of randomness is {@link org.apache.commons.rng.core.source32.XoShiRo128StarStar}.
359     * <ul>
360     *  <li>Native seed type: {@code int[]}.</li>
361     *  <li>Native seed size: 4.</li>
362     * </ul>
363     * @since 1.3
364     */
365    XO_SHI_RO_128_SS(ProviderBuilder.RandomSourceInternal.XO_SHI_RO_128_SS),
366    /**
367     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoRoShiRo128Plus}.
368     * <ul>
369     *  <li>Native seed type: {@code long[]}.</li>
370     *  <li>Native seed size: 2.</li>
371     * </ul>
372     * @since 1.3
373     */
374    XO_RO_SHI_RO_128_PLUS(ProviderBuilder.RandomSourceInternal.XO_RO_SHI_RO_128_PLUS),
375    /**
376     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoRoShiRo128StarStar}.
377     * <ul>
378     *  <li>Native seed type: {@code long[]}.</li>
379     *  <li>Native seed size: 2.</li>
380     * </ul>
381     * @since 1.3
382     */
383    XO_RO_SHI_RO_128_SS(ProviderBuilder.RandomSourceInternal.XO_RO_SHI_RO_128_SS),
384    /**
385     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoShiRo256Plus}.
386     * <ul>
387     *  <li>Native seed type: {@code long[]}.</li>
388     *  <li>Native seed size: 4.</li>
389     * </ul>
390     * @since 1.3
391     */
392    XO_SHI_RO_256_PLUS(ProviderBuilder.RandomSourceInternal.XO_SHI_RO_256_PLUS),
393    /**
394     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoShiRo256StarStar}.
395     * <ul>
396     *  <li>Native seed type: {@code long[]}.</li>
397     *  <li>Native seed size: 4.</li>
398     * </ul>
399     * @since 1.3
400     */
401    XO_SHI_RO_256_SS(ProviderBuilder.RandomSourceInternal.XO_SHI_RO_256_SS),
402    /**
403     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoShiRo512Plus}.
404     * <ul>
405     *  <li>Native seed type: {@code long[]}.</li>
406     *  <li>Native seed size: 8.</li>
407     * </ul>
408     * @since 1.3
409     */
410    XO_SHI_RO_512_PLUS(ProviderBuilder.RandomSourceInternal.XO_SHI_RO_512_PLUS),
411    /**
412     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoShiRo512StarStar}.
413     * <ul>
414     *  <li>Native seed type: {@code long[]}.</li>
415     *  <li>Native seed size: 8.</li>
416     * </ul>
417     * @since 1.3
418     */
419    XO_SHI_RO_512_SS(ProviderBuilder.RandomSourceInternal.XO_SHI_RO_512_SS),
420    /**
421     * Source of randomness is {@link org.apache.commons.rng.core.source32.PcgXshRr32}.
422     * <ul>
423     *  <li>Native seed type: {@code long[]}.</li>
424     *  <li>Native seed size: 2.</li>
425     * </ul>
426     * @since 1.3
427     */
428    PCG_XSH_RR_32(ProviderBuilder.RandomSourceInternal.PCG_XSH_RR_32),
429    /**
430     * Source of randomness is {@link org.apache.commons.rng.core.source32.PcgXshRs32}.
431     * <ul>
432     *  <li>Native seed type: {@code long[]}.</li>
433     *  <li>Native seed size: 2.</li>
434     * </ul>
435     * @since 1.3
436     */
437    PCG_XSH_RS_32(ProviderBuilder.RandomSourceInternal.PCG_XSH_RS_32),
438    /**
439     * Source of randomness is {@link org.apache.commons.rng.core.source64.PcgRxsMXs64}.
440     * <ul>
441     *  <li>Native seed type: {@code long[]}.</li>
442     *  <li>Native seed size: 2.</li>
443     * </ul>
444     * @since 1.3
445     */
446    PCG_RXS_M_XS_64(ProviderBuilder.RandomSourceInternal.PCG_RXS_M_XS_64),
447    /**
448     * Source of randomness is {@link org.apache.commons.rng.core.source32.PcgMcgXshRr32}.
449     * <ul>
450     *  <li>Native seed type: {@code Long}.</li>
451     * </ul>
452     * @since 1.3
453     */
454    PCG_MCG_XSH_RR_32(ProviderBuilder.RandomSourceInternal.PCG_MCG_XSH_RR_32),
455    /**
456     * Source of randomness is {@link org.apache.commons.rng.core.source32.PcgMcgXshRs32}.
457     * <ul>
458     *  <li>Native seed type: {@code Long}.</li>
459     * </ul>
460     * @since 1.3
461     */
462    PCG_MCG_XSH_RS_32(ProviderBuilder.RandomSourceInternal.PCG_MCG_XSH_RS_32),
463    /**
464     * Source of randomness is {@link org.apache.commons.rng.core.source32.MiddleSquareWeylSequence}.
465     * <ul>
466     *  <li>Native seed type: {@code long[]}.</li>
467     *  <li>Native seed size: 3.</li>
468     * </ul>
469     * @since 1.3
470     */
471    MSWS(ProviderBuilder.RandomSourceInternal.MSWS),
472    /**
473     * Source of randomness is {@link org.apache.commons.rng.core.source32.DotyHumphreySmallFastCounting32}.
474     * <ul>
475     *  <li>Native seed type: {@code int[]}.</li>
476     *  <li>Native seed size: 3.</li>
477     * </ul>
478     * @since 1.3
479     */
480    SFC_32(ProviderBuilder.RandomSourceInternal.SFC_32),
481    /**
482     * Source of randomness is {@link org.apache.commons.rng.core.source64.DotyHumphreySmallFastCounting64}.
483     * <ul>
484     *  <li>Native seed type: {@code long[]}.</li>
485     *  <li>Native seed size: 3.</li>
486     * </ul>
487     * @since 1.3
488     */
489    SFC_64(ProviderBuilder.RandomSourceInternal.SFC_64),
490    /**
491     * Source of randomness is {@link org.apache.commons.rng.core.source32.JenkinsSmallFast32}.
492     * <ul>
493     *  <li>Native seed type: {@code Integer}.</li>
494     * </ul>
495     * @since 1.3
496     */
497    JSF_32(ProviderBuilder.RandomSourceInternal.JSF_32),
498    /**
499     * Source of randomness is {@link org.apache.commons.rng.core.source64.JenkinsSmallFast64}.
500     * <ul>
501     *  <li>Native seed type: {@code Long}.</li>
502     * </ul>
503     * @since 1.3
504     */
505    JSF_64(ProviderBuilder.RandomSourceInternal.JSF_64),
506    /**
507     * Source of randomness is {@link org.apache.commons.rng.core.source32.XoShiRo128PlusPlus}.
508     * <ul>
509     *  <li>Native seed type: {@code int[]}.</li>
510     *  <li>Native seed size: 4.</li>
511     * </ul>
512     * @since 1.3
513     */
514    XO_SHI_RO_128_PP(ProviderBuilder.RandomSourceInternal.XO_SHI_RO_128_PP),
515    /**
516     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoRoShiRo128PlusPlus}.
517     * <ul>
518     *  <li>Native seed type: {@code long[]}.</li>
519     *  <li>Native seed size: 2.</li>
520     * </ul>
521     * @since 1.3
522     */
523    XO_RO_SHI_RO_128_PP(ProviderBuilder.RandomSourceInternal.XO_RO_SHI_RO_128_PP),
524    /**
525     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoShiRo256PlusPlus}.
526     * <ul>
527     *  <li>Native seed type: {@code long[]}.</li>
528     *  <li>Native seed size: 4.</li>
529     * </ul>
530     * @since 1.3
531     */
532    XO_SHI_RO_256_PP(ProviderBuilder.RandomSourceInternal.XO_SHI_RO_256_PP),
533    /**
534     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoShiRo512PlusPlus}.
535     * <ul>
536     *  <li>Native seed type: {@code long[]}.</li>
537     *  <li>Native seed size: 8.</li>
538     * </ul>
539     * @since 1.3
540     */
541    XO_SHI_RO_512_PP(ProviderBuilder.RandomSourceInternal.XO_SHI_RO_512_PP),
542    /**
543     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoRoShiRo1024PlusPlus}.
544     * <ul>
545     *  <li>Native seed type: {@code long[]}.</li>
546     *  <li>Native seed size: 16.</li>
547     * </ul>
548     * @since 1.3
549     */
550    XO_RO_SHI_RO_1024_PP(ProviderBuilder.RandomSourceInternal.XO_RO_SHI_RO_1024_PP),
551    /**
552     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoRoShiRo1024Star}.
553     * <ul>
554     *  <li>Native seed type: {@code long[]}.</li>
555     *  <li>Native seed size: 16.</li>
556     * </ul>
557     * @since 1.3
558     */
559    XO_RO_SHI_RO_1024_S(ProviderBuilder.RandomSourceInternal.XO_RO_SHI_RO_1024_S),
560    /**
561     * Source of randomness is {@link org.apache.commons.rng.core.source64.XoRoShiRo1024StarStar}.
562     * <ul>
563     *  <li>Native seed type: {@code long[]}.</li>
564     *  <li>Native seed size: 16.</li>
565     * </ul>
566     * @since 1.3
567     */
568    XO_RO_SHI_RO_1024_SS(ProviderBuilder.RandomSourceInternal.XO_RO_SHI_RO_1024_SS),
569    /**
570     * Source of randomness is {@link org.apache.commons.rng.core.source32.PcgXshRr32}.
571     * <ul>
572     *  <li>Native seed type: {@code Long}.</li>
573     * </ul>
574     * @since 1.4
575     */
576    PCG_XSH_RR_32_OS(ProviderBuilder.RandomSourceInternal.PCG_XSH_RR_32_OS),
577    /**
578     * Source of randomness is {@link org.apache.commons.rng.core.source32.PcgXshRs32}.
579     * <ul>
580     *  <li>Native seed type: {@code Long}.</li>
581     * </ul>
582     * @since 1.4
583     */
584    PCG_XSH_RS_32_OS(ProviderBuilder.RandomSourceInternal.PCG_XSH_RS_32_OS),
585    /**
586     * Source of randomness is {@link org.apache.commons.rng.core.source64.PcgRxsMXs64}.
587     * <ul>
588     *  <li>Native seed type: {@code Long}.</li>
589     * </ul>
590     * @since 1.4
591     */
592    PCG_RXS_M_XS_64_OS(ProviderBuilder.RandomSourceInternal.PCG_RXS_M_XS_64_OS),
593    /**
594     * Source of randomness is {@link org.apache.commons.rng.core.source64.L64X128StarStar}.
595     * <ul>
596     *  <li>Native seed type: {@code long[]}.</li>
597     *  <li>Native seed size: 4.</li>
598     * </ul>
599     * @since 1.5
600     */
601    L64_X128_SS(ProviderBuilder.RandomSourceInternal.L64_X128_SS),
602    /**
603     * Source of randomness is {@link org.apache.commons.rng.core.source64.L64X128Mix}.
604     * <ul>
605     *  <li>Native seed type: {@code long[]}.</li>
606     *  <li>Native seed size: 4.</li>
607     * </ul>
608     * @since 1.5
609     */
610    L64_X128_MIX(ProviderBuilder.RandomSourceInternal.L64_X128_MIX),
611    /**
612     * Source of randomness is {@link org.apache.commons.rng.core.source64.L64X256Mix}.
613     * <ul>
614     *  <li>Native seed type: {@code long[]}.</li>
615     *  <li>Native seed size: 6.</li>
616     * </ul>
617     * @since 1.5
618     */
619    L64_X256_MIX(ProviderBuilder.RandomSourceInternal.L64_X256_MIX),
620    /**
621     * Source of randomness is {@link org.apache.commons.rng.core.source64.L64X1024Mix}.
622     * <ul>
623     *  <li>Native seed type: {@code long[]}.</li>
624     *  <li>Native seed size: 18.</li>
625     * </ul>
626     * @since 1.5
627     */
628    L64_X1024_MIX(ProviderBuilder.RandomSourceInternal.L64_X1024_MIX),
629    /**
630     * Source of randomness is {@link org.apache.commons.rng.core.source64.L128X128Mix}.
631     * <ul>
632     *  <li>Native seed type: {@code long[]}.</li>
633     *  <li>Native seed size: 6.</li>
634     * </ul>
635     * @since 1.5
636     */
637    L128_X128_MIX(ProviderBuilder.RandomSourceInternal.L128_X128_MIX),
638    /**
639     * Source of randomness is {@link org.apache.commons.rng.core.source64.L128X256Mix}.
640     * <ul>
641     *  <li>Native seed type: {@code long[]}.</li>
642     *  <li>Native seed size: 8.</li>
643     * </ul>
644     * @since 1.5
645     */
646    L128_X256_MIX(ProviderBuilder.RandomSourceInternal.L128_X256_MIX),
647    /**
648     * Source of randomness is {@link org.apache.commons.rng.core.source64.L128X1024Mix}.
649     * <ul>
650     *  <li>Native seed type: {@code long[]}.</li>
651     *  <li>Native seed size: 20.</li>
652     * </ul>
653     * @since 1.5
654     */
655    L128_X1024_MIX(ProviderBuilder.RandomSourceInternal.L128_X1024_MIX),
656    /**
657     * Source of randomness is {@link org.apache.commons.rng.core.source32.L32X64Mix}.
658     * <ul>
659     *  <li>Native seed type: {@code int[]}.</li>
660     *  <li>Native seed size: 4.</li>
661     * </ul>
662     * @since 1.5
663     */
664    L32_X64_MIX(ProviderBuilder.RandomSourceInternal.L32_X64_MIX),
665    /**
666     * Source of randomness is {@link org.apache.commons.rng.core.source32.Philox4x32}.
667     * <ul>
668     *  <li>Native seed type: {@code int[]}.</li>
669     *  <li>Native seed size: 6.</li>
670     * </ul>
671     * @since 1.7
672     */
673    PHILOX_4X32(ProviderBuilder.RandomSourceInternal.PHILOX_4X32),
674    /**
675     * Source of randomness is {@link org.apache.commons.rng.core.source64.Philox4x64}.
676     * <ul>
677     *  <li>Native seed type: {@code long[]}.</li>
678     *  <li>Native seed size: 6.</li>
679     * </ul>
680     * @since 1.7
681     */
682    PHILOX_4X64(ProviderBuilder.RandomSourceInternal.PHILOX_4X64);
683
684
685    /** Internal identifier. */
686    private final ProviderBuilder.RandomSourceInternal internalIdentifier;
687
688    /**
689     * @param id Internal identifier.
690     */
691    RandomSource(ProviderBuilder.RandomSourceInternal id) {
692        internalIdentifier = id;
693    }
694
695    /**
696     * @return the internal identifier.
697     */
698    ProviderBuilder.RandomSourceInternal getInternalIdentifier() {
699        return internalIdentifier;
700    }
701
702    /**
703     * Checks whether the type of given {@code seed} is the native type
704     * of the implementation.
705     *
706     * @param seed Seed value.
707     * @return {@code true} if the type of {@code seed} is the native
708     * type for this RNG source.
709     */
710    public boolean isNativeSeed(Object seed) {
711        return internalIdentifier.isNativeSeed(seed);
712    }
713
714    /**
715     * Creates a seed suitable for the implementing class represented by this random source.
716     *
717     * <p>The seed will be created as if passing a {@code null} seed to the method
718     * {@link #create(Object, Object...)}. It will satisfy the seed size and any
719     * other seed requirements for the implementing class. The seed is converted from the native
720     * type to a byte representation.</p>
721     *
722     * <p>Usage example:</p>
723     * <pre><code>
724     *  RandomSource source = ...;
725     *  byte[] seed = source.createSeed();
726     *  UniformRandomProvider rng = source.create(seed);
727     * </code></pre>
728     *
729     * @return the seed
730     * @since 1.3
731     */
732    public byte[] createSeed() {
733        return internalIdentifier.createSeedBytes();
734    }
735
736    /**
737     * Creates a seed suitable for the implementing class represented by this random source
738     * using the supplied source of randomness.
739     *
740     * <p>The seed will satisfy the seed size and any other seed requirements for the
741     * implementing class.</p>
742     *
743     * <p>Usage example:</p>
744     * <pre><code>
745     *  RandomSource source = ...;
746     *  UniformRandomProvider seedRng = new JDKRandomWrapper(new SecureRandom());
747     *  byte[] seed = source.createSeed(seedRng);
748     *  UniformRandomProvider rng = source.create(seed);
749     * </code></pre>
750     *
751     * @param rng Source of randomness.
752     * @return the seed
753     * @since 1.3
754     */
755    public byte[] createSeed(UniformRandomProvider rng) {
756        return internalIdentifier.createSeedBytes(rng);
757    }
758
759    /**
760     * Checks whether the implementing class represented by this random source
761     * supports the {@link org.apache.commons.rng.JumpableUniformRandomProvider
762     * JumpableUniformRandomProvider} interface. If {@code true} the instance returned
763     * by {@link #create(RandomSource)} may be cast to the interface; otherwise a class
764     * cast exception will occur.
765     *
766     * <p>Usage example:</p>
767     * <pre><code>
768     *  RandomSource source = ...;
769     *  if (source.isJumpable()) {
770     *      JumpableUniformRandomProvider rng =
771     *          (JumpableUniformRandomProvider) source.create();
772     *  }
773     * </code></pre>
774     *
775     * @return {@code true} if jumpable
776     * @since 1.3
777     */
778    public boolean isJumpable() {
779        return isAssignableTo(org.apache.commons.rng.JumpableUniformRandomProvider.class);
780    }
781
782    /**
783     * Checks whether the implementing class represented by this random source
784     * supports the {@link org.apache.commons.rng.LongJumpableUniformRandomProvider
785     * LongJumpableUniformRandomProvider} interface. If {@code true} the instance returned
786     * by {@link #create(RandomSource)} may be cast to the interface; otherwise a class
787     * cast exception will occur.
788     *
789     * <p>Usage example:</p>
790     * <pre><code>
791     *  RandomSource source = ...;
792     *  if (source.isJumpable()) {
793     *      LongJumpableUniformRandomProvider rng =
794     *          (LongJumpableUniformRandomProvider) source.create();
795     *  }
796     * </code></pre>
797     *
798     * @return {@code true} if long jumpable
799     * @since 1.3
800     */
801    public boolean isLongJumpable() {
802        return isAssignableTo(org.apache.commons.rng.LongJumpableUniformRandomProvider.class);
803    }
804
805    /**
806     * Checks whether the implementing class represented by this random source
807     * supports the {@link org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider
808     * ArbitrarilyJumpableUniformRandomProvider} interface. If {@code true} the instance returned
809     * by {@link #create(RandomSource)} may be cast to the interface; otherwise a class
810     * cast exception will occur.
811     *
812     * <p>Usage example:</p>
813     * <pre><code>
814     *  RandomSource source = ...;
815     *  if (source.isJumpable()) {
816     *      ArbitrarilyJumpableUniformRandomProvider rng =
817     *          (ArbitrarilyJumpableUniformRandomProvider) source.create();
818     *  }
819     * </code></pre>
820     *
821     * @return {@code true} if arbitrarily jumpable
822     * @since 1.7
823     */
824    public boolean isArbitrarilyJumpable() {
825        return isAssignableTo(org.apache.commons.rng.ArbitrarilyJumpableUniformRandomProvider.class);
826    }
827
828    /**
829     * Checks whether the implementing class represented by this random source
830     * supports the {@link org.apache.commons.rng.SplittableUniformRandomProvider
831     * SplittableUniformRandomProvider} interface. If {@code true} the instance returned
832     * by {@link #create(RandomSource)} may be cast to the interface; otherwise a class
833     * cast exception will occur.
834     *
835     * <p>Usage example:</p>
836     * <pre><code>
837     *  RandomSource source = ...;
838     *  if (source.isSplittable()) {
839     *      SplittableUniformRandomProvider rng =
840     *          (SplittableUniformRandomProvider) source.create();
841     *  }
842     * </code></pre>
843     *
844     * @return {@code true} if splittable
845     * @since 1.5
846     */
847    public boolean isSplittable() {
848        return isAssignableTo(org.apache.commons.rng.SplittableUniformRandomProvider.class);
849    }
850
851    /**
852     * Determines if the implementing class represented by this random source is either the same
853     * as, or is a subclass or subinterface of, the class or interface represented
854     * by the specified {@code Class} parameter. It returns true if so; otherwise it returns
855     * false.
856     *
857     * @param type the {@code Class} object to be checked
858     * @return the boolean value indicating whether the class of this random source
859     * can be assigned to objects of the specified type
860     */
861    private boolean isAssignableTo(Class<?> type) {
862        return type.isAssignableFrom(internalIdentifier.getRng());
863    }
864
865    /**
866     * Creates a random number generator with a random seed.
867     *
868     * <p>Usage example:</p>
869     * <pre><code>
870     *  UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create();
871     * </code></pre>
872     * <p>or, if a {@link RestorableUniformRandomProvider "save/restore"} functionality is needed,</p>
873     * <pre><code>
874     *  RestorableUniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create();
875     * </code></pre>
876     *
877     * <p>This method will raise an exception if the generator requires arguments in addition
878     * to a seed (e.g. {@link #TWO_CMRES_SELECT}).</p>
879     *
880     * @return the RNG.
881     * @throws IllegalArgumentException if the generator requires arguments in addition
882     * to a seed.
883     *
884     * @see #create(Object,Object[])
885     * @since 1.4
886     */
887    public RestorableUniformRandomProvider create() {
888        return ProviderBuilder.create(getInternalIdentifier());
889    }
890
891    /**
892     * Creates a random number generator with the given {@code seed}.
893     *
894     * <p>Usage example:</p>
895     * <pre><code>
896     *  UniformRandomProvider rng = RandomSource.XO_RO_SHI_RO_128_PP.create(0x123abcL);
897     *  UniformRandomProvider rng = RandomSource.TWO_CMRES_SELECT.create(26219, 6, 9);
898     *  // null seed with arguments
899     *  UniformRandomProvider rng = RandomSource.TWO_CMRES_SELECT.create((Object) null, 6, 9);
900     * </code></pre>
901     *
902     * <p>Valid types for the {@code seed} are:</p>
903     *  <ul>
904     *   <li>{@code Integer} (or {@code int})</li>
905     *   <li>{@code Long} (or {@code long})</li>
906     *   <li>{@code int[]}</li>
907     *   <li>{@code long[]}</li>
908     *   <li>{@code byte[]}</li>
909     *  </ul>
910     *
911     * <p>Notes:</p>
912     * <ul>
913     *  <li>
914     *   When the seed type passed as argument is more complex (i.e. more
915     *   bits can be independently chosen) than the generator's
916     *   {@link #isNativeSeed(Object) native type}, the conversion of a
917     *   set of different seeds will necessarily result in the same value
918     *   of the native seed type.
919     *  </li>
920     *  <li>
921     *   When the native seed type is an array, the same remark applies
922     *   when the array contains more bits than the state of the generator.
923     *  </li>
924     *  <li>
925     *   When the {@code seed} is {@code null}, a seed of the native type
926     *   will be generated. If the native type is an array, the generated
927     *   size is limited a maximum of 128.
928     *  </li>
929     * </ul>
930     *
931     * <p>This method will raise an exception if the additional arguments for
932     * the implementation's constructor are incorrect (e.g. {@link #TWO_CMRES_SELECT}).
933     * This includes the case where arguments are supplied and the implementation
934     * does not require additional arguments.</p>
935     *
936     * @param seed Seed value.  It can be {@code null} (in which case a
937     * random value will be used).
938     * @param data Additional arguments to the implementation's constructor.
939     * Please refer to the documentation of each specific implementation.
940     * @return the RNG.
941     * @throws IllegalArgumentException if the argument data required to initialize the
942     * generator is incorrect.
943     * @throws UnsupportedOperationException if the type of the {@code seed}
944     * is invalid.
945     *
946     * @see #create()
947     * @since 1.4
948     */
949    public RestorableUniformRandomProvider create(Object seed,
950                                                  Object... data) {
951        return ProviderBuilder.create(getInternalIdentifier(), seed, data);
952    }
953
954    /**
955     * Creates a random number generator with a random seed.
956     *
957     * <p>Usage example:</p>
958     * <pre><code>
959     *  UniformRandomProvider rng = RandomSource.create(RandomSource.MT);
960     * </code></pre>
961     * <p>or, if a {@link RestorableUniformRandomProvider "save/restore"} functionality is needed,</p>
962     * <pre><code>
963     *  RestorableUniformRandomProvider rng = RandomSource.create(RandomSource.MT);
964     * </code></pre>
965     *
966     * <p>This method will raise an exception if the generator requires arguments in addition
967     * to a seed (e.g. {@link #TWO_CMRES_SELECT}).</p>
968     *
969     * @param source RNG type.
970     * @return the RNG.
971     * @throws IllegalArgumentException if the generator requires arguments in addition
972     * to a seed.
973     *
974     * @see #create(RandomSource,Object,Object[])
975     * @deprecated It is preferred to use the {@link RandomSource#create()} instance method.
976     */
977    @Deprecated
978    public static RestorableUniformRandomProvider create(RandomSource source) {
979        return ProviderBuilder.create(source.getInternalIdentifier());
980    }
981
982    /**
983     * Creates a random number generator with the given {@code seed}.
984     *
985     * <p>Usage example:</p>
986     * <pre><code>
987     *  UniformRandomProvider rng = RandomSource.create(RandomSource.XO_RO_SHI_RO_128_PP, 0x123abcL);
988     *  UniformRandomProvider rng = RandomSource.create(RandomSource.TWO_CMRES_SELECT, 26219, 6, 9);
989     * </code></pre>
990     *
991     * <p>Valid types for the {@code seed} are:</p>
992     *  <ul>
993     *   <li>{@code Integer} (or {@code int})</li>
994     *   <li>{@code Long} (or {@code long})</li>
995     *   <li>{@code int[]}</li>
996     *   <li>{@code long[]}</li>
997     *   <li>{@code byte[]}</li>
998     *  </ul>
999     *
1000     * <p>Notes:</p>
1001     * <ul>
1002     *  <li>
1003     *   When the seed type passed as argument is more complex (i.e. more
1004     *   bits can be independently chosen) than the generator's
1005     *   {@link #isNativeSeed(Object) native type}, the conversion of a
1006     *   set of different seeds will necessarily result in the same value
1007     *   of the native seed type.
1008     *  </li>
1009     *  <li>
1010     *   When the native seed type is an array, the same remark applies
1011     *   when the array contains more bits than the state of the generator.
1012     *  </li>
1013     *  <li>
1014     *   When the {@code seed} is {@code null}, a seed of the native type
1015     *   will be generated. If the native type is an array, the generated
1016     *   size is limited a maximum of 128.
1017     *  </li>
1018     * </ul>
1019     *
1020     * <p>This method will raise an exception if the additional arguments for
1021     * the implementation's constructor are incorrect (e.g. {@link #TWO_CMRES_SELECT}).
1022     * This includes the case where arguments are supplied and the implementation
1023     * does not require additional arguments.</p>
1024     *
1025     * @param source RNG type.
1026     * @param seed Seed value.  It can be {@code null} (in which case a
1027     * random value will be used).
1028     * @param data Additional arguments to the implementation's constructor.
1029     * Please refer to the documentation of each specific implementation.
1030     * @return the RNG.
1031     * @throws IllegalArgumentException if the argument data required to initialize the
1032     * generator is incorrect.
1033     * @throws UnsupportedOperationException if the type of the {@code seed}
1034     * is invalid.
1035     *
1036     * @see #create(RandomSource)
1037     * @deprecated It is preferred to use the {@link RandomSource#create(Object, Object...)} instance method.
1038     */
1039    @Deprecated
1040    public static RestorableUniformRandomProvider create(RandomSource source,
1041                                                         Object seed,
1042                                                         Object... data) {
1043        return ProviderBuilder.create(source.getInternalIdentifier(), seed, data);
1044    }
1045
1046    /**
1047     * Creates a number for use as a seed.
1048     *
1049     * @return a random number.
1050     */
1051    public static int createInt() {
1052        return SeedFactory.createInt();
1053    }
1054
1055    /**
1056     * Creates a number for use as a seed.
1057     *
1058     * @return a random number.
1059     */
1060    public static long createLong() {
1061        return SeedFactory.createLong();
1062    }
1063
1064    /**
1065     * Creates an array of numbers for use as a seed.
1066     *
1067     * @param n Size of the array to create.
1068     * @return an array of {@code n} random numbers.
1069     */
1070    public static int[] createIntArray(int n) {
1071        return SeedFactory.createIntArray(n);
1072    }
1073
1074    /**
1075     * Creates an array of numbers for use as a seed.
1076     *
1077     * @param n Size of the array to create.
1078     * @return an array of {@code n} random numbers.
1079     */
1080    public static long[] createLongArray(int n) {
1081        return SeedFactory.createLongArray(n);
1082    }
1083
1084    /**
1085     * Wraps the given {@code delegate} generator in a new instance that
1086     * only provides access to the {@link UniformRandomProvider} methods.
1087     *
1088     * <p>This method can be used to prevent access to any methods of the {@code delegate}
1089     * that are not defined in the {@link UniformRandomProvider} interface.
1090     * For example this will prevent access to the "save/restore" functionality of
1091     * any {@link RestorableUniformRandomProvider} {@link #create() created}
1092     * by the {@link RandomSource} factory methods, or will prevent access to the jump
1093     * functionality of generators.
1094     *
1095     * <p>Since the method applies to more than the {@link RestorableUniformRandomProvider}
1096     * interface it is left to the caller to determine if any methods require hiding,
1097     * for example:
1098     *
1099     * <pre><code>
1100     * UniformRandomProvider rng = ...;
1101     * if (rng instanceof JumpableUniformRandomProvider) {
1102     *    rng = RandomSource.unrestorable(rng);
1103     * }
1104     * </code></pre>
1105     *
1106     * @param delegate Generator to which calls will be delegated.
1107     * @return a new instance
1108     */
1109    public static UniformRandomProvider unrestorable(final UniformRandomProvider delegate) {
1110        return new UniformRandomProvider() {
1111            @Override
1112            public void nextBytes(byte[] bytes) {
1113                delegate.nextBytes(bytes);
1114            }
1115
1116            @Override
1117            public void nextBytes(byte[] bytes,
1118                                  int start,
1119                                  int len) {
1120                delegate.nextBytes(bytes, start, len);
1121            }
1122
1123            @Override
1124            public int nextInt() {
1125                return delegate.nextInt();
1126            }
1127
1128            @Override
1129            public int nextInt(int n) {
1130                return delegate.nextInt(n);
1131            }
1132
1133            @Override
1134            public int nextInt(int origin, int bound) {
1135                return delegate.nextInt(origin, bound);
1136            }
1137
1138            @Override
1139            public long nextLong() {
1140                return delegate.nextLong();
1141            }
1142
1143            @Override
1144            public long nextLong(long n) {
1145                return delegate.nextLong(n);
1146            }
1147
1148            @Override
1149            public long nextLong(long origin, long bound) {
1150                return delegate.nextLong(origin, bound);
1151            }
1152
1153            @Override
1154            public boolean nextBoolean() {
1155                return delegate.nextBoolean();
1156            }
1157
1158            @Override
1159            public float nextFloat() {
1160                return delegate.nextFloat();
1161            }
1162
1163            @Override
1164            public float nextFloat(float bound) {
1165                return delegate.nextFloat(bound);
1166            }
1167
1168            @Override
1169            public float nextFloat(float origin, float bound) {
1170                return delegate.nextFloat(origin, bound);
1171            }
1172
1173            @Override
1174            public double nextDouble() {
1175                return delegate.nextDouble();
1176            }
1177
1178            @Override
1179            public double nextDouble(double bound) {
1180                return delegate.nextDouble(bound);
1181            }
1182
1183            @Override
1184            public double nextDouble(double origin, double bound) {
1185                return delegate.nextDouble(origin, bound);
1186            }
1187
1188            @Override
1189            public IntStream ints() {
1190                return delegate.ints();
1191            }
1192
1193            @Override
1194            public IntStream ints(int origin, int bound) {
1195                return delegate.ints(origin, bound);
1196            }
1197
1198            @Override
1199            public IntStream ints(long streamSize) {
1200                return delegate.ints(streamSize);
1201            }
1202
1203            @Override
1204            public IntStream ints(long streamSize, int origin, int bound) {
1205                return delegate.ints(streamSize, origin, bound);
1206            }
1207
1208            @Override
1209            public LongStream longs() {
1210                return delegate.longs();
1211            }
1212
1213            @Override
1214            public LongStream longs(long origin, long bound) {
1215                return delegate.longs(origin, bound);
1216            }
1217
1218            @Override
1219            public LongStream longs(long streamSize) {
1220                return delegate.longs(streamSize);
1221            }
1222
1223            @Override
1224            public LongStream longs(long streamSize, long origin, long bound) {
1225                return delegate.longs(streamSize, origin, bound);
1226            }
1227
1228            @Override
1229            public DoubleStream doubles() {
1230                return delegate.doubles();
1231            }
1232
1233            @Override
1234            public DoubleStream doubles(double origin, double bound) {
1235                return delegate.doubles(origin, bound);
1236            }
1237
1238            @Override
1239            public DoubleStream doubles(long streamSize) {
1240                return delegate.doubles(streamSize);
1241            }
1242
1243            @Override
1244            public DoubleStream doubles(long streamSize, double origin, double bound) {
1245                return delegate.doubles(streamSize, origin, bound);
1246            }
1247
1248            @Override
1249            public String toString() {
1250                return delegate.toString();
1251            }
1252        };
1253    }
1254}