All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.isi.nlp.DoubleAccumulator Maven / Gradle / Ivy

The newest version!
package edu.isi.nlp;

/**
 * An {@link Accumulator} for {@code double}s. This class is not thread-safe!
 *
 * 

Based on FACTORIE's {@code DoubleAccumulator}. */ public final class DoubleAccumulator implements ScalableAccumulator { private double val = 0.0; private DoubleAccumulator() {} public static DoubleAccumulator create() { return new DoubleAccumulator(); } @Override public void accumulate(final Double x) { val += x; } @Override public void accumulate(final Double data, final double factor) { val += data * factor; } @Override public void accumulate(final Accumulator accumulator) { val += accumulator.value(); } @Override public void accumulate(final Accumulator accumulator, double factor) { val += accumulator.value() * factor; } @Override public void reset() { val = 0.0; } @Override public Double value() { return val; } @Override public String toString() { return "accumulator=" + val; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy