@Override public void mutate(final ArrayImg<LongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] -= value; } }
@Override public void mutate(final ArrayImg<UnsignedLongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] /= value; } }
@Override public void mutate(final ArrayImg<LongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] /= value; } }
@Override public void mutate(final ArrayImg<UnsignedLongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] *= value; } }
@Override public void mutate(final ArrayImg<LongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] += value; } }
@Override public void mutate(final ArrayImg<LongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] *= value; } }
@Override public void mutate(final ArrayImg<UnsignedLongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] += value; } }
@Override public void mutate(final ArrayImg<UnsignedLongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] -= value; } }
@Override public void mutate(final PlanarImg<UnsignedLongType, LongArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final long[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] *= value; } } }
@Override public void mutate(final PlanarImg<LongType, LongArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final long[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] -= value; } } }
@Override public void mutate(final PlanarImg<UnsignedLongType, LongArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final long[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] -= value; } } }
@Override public void mutate(final PlanarImg<UnsignedLongType, LongArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final long[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] += value; } } }
@Override public void mutate(final PlanarImg<LongType, LongArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final long[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] += value; } } }
@Override public void mutate(final PlanarImg<LongType, LongArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final long[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] *= value; } } }
@Override public void mutate(final PlanarImg<LongType, LongArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final long[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] /= value; } } }
@Override public void mutate(final PlanarImg<UnsignedLongType, LongArray> arg) { long planeCount = 1; for (int d = 2; d < arg.numDimensions(); d++) { planeCount *= arg.dimension(d); } for (int p = 0; p < planeCount; p++) { final long[] plane = arg.getPlane(p).getCurrentStorageArray(); for (int i = 0; i < plane.length; i++) { plane[i] /= value; } } }
@Override public void mutate(final ArrayImg<LongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); ops().run(ChunkerOp.class, new Chunk() { @Override public void execute(final long startIndex, final long stepSize, final long numSteps) { final int startIndexSafe32 = (startIndex==0) ? 0 : ArrayUtils.safeMultiply32(startIndex); final int stepSizeSafe32 = (stepSize==0) ? 0 : ArrayUtils.safeMultiply32(stepSize); if (stepSizeSafe32 != 1) { for (int i = startIndexSafe32, j = 0; j < numSteps; i = i + stepSizeSafe32, j++) { data[i] -= value; } } else { for (int i = startIndexSafe32; i < startIndex + numSteps; i++) { data[i] -= value; } } } }, data.length); }
@Override public void mutate(final ArrayImg<UnsignedLongType, LongArray> arg) { final long[] data = arg.update(null).getCurrentStorageArray(); ops().run(ChunkerOp.class, new Chunk() { @Override public void execute(final long startIndex, final long stepSize, final long numSteps) { final int startIndexSafe32 = (startIndex==0) ? 0 : ArrayUtils.safeMultiply32(startIndex); final int stepSizeSafe32 = (stepSize==0) ? 0 : ArrayUtils.safeMultiply32(stepSize); if (stepSizeSafe32 != 1) { for (int i = startIndexSafe32, j = 0; j < numSteps; i = i + stepSizeSafe32, j++) { data[i] -= value; } } else { for (int i = startIndexSafe32; i < startIndex + numSteps; i++) { data[i] -= value; } } } }, data.length); }
@Test public void testUnsigned4Bits() { final long[] size = { 5, 10 }; final ArrayImg< Unsigned4BitType, LongArray > img = ArrayImgs.unsigned4Bits( size ); int previous = 1, current = 1; for ( final Unsigned4BitType t : img ) { t.set( current % 16 ); final int next = current + previous; previous = current; current = next; } final long[] expected = { 0xdb29909725d85321L, 0x25d85321101f2d58L, 0x101f2d58db299097L, 0x0000000000000021L }; final long[] actual = img.update( null ).getCurrentStorageArray(); assertArrayEquals( expected, actual ); }
@Test public void testUnsignedVariableBits7() { final long[] size = { 5, 5 }; final ArrayImg< UnsignedVariableBitLengthType, LongArray > img = ArrayImgs.unsignedVariableBitLengths( 7, size ); long previous = 1, current = 1, next = 0; for ( final UnsignedVariableBitLengthType t : img ) { t.set( current % 128 ); next = current + previous; previous = current; current = next; } final long[] expected = { 0xb744546880a0c101L, 0x6a987b6f179d242cL, 0x00003122838af85bL }; final long[] actual = img.update( null ).getCurrentStorageArray(); assertArrayEquals( expected, actual ); }