Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. public LinkedListTabulatedFunction(double leftX, double rightX, double[] values) {
  2.         if (leftX >= rightX || values.length < 2) {
  3.             throw new IllegalArgumentException();
  4.         }
  5.         size = values.length;
  6.         double difference = (rightX - leftX) / (values.length - 1);
  7.         FunctionNode[] array = new FunctionNode[(int) (size + Math.ceil(size / 2.))];
  8.         for (int i = 0; i < size; ++i) {
  9.             array[i] = new FunctionNode(new FunctionPoint(leftX + difference * i, values[i]));
  10.         }
  11.         array[0] = new FunctionNode (array[0].point, array[size - 1], array[1]);
  12.         for (int i = 1; i < size - 1; ++i) {
  13.             array[i] = new FunctionNode(array[i].point, array[i - 1], array[i + 1]);
  14.         }
  15.         array[size - 1] = new FunctionNode(array[size - 1].point, array[size - 2], array[0]);
  16.         currentFunctionNode = array[size - 1];
  17.         currentIndex = size - 1;
  18.         head = array[0];
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement