net.fortytwo.flow.rdf.ranking
Class WeightedVector<T>
java.lang.Object
net.fortytwo.flow.rdf.ranking.WeightedVector<T>
public class WeightedVector<T>
- extends Object
- Author:
- Joshua Shinavier (http://fortytwo.net)
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
valueToWeightedValue
protected Map<T,WeightedValue<T>> valueToWeightedValue
WeightedVector
public WeightedVector()
WeightedVector
public WeightedVector(WeightedVector<T> other)
WeightedVector
protected WeightedVector(Map<T,WeightedValue<T>> map)
size
public int size()
keySet
public Set<T> keySet()
values
public Collection<WeightedValue<T>> values()
getWeight
public double getWeight(T v)
setWeight
public void setWeight(T v,
double weight)
addWeight
public void addWeight(T v,
double weight)
createAddValueHandler
public Handler<WeightedValue<T>,Exception> createAddValueHandler()
createSubtractValueHandler
public Handler<WeightedValue<T>,Exception> createSubtractValueHandler()
toArray
public WeightedValue<T>[] toArray()
- Returns:
- the vector as an unordered array of weighted values
toSortedArray
public WeightedValue<T>[] toSortedArray()
- Returns:
- the vector as an array of weighted values, sorted in order of
decreasing weight
clear
public void clear()
getMagnitude
public double getMagnitude()
- Returns:
- magnitude of this vector
multiplyBy
public WeightedVector<T> multiplyBy(double c)
- Parameters:
c -
- Returns:
- product of this vector with a constant value
add
public WeightedVector<T> add(WeightedVector<T> other)
- Parameters:
other - another vector to add to this one
- Returns:
- sum of this vector with another vector (set union)
subtract
public WeightedVector<T> subtract(WeightedVector<T> other)
- Parameters:
other - another vector to subtract from this one
- Returns:
- result of subtracting another vector from this
vector (set exclusion)
dotMultiplyBy
public double dotMultiplyBy(WeightedVector<T> other)
- Parameters:
other -
- Returns:
- dot product of this vector with another vector
multiplyByTransposeOf
public WeightedVector<T> multiplyByTransposeOf(WeightedVector<T> other)
- Parameters:
other -
- Returns:
- product of this vector with the transpose of another vector
(set intersection)
positiveClip
public WeightedVector<T> positiveClip()
- Removes each negative element from the vector.
normalize
public void normalize()
- Turns this vector into a unit vector (unless it is a zero vector).
normalized
public WeightedVector<T> normalized()
normalizeAsDist
public void normalizeAsDist()
- Note: assumes all non-negative weights.
normalizedAsDist
public WeightedVector<T> normalizedAsDist()
Copyright © 2007-2014. All Rights Reserved.