Class Unsigned128BitType
- java.lang.Object
-
- net.imglib2.type.numeric.complex.AbstractComplexType<T>
-
- net.imglib2.type.numeric.real.AbstractRealType<T>
-
- net.imglib2.type.numeric.integer.AbstractIntegerType<Unsigned128BitType>
-
- net.imglib2.type.numeric.integer.Unsigned128BitType
-
- All Implemented Interfaces:
java.lang.Comparable<Unsigned128BitType>,NativeType<Unsigned128BitType>,ComplexType<Unsigned128BitType>,IntegerType<Unsigned128BitType>,NumericType<Unsigned128BitType>,RealType<Unsigned128BitType>,Add<Unsigned128BitType>,Div<Unsigned128BitType>,Mul<Unsigned128BitType>,MulFloatingPoint,Pow<Unsigned128BitType>,PowFloatingPoint,SetOne,SetZero,Sub<Unsigned128BitType>,ValueEquals<Unsigned128BitType>,Type<Unsigned128BitType>
public class Unsigned128BitType extends AbstractIntegerType<Unsigned128BitType> implements NativeType<Unsigned128BitType>
ATypewith 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 superinterfaceNumericTypeare implemented usingBigIntegerandBigDecimal. This class is notThread-safe; do acopy()first to operate on a differentThread.
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]bytesprotected LongAccessdataAccessprivate Indexiprotected NativeImg<?,? extends LongAccess>imgprivate static NativeTypeFactory<Unsigned128BitType,LongAccess>typeFactory
-
Constructor Summary
Constructors Constructor Description Unsigned128BitType()Unsigned128BitType(long lower, long upper)Unsigned128BitType(java.math.BigInteger value)Unsigned128BitType(LongAccess access)Unsigned128BitType(NativeImg<?,? extends LongAccess> bitStorage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Unsigned128BitType t)Relies onBigInteger.add(BigInteger).intcompareTo(Unsigned128BitType t)Unsigned128BitTypecopy()Unsigned128BitTypecreateVariable()Creates a newTypevariable which can only store one value.voiddec()voiddiv(Unsigned128BitType t)Relies onBigInteger.divide(BigInteger).Unsigned128BitTypeduplicateTypeOnSameNativeImg()Creates a newNativeTypewhich stores in the same physical array.booleanequals(java.lang.Object obj)java.math.BigIntegerget()java.math.BigIntegergetBigInteger()intgetBitsPerPixel()FractiongetEntitiesPerPixel()Get the number of entities in the storage array required to store one pixel value.intgetInteger()Return the lowest 32 bits, likeBigInteger.intValue().longgetIntegerLong()Return the lowest 64 bits, likeBigInteger.intValue().java.math.BigIntegergetMaxBigIntegerValue()The true maximum value, unlikegetMaxValue()which cannot represent it in adouble.doublegetMaxValue()The maximum value that can be stored isMath.pow(2, 128) -1, which cannot be represented with precision using a doubledoublegetMinValue()NativeTypeFactory<Unsigned128BitType,LongAccess>getNativeTypeFactory()doublegetRealDouble()floatgetRealFloat()inthashCode()voidinc()Indexindex()Get the (modifiable) index into the current data array.private voidintoBytes(long lower, long upper)voidmul(double c)Implemented usingBigDecimal.multiply(BigDecimal)andBigDecimal.toBigInteger().voidmul(float c)Seemul(double).voidmul(Unsigned128BitType t)Relies onBigInteger.multiply(BigInteger).voidpow(double power)voidpow(Unsigned128BitType t)voidset(byte[] bytes)The first byte is the most significant byte, like inBigInteger.toByteArray().voidset(long lower, long upper)voidset(java.math.BigInteger value)voidsetBigInteger(java.math.BigInteger b)voidsetInteger(int value)voidsetInteger(long value)voidsetOne()voidsetReal(double real)voidsetReal(float real)voidsetZero()voidsub(Unsigned128BitType t)Relies onBigInteger.subtract(BigInteger).java.lang.StringtoString()voidupdateContainer(java.lang.Object c)This method is used by an accessor (e.g., aCursor) to request an update of the current data array.booleanvalueEquals(Unsigned128BitType t)-
Methods inherited from class net.imglib2.type.numeric.integer.AbstractIntegerType
getMinIncrement
-
Methods inherited from class net.imglib2.type.numeric.real.AbstractRealType
getImaginaryDouble, getImaginaryFloat, getPhaseDouble, getPhaseFloat, getPowerDouble, getPowerFloat, set, setImaginary, setImaginary
-
Methods inherited from class net.imglib2.type.numeric.complex.AbstractComplexType
complexConjugate, setComplexNumber, setComplexNumber
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.imglib2.type.numeric.ComplexType
complexConjugate, getImaginaryDouble, getImaginaryFloat, getPhaseDouble, getPhaseFloat, getPowerDouble, getPowerFloat, setComplexNumber, setComplexNumber, setImaginary, setImaginary
-
Methods inherited from interface net.imglib2.type.NativeType
decIndex, decIndex, getIndex, incIndex, incIndex, updateIndex
-
-
-
-
Field Detail
-
i
private final Index i
-
img
protected final NativeImg<?,? extends LongAccess> img
-
bytes
protected final byte[] bytes
-
dataAccess
protected LongAccess dataAccess
-
typeFactory
private static final NativeTypeFactory<Unsigned128BitType,LongAccess> typeFactory
-
-
Constructor Detail
-
Unsigned128BitType
public Unsigned128BitType(NativeImg<?,? extends LongAccess> bitStorage)
-
Unsigned128BitType
public Unsigned128BitType(long lower, long upper)
-
Unsigned128BitType
public Unsigned128BitType(java.math.BigInteger value)
-
Unsigned128BitType
public Unsigned128BitType(LongAccess access)
-
Unsigned128BitType
public Unsigned128BitType()
-
-
Method Detail
-
updateContainer
public void updateContainer(java.lang.Object c)
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).
-
index
public Index index()
Description copied from interface:NativeTypeGet the (modifiable) index into the current data array. The returned instance will always be the same for the same Type.- Specified by:
indexin interfaceNativeType<Unsigned128BitType>
-
duplicateTypeOnSameNativeImg
public Unsigned128BitType 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
-
getNativeTypeFactory
public NativeTypeFactory<Unsigned128BitType,LongAccess> getNativeTypeFactory()
- Specified by:
getNativeTypeFactoryin interfaceNativeType<Unsigned128BitType>
-
intoBytes
private final void intoBytes(long lower, long upper)
-
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
public java.math.BigInteger get()
-
set
public void set(java.math.BigInteger value)
-
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
public java.math.BigInteger getBigInteger()
- Specified by:
getBigIntegerin interfaceIntegerType<Unsigned128BitType>
-
getRealFloat
public float getRealFloat()
- Specified by:
getRealFloatin interfaceComplexType<Unsigned128BitType>- Overrides:
getRealFloatin classAbstractIntegerType<Unsigned128BitType>
-
getRealDouble
public double getRealDouble()
- Specified by:
getRealDoublein interfaceComplexType<Unsigned128BitType>- Overrides:
getRealDoublein classAbstractIntegerType<Unsigned128BitType>
-
setInteger
public void setInteger(int value)
- Specified by:
setIntegerin interfaceIntegerType<Unsigned128BitType>
-
setInteger
public void setInteger(long value)
- Specified by:
setIntegerin interfaceIntegerType<Unsigned128BitType>
-
setBigInteger
public void setBigInteger(java.math.BigInteger b)
- Specified by:
setBigIntegerin interfaceIntegerType<Unsigned128BitType>
-
setReal
public void setReal(float real)
- Specified by:
setRealin interfaceComplexType<Unsigned128BitType>- Overrides:
setRealin classAbstractIntegerType<Unsigned128BitType>
-
setReal
public void setReal(double real)
- Specified by:
setRealin interfaceComplexType<Unsigned128BitType>- Overrides:
setRealin classAbstractIntegerType<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
public java.math.BigInteger getMaxBigIntegerValue()
The true maximum value, unlikegetMaxValue()which cannot represent it in adouble.
-
getMinValue
public double getMinValue()
- Specified by:
getMinValuein interfaceRealType<Unsigned128BitType>
-
createVariable
public Unsigned128BitType createVariable()
Description copied from interface:TypeCreates a newTypevariable which can only store one value.- Specified by:
createVariablein interfaceType<Unsigned128BitType>- Returns:
- a new
Typevariable
-
copy
public Unsigned128BitType copy()
Description copied from interface:Type- Specified by:
copyin interfaceType<Unsigned128BitType>- Returns:
- a new
Typevariable
-
getEntitiesPerPixel
public Fraction 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
public void add(Unsigned128BitType t)
Relies onBigInteger.add(BigInteger).- Specified by:
addin interfaceAdd<Unsigned128BitType>- Overrides:
addin classAbstractRealType<Unsigned128BitType>
-
sub
public void sub(Unsigned128BitType t)
Relies onBigInteger.subtract(BigInteger).- Specified by:
subin interfaceSub<Unsigned128BitType>- Overrides:
subin classAbstractRealType<Unsigned128BitType>
-
mul
public void mul(Unsigned128BitType t)
Relies onBigInteger.multiply(BigInteger).- Specified by:
mulin interfaceMul<Unsigned128BitType>- Overrides:
mulin classAbstractRealType<Unsigned128BitType>
-
div
public void div(Unsigned128BitType t)
Relies onBigInteger.divide(BigInteger).- Specified by:
divin interfaceDiv<Unsigned128BitType>- Overrides:
divin classAbstractRealType<Unsigned128BitType>
-
pow
public void pow(Unsigned128BitType t)
- Specified by:
powin interfacePow<Unsigned128BitType>- Overrides:
powin classAbstractRealType<Unsigned128BitType>
-
pow
public void pow(double power)
- Specified by:
powin interfacePowFloatingPoint- Overrides:
powin classAbstractRealType<Unsigned128BitType>
-
compareTo
public int compareTo(Unsigned128BitType t)
- Specified by:
compareToin interfacejava.lang.Comparable<Unsigned128BitType>- Overrides:
compareToin classAbstractIntegerType<Unsigned128BitType>
-
valueEquals
public boolean valueEquals(Unsigned128BitType t)
- Specified by:
valueEqualsin interfaceValueEquals<Unsigned128BitType>- Overrides:
valueEqualsin classAbstractIntegerType<Unsigned128BitType>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classAbstractIntegerType<Unsigned128BitType>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractIntegerType<Unsigned128BitType>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractIntegerType<Unsigned128BitType>
-
-