return result;
}
public static RyanFeatureVector getAddedVector(RyanFeatureVector fv1, RyanFeatureVector fv2, double rate) {
TIntDoubleHashMap hm = new TIntDoubleHashMap();
for (RyanFeatureVector curr = fv1; curr.next != null; curr = curr.next) {
if (curr.index >= 0) {
hm.put(curr.index, (hm.containsKey(curr.index) ? hm.get(curr.index) : 0) + curr.value);
}
}
for (RyanFeatureVector curr = fv2; curr.next != null; curr = curr.next) {
if (curr.index >= 0) {
hm.put(curr.index, (hm.containsKey(curr.index) ? hm.get(curr.index) : 0) + rate * curr.value);
}
}
RyanFeatureVector result = new RyanFeatureVector(-1, -1, null);
TIntDoubleIterator hmIter = hm.iterator();
while (hmIter.hasNext()) {
hmIter.advance();
result = new RyanFeatureVector(hmIter.key(), hmIter.value(), result);
}
return result;