public double innerProduct(FeatureVector other) { double result = 0.0; for (FeatureVector.Entry entry : this) { result += entry.value * other.get(entry.index); } return result; } }
public double innerProduct(FeatureVector other) { double result = 0.0; for (FeatureVector.Entry entry : other) { result += this.get(entry.index) * entry.value; } return result; }
public void add(FeatureVector other) throws InvalidFeatureVectorValueException { for (FeatureVector.Entry entry : other) { this.set(entry.index, this.get(entry.index) + entry.value); } }
public void multiply(double factor) throws InvalidFeatureVectorValueException { for (FeatureVector.Entry entry : this) { this.set(entry.index, this.get(entry.index) * factor); } }