:- use_module(rosenbrock). near(X, Y, Epsilon) :- Epsilon >= abs(X-Y); Error is abs(X-Y), write(Error). check_integration_1([]). check_integration_1([Head|Tail]) :- Head = row(T,A,B), Sum is A+B, near(1.0, Sum, 0.001), Value is exp(-T), near(B, Value, 0.001), check_integration_1(Tail). :- begin_tests(rosenbrock). test(eva_coeff_1) :- nb_setval(hdid,0.01), rosenbrock:eval_coeff(1*[0],[1.5,2.5,3.5],[-1,2], 1, R1), R1 =:= 1.5, rosenbrock:eval_coeff(2*[0] + p(1),[1.5,2.5,3.5],[-1,2], 1, R2), R2 =:= 5.0, rosenbrock:eval_coeff(t,[1.5,2.5,3.5],[-1,2], 1.23, R3), R3 =:= 1.23, rosenbrock:eval_coeff(2*[0] - p(0),[1.5,2.5,3.5],[-1,2], 1, R4), R4 =:=4.0, rosenbrock:eval_coeff(-p(1),[1.5,2.5,3.5],[-1,2], 1, R5), R5 =:= -2, rosenbrock:eval_coeff(25/[1],[1.5,2.5,3.5],[-1,2], 1, R6), R6 =:= 10, rosenbrock:eval_coeff([1]^p(1),[1.5,2.5,3.5],[-1,2], 1, R7), R7 =:= 6.25. test(eva_coeff_2) :- nb_setval(hdid,0.01), rosenbrock:eval_coeff(floor(1*[0]),[1.5,2.5,3.5],[-1,2], 1, R1), R1 =:= 1, rosenbrock:eval_coeff(min([0], p(1)),[1.5,2.5,3.5],[-1,2], 1, R2), R2 =:= 1.5, rosenbrock:eval_coeff(infinity,[1.5,2.5,3.5],[-1,2], 1, R3), R3 =:= inf, rosenbrock:eval_coeff(random,[1.5,2.5,3.5],[-1,2], 1, _R4). test(simple_integration) :- command(a => b), command(present(a,1.0)), command(numerical_simulation(method:rsbk)), get_table_data(D), check_integration_1(D). :- end_tests(rosenbrock).