Class IntVec
- java.lang.Object
-
- com.actelion.research.util.datamodel.IntVec
-
-
Field Summary
Fields Modifier and Type Field Description static intLEN_INTEGER_BYTESstatic intMASK_FIRST_BYTEstatic intMASK_FOURTH_BYTEstatic intMASK_INVERSE_FIRST_BYTEstatic intMASK_INVERSE_FOURTH_BYTEstatic intMASK_INVERSE_SEC_BYTEstatic intMASK_INVERSE_THIRD_BYTEstatic intMASK_SEC_BYTEstatic intMASK_THIRD_BYTE
-
Constructor Summary
Constructors Constructor Description IntVec()IntVec(boolean[] arr)Puts an boolean array into an int array.IntVec(int size)Don't forget to calculate the hash code after setting the bits!IntVec(int[] arr)Deep copy, hash code is calculated.IntVec(int[] arr, boolean binary)If true each int contains only a 0 or a 1.IntVec(IntVec iv)Deep copy, hash code is calculated.IntVec(java.util.List<java.lang.Integer> vec)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IntVecadd(IntVec dvVec)booleanallFieldsEquals(int v)static IntVecAND(IntVec iv1, IntVec iv2)Makes an logical AND and calculates the hash code.voidcalculateHashCode()static intcalculateHashCode(IntVec iv)voidclear()intcompareTo(IntVec iv)voidcopy(IntVec ivOrigin)static doublecubicDistance(IntVec dVec1, IntVec dVec2)static IntVecdevide(IntVec iv1, IntVec iv2)booleanequal(IntVec iv)booleanequals(java.lang.Object o)static int[]extractForGivenResolution(IntVec iv, int nValues, int bitsResolution)Converts the IntVec into an array.int[]get()intget(int col)intgetBitsSet()int[]getBitWise()intgetByte(int indexBytes)static intgetByte(int[] data, int indexBytes)byte[]getByteVec()static byte[]getByteVec(int intVal)static byte[]getByteVec(int[] a)int[]getByteWise()static doublegetCosine(IntVec iv1, IntVec iv2)static doublegetEuclidDist(IntVec iv1, IntVec iv2)Euclidean distancestatic doublegetEuclidDistBitWise(IntVec iv1, IntVec iv2)static doublegetEuclidDistFast(IntVec dVec1, IntVec dVec2)Euclidean distance without sqrtjava.util.List<java.lang.Integer>getIndicesBitsSet()static intgetInt(byte[] arr)doublegetNorm()static intgetNumberAbove(int[] a, int val)static intgetOverlap(IntVec iv1, IntVec iv2)static int[]getRND(int size)static doublegetScoreFracBitsCommonQuery(IntVec query, IntVec base)(sum bits set common) / (sum bits set in query)static doublegetScoreFracBitsInCommonBitWise(IntVec v1, IntVec v2)(sum bits set common) / (sum bits set in both)static doublegetScoreQueryInBase(IntVec query, IntVec base)static doublegetScoreQueryInBaseBitWise(int[] query, int[] base)(sum bits set only in query) / (sum bits set in query)static doublegetScoreQueryInBaseBitWise(IntVec query, IntVec base)static doublegetScoreQueryInBaseByteWise(IntVec query, IntVec base)static doublegetSimilarityBytewiseOverlap(int[] a1, int[] a2)static intgetSizeForBits(int bits)static doublegetTanimotoDist(IntVec iv1, IntVec iv2)Calculates the Inverse Tanimoto coefficientstatic doublegetTanimotoDistBitWise(int[] arr1, int[] arr2)static doublegetTanimotoDistBitWise(IntVec iv1, IntVec iv2)Calculates the Tanimoto coefficientstatic doublegetTanimotoDistInv(IntVec iv1, IntVec iv2)static doublegetTanimotoDistInvBitWise(int[] arr1, int[] arr2)static doublegetTanimotoDistInvBitWise(IntVec iv1, IntVec iv2)Calculates the Inverse Tanimoto coefficientstatic doublegetTanimotoDistInvByteWise(int[] iv1, int[] iv2)static doublegetTanimotoDistInvByteWise(IntVec iv1, IntVec iv2)inthashCode()static voidincrementByte(int[] data, int i)booleanisBitSet(int i)static booleanisBitSet(int[] a, int i)static booleanisBitSet(int val, int index)booleanisValidBitIndex(int i)static doublemanhattanBlockDistance(IntVec iv1, IntVec iv2)static IntVecmaskByteWise(IntVec mask, IntVec query)static IntVecminus(IntVec dVec1, IntVec dVec2)IntVecmult(double factor)static doublemult(IntVec iv1, IntVec iv2)static doublemultByteWise(int[] iv1, int[] iv2)static doublemultByteWise(IntVec iv1, IntVec iv2)static IntVecmultEl(IntVec iv1, IntVec iv2)Elementwise multiplicationvoidnorm2One()static IntVecOR(IntVec iv1, IntVec iv2)Makes an logical OR and calculates the hash code.static IntVecOR(java.util.List<IntVec> li)Makes an logical OR and calculates the hash code.static IntVecplus(IntVec dVec1, IntVec dVec2)static IntVec[]read(java.io.File file)static IntVecread(java.io.InputStream s)voidread(java.lang.String s)static java.util.List<IntVec>readBitStringDense(java.io.File fi)static IntVecreadBitStringDense(java.lang.String s)voidreduce(java.util.List<java.lang.Integer> liIndices)Removes all values with no corresponding index in the list.voidresize(int newlen)voidset(int val)Don't forget to set the hash code!voidset(int col, int val)Don't forget to set the hash code!voidset(IntVec v)Don't forget to set the hash code!voidsetBit(int i)Counts from the left to the right Don't forget to set the hash code!static voidsetBit(int[] data, int i)voidsetBits(int iStart, int num)static voidsetByte(int[] data, int i, int val)voidsetByte(int i, int val)Counts from the left to the right Don't forget to set the hash code!static voidsetBytes(int[] data, int val)voidsetBytes(int iStart, int num, int val)voidsetRNDvalue(double dRange)voidsetRNDvalue(double dCenter, double dRange)intsize()intsizeBits()intsizeBytes()IntVecsub(IntVec dvSub)Substractionstatic IntVecsubtractByteWise(IntVec iv1, IntVec iv2)voidswitchBit(int i)int[]toArray()double[]toDoubleBitWise()int[]toIntByteWise()java.lang.StringtoString()java.lang.StringtoString(int iNumDigits)java.lang.StringtoStringBinary()static java.lang.StringtoStringBinary(int v)static java.lang.StringtoStringBinary(int v, boolean space)java.lang.StringtoStringBinaryDense()java.lang.StringtoStringBytes()java.lang.StringtoStringHex()voidunsetBit(int i)Don't forget to set the hash code!java.lang.Stringwrite2String()static voidwriteBitStringDense(java.io.File fi, java.util.List<IntVec> li)
-
-
-
Field Detail
-
LEN_INTEGER_BYTES
public static final int LEN_INTEGER_BYTES
- See Also:
- Constant Field Values
-
MASK_FIRST_BYTE
public static final int MASK_FIRST_BYTE
- See Also:
- Constant Field Values
-
MASK_SEC_BYTE
public static final int MASK_SEC_BYTE
- See Also:
- Constant Field Values
-
MASK_THIRD_BYTE
public static final int MASK_THIRD_BYTE
- See Also:
- Constant Field Values
-
MASK_FOURTH_BYTE
public static final int MASK_FOURTH_BYTE
- See Also:
- Constant Field Values
-
MASK_INVERSE_FIRST_BYTE
public static final int MASK_INVERSE_FIRST_BYTE
- See Also:
- Constant Field Values
-
MASK_INVERSE_SEC_BYTE
public static final int MASK_INVERSE_SEC_BYTE
- See Also:
- Constant Field Values
-
MASK_INVERSE_THIRD_BYTE
public static final int MASK_INVERSE_THIRD_BYTE
- See Also:
- Constant Field Values
-
MASK_INVERSE_FOURTH_BYTE
public static final int MASK_INVERSE_FOURTH_BYTE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IntVec
public IntVec()
-
IntVec
public IntVec(IntVec iv)
Deep copy, hash code is calculated.- Parameters:
iv-
-
IntVec
public IntVec(int size)
Don't forget to calculate the hash code after setting the bits!- Parameters:
size-
-
IntVec
public IntVec(int[] arr)
Deep copy, hash code is calculated.- Parameters:
arr-
-
IntVec
public IntVec(int[] arr, boolean binary)If true each int contains only a 0 or a 1. The binary information is summarized by factor 32 (Integer.size).- Parameters:
arr-binary-- Throws:
java.lang.Exception
-
IntVec
public IntVec(boolean[] arr)
Puts an boolean array into an int array.- Parameters:
arr-- Throws:
java.lang.Exception
-
IntVec
public IntVec(java.util.List<java.lang.Integer> vec)
-
-
Method Detail
-
copy
public void copy(IntVec ivOrigin)
-
clear
public void clear()
-
compareTo
public int compareTo(IntVec iv)
- Specified by:
compareToin interfacejava.lang.Comparable<IntVec>- Parameters:
iv- IntVec- Returns:
- -1 if the first different value is smaller than the corresponding value in dv. 0 if bot vectors are equal. 1 if the first different value is bigger than the corresponding value in dv.
-
equal
public boolean equal(IntVec iv)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
getEuclidDist
public static double getEuclidDist(IntVec iv1, IntVec iv2)
Euclidean distance- Parameters:
iv1-iv2-- Returns:
-
getEuclidDistFast
public static double getEuclidDistFast(IntVec dVec1, IntVec dVec2) throws java.lang.ArrayIndexOutOfBoundsException
Euclidean distance without sqrt- Parameters:
dVec1-dVec2-- Returns:
- Throws:
java.lang.ArrayIndexOutOfBoundsException
-
OR
public static IntVec OR(IntVec iv1, IntVec iv2)
Makes an logical OR and calculates the hash code.- Returns:
-
OR
public static IntVec OR(java.util.List<IntVec> li)
Makes an logical OR and calculates the hash code.- Parameters:
li-- Returns:
-
AND
public static IntVec AND(IntVec iv1, IntVec iv2)
Makes an logical AND and calculates the hash code.- Parameters:
iv1-iv2-- Returns:
-
getRND
public static int[] getRND(int size)
-
get
public int[] get()
-
getByte
public int getByte(int indexBytes)
-
getByte
public static int getByte(int[] data, int indexBytes)
-
getByteVec
public byte[] getByteVec()
-
getByteVec
public static byte[] getByteVec(int intVal)
-
getByteVec
public static byte[] getByteVec(int[] a)
-
getSizeForBits
public static int getSizeForBits(int bits)
-
getNumberAbove
public static int getNumberAbove(int[] a, int val)
-
getInt
public static int getInt(byte[] arr)
-
getBitsSet
public int getBitsSet()
-
getByteWise
public int[] getByteWise()
-
getBitWise
public int[] getBitWise()
-
extractForGivenResolution
public static int[] extractForGivenResolution(IntVec iv, int nValues, int bitsResolution)
Converts the IntVec into an array. Each field in the array contains a value that was derived with the given resolution from IntVec.- Parameters:
iv-nValues- so many values are encoded in IntVec.bitsResolution- So many bits were used to encode a single value.- Returns:
-
allFieldsEquals
public boolean allFieldsEquals(int v)
-
get
public int get(int col)
-
getNorm
public double getNorm()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
calculateHashCode
public void calculateHashCode()
-
getCosine
public static double getCosine(IntVec iv1, IntVec iv2)
- Parameters:
iv1- normed vector1iv2- normed vector2- Returns:
- Cosine
-
calculateHashCode
public static int calculateHashCode(IntVec iv)
-
readBitStringDense
public static IntVec readBitStringDense(java.lang.String s)
-
mult
public IntVec mult(double factor)
-
multByteWise
public static double multByteWise(int[] iv1, int[] iv2)
-
getSimilarityBytewiseOverlap
public static double getSimilarityBytewiseOverlap(int[] a1, int[] a2)
-
multEl
public static IntVec multEl(IntVec iv1, IntVec iv2)
Elementwise multiplication- Parameters:
iv1- input vectoriv2- input vector- Returns:
- IntVec
-
norm2One
public void norm2One()
-
read
public void read(java.lang.String s)
-
read
public static IntVec[] read(java.io.File file)
-
reduce
public void reduce(java.util.List<java.lang.Integer> liIndices)
Removes all values with no corresponding index in the list.- Parameters:
liIndices- list with indices for values that will be kept.
-
resize
public void resize(int newlen)
-
set
public void set(int val)
Don't forget to set the hash code!- Parameters:
val-
-
set
public void set(IntVec v)
Don't forget to set the hash code!- Parameters:
v-
-
set
public void set(int col, int val)Don't forget to set the hash code!- Parameters:
col-val-
-
setBit
public void setBit(int i)
Counts from the left to the right Don't forget to set the hash code!- Parameters:
i- index bit
-
unsetBit
public void unsetBit(int i)
Don't forget to set the hash code!- Parameters:
i-
-
isValidBitIndex
public boolean isValidBitIndex(int i)
-
setByte
public void setByte(int i, int val)Counts from the left to the right Don't forget to set the hash code!- Parameters:
i- index byteval- value
-
setBytes
public static void setBytes(int[] data, int val)
-
setByte
public static void setByte(int[] data, int i, int val)
-
getIndicesBitsSet
public java.util.List<java.lang.Integer> getIndicesBitsSet()
-
isBitSet
public boolean isBitSet(int i)
-
switchBit
public void switchBit(int i)
-
setBits
public void setBits(int iStart, int num)
-
setBytes
public void setBytes(int iStart, int num, int val)
-
setRNDvalue
public void setRNDvalue(double dCenter, double dRange)
-
size
public int size()
-
sizeBits
public int sizeBits()
-
sizeBytes
public int sizeBytes()
-
setRNDvalue
public void setRNDvalue(double dRange)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toStringHex
public java.lang.String toStringHex()
-
toStringBinary
public java.lang.String toStringBinary()
-
toStringBinaryDense
public java.lang.String toStringBinaryDense()
-
toStringBytes
public java.lang.String toStringBytes()
-
toDoubleBitWise
public double[] toDoubleBitWise()
-
toIntByteWise
public int[] toIntByteWise()
-
toString
public java.lang.String toString(int iNumDigits)
- Parameters:
iNumDigits- number of decimal places- Returns:
- String with doubles in 0.0 notation 16.10.2003 MvK
-
write2String
public java.lang.String write2String() throws java.io.IOException- Throws:
java.io.IOException
-
toArray
public int[] toArray()
-
getTanimotoDistBitWise
public static double getTanimotoDistBitWise(IntVec iv1, IntVec iv2)
Calculates the Tanimoto coefficient- Parameters:
iv1- vector1iv2- vector2- Returns:
- Tanimoto: 1.0: identical bits are set. 0.0 no matching bits are set. Calculation according http://www.pnylab.com/pny/papers/nmet/nmet/ Congruent with DoubleVec
-
getTanimotoDistBitWise
public static final double getTanimotoDistBitWise(int[] arr1, int[] arr2)- Parameters:
arr1-arr2-- Returns:
- Tanimoto: 1: identical bits are set. 0 no matching bits are set.
-
getTanimotoDistInvBitWise
public static double getTanimotoDistInvBitWise(IntVec iv1, IntVec iv2)
Calculates the Inverse Tanimoto coefficient- Parameters:
iv1- vector1iv2- vector2- Returns:
- Inverse Tanimoto: 0: identical bits are set. 1 no matching bits are set. Calculation according Duda, Hart, Stork; Pattern Classification; Wiley 2001 p188.
-
getTanimotoDistInvBitWise
public static double getTanimotoDistInvBitWise(int[] arr1, int[] arr2)
-
getTanimotoDist
public static double getTanimotoDist(IntVec iv1, IntVec iv2)
Calculates the Inverse Tanimoto coefficient- Parameters:
iv1- vector1iv2- vector2- Returns:
- Tanimoto: 1: identical bits are set. 0 no matching bits are set.
-
getTanimotoDistInv
public static final double getTanimotoDistInv(IntVec iv1, IntVec iv2)
- Parameters:
iv1-iv2-- Returns:
- Inverse Tanimoto: 0: identical bits are set. 1 no matching bits are set.
-
getScoreQueryInBaseByteWise
public static double getScoreQueryInBaseByteWise(IntVec query, IntVec base)
-
getScoreQueryInBaseBitWise
public static double getScoreQueryInBaseBitWise(IntVec query, IntVec base)
-
getScoreQueryInBaseBitWise
public static double getScoreQueryInBaseBitWise(int[] query, int[] base)(sum bits set only in query) / (sum bits set in query)- Parameters:
query-base-- Returns:
-
getScoreFracBitsInCommonBitWise
public static double getScoreFracBitsInCommonBitWise(IntVec v1, IntVec v2)
(sum bits set common) / (sum bits set in both)- Returns:
-
getTanimotoDistInvByteWise
public static double getTanimotoDistInvByteWise(IntVec iv1, IntVec iv2)
- Parameters:
iv1-iv2-- Returns:
- Inverse Tanimoto: 0: identical bits are set. 1 no matching bits are set.
-
getTanimotoDistInvByteWise
public static double getTanimotoDistInvByteWise(int[] iv1, int[] iv2)- Parameters:
iv1-iv2-- Returns:
- Inverse Tanimoto: 0: identical bits are set. 1 no matching bits are set.
-
getScoreFracBitsCommonQuery
public static double getScoreFracBitsCommonQuery(IntVec query, IntVec base)
(sum bits set common) / (sum bits set in query)- Parameters:
query-base-- Returns:
-
getOverlap
public static int getOverlap(IntVec iv1, IntVec iv2)
- Parameters:
iv1-iv2-- Returns:
- number of overlapping bits.
-
incrementByte
public static void incrementByte(int[] data, int i)
-
writeBitStringDense
public static void writeBitStringDense(java.io.File fi, java.util.List<IntVec> li) throws java.io.IOException- Throws:
java.io.IOException
-
readBitStringDense
public static java.util.List<IntVec> readBitStringDense(java.io.File fi) throws java.io.IOException
- Throws:
java.io.IOException
-
read
public static IntVec read(java.io.InputStream s) throws java.io.IOException
- Throws:
java.io.IOException
-
isBitSet
public static boolean isBitSet(int[] a, int i)
-
isBitSet
public static boolean isBitSet(int val, int index)- Parameters:
val-index-- Returns:
-
setBit
public static void setBit(int[] data, int i)
-
toStringBinary
public static java.lang.String toStringBinary(int v)
-
toStringBinary
public static java.lang.String toStringBinary(int v, boolean space)
-
-