@Override
    protected Num calculate(int index) {
        // serial access can benefit from previous partial sums
        // which saves a lot of CPU work for very long barCounts
        if (previousIndex != -1 && previousIndex == index - 1) {
            return fastPath(index);
        }

        return slowPath(index);
    }
@Test
    public void calculate() {
        Indicator<Num> runningTotal = getIndicator(new ClosePriceIndicator(data), 3);
        double[] expected = new double[] { 1.0, 3.0, 6.0, 9.0, 12.0 };
        for (int i = 0; i < expected.length; i++) {
            assertNumEquals(expected[i], runningTotal.getValue(i));
        }
    }