@Override public FloatArray createArray( final int numEntities ) { return new FloatArray( numEntities ); } }
/** * This has to be overwritten, otherwise two different instances exist (one in the imageplus, one in the mirror) */ @Override public void setPlane( final int no, final FloatArray plane ) { System.arraycopy( plane.getCurrentStorageArray(), 0, mirror.get( no ).getCurrentStorageArray(), 0, plane.getCurrentStorageArray().length ); }
FloatArray levels = new FloatArray(); levels.add(5993); levels.add(5995); ... Preferences p = Gdx.app.getPreferences("SETTINGS"); Json json = new Json(); String levelsJson = json.toJson(FloatArray.class, levels); p.putString("levels", levelsJson);
return dirty ? ( volatil ? ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new FloatArray( 0 ), a -> new DirtyVolatileFloatArray( a.getCurrentStorageArray(), true ) ) : ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new FloatArray( 0 ), a -> new DirtyFloatArray( a.getCurrentStorageArray() ) ) ) : ( volatil ? ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new FloatArray( 0 ), a -> new VolatileFloatArray( a.getCurrentStorageArray(), true ) ) : ( RandomAccessibleCacheLoader< T, A, CA > ) new RandomAccessibleCacheLoader<>( grid, source, type, new FloatArray( 0 ), a -> a ) ); case INT: return dirty
@Override public void convertBytes(final FloatArray data, final byte[] bytes, final int planesRead) { final ImageMetadata iMeta = reader().getMetadata().get(0); if (isCompatible()) { final int bpp = getBitsPerElement() / 8; final int offset = planesRead * (bytes.length / bpp); final ByteBuffer bb = ByteBuffer.wrap(bytes); bb.order(iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); bb.asFloatBuffer().get(data.getCurrentStorageArray(), offset, bytes.length / bpp); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel(pixelType); final int offset = planesRead * (bytes.length / bpp); for (int index = 0; index < bytes.length / bpp; index++) { final float value = (float) utils().decodeWord(bytes, index * bpp, pixelType, iMeta.isLittleEndian()); data.setValue(offset + index, value); } } }
floatBuf.get(floats, 0, floatBuf.limit()); return new FloatArray(floats); float[] floats = theArray.getDescriptor(); ByteBuffer byteBuf = ByteBuffer.allocate(4 * descriptor.length); FloatBuffer floatBuf = byteBuf.asFloatBuffer();
@Override public void convertBytes(final FloatArray data, final byte[] bytes, final int planesRead) { final ImageMetadata iMeta = reader().getMetadata().get(0); if (isCompatible()) { final int bpp = getBitsPerElement() / 8; final int offset = planesRead * (bytes.length / bpp); final ByteBuffer bb = ByteBuffer.wrap(bytes); bb.order(iMeta.isLittleEndian() ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); bb.asFloatBuffer().get(data.getCurrentStorageArray(), offset, bytes.length / bpp); } else { final int pixelType = iMeta.getPixelType(); final int bpp = FormatTools.getBytesPerPixel(pixelType); final int offset = planesRead * (bytes.length / bpp); for (int index = 0; index < bytes.length / bpp; index++) { final float value = (float) utils().decodeWord(bytes, index * bpp, pixelType, iMeta.isLittleEndian()); data.setValue(offset + index, value); } } }
@Override public FloatArray createArray( final int numEntities ) { return new FloatArray( numEntities ); } }
@Override protected DataBufferFloat createDataBuffer( final FloatArray data ) { final float[] sourceArray = data.getCurrentStorageArray(); return new DataBufferFloat( sourceArray, sourceArray.length ); }
public class run { public static void main(String[] argv) { FloatArray arr = new FloatArray(100); test.foo(arr); } }
@Override protected DataBufferFloat createDataBuffer( final FloatArray data ) { final float[] sourceArray = data.getCurrentStorageArray(); return new DataBufferFloat( sourceArray, sourceArray.length ); }
@Override public FloatArray emptyArray(final int entities) { return new FloatArray(entities); }
@Override public void mutate(final ArrayImg<FloatType, FloatArray> arg) { final float[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] /= value; } }
@Override public FloatArray emptyArray(final int entities) { return new FloatArray(entities); }
@Override public void mutate(final ArrayImg<FloatType, FloatArray> arg) { final float[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] -= value; } }
public FloatType( final float value ) { img = null; dataAccess = new FloatArray( 1 ); set( value ); }
@Override public void mutate(final ArrayImg<FloatType, FloatArray> arg) { final float[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] += value; } }
public ComplexFloatType( final float r, final float i ) { img = null; dataAccess = new FloatArray( 2 ); set( r, i ); }
@Override public void mutate(final ArrayImg<FloatType, FloatArray> arg) { final float[] data = arg.update(null).getCurrentStorageArray(); for (int i = 0; i < data.length; i++) { data[i] *= value; } }
/** * Creates an {@link ArrayImg}<{@link FloatType}, {@link FloatArray}> * reusing a passed float[] array. */ final public static ArrayImg< ComplexFloatType, FloatArray > complexFloats( final float[] array, final long... dim ) { return complexFloats( new FloatArray( array ), dim ); }