public class BitVector extends AbstractNumberVector<BitVector,Bit> implements ByteBufferSerializer<BitVector>
Modifier and Type | Field and Description |
---|---|
private BitSet |
bits
Storing the bits.
|
private int |
dimensionality
Dimensionality of this bit vector.
|
ATTRIBUTE_SEPARATOR
Constructor and Description |
---|
BitVector(Bit[] bits)
Provides a new BitVector corresponding to the bits in the given array.
|
BitVector(BitSet bits,
int dimensionality)
Provides a new BitVector corresponding to the specified bits and of the
specified dimensionality.
|
BitVector(List<Bit> bits)
Provides a new BitVector corresponding to the bits in the given list.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(BitSet 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.
|
BitVector |
fromByteBuffer(ByteBuffer buffer)
Deserialize an object from a byte buffer (e.g. disk)
|
BitSet |
getBits()
Returns a copy of the bits currently set in this BitVector.
|
int |
getByteSize(BitVector vec)
Get the size of the object in bytes.
|
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 binary vector space of which this BitVector is an
element.
|
Matrix |
getRowVector()
Returns a Matrix representing in one row and
getDimensionality() columns the values of this BitVector as
double values. |
Bit |
getValue(int dimension)
Returns the value in the specified dimension.
|
long |
longValue(int dimension)
Returns the value in the specified dimension as long.
|
BitVector |
minus(BitVector fv)
Returns a bit vector corresponding to an NXOR operation on this and the
specified bit vector.
|
BitVector |
multiplicate(double k)
Returns a bit vector equal to this bit vector, if k is not 0, a bit vector
with all components equal to zero otherwise.
|
BitVector |
negativeVector()
Returns the inverse of the bit vector.
|
BitVector |
newInstance(Bit[] values)
Creates and returns a new BitVector based on the passed values.
|
BitVector |
newInstance(double[] values)
Returns a new NumberVector of N for the given values.
|
BitVector |
newInstance(List<Bit> values)
Creates and returns a new BitVector based on the passed values.
|
BitVector |
newInstance(Vector values)
Returns a new NumberVector of N for the given values.
|
BitVector |
nullVector()
Returns a bit vector of equal dimensionality but containing 0 only.
|
BitVector |
plus(BitVector fv)
Returns a bit vector corresponding to an XOR operation on this and the
specified bit vector.
|
Bit |
scalarProduct(BitVector fv)
Provides the scalar product (inner product) of this BitVector and the given
BitVector.
|
void |
toByteBuffer(ByteBuffer buffer,
BitVector vec)
Serialize the object to a byte array (e.g. disk)
|
String |
toString()
Returns a String representation of this BitVector.
|
byteValue, floatValue, getMax, getMin, hashCode, intValue, shortValue
private BitSet bits
private int dimensionality
public BitVector(BitSet bits, int dimensionality) throws IllegalArgumentException
bits
- the bits to be set in this BitVectordimensionality
- the dimensionality of this BitVectorIllegalArgumentException
- if the specified dimensionality is to
small to match the given BitSetpublic BitVector(Bit[] bits)
bits
- an array of bits specifying the bits in this bit vectorpublic int getDimensionality()
getDimensionality
in interface FeatureVector<BitVector,Bit>
getDimensionality
in interface SpatialComparable
FeatureVector.getDimensionality()
public Bit getValue(int dimension)
getValue
in interface FeatureVector<BitVector,Bit>
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
FeatureVector.getValue(int)
public double doubleValue(int dimension)
doubleValue
in interface NumberVector<BitVector,Bit>
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
NumberVector.doubleValue(int)
public long longValue(int dimension)
longValue
in interface NumberVector<BitVector,Bit>
dimension
- the desired dimension, where 1 ≤ dimension ≤
this.getDimensionality()
NumberVector.longValue(int)
public Vector getColumnVector()
getDimensionality()
rows the values of this BitVector as
double values.getColumnVector
in interface NumberVector<BitVector,Bit>
getDimensionality()
rows the values of this BitVector
as double valuesNumberVector.getColumnVector()
public Matrix getRowVector()
getDimensionality()
columns the values of this BitVector as
double values.getRowVector
in interface NumberVector<BitVector,Bit>
getDimensionality()
columns the values of this
BitVector as double valuesNumberVector.getRowVector()
public BitVector multiplicate(double k)
multiplicate
in interface NumberVector<BitVector,Bit>
k
- used as multiplier 1 if k ≠ 0, otherwise the resulting bit
vector will have all values equal to zeropublic BitVector negativeVector()
negativeVector
in interface NumberVector<BitVector,Bit>
BitSet.flip(int,int)
public BitVector nullVector()
nullVector
in interface NumberVector<BitVector,Bit>
public BitVector plus(BitVector fv)
plus
in interface NumberVector<BitVector,Bit>
fv
- the bit vector to addpublic BitVector minus(BitVector fv)
minus
in interface NumberVector<BitVector,Bit>
fv
- the bit vector to addpublic boolean contains(BitSet bitset)
bitset
- the bits to inspect in this BitVectorpublic BitSet getBits()
public String toString()
BitVectorLabelParser
.toString
in interface FeatureVector<BitVector,Bit>
toString
in class Object
Object.toString()
public boolean equals(Object obj)
equals
in class AbstractNumberVector<BitVector,Bit>
obj
- another Objectpublic Bit scalarProduct(BitVector fv)
scalarProduct
in interface NumberVector<BitVector,Bit>
fv
- the BitVector to compute the scalar product forpublic BitVector newInstance(double[] values)
NumberVector
newInstance
in interface NumberVector<BitVector,Bit>
values
- the values of the NumberVectorpublic BitVector newInstance(Vector values)
NumberVector
newInstance
in interface NumberVector<BitVector,Bit>
values
- the values of the NumberVectorpublic BitVector newInstance(Bit[] values)
newInstance
in interface FeatureVector<BitVector,Bit>
values
- the values of the featureVectorpublic BitVector newInstance(List<Bit> values)
newInstance
in interface FeatureVector<BitVector,Bit>
values
- the values of the featureVectorpublic BitVector fromByteBuffer(ByteBuffer buffer) throws IOException
ByteBufferSerializer
fromByteBuffer
in interface ByteBufferSerializer<BitVector>
buffer
- Data array to processIOException
public void toByteBuffer(ByteBuffer buffer, BitVector vec) throws IOException
ByteBufferSerializer
toByteBuffer
in interface ByteBufferSerializer<BitVector>
buffer
- Buffer to serialize tovec
- Object to serializeIOException
public int getByteSize(BitVector vec)
ByteBufferSerializer
getByteSize
in interface ByteBufferSerializer<BitVector>
vec
- Object to serialize