### Question:
ListMath { public static ListDouble rescale(final ListNumber data, final double factor, final double offset) { if (factor == 1.0) return add(data, offset); return new ListDouble() { @Override public double getDouble(int index) { return factor * data.getDouble(index) + offset; } @Override public int size() { return data.size(); } }; } private  ListMath(); static ListDouble limit(final ListDouble data, final int start, final int end); static ListNumber limit(final ListNumber data, final int start, final int end); static ListLong limit(final ListLong data, final int start, final int end); static ListDouble rescale(final ListNumber data, final double factor, final double offset); static ListDouble inverseRescale(final ListNumber data, final double numerator, final double offset); static ListDouble pow(final ListNumber data, final double expon); static ListDouble pow(final double base, final ListNumber expons); static ListDouble add(final ListNumber data, final double offset); static ListDouble add(final ListNumber data1, final ListNumber data2); static ListDouble subtract(final ListNumber data1, final ListNumber data2); static ListDouble multiply(final ListNumber data1, final ListNumber data2); static ListDouble divide(final ListNumber data1, final ListNumber data2); static List<ListNumber> dft(ListNumber x, ListNumber y);  }### Answer:
@Test public void rescale1() { ArrayDouble array1 = new ArrayDouble(new double[] {0, 1, 2, 3, 4, 5}); ListDouble rescaled = ListMath.rescale(array1, 2.5, -5.0); assertThat(CollectionNumbers.doubleArrayCopyOf(rescaled), equalTo(new double[] {-5.0, -2.5, 0, 2.5, 5.0, 7.5})); }
@Test public void rescaleWithfactor1() { ArrayDouble array1 = new ArrayDouble(new double[] {0, 1, 2, 3, 4, 5}); ListDouble rescaled = ListMath.rescale(array1, 1, 1); assertThat(CollectionNumbers.doubleArrayCopyOf(rescaled), equalTo(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0})); }