Package net.imglib2.type.numeric.integer
Class UnsignedVariableBitLengthType
- java.lang.Object
-
- net.imglib2.type.AbstractBitType<T>
-
- net.imglib2.type.AbstractBit64Type<UnsignedVariableBitLengthType>
-
- net.imglib2.type.numeric.integer.UnsignedVariableBitLengthType
-
- All Implemented Interfaces:
java.lang.Comparable<UnsignedVariableBitLengthType>
,NativeType<UnsignedVariableBitLengthType>
,ComplexType<UnsignedVariableBitLengthType>
,IntegerType<UnsignedVariableBitLengthType>
,NumericType<UnsignedVariableBitLengthType>
,RealType<UnsignedVariableBitLengthType>
,Add<UnsignedVariableBitLengthType>
,Div<UnsignedVariableBitLengthType>
,Mul<UnsignedVariableBitLengthType>
,MulFloatingPoint
,SetOne
,SetZero
,Sub<UnsignedVariableBitLengthType>
,ValueEquals<UnsignedVariableBitLengthType>
,Type<UnsignedVariableBitLengthType>
public class UnsignedVariableBitLengthType extends AbstractBit64Type<UnsignedVariableBitLengthType> implements IntegerType<UnsignedVariableBitLengthType>
AType
with arbitrary bit depth up to maximum 64 bits. The behavior beyond 64 bits is undefined. The performance of this type is traded off for the gain in memory storage. Theset(long)
operation takes have the time as theget()
operation. The performance may degrade very slightly with increasing bit depth, but the decrease is barely noticeable.- Author:
- Albert Cardona, Stephan Preibisch
-
-
Field Summary
-
Fields inherited from class net.imglib2.type.AbstractBitType
dataAccess, i, img, nBits
-
-
Constructor Summary
Constructors Constructor Description UnsignedVariableBitLengthType(int nBits)
UnsignedVariableBitLengthType(long value, int nBits)
UnsignedVariableBitLengthType(LongAccess access, int nBits)
UnsignedVariableBitLengthType(NativeImg<?,? extends LongAccess> bitStorage, int nBits)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(UnsignedVariableBitLengthType t)
int
compareTo(UnsignedVariableBitLengthType t)
void
complexConjugate()
UnsignedVariableBitLengthType
copy()
NativeImg<UnsignedVariableBitLengthType,? extends LongAccess>
createSuitableNativeImg(NativeImgFactory<UnsignedVariableBitLengthType> storageFactory, long[] dim)
TheNativeType
creates theNativeImg
used for storing image data; based on the given storage strategy and its size.UnsignedVariableBitLengthType
createVariable()
Creates a newType
variable which can only store one value.void
dec()
void
div(UnsignedVariableBitLengthType t)
UnsignedVariableBitLengthType
duplicateTypeOnSameNativeImg()
Creates a newNativeType
which stores in the same physical array.long
get()
java.math.BigInteger
getBigInteger()
int
getBitsPerPixel()
double
getImaginaryDouble()
float
getImaginaryFloat()
int
getInteger()
long
getIntegerLong()
double
getMaxValue()
The maximum value that can be stored isMath.pow(2, nBits) -1
.double
getMinIncrement()
double
getMinValue()
double
getPhaseDouble()
float
getPhaseFloat()
double
getPowerDouble()
float
getPowerFloat()
double
getRealDouble()
float
getRealFloat()
void
inc()
void
mul(double c)
void
mul(float c)
void
mul(UnsignedVariableBitLengthType t)
void
set(long value)
void
set(UnsignedVariableBitLengthType c)
Sets the value of anotherType
.void
setBigInteger(java.math.BigInteger b)
void
setComplexNumber(double r, double i)
void
setComplexNumber(float r, float i)
void
setImaginary(double complex)
void
setImaginary(float complex)
void
setInteger(int f)
void
setInteger(long f)
void
setOne()
void
setReal(double real)
void
setReal(float real)
void
setZero()
void
sub(UnsignedVariableBitLengthType t)
java.lang.String
toString()
boolean
valueEquals(UnsignedVariableBitLengthType t)
Default test at long precision.-
Methods inherited from class net.imglib2.type.AbstractBit64Type
getBits, setBits
-
Methods inherited from class net.imglib2.type.AbstractBitType
decIndex, decIndex, getEntitiesPerPixel, getIndex, incIndex, incIndex, updateContainer, updateIndex
-
-
-
-
Constructor Detail
-
UnsignedVariableBitLengthType
public UnsignedVariableBitLengthType(NativeImg<?,? extends LongAccess> bitStorage, int nBits)
-
UnsignedVariableBitLengthType
public UnsignedVariableBitLengthType(long value, int nBits)
-
UnsignedVariableBitLengthType
public UnsignedVariableBitLengthType(LongAccess access, int nBits)
-
UnsignedVariableBitLengthType
public UnsignedVariableBitLengthType(int nBits)
-
-
Method Detail
-
createSuitableNativeImg
public NativeImg<UnsignedVariableBitLengthType,? extends LongAccess> createSuitableNativeImg(NativeImgFactory<UnsignedVariableBitLengthType> storageFactory, long[] dim)
Description copied from interface:NativeType
TheNativeType
creates theNativeImg
used 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:
createSuitableNativeImg
in interfaceNativeType<UnsignedVariableBitLengthType>
- Parameters:
storageFactory
- which storage strategy is useddim
- the dimensions- Returns:
- the instantiated
NativeImg
where only theType
knows the BasicType it contains.
-
set
public void set(long value)
-
get
public long get()
-
set
public void set(UnsignedVariableBitLengthType c)
Description copied from interface:Type
Sets the value of anotherType
.- Specified by:
set
in interfaceType<UnsignedVariableBitLengthType>
- Parameters:
c
- the new value
-
duplicateTypeOnSameNativeImg
public UnsignedVariableBitLengthType duplicateTypeOnSameNativeImg()
Description copied from interface:NativeType
Creates a newNativeType
which stores in the same physical array. This is only used internally.- Specified by:
duplicateTypeOnSameNativeImg
in interfaceNativeType<UnsignedVariableBitLengthType>
- Returns:
- a new
NativeType
instance working on the sameNativeImg
-
createVariable
public UnsignedVariableBitLengthType createVariable()
Description copied from interface:Type
Creates a newType
variable which can only store one value.- Specified by:
createVariable
in interfaceType<UnsignedVariableBitLengthType>
- Returns:
- a new
Type
variable
-
copy
public UnsignedVariableBitLengthType copy()
Description copied from interface:Type
- Specified by:
copy
in interfaceType<UnsignedVariableBitLengthType>
- Returns:
- a new
Type
variable
-
div
public void div(UnsignedVariableBitLengthType t)
- Specified by:
div
in interfaceDiv<UnsignedVariableBitLengthType>
- See Also:
UnsignedLongType.divide(long, long)
-
compareTo
public int compareTo(UnsignedVariableBitLengthType t)
- Specified by:
compareTo
in interfacejava.lang.Comparable<UnsignedVariableBitLengthType>
- See Also:
UnsignedLongType.compare(long, long)
-
mul
public void mul(float c)
- Specified by:
mul
in interfaceMulFloatingPoint
-
mul
public void mul(double c)
- Specified by:
mul
in interfaceMulFloatingPoint
-
getRealFloat
public float getRealFloat()
- Specified by:
getRealFloat
in interfaceComplexType<UnsignedVariableBitLengthType>
-
getRealDouble
public double getRealDouble()
- Specified by:
getRealDouble
in interfaceComplexType<UnsignedVariableBitLengthType>
-
setReal
public void setReal(float real)
- Specified by:
setReal
in interfaceComplexType<UnsignedVariableBitLengthType>
-
setReal
public void setReal(double real)
- Specified by:
setReal
in interfaceComplexType<UnsignedVariableBitLengthType>
-
getBitsPerPixel
public int getBitsPerPixel()
- Specified by:
getBitsPerPixel
in interfaceRealType<UnsignedVariableBitLengthType>
-
getMinIncrement
public double getMinIncrement()
- Specified by:
getMinIncrement
in interfaceRealType<UnsignedVariableBitLengthType>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getInteger
public int getInteger()
- Specified by:
getInteger
in interfaceIntegerType<UnsignedVariableBitLengthType>
-
getIntegerLong
public long getIntegerLong()
- Specified by:
getIntegerLong
in interfaceIntegerType<UnsignedVariableBitLengthType>
-
getBigInteger
public java.math.BigInteger getBigInteger()
- Specified by:
getBigInteger
in interfaceIntegerType<UnsignedVariableBitLengthType>
-
setInteger
public void setInteger(int f)
- Specified by:
setInteger
in interfaceIntegerType<UnsignedVariableBitLengthType>
-
setInteger
public void setInteger(long f)
- Specified by:
setInteger
in interfaceIntegerType<UnsignedVariableBitLengthType>
-
setBigInteger
public void setBigInteger(java.math.BigInteger b)
- Specified by:
setBigInteger
in interfaceIntegerType<UnsignedVariableBitLengthType>
-
getMaxValue
public double getMaxValue()
The maximum value that can be stored isMath.pow(2, nBits) -1
.- Specified by:
getMaxValue
in interfaceRealType<UnsignedVariableBitLengthType>
-
getMinValue
public double getMinValue()
- Specified by:
getMinValue
in interfaceRealType<UnsignedVariableBitLengthType>
-
inc
public void inc()
- Specified by:
inc
in interfaceRealType<UnsignedVariableBitLengthType>
-
dec
public void dec()
- Specified by:
dec
in interfaceRealType<UnsignedVariableBitLengthType>
-
add
public void add(UnsignedVariableBitLengthType t)
- Specified by:
add
in interfaceAdd<UnsignedVariableBitLengthType>
-
sub
public void sub(UnsignedVariableBitLengthType t)
- Specified by:
sub
in interfaceSub<UnsignedVariableBitLengthType>
-
mul
public void mul(UnsignedVariableBitLengthType t)
- Specified by:
mul
in interfaceMul<UnsignedVariableBitLengthType>
-
getImaginaryFloat
public float getImaginaryFloat()
- Specified by:
getImaginaryFloat
in interfaceComplexType<UnsignedVariableBitLengthType>
-
getImaginaryDouble
public double getImaginaryDouble()
- Specified by:
getImaginaryDouble
in interfaceComplexType<UnsignedVariableBitLengthType>
-
setImaginary
public void setImaginary(float complex)
- Specified by:
setImaginary
in interfaceComplexType<UnsignedVariableBitLengthType>
-
setImaginary
public void setImaginary(double complex)
- Specified by:
setImaginary
in interfaceComplexType<UnsignedVariableBitLengthType>
-
getPhaseFloat
public float getPhaseFloat()
- Specified by:
getPhaseFloat
in interfaceComplexType<UnsignedVariableBitLengthType>
-
getPhaseDouble
public double getPhaseDouble()
- Specified by:
getPhaseDouble
in interfaceComplexType<UnsignedVariableBitLengthType>
-
getPowerFloat
public float getPowerFloat()
- Specified by:
getPowerFloat
in interfaceComplexType<UnsignedVariableBitLengthType>
-
getPowerDouble
public double getPowerDouble()
- Specified by:
getPowerDouble
in interfaceComplexType<UnsignedVariableBitLengthType>
-
setComplexNumber
public void setComplexNumber(float r, float i)
- Specified by:
setComplexNumber
in interfaceComplexType<UnsignedVariableBitLengthType>
-
setComplexNumber
public void setComplexNumber(double r, double i)
- Specified by:
setComplexNumber
in interfaceComplexType<UnsignedVariableBitLengthType>
-
complexConjugate
public void complexConjugate()
- Specified by:
complexConjugate
in interfaceComplexType<UnsignedVariableBitLengthType>
-
valueEquals
public boolean valueEquals(UnsignedVariableBitLengthType t)
Default test at long precision. Please override for types longer than 64bit.- Specified by:
valueEquals
in interfaceValueEquals<UnsignedVariableBitLengthType>
- Parameters:
t
-- Returns:
-
-