Class IntVec
- java.lang.Object
-
- com.actelion.research.util.datamodel.IntVec
-
-
Field Summary
Fields Modifier and Type Field Description static int
LEN_INTEGER_BYTES
static int
MASK_FIRST_BYTE
static int
MASK_FOURTH_BYTE
static int
MASK_INVERSE_FIRST_BYTE
static int
MASK_INVERSE_FOURTH_BYTE
static int
MASK_INVERSE_SEC_BYTE
static int
MASK_INVERSE_THIRD_BYTE
static int
MASK_SEC_BYTE
static int
MASK_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 IntVec
add(IntVec dvVec)
boolean
allFieldsEquals(int v)
static IntVec
AND(IntVec iv1, IntVec iv2)
Makes an logical AND and calculates the hash code.void
calculateHashCode()
static int
calculateHashCode(IntVec iv)
void
clear()
int
compareTo(IntVec iv)
void
copy(IntVec ivOrigin)
static double
cubicDistance(IntVec dVec1, IntVec dVec2)
static IntVec
devide(IntVec iv1, IntVec iv2)
boolean
equal(IntVec iv)
boolean
equals(java.lang.Object o)
static int[]
extractForGivenResolution(IntVec iv, int nValues, int bitsResolution)
Converts the IntVec into an array.int[]
get()
int
get(int col)
int
getBitsSet()
int[]
getBitWise()
int
getByte(int indexBytes)
static int
getByte(int[] data, int indexBytes)
byte[]
getByteVec()
static byte[]
getByteVec(int intVal)
static byte[]
getByteVec(int[] a)
int[]
getByteWise()
static double
getCosine(IntVec iv1, IntVec iv2)
static double
getEuclidDist(IntVec iv1, IntVec iv2)
Euclidean distancestatic double
getEuclidDistBitWise(IntVec iv1, IntVec iv2)
static double
getEuclidDistFast(IntVec dVec1, IntVec dVec2)
Euclidean distance without sqrtjava.util.List<java.lang.Integer>
getIndicesBitsSet()
static int
getInt(byte[] arr)
double
getNorm()
static int
getNumberAbove(int[] a, int val)
static int
getOverlap(IntVec iv1, IntVec iv2)
static int[]
getRND(int size)
static double
getScoreFracBitsCommonQuery(IntVec query, IntVec base)
(sum bits set common) / (sum bits set in query)static double
getScoreFracBitsInCommonBitWise(IntVec v1, IntVec v2)
(sum bits set common) / (sum bits set in both)static double
getScoreQueryInBase(IntVec query, IntVec base)
static double
getScoreQueryInBaseBitWise(int[] query, int[] base)
(sum bits set only in query) / (sum bits set in query)static double
getScoreQueryInBaseBitWise(IntVec query, IntVec base)
static double
getScoreQueryInBaseByteWise(IntVec query, IntVec base)
static double
getSimilarityBytewiseOverlap(int[] a1, int[] a2)
static int
getSizeForBits(int bits)
static double
getTanimotoDist(int[] a, int[] b)
static double
getTanimotoDist(IntVec iv1, IntVec iv2)
Calculates the Inverse Tanimoto coefficientstatic double
getTanimotoDistBitWise(int[] arr1, int[] arr2)
static double
getTanimotoDistBitWise(IntVec iv1, IntVec iv2)
Calculates the Tanimoto coefficientstatic double
getTanimotoDistInv(IntVec iv1, IntVec iv2)
static double
getTanimotoDistInvBitWise(int[] arr1, int[] arr2)
static double
getTanimotoDistInvBitWise(IntVec iv1, IntVec iv2)
Calculates the Inverse Tanimoto coefficientstatic double
getTanimotoDistInvByteWise(int[] iv1, int[] iv2)
static double
getTanimotoDistInvByteWise(IntVec iv1, IntVec iv2)
int
hashCode()
static void
incrementByte(int[] data, int i)
boolean
isBitSet(int i)
static boolean
isBitSet(int[] a, int i)
static boolean
isBitSet(int val, int index)
boolean
isValidBitIndex(int i)
static double
manhattanBlockDistance(IntVec iv1, IntVec iv2)
static IntVec
maskByteWise(IntVec mask, IntVec query)
static IntVec
minus(IntVec dVec1, IntVec dVec2)
IntVec
mult(double factor)
static double
mult(int[] a, int[] b)
static double
mult(IntVec iv1, IntVec iv2)
static double
multByteWise(int[] iv1, int[] iv2)
static double
multByteWise(IntVec iv1, IntVec iv2)
static IntVec
multEl(IntVec iv1, IntVec iv2)
Elementwise multiplicationvoid
norm2One()
static IntVec
OR(IntVec iv1, IntVec iv2)
Makes an logical OR and calculates the hash code.static IntVec
OR(java.util.List<IntVec> li)
Makes an logical OR and calculates the hash code.static IntVec
plus(IntVec dVec1, IntVec dVec2)
static IntVec[]
read(java.io.File file)
static IntVec
read(java.io.InputStream s)
void
read(java.lang.String s)
static java.util.List<IntVec>
readBitStringDense(java.io.File fi)
static IntVec
readBitStringDense(java.lang.String s)
void
reduce(java.util.List<java.lang.Integer> liIndices)
Removes all values with no corresponding index in the list.void
resize(int newlen)
void
set(int val)
Don't forget to set the hash code!void
set(int col, int val)
Don't forget to set the hash code!void
set(IntVec v)
Don't forget to set the hash code!void
setBit(int i)
Counts from the left to the right Don't forget to set the hash code!static void
setBit(int[] data, int i)
void
setBits(int iStart, int num)
static void
setByte(int[] data, int i, int val)
void
setByte(int i, int val)
Counts from the left to the right Don't forget to set the hash code!static void
setBytes(int[] data, int val)
void
setBytes(int iStart, int num, int val)
void
setRNDvalue(double dRange)
void
setRNDvalue(double dCenter, double dRange)
int
size()
int
sizeBits()
int
sizeBytes()
IntVec
sub(IntVec dvSub)
Substractionstatic IntVec
subtractByteWise(IntVec iv1, IntVec iv2)
void
switchBit(int i)
int[]
toArray()
double[]
toDoubleBitWise()
int[]
toIntByteWise()
java.lang.String
toString()
java.lang.String
toString(int iNumDigits)
java.lang.String
toStringBinary()
static java.lang.String
toStringBinary(int v)
static java.lang.String
toStringBinary(int v, boolean space)
java.lang.String
toStringBinaryDense()
java.lang.String
toStringBytes()
java.lang.String
toStringHex()
void
unsetBit(int i)
Don't forget to set the hash code!java.lang.String
write2String()
static void
writeBitStringDense(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:
compareTo
in 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:
equals
in 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:
hashCode
in 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)
-
mult
public static double mult(int[] a, int[] b)
-
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:
toString
in 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.
-
getTanimotoDist
public static double getTanimotoDist(int[] a, int[] b)
-
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)
-
-