Search in sources :

Example 1 with MersenneTwisterFast

use of org.scijava.util.MersenneTwisterFast in project imagej-ops by imagej.

the class AbstractOpTest method generateUnsigned128BitArrayTestImg.

public ArrayImg<Unsigned128BitType, LongArray> generateUnsigned128BitArrayTestImg(final boolean fill, final long... dims) {
    ArrayImg<Unsigned128BitType, LongArray> bits = ArrayImgs.unsigned128Bits(dims);
    if (fill) {
        MersenneTwisterFast betterRNG = new MersenneTwisterFast(0xf1eece);
        for (Unsigned128BitType b : bits) {
            BigInteger big = BigInteger.valueOf(betterRNG.nextLong());
            b.set(big);
        }
    }
    return bits;
}
Also used : LongArray(net.imglib2.img.basictypeaccess.array.LongArray) MersenneTwisterFast(org.scijava.util.MersenneTwisterFast) BigInteger(java.math.BigInteger) Unsigned128BitType(net.imglib2.type.numeric.integer.Unsigned128BitType)

Example 2 with MersenneTwisterFast

use of org.scijava.util.MersenneTwisterFast in project imagej-ops by imagej.

the class AbstractOpTest method generateUnboundedIntegerTypeListTestImg.

public ListImg<UnboundedIntegerType> generateUnboundedIntegerTypeListTestImg(final boolean fill, final long... dims) {
    final ListImg<UnboundedIntegerType> l = new ListImgFactory<UnboundedIntegerType>().create(dims, new UnboundedIntegerType());
    final BigInteger[] array = new BigInteger[(int) Intervals.numElements(dims)];
    RandomAccess<UnboundedIntegerType> ra = l.randomAccess();
    if (fill) {
        MersenneTwisterFast betterRNG = new MersenneTwisterFast(0xf1eece);
        for (int i = 0; i < Intervals.numElements(dims); i++) {
            BigInteger val = BigInteger.valueOf(betterRNG.nextLong());
            ra.get().set(val);
            ra.fwd(0);
        }
    }
    return l;
}
Also used : UnboundedIntegerType(net.imagej.types.UnboundedIntegerType) MersenneTwisterFast(org.scijava.util.MersenneTwisterFast) BigInteger(java.math.BigInteger)

Aggregations

BigInteger (java.math.BigInteger)2 MersenneTwisterFast (org.scijava.util.MersenneTwisterFast)2 UnboundedIntegerType (net.imagej.types.UnboundedIntegerType)1 LongArray (net.imglib2.img.basictypeaccess.array.LongArray)1 Unsigned128BitType (net.imglib2.type.numeric.integer.Unsigned128BitType)1