Search in sources :

Example 1 with LongArray

use of net.imglib2.img.basictypeaccess.array.LongArray in project imagej-ops by imagej.

the class AbstractOpTest method generateUnsignedVariableBitLengthTypeArrayTestImg.

public ArrayImg<UnsignedVariableBitLengthType, LongArray> generateUnsignedVariableBitLengthTypeArrayTestImg(final boolean fill, final int nbits, final long... dims) {
    final long[] array = new long[(int) Intervals.numElements(new FinalInterval(dims))];
    if (fill) {
        seed = 17;
        for (int i = 0; i < array.length; i++) {
            array[i] = (long) (((pseudoRandom() / Integer.MAX_VALUE)) % (Math.pow(2, nbits)));
        }
    }
    final LongArray l = new LongArray(array);
    return ArrayImgs.unsignedVariableBitLengths(l, nbits, dims);
}
Also used : LongArray(net.imglib2.img.basictypeaccess.array.LongArray) FinalInterval(net.imglib2.FinalInterval)

Example 2 with LongArray

use of net.imglib2.img.basictypeaccess.array.LongArray 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)

Aggregations

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