sclass InterpolatedDoubleArray is IntSize { int[] indices; double[] values; public int size aka length() { ret empty(indices) ? 0 : last(indices)+1; } double[] toDoubleArray aka get() { int n = length(); double[] array = new[n]; for (int i = 0; i < indices.length; i++) { int iEnd = indices[i]; double value = values[i]; values[iEnd] = value; if (i > 0) { int iStart = indices[i-1]; if (iStart+1 < iEnd) { double startValue = values[i-1]; double step = (value-startValue)/(iEnd-iStart), val = startValue; for (int j = iStart+1; j < iEnd; j++) { val += step; values[j] = val; } } } } ret array; } }