rosenbrock.plt 1.4 KB
Newer Older
Mathieu Hemery's avatar
Mathieu Hemery committed
1
2
:- use_module(rosenbrock).

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's avatar
Mathieu Hemery committed
15
16
:- begin_tests(rosenbrock).

17
test(eva_coeff_1) :-
18
  nb_setval(hdid,0.01),
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) :-
28
  nb_setval(hdid,0.01),
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,
32
  rosenbrock:eval_coeff(random,[1.5,2.5,3.5],[-1,2], 1, _R4).
33

HEMERY Mathieu's avatar
HEMERY Mathieu committed
34
35
36
test(simple_integration) :-
  command(a => b),
  command(present(a,1.0)),
37
38
39
  command(numerical_simulation(method:rsbk)),
  get_table_data(D),
  check_integration_1(D).
HEMERY Mathieu's avatar
HEMERY Mathieu committed
40

Mathieu Hemery's avatar
Mathieu Hemery committed
41
:- end_tests(rosenbrock).