public static class ObjectIntMultiVector.MapMultiWeightProvider extends java.lang.Object implements ObjectIntMultiVector.WeightProvider, java.io.Serializable
ObjectIntMultiVector.WeightProvider
that has a map of weights for
based on items of ObjectIntMultiVector
.
Note that the map must contain a weight for every value in the
respective ObjectIntMultiVector
.Constructor and Description |
---|
ObjectIntMultiVector.MapMultiWeightProvider(java.util.Map<java.lang.Integer,java.lang.Float> dataToWeightMap)
Creates a new weight provider with a map of weights.
|
Modifier and Type | Method and Description |
---|---|
protected float |
getWeight(java.lang.Integer value)
Returns the weight from the data weight map.
|
float |
getWeight(ObjectIntMultiVector.SortedDataIterator iterator)
Returns the weight for the item that the
iterator points to. |
double |
getWeightNorm(ObjectIntMultiVector obj)
Returns the square root of the sum of all weight squares for the given object.
|
float |
getWeightSum(ObjectIntMultiVector obj)
Returns the sum of all weights for the given object.
|
public ObjectIntMultiVector.MapMultiWeightProvider(java.util.Map<java.lang.Integer,java.lang.Float> dataToWeightMap)
ObjectIntMultiVector
.dataToWeightMap
- the map of weightsprotected float getWeight(java.lang.Integer value) throws java.lang.IllegalArgumentException
value
- the value for which to get the weightjava.lang.IllegalArgumentException
- if the map does not contain a weight for the given valuepublic float getWeight(ObjectIntMultiVector.SortedDataIterator iterator)
ObjectIntMultiVector.WeightProvider
iterator
points to.getWeight
in interface ObjectIntMultiVector.WeightProvider
iterator
- this iterator's current object weight is to be retrievedpublic float getWeightSum(ObjectIntMultiVector obj)
ObjectIntMultiVector.WeightProvider
ObjectIntMultiVector.WeightProvider.getWeight(messif.objects.impl.ObjectIntMultiVector.SortedDataIterator)
,
i.e. the returned sum is the sum of the weight retrieved by iterating over
all items from the obj.getSortedIterator()
.getWeightSum
in interface ObjectIntMultiVector.WeightProvider
obj
- the object for which the weights are givenpublic double getWeightNorm(ObjectIntMultiVector obj)
ObjectIntMultiVector.WeightProvider
ObjectIntMultiVector.WeightProvider.getWeight(messif.objects.impl.ObjectIntMultiVector.SortedDataIterator)
,
i.e. the returned number is the square root of the sum of all weight squares retrieved by iterating over
all items from the obj.getSortedIterator()
.getWeightNorm
in interface ObjectIntMultiVector.WeightProvider
obj
- the object for which the weights are given