Class Unsigned128BitType
- All Implemented Interfaces:
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>
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final byte[]protected LongAccessprivate final Indexprotected final NativeImg<?, ? extends LongAccess> private static final NativeTypeFactory<Unsigned128BitType, 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()Creates a newTypevariable which can only store one value.voiddec()voidRelies onBigInteger.divide(BigInteger).Creates a newNativeTypewhich stores in the same physical array.booleanget()intGet the number of entities in the storage array required to store one pixel value.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 doubledoubledoublefloatinthashCode()voidinc()index()Get the (modifiable) index into the current data array.private final voidintoBytes(long lower, long upper) voidmul(double c) Implemented usingBigDecimal.multiply(BigDecimal)andBigDecimal.toBigInteger().voidmul(float c) Seemul(double).voidRelies onBigInteger.multiply(BigInteger).voidpow(double power) voidvoidset(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()voidsetReal(double real) voidsetReal(float real) voidsetZero()voidRelies onBigInteger.subtract(BigInteger).toString()voidThis method is used by an accessor (e.g., aCursor) to request an update of the current data array.booleanMethods inherited from class AbstractIntegerType
getMinIncrementMethods inherited from class AbstractRealType
getImaginaryDouble, getImaginaryFloat, getPhaseDouble, getPhaseFloat, getPowerDouble, getPowerFloat, set, setImaginary, setImaginaryMethods inherited from class AbstractComplexType
complexConjugate, setComplexNumber, setComplexNumberMethods inherited from interface ComplexType
complexConjugate, getImaginaryDouble, getImaginaryFloat, getPhaseDouble, getPhaseFloat, getPowerDouble, getPowerFloat, setComplexNumber, setComplexNumber, setImaginary, setImaginaryMethods inherited from interface NativeType
decIndex, decIndex, getIndex, incIndex, incIndex, updateIndex
-
Field Details
-
i
-
img
-
bytes
protected final byte[] bytes -
dataAccess
-
typeFactory
-
-
Constructor Details
-
Unsigned128BitType
-
Unsigned128BitType
public Unsigned128BitType(long lower, long upper) -
Unsigned128BitType
-
Unsigned128BitType
-
Unsigned128BitType
public Unsigned128BitType()
-
-
Method Details
-
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).
-
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
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
- 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
-
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>
-
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
- 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
The true maximum value, unlikegetMaxValue()which cannot represent it in adouble. -
getMinValue
public double getMinValue()- Specified by:
getMinValuein interfaceRealType<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
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>
-
pow
- Specified by:
powin interfacePow<Unsigned128BitType>- Overrides:
powin classAbstractRealType<Unsigned128BitType>
-
pow
public void pow(double power) - Specified by:
powin interfacePowFloatingPoint- Overrides:
powin classAbstractRealType<Unsigned128BitType>
-
compareTo
- Specified by:
compareToin interfaceComparable<Unsigned128BitType>- Overrides:
compareToin classAbstractIntegerType<Unsigned128BitType>
-
valueEquals
- Specified by:
valueEqualsin interfaceValueEquals<Unsigned128BitType>- Overrides:
valueEqualsin classAbstractIntegerType<Unsigned128BitType>
-
equals
- Overrides:
equalsin classAbstractIntegerType<Unsigned128BitType>
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractIntegerType<Unsigned128BitType>
-
toString
- Overrides:
toStringin classAbstractIntegerType<Unsigned128BitType>
-