File weight_vector_bit.hpp¶
-
class BitWeightVector : public IWeightVector¶
- #include <weight_vector_bit.hpp>
An one-dimensional vector that provides random access to a fixed number of binary weights stored in a
BitVector
.Public Functions
-
BitWeightVector(uint32 numElements, bool init = false)¶
- Parameters:
numElements – The number of elements in the vector
init – True, if all elements in the vector should be value-initialized, false otherwise
-
uint32 getNumElements() const¶
Returns the number of elements in the vector.
- Returns:
The number of elements
-
bool operator[](uint32 pos) const¶
Returns the weight at a specific position.
- Parameters:
pos – The position
- Returns:
The weight at the specified position
-
void set(uint32 pos, bool weight)¶
Sets the weight at a specific position.
- Parameters:
pos – The position
weight – The weight to be set
-
void clear()¶
Sets all weights to zero.
-
uint32 getNumNonZeroWeights() const¶
Returns the number of non-zero weights.
- Returns:
The number of non-zero weights
-
void setNumNonZeroWeights(uint32 numNonZeroWeights)¶
Sets the number of non-zero weights.
- Parameters:
numNonZeroWeights – The number of non-zero weights to be set
-
virtual bool hasZeroWeights() const override¶
Returns whether the vector contains any zero weights or not.
- Returns:
True, if the vector contains any zero weights, false otherwise
-
virtual std::unique_ptr<IFeatureSubspace> createFeatureSubspace(IFeatureSpace &featureSpace) const override¶
Creates and returns a new instance of type
IFeatureSubspace
that uses the weights in this vector for the training examples it includes.- Parameters:
featureSpace – A reference to an object of type
IFeatureSpace
that should be used to create the instance- Returns:
An unique pointer to an object of type
IFeatureSubspace
that has been created
-
BitWeightVector(uint32 numElements, bool init = false)¶