net.fortytwo.flow.rdf.ranking
Class WeightedVector<T>

java.lang.Object
  extended by net.fortytwo.flow.rdf.ranking.WeightedVector<T>

public class WeightedVector<T>
extends Object

Author:
Joshua Shinavier (http://fortytwo.net)

Field Summary
protected  Map<T,WeightedValue<T>> valueToWeightedValue
           
 
Constructor Summary
  WeightedVector()
           
protected WeightedVector(Map<T,WeightedValue<T>> map)
           
  WeightedVector(WeightedVector<T> other)
           
 
Method Summary
 WeightedVector<T> add(WeightedVector<T> other)
           
 void addWeight(T v, double weight)
           
 void clear()
           
 Handler<WeightedValue<T>,Exception> createAddValueHandler()
           
 Handler<WeightedValue<T>,Exception> createSubtractValueHandler()
           
 double dotMultiplyBy(WeightedVector<T> other)
           
 double getMagnitude()
           
 double getWeight(T v)
           
 Set<T> keySet()
           
 WeightedVector<T> multiplyBy(double c)
           
 WeightedVector<T> multiplyByTransposeOf(WeightedVector<T> other)
           
 void normalize()
          Turns this vector into a unit vector (unless it is a zero vector).
 void normalizeAsDist()
          Note: assumes all non-negative weights.
 WeightedVector<T> normalized()
           
 WeightedVector<T> normalizedAsDist()
           
 WeightedVector<T> positiveClip()
          Removes each negative element from the vector.
 void setWeight(T v, double weight)
           
 int size()
           
 WeightedVector<T> subtract(WeightedVector<T> other)
           
 WeightedValue<T>[] toArray()
           
 WeightedValue<T>[] toSortedArray()
           
 Collection<WeightedValue<T>> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

valueToWeightedValue

protected Map<T,WeightedValue<T>> valueToWeightedValue
Constructor Detail

WeightedVector

public WeightedVector()

WeightedVector

public WeightedVector(WeightedVector<T> other)

WeightedVector

protected WeightedVector(Map<T,WeightedValue<T>> map)
Method Detail

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.