List of usage examples for org.apache.mahout.math.function DoubleDoubleFunction apply
public abstract double apply(double arg1, double arg2);
From source file:org.qcri.pca.NormalizeJob.java
static void sparseVectorAssign(Vector mainV, final Vector otherV, DoubleDoubleFunction function) { java.util.Vector<IndexValue> newZeroElements = new java.util.Vector<IndexValue>(); Iterator<Vector.Element> nonZeroElements = mainV.nonZeroes().iterator(); while (nonZeroElements.hasNext()) { Vector.Element e = nonZeroElements.next(); double res = function.apply(e.get(), otherV.getQuick(e.index())); if (res != 0) mainV.setQuick(e.index(), res); else //Don't affect the iterator newZeroElements.add(new IndexValue(e.index(), res)); }//from ww w . j a va 2s. c om for (IndexValue iv : newZeroElements) mainV.setQuick(iv.index, iv.value); }