class TimeSeriesDifferenceOperator extends Function1D<DateDoubleTimeSeries<?>, DateDoubleTimeSeries<?>> {

  @Override
  public DateDoubleTimeSeries<?> evaluate(final DateDoubleTimeSeries<?> ts) {
    Validate.notNull(ts, "time series");
    Validate.isTrue(ts.size() > _lag, "time series length must be > _lag");
    final int[] times = ts.timesArrayFast();
    final double[] values = ts.valuesArrayFast();
    final int n = times.length;
    final int[] differenceTimes = new int[n - _lag];
    final double[] differenceValues = new double[n - _lag];
    for (int i = _lag; i < n; i++) {
      differenceTimes[i - _lag] = times[i];
      differenceValues[i - _lag] = values[i] - values[i - _lag];
    }
    return ImmutableLocalDateDoubleTimeSeries.of(differenceTimes, differenceValues);
  }

  public  TimeSeriesDifferenceOperator();
  public  TimeSeriesDifferenceOperator(int lag);

}