Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public LinkedListTabulatedFunction(double leftX, double rightX, double[] values) {
- if (leftX >= rightX || values.length < 2) {
- throw new IllegalArgumentException();
- }
- size = values.length;
- double difference = (rightX - leftX) / (values.length - 1);
- FunctionNode[] array = new FunctionNode[(int) (size + Math.ceil(size / 2.))];
- for (int i = 0; i < size; ++i) {
- array[i] = new FunctionNode(new FunctionPoint(leftX + difference * i, values[i]));
- }
- array[0] = new FunctionNode (array[0].point, array[size - 1], array[1]);
- for (int i = 1; i < size - 1; ++i) {
- array[i] = new FunctionNode(array[i].point, array[i - 1], array[i + 1]);
- }
- array[size - 1] = new FunctionNode(array[size - 1].point, array[size - 2], array[0]);
- currentFunctionNode = array[size - 1];
- currentIndex = size - 1;
- head = array[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement