Class Unsigned128BitType
- All Implemented Interfaces:
Comparable<Unsigned128BitType>,NativeType<Unsigned128BitType>,ComplexType<Unsigned128BitType>,IntegerType<Unsigned128BitType>,NumericType<Unsigned128BitType>,RealType<Unsigned128BitType>,Add<Unsigned128BitType>,Div<Unsigned128BitType>,Mul<Unsigned128BitType>,MulFloatingPoint,SetOne,SetZero,Sub<Unsigned128BitType>,ValueEquals<Unsigned128BitType>,Type<Unsigned128BitType>
Type with a bit depth of 128.
Each value is stored in two adjacent long in an array,
with the lower long first, then the upper long.
Currently the math methods defined in the superinterface NumericType are implemented using BigInteger and BigDecimal.
This class is not Thread-safe; do a copy() first to operate on a different Thread.- Author:
- Albert Cardona
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final byte[]protected LongAccessprotected final NativeImg<?, ? extends LongAccess> -
Constructor Summary
ConstructorsConstructorDescriptionUnsigned128BitType(long lower, long upper) Unsigned128BitType(BigInteger value) Unsigned128BitType(LongAccess access) Unsigned128BitType(NativeImg<?, ? extends LongAccess> bitStorage) -
Method Summary
Modifier and TypeMethodDescriptionvoidRelies onBigInteger.add(BigInteger).intcopy()NativeImg<Unsigned128BitType, ? extends LongAccess> createSuitableNativeImg(NativeImgFactory<Unsigned128BitType> storageFactory, long[] dim) TheNativeTypecreates theNativeImgused for storing image data; based on the given storage strategy and its size.Creates a newTypevariable which can only store one value.voiddec()voiddecIndex()Decrement the index into the current data array.voiddecIndex(int decrement) Decrease the index into the current data array bydecrementsteps.voidRelies onBigInteger.divide(BigInteger).Creates a newNativeTypewhich stores in the same physical array.get()intGet the number of entities in the storage array required to store one pixel value.intgetIndex()Get the current index into the current data array.intReturn the lowest 32 bits, likeBigInteger.intValue().longReturn the lowest 64 bits, likeBigInteger.intValue().The true maximum value, unlikegetMaxValue()which cannot represent it in adouble.doubleThe maximum value that can be stored isMath.pow(2, 128) -1, which cannot be represented with precision using a doubledoublevoidinc()voidincIndex()Increment the index into the current data array.voidincIndex(int increment) Increases the index into the current data array byincrementsteps.voidmul(double c) Implemented usingBigDecimal.multiply(BigDecimal)andBigDecimal.toBigInteger().voidmul(float c) Seemul(double).voidRelies onBigInteger.multiply(BigInteger).voidset(byte[] bytes) The first byte is the most significant byte, like inBigInteger.toByteArray().voidset(long lower, long upper) voidset(BigInteger value) voidvoidsetInteger(int value) voidsetInteger(long value) voidsetOne()voidsetZero()voidRelies onBigInteger.subtract(BigInteger).voidThis method is used by an accessor (e.g., aCursor) to request an update of the current data array.voidupdateIndex(int index) Set the index into the current data array.booleanMethods inherited from class net.imglib2.type.numeric.integer.AbstractIntegerType
getMinIncrement, getRealDouble, getRealFloat, hashCode, setReal, setReal, toStringMethods inherited from class net.imglib2.type.numeric.real.AbstractRealType
equals, getImaginaryDouble, getImaginaryFloat, getPhaseDouble, getPhaseFloat, getPowerDouble, getPowerFloat, set, setImaginary, setImaginaryMethods inherited from class net.imglib2.type.numeric.complex.AbstractComplexType
complexConjugate, setComplexNumber, setComplexNumberMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.imglib2.type.numeric.ComplexType
complexConjugate, getImaginaryDouble, getImaginaryFloat, getPhaseDouble, getPhaseFloat, getPowerDouble, getPowerFloat, setComplexNumber, setComplexNumber, setImaginary, setImaginary
-
Field Details
-
img
-
bytes
protected final byte[] bytes -
dataAccess
-
-
Constructor Details
-
Unsigned128BitType
-
Unsigned128BitType
public Unsigned128BitType(long lower, long upper) -
Unsigned128BitType
-
Unsigned128BitType
-
Unsigned128BitType
public Unsigned128BitType()
-
-
Method Details
-
createSuitableNativeImg
public NativeImg<Unsigned128BitType,? extends LongAccess> createSuitableNativeImg(NativeImgFactory<Unsigned128BitType> storageFactory, long[] dim) Description copied from interface:NativeTypeTheNativeTypecreates theNativeImgused for storing image data; based on the given storage strategy and its size. It basically only decides here which BasicType it uses (float, int, byte, bit, ...) and how many entities per pixel it needs (e.g. 2 floats per pixel for a complex number). This enables the separation of containers and the basic types.- Specified by:
createSuitableNativeImgin interfaceNativeType<Unsigned128BitType>- Parameters:
storageFactory- which storage strategy is useddim- the dimensions- Returns:
- the instantiated
NativeImgwhere only theTypeknows the BasicType it contains.
-
updateContainer
Description copied from interface:NativeTypeThis method is used by an accessor (e.g., aCursor) to request an update of the current data array.As an example consider a
CellCursormoving on aCellImg. The cursor maintains aNativeTypewhich provides access to the image data. When the cursor moves from one cell to the next, the underlying data array of theNativeTypemust be switched to the data array of the new cell.To achieve this, the
CellCursorcallsupdateContainer()with itself as the argument.updateContainer()in turn will callNativeImg.update(Object)on it's container, passing along the reference to the cursor. In this example, the container would be aCellImg. While theNativeTypedoes not know about the type of the cursor, the container does.CellImgknows that it is passed aCellCursorinstance, which can be used to figure out the current cell and the underlying data array, which is then returned to theNativeType.The idea behind this concept is maybe not obvious. The
NativeTypeknows which basic type is used (float, int, byte, ...). However, it does not know how the data is stored (ArrayImg,CellImg, ...). This prevents the need for multiple implementations ofNativeType.- Specified by:
updateContainerin interfaceNativeType<Unsigned128BitType>- Parameters:
c- reference to an accessor which can be passed on to the container (which will know what to do with it).
-
duplicateTypeOnSameNativeImg
Description copied from interface:NativeTypeCreates a newNativeTypewhich stores in the same physical array. This is only used internally.- Specified by:
duplicateTypeOnSameNativeImgin interfaceNativeType<Unsigned128BitType>- Returns:
- a new
NativeTypeinstance working on the sameNativeImg
-
set
public void set(byte[] bytes) The first byte is the most significant byte, like inBigInteger.toByteArray(). Only the last 16 bytes are read, if there are more. -
get
-
set
-
set
public void set(long lower, long upper) -
getInteger
public int getInteger()Return the lowest 32 bits, likeBigInteger.intValue().- Specified by:
getIntegerin interfaceIntegerType<Unsigned128BitType>
-
getIntegerLong
public long getIntegerLong()Return the lowest 64 bits, likeBigInteger.intValue().- Specified by:
getIntegerLongin interfaceIntegerType<Unsigned128BitType>
-
getBigInteger
- Specified by:
getBigIntegerin interfaceIntegerType<Unsigned128BitType>
-
setInteger
public void setInteger(int value) - Specified by:
setIntegerin interfaceIntegerType<Unsigned128BitType>
-
setInteger
public void setInteger(long value) - Specified by:
setIntegerin interfaceIntegerType<Unsigned128BitType>
-
setBigInteger
- Specified by:
setBigIntegerin interfaceIntegerType<Unsigned128BitType>
-
getMaxValue
public double getMaxValue()The maximum value that can be stored isMath.pow(2, 128) -1, which cannot be represented with precision using a double- Specified by:
getMaxValuein interfaceRealType<Unsigned128BitType>
-
getMaxBigIntegerValue
The true maximum value, unlikegetMaxValue()which cannot represent it in adouble. -
getMinValue
public double getMinValue()- Specified by:
getMinValuein interfaceRealType<Unsigned128BitType>
-
getIndex
public int getIndex()Description copied from interface:NativeTypeGet the current index into the current data array.This is used by accessors (e.g., a
Cursor) to position theNativeTypein the container.- Specified by:
getIndexin interfaceNativeType<Unsigned128BitType>- Returns:
- the current index into the underlying data array
-
updateIndex
public void updateIndex(int index) Description copied from interface:NativeTypeSet the index into the current data array.This is used by accessors (e.g., a
Cursor) to position theNativeTypein the container.- Specified by:
updateIndexin interfaceNativeType<Unsigned128BitType>- Parameters:
index- the new array index
-
incIndex
public void incIndex()Description copied from interface:NativeTypeIncrement the index into the current data array.This is used by accessors (e.g., a
Cursor) to position theNativeTypein the container.- Specified by:
incIndexin interfaceNativeType<Unsigned128BitType>
-
incIndex
public void incIndex(int increment) Description copied from interface:NativeTypeIncreases the index into the current data array byincrementsteps.This is used by accessors (e.g., a
Cursor) to position theNativeTypein the container.- Specified by:
incIndexin interfaceNativeType<Unsigned128BitType>- Parameters:
increment- how many steps
-
decIndex
public void decIndex()Description copied from interface:NativeTypeDecrement the index into the current data array.This is used by accessors (e.g., a
Cursor) to position theNativeTypein the container.- Specified by:
decIndexin interfaceNativeType<Unsigned128BitType>
-
decIndex
public void decIndex(int decrement) Description copied from interface:NativeTypeDecrease the index into the current data array bydecrementsteps.This is used by accessors (e.g., a
Cursor) to position theNativeTypein the container.- Specified by:
decIndexin interfaceNativeType<Unsigned128BitType>- Parameters:
decrement- how many steps
-
createVariable
Description copied from interface:TypeCreates a newTypevariable which can only store one value.- Specified by:
createVariablein interfaceType<Unsigned128BitType>- Returns:
- a new
Typevariable
-
copy
Description copied from interface:Type- Specified by:
copyin interfaceType<Unsigned128BitType>- Returns:
- a new
Typevariable
-
getEntitiesPerPixel
Description copied from interface:NativeTypeGet the number of entities in the storage array required to store one pixel value. A pixel value may be spread over several or less than one entity. For example, a complex number may require 2 entries of a float[] array to store one pixel. Or a 12-bit type might need 12/64th entries of a long[] array.- Specified by:
getEntitiesPerPixelin interfaceNativeType<Unsigned128BitType>- Returns:
- the number of storage type entities required to store one pixel value.
-
getBitsPerPixel
public int getBitsPerPixel()- Specified by:
getBitsPerPixelin interfaceRealType<Unsigned128BitType>
-
inc
public void inc()- Specified by:
incin interfaceRealType<Unsigned128BitType>- Overrides:
incin classAbstractIntegerType<Unsigned128BitType>
-
dec
public void dec()- Specified by:
decin interfaceRealType<Unsigned128BitType>- Overrides:
decin classAbstractIntegerType<Unsigned128BitType>
-
setZero
public void setZero()- Specified by:
setZeroin interfaceSetZero- Overrides:
setZeroin classAbstractIntegerType<Unsigned128BitType>
-
setOne
public void setOne()- Specified by:
setOnein interfaceSetOne- Overrides:
setOnein classAbstractIntegerType<Unsigned128BitType>
-
mul
public void mul(float c) Seemul(double).- Specified by:
mulin interfaceMulFloatingPoint- Overrides:
mulin classAbstractRealType<Unsigned128BitType>
-
mul
public void mul(double c) Implemented usingBigDecimal.multiply(BigDecimal)andBigDecimal.toBigInteger().- Specified by:
mulin interfaceMulFloatingPoint- Overrides:
mulin classAbstractRealType<Unsigned128BitType>
-
add
Relies onBigInteger.add(BigInteger).- Specified by:
addin interfaceAdd<Unsigned128BitType>- Overrides:
addin classAbstractRealType<Unsigned128BitType>
-
sub
Relies onBigInteger.subtract(BigInteger).- Specified by:
subin interfaceSub<Unsigned128BitType>- Overrides:
subin classAbstractRealType<Unsigned128BitType>
-
mul
Relies onBigInteger.multiply(BigInteger).- Specified by:
mulin interfaceMul<Unsigned128BitType>- Overrides:
mulin classAbstractRealType<Unsigned128BitType>
-
div
Relies onBigInteger.divide(BigInteger).- Specified by:
divin interfaceDiv<Unsigned128BitType>- Overrides:
divin classAbstractRealType<Unsigned128BitType>
-
compareTo
- Specified by:
compareToin interfaceComparable<Unsigned128BitType>- Overrides:
compareToin classAbstractIntegerType<Unsigned128BitType>
-
valueEquals
- Specified by:
valueEqualsin interfaceValueEquals<Unsigned128BitType>
-