
public class BitVector extends AbstractNumberVector implements SparseNumberVector
long[] storage.| Modifier and Type | Class and Description |
|---|---|
static class |
BitVector.Factory
Factory for bit vectors.
|
static class |
BitVector.ShortSerializer
Serialization class for dense integer vectors with up to
Short.MAX_VALUE dimensions, by using a short for storing the
dimensionality. |
| Modifier and Type | Field and Description |
|---|---|
private long[] |
bits
Storing the bits.
|
private int |
dimensionality
Dimensionality of this bit vector.
|
static BitVector.Factory |
FACTORY
Static instance.
|
static ByteBufferSerializer<BitVector> |
SHORT_SERIALIZER
Serializer for up to 2^15-1 dimensions.
|
ATTRIBUTE_SEPARATOR| Constructor and Description |
|---|
BitVector(long[] bits,
int dimensionality)
Create a new BitVector corresponding to the specified bits and of the
specified dimensionality.
|
| Modifier and Type | Method and Description |
|---|---|
void |
andOnto(long[] v)
Combine onto v using the AND operation, i.e.
|
boolean |
booleanValue(int dimension)
Get the value of a single bit.
|
int |
cardinality()
Compute the vector cardinality (uncached!)
|
long[] |
cloneBits()
Returns a copy of the bits currently set in this BitVector.
|
boolean |
contains(long[] bitset)
Returns whether this BitVector contains all bits that are set to true in
the specified BitSet.
|
double |
doubleValue(int dimension)
Returns the value in the specified dimension as double.
|
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this BitVector.
|
Vector |
getColumnVector()
Returns a Vector representing in one column and
getDimensionality() rows the values of this BitVector as
double values. |
int |
getDimensionality()
The dimensionality of the vector space where of this FeatureVector of V is
an element.
|
Bit |
getValue(int dimension)
Deprecated.
|
int |
hammingDistance(BitVector v2)
Compute the Hamming distance of two bit vectors.
|
boolean |
intersect(BitVector v2)
Compute whether two vectors intersect.
|
int |
intersectionSize(BitVector v2)
Compute the vector intersection size.
|
int |
iter()
Iterator over non-zero features only, ascendingly.
|
int |
iterAdvance(int iter)
Advance the iterator to the next position.
|
byte |
iterByteValue(int iter)
Get the value of the iterators' current dimension.
|
int |
iterDim(int iter)
Get the dimension an iterator points to.
|
double |
iterDoubleValue(int iter)
Get the value of the iterators' current dimension.
|
float |
iterFloatValue(int iter)
Get the value of the iterators' current dimension.
|
int |
iterIntValue(int iter)
Get the value of the iterators' current dimension.
|
long |
iterLongValue(int iter)
Get the value of the iterators' current dimension.
|
short |
iterShortValue(int iter)
Get the value of the iterators' current dimension.
|
boolean |
iterValid(int iter)
Test the iterator position for validity.
|
double |
jaccardSimilarity(BitVector v2)
Compute the Jaccard similarity of two bit vectors.
|
long |
longValue(int dimension)
Returns the value in the specified dimension as long.
|
void |
orOnto(long[] v)
Combine onto v using the OR operation, i.e.
|
void |
setDimensionality(int dimensionality)
Update the vector space dimensionality.
|
String |
toString()
Returns a String representation of this BitVector.
|
int |
unionSize(BitVector v2)
Compute the vector union size.
|
void |
xorOnto(long[] v)
Combine onto v using the XOR operation, i.e.
|
byteValue, floatValue, getMax, getMin, intValue, shortValueclone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbyteValue, floatValue, intValue, shortValuegetMax, getMinpublic static final BitVector.Factory FACTORY
public static final ByteBufferSerializer<BitVector> SHORT_SERIALIZER
private final long[] bits
private int dimensionality
public BitVector(long[] bits,
int dimensionality)
bits - the bits to be set in this BitVector.dimensionality - the dimensionality of this BitVectorpublic int getDimensionality()
FeatureVectorgetDimensionality in interface FeatureVector<Number>getDimensionality in interface SpatialComparablepublic void setDimensionality(int dimensionality)
SparseNumberVectorsetDimensionality in interface SparseNumberVectordimensionality - New dimensionalitypublic boolean booleanValue(int dimension)
dimension - Bit number to gettrue when set@Deprecated public Bit getValue(int dimension)
FeatureVectorgetValue in interface FeatureVector<Number>getValue in interface NumberVectordimension - the desired dimension, where 0 ≤ dimension ≤
this.getDimensionality()-1public double doubleValue(int dimension)
NumberVectorgetValue(dim).doubleValue(), but usually this is much more
efficient due to boxing/unboxing cost.doubleValue in interface NumberVectordoubleValue in interface SparseNumberVectordimension - the desired dimension, where 0 ≤ dimension <
this.getDimensionality()public long longValue(int dimension)
NumberVectorgetValue(dim).longValue(), but usually this is much more efficient
due to boxing/unboxing cost.longValue in interface NumberVectorlongValue in interface SparseNumberVectordimension - the desired dimension, where 0 ≤ dimension <
this.getDimensionality()public int iter()
SparseNumberVectorSparseFeatureVector.iterDim(int) to get the actual dimension. In fact,
usually this will be the ith non-zero value, assuming an array
representation.
Think of this number as an iterator. For efficiency, it has a primitive
type!
Intended usage:
for (int iter = v.iter(); v.iterValid(iter); iter = v.iterAdvance(iter)) {
final int dim = v.iterDim(iter);
final double val = v.iterDoubleValue(iter);
// Do something.
}
iter in interface SparseFeatureVector<Number>iter in interface SparseNumberVectorpublic int iterAdvance(int iter)
SparseFeatureVectoriterAdvance in interface SparseFeatureVector<Number>iter - Previous iterator positionpublic boolean iterValid(int iter)
SparseFeatureVectoriterValid in interface SparseFeatureVector<Number>iter - Iterator positiontrue when it refers to a valid position.public int iterDim(int iter)
SparseFeatureVectoriterDim in interface SparseFeatureVector<Number>iter - Iterator positionpublic double iterDoubleValue(int iter)
SparseNumberVectoriterDoubleValue in interface SparseNumberVectoriter - Iteratorpublic float iterFloatValue(int iter)
SparseNumberVectoriterFloatValue in interface SparseNumberVectoriter - Iteratorpublic int iterIntValue(int iter)
SparseNumberVectoriterIntValue in interface SparseNumberVectoriter - Iteratorpublic short iterShortValue(int iter)
SparseNumberVectoriterShortValue in interface SparseNumberVectoriter - Iteratorpublic long iterLongValue(int iter)
SparseNumberVectoriterLongValue in interface SparseNumberVectoriter - Iteratorpublic byte iterByteValue(int iter)
SparseNumberVectoriterByteValue in interface SparseNumberVectoriter - Iteratorpublic Vector getColumnVector()
getDimensionality() rows the values of this BitVector as
double values.getColumnVector in interface NumberVectorgetDimensionality() rows the values of this BitVector
as double valuesNumberVector.getColumnVector()public boolean contains(long[] bitset)
bitset - the bits to inspect in this BitVectorpublic long[] cloneBits()
public int cardinality()
public double jaccardSimilarity(BitVector v2)
v2 - Second bit vectorpublic int hammingDistance(BitVector v2)
v2 - Second bit vectorpublic int intersectionSize(BitVector v2)
v2 - Second bit vectorpublic int unionSize(BitVector v2)
v2 - Second bit vectorpublic boolean intersect(BitVector v2)
v2 - Second bit vectortrue if they intersect in at least one bit.public void andOnto(long[] v)
v &= this.v - Existing bit set of same length.public void orOnto(long[] v)
v |= this.v - Existing bit set of same length.public void xorOnto(long[] v)
v ^= this.v - Existing bit set of same length.public String toString()
BitVectorLabelParser.
Returns a String representation of the FeatureVector of V as a line that is
suitable to be printed in a sequential file.toString in interface FeatureVector<Number>toString in class ObjectCopyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.