use of org.nd4j.rng.NativeRandom in project nd4j by deeplearning4j.
the class RandomTests method testStepOver3.
@Test
public void testStepOver3() throws Exception {
Random random = Nd4j.getRandomFactory().getNewRandomInstance(119);
if (random instanceof NativeRandom) {
NativeRandom rng = (NativeRandom) random;
assertTrue(rng.getBufferSize() > 1000000L);
int someInt = rng.nextInt();
for (int e = 0; e < 10000; e++) rng.nextInt();
random.setSeed(119);
int sameInt = rng.nextInt();
assertEquals(someInt, sameInt);
random.setSeed(120);
int otherInt = rng.nextInt();
assertNotEquals(someInt, otherInt);
} else
log.warn("Not a NativeRandom object received, skipping test");
}
use of org.nd4j.rng.NativeRandom in project nd4j by deeplearning4j.
the class RandomTests method testStepOver2.
@Test
public void testStepOver2() throws Exception {
Random random = Nd4j.getRandomFactory().getNewRandomInstance(119);
if (random instanceof NativeRandom) {
NativeRandom rng = (NativeRandom) random;
assertTrue(rng.getBufferSize() > 1000000L);
assertEquals(0, rng.getPosition());
rng.nextLong();
assertEquals(1, rng.getPosition());
assertEquals(1, rng.getGeneration());
for (long e = 0; e <= rng.getBufferSize(); e++) {
rng.nextLong();
}
assertEquals(2, rng.getPosition());
assertEquals(2, rng.getGeneration());
rng.reSeed(8792);
assertEquals(2, rng.getGeneration());
assertEquals(2, rng.getPosition());
} else
log.warn("Not a NativeRandom object received, skipping test");
}
Aggregations