#!/usr/bin/octave --silent

unit_init(1, {});

unit_test_equals("sin[0] == 0", ...
		 0, ...
		 divided_difference(@sin, 0));

unit_test_equals("sin[0, pi] == 0", ...
		 0, ...
		 divided_difference(@sin, [0,pi]));

unit_test_equals("sin[0, pi, 2*pi] == 0", ...
		 0, ...
		 divided_difference(@sin, [0,pi,2*pi]));

unit_test_equals("zero order divided_difference_coefficients", ...
		 [1], ...
		 divided_difference_coefficients([0]));

unit_test_equals("first order divided_difference_coefficients", ...
		 [-1, 1] / pi, ...
		 divided_difference_coefficients([0, pi]));

unit_test_equals("second order divided_difference_coefficients", ...
		 [1, -2, 1] / (2*pi^2), ...
		 divided_difference_coefficients([0, pi, 2*pi]));


unit_test_equals("1 is odd", ...
		 true, ...
		 odd(1));

unit_test_equals("1 is not even", ...
		 false, ...
		 even(1));

unit_test_equals("2 is not odd", ...
		 false, ...
		 odd(2));

unit_test_equals("2 is even", ...
		 true, ...
		 even(2));

expected_A = [1, 0, 0, 0, 0; ...
              16, -32,  16,  0,  0; ...
	      0,   16, -32,  16, 0; ...
	      0,   0,   16, -32, 16; ...
	      0,   0,   0,   0,  1];
unit_test_equals("Homework #1 problem #1 Poisson matrix is correct", ...
		 true, ...
		 expected_A == poisson_matrix(4, 0, 1));
