static void ensureNonZero()

in commons-rng-simple/src/main/java/org/apache/commons/rng/simple/internal/SeedFactory.java [279:298]


    static void ensureNonZero(int[] seed, int from, int to) {
        if (from >= to) {
            return;
        }
        // No check on the range so an IndexOutOfBoundsException will occur if invalid
        for (int i = from; i < to; i++) {
            if (seed[i] != 0) {
                return;
            }
        }
        // Fill with non-zero values using a SplitMix-style PRNG.
        // The range is at least 1.
        // To ensure the first value is not zero requires the input to the mix function
        // to be non-zero. This is ensured if the start is even since the increment is odd.
        int x = createInt() << 1;
        for (int i = from; i < to; i++) {
            x += MixFunctions.GOLDEN_RATIO_32;
            seed[i] = MixFunctions.murmur3(x);
        }
    }