// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
// CMRG algorithm
//
// L'Ecuyer Operations Research 1996.
//
// cycle = 2^205 = approc. 1E61

public class CMRG extends Combined {
    private static class CMRGCombiner implements Combiner {
        public int combine(int[] num) {
            long tmp = num[0] - num[1];
            tmp = (tmp + 2147483647) % 2147483647;
            return (int)tmp;
        }
        public int getMaxInt() {
            return 2147483647;
        }
    }
    public CMRG(int[] seed1, int[] seed2) {
        super(new RNG[] { new MRG(new int[] { 0, 63308, -183326 }, 0, 2147483647, seed1),
                          new MRG(new int[] { 86098, 0, -539608 }, 0, 2145483479, seed2) },
              new CMRGCombiner());
    }
}
