public class BitUtil
A variety of high efficiency bit twiddling routines.
public static kotlin.Array[] ntzTable
table of number of trailing zeros in a byte
public static int pop(long x)
Returns the number of bits set in the long
public static long pop_array_to_index(kotlin.Array[] A,
int index)
public static long pop_array(kotlin.Array[] A,
int wordOffset,
int numWords)
* Returns the number of set bits in an array of longs.
public static long pop_intersect(kotlin.Array[] A,
kotlin.Array[] B,
int wordOffset,
int numWords)
Returns the popcount or cardinality of the two sets after an intersection. Neither array is modified.
public static long pop_union(kotlin.Array[] A,
kotlin.Array[] B,
int wordOffset,
int numWords)
Returns the popcount or cardinality of the union of two sets. Neither array is modified.
public static long pop_andnot(kotlin.Array[] A,
kotlin.Array[] B,
int wordOffset,
int numWords)
Returns the popcount or cardinality of A & ~B Neither array is modified.
public static long pop_xor(kotlin.Array[] A,
kotlin.Array[] B,
int wordOffset,
int numWords)
public static int ntz(long val)
Returns number of trailing zeros in a 64 bit long value.
public static int ntz(int val)
Returns number of trailing zeros in a 32 bit int value.
public static int ntz2(long x)
returns 0 based index of first set bit (only works for x!=0)
This is an alternate implementation of ntz()
public static int ntz3(long x)
returns 0 based index of first set bit
This is an alternate implementation of ntz()
public static boolean isPowerOfTwo(int v)
returns true if v is a power of two or zero
public static boolean isPowerOfTwo(long v)
returns true if v is a power of two or zero
public static int nextHighestPowerOfTwo(int v)
returns the next highest power of two, or the current value if it's already a power of two or zero
public static long nextHighestPowerOfTwo(long v)
returns the next highest power of two, or the current value if it's already a power of two or zero
public static BitSet[] transpose(BitSet[] matrix, int numDataRows, int numRows, int numColumns, ProgressListener listener)
This converts taxa optimized Bit Sets to site optimized Bit Sets and vice versa.
matrix - matrix to convertnumDataRows - number data rows (i.e. max num alleles + rare?)numRows - number rows (i.e. number taxa)numColumns - number columns (i.e. number sites)public static int bits2words(long numBits)
returns the number of 64 bit words it would take to hold numBits
public static kotlin.Array[] transpose(kotlin.Array[] orig)
Transposes 64 x 64 bit matrix. The below before and after locations. 1 2 4 2 3 4 3 1
orig - originalpublic static void printBitLong(long A)
public static java.lang.String toPadString(long A)
public static java.lang.String toPadStringLowSiteToHighSite(long A)
Returns the bits in the same order that we store them for TASSEL
A - public static void printBitMatrix(kotlin.Array[] A)
public static java.lang.String toReadableString(BitSet bitSet)