rosenbrock.plt 1.4 KB
 Mathieu Hemery committed Sep 30, 2019 1 2 ``````:- use_module(rosenbrock). `````` HEMERY Mathieu committed Oct 29, 2019 3 4 5 6 7 8 9 10 11 12 13 14 ``````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). `````` Mathieu Hemery committed Sep 30, 2019 15 16 ``````:- begin_tests(rosenbrock). `````` Mathieu Hemery committed Oct 01, 2019 17 ``````test(eva_coeff_1) :- `````` HEMERY Mathieu committed Oct 03, 2019 18 `````` nb_setval(hdid,0.01), `````` Mathieu Hemery committed Oct 01, 2019 19 20 21 22 23 24 25 26 27 `````` 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) :- `````` HEMERY Mathieu committed Oct 03, 2019 28 `````` nb_setval(hdid,0.01), `````` Mathieu Hemery committed Oct 01, 2019 29 30 31 `````` 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, `````` HEMERY Mathieu committed Oct 03, 2019 32 `````` rosenbrock:eval_coeff(random,[1.5,2.5,3.5],[-1,2], 1, _R4). `````` Mathieu Hemery committed Oct 01, 2019 33 `````` `````` HEMERY Mathieu committed Oct 03, 2019 34 35 36 ``````test(simple_integration) :- command(a => b), command(present(a,1.0)), `````` HEMERY Mathieu committed Oct 29, 2019 37 38 39 `````` command(numerical_simulation(method:rsbk)), get_table_data(D), check_integration_1(D). `````` HEMERY Mathieu committed Oct 03, 2019 40 `````` `````` Mathieu Hemery committed Sep 30, 2019 41 ``:- end_tests(rosenbrock).``