/** * Apply an operator V->V to all points in this time series. * * @param operator */ public void applyLinearOperator(LinearSampledValueOperator operator) { final SortedSet<SampledValue> values = getValues(); final List<SampledValue> newValues = new ArrayList<>(values.size()); for (SampledValue value : values) { final SampledValue newValue = operator.apply(value); newValues.add(newValue); } deleteValues(); addValues(newValues); }
@Override public final void setConstant(float value) { deleteValues(); setInterpolationMode(InterpolationMode.STEPS); addValue(Long.MIN_VALUE, new FloatValue(value)); addValue(0, new FloatValue(value)); }
/** * Apply the bi-linear operator on all points of this. Second operator input * is taken from values. Store the values in this. */ public void applyBilinearOperator(BilinearSampledValueOperator operator, ReadOnlyTimeSeries values) { // final FloatTimeSeries factors = new FloatTreeTimeSeries(values); final TimeSeriesMerger merger = new TimeSeriesMerger(this, values); // calculate the new values for this. final List<SampledValue> newValues = new ArrayList<>(merger.getTimestamps().size()); for (Long t : merger.getTimestamps()) { final SampledValue v1 = this.getValueSecure(t); final SampledValue v2 = getValueSecure(values, t); final SampledValue newValue = operator.apply(v1, v2); newValues.add(newValue); } // replace values in this with new values and set interpolation mode. deleteValues(); addValues(newValues); setInterpolationMode(merger.getInterpolationMode()); }