de.unkrig.commons.math
Class Sequences

java.lang.Object
  extended by de.unkrig.commons.math.Sequences

public final class Sequences
extends java.lang.Object

A collection of utility methods related to mathematical sequences.


Method Summary
static Producer<java.lang.Long> linearCongruentialGenerator(long seed, long m, long a, long c)
          See Wikipedia article: Linear congruential generator.
static Producer<java.lang.Long> multiplicativeCongruentialGenerator(long seed, long m, long a)
          See Wikipedia article: Linear congruential generator.
static Producer<java.lang.Long> randomSequence(long period)
          Produces a periodic sequence of random, but unique Longs with values ranging from 0 to period - 1.
static Producer<java.lang.Long> randomSequence(long seed, long period)
          Produces a periodic sequence of random, but unique Longs with values ranging from 0 to period - 1.
static Producer<java.lang.Long> randomSequence(long seed, long min, long max)
          Produces a periodic sequence of random, but unique Longs with values ranging from min to max - 1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

randomSequence

public static Producer<java.lang.Long> randomSequence(long period)
Produces a periodic sequence of random, but unique Longs with values ranging from 0 to period - 1.


randomSequence

public static Producer<java.lang.Long> randomSequence(long seed,
                                                      long period)
Produces a periodic sequence of random, but unique Longs with values ranging from 0 to period - 1. For identical seeds, the returned sequences will be identical.


randomSequence

public static Producer<java.lang.Long> randomSequence(long seed,
                                                      long min,
                                                      long max)
Produces a periodic sequence of random, but unique Longs with values ranging from min to max - 1. The period of the sequence is max - min. For identical seeds, the returned sequences will be identical.


linearCongruentialGenerator

public static Producer<java.lang.Long> linearCongruentialGenerator(long seed,
                                                                   long m,
                                                                   long a,
                                                                   long c)
See Wikipedia article: Linear congruential generator.


multiplicativeCongruentialGenerator

public static Producer<java.lang.Long> multiplicativeCongruentialGenerator(long seed,
                                                                           long m,
                                                                           long a)
See Wikipedia article: Linear congruential generator. Notice that this variant of a congruential generator produces values starting at one, not starting at zero!