________________________________________________________________________

This file is part of Logtalk <http://logtalk.org/>  

Logtalk is free software. You can redistribute it and/or modify it under
the terms of the FSF GNU General Public License 3  (plus some additional
terms per section 7).        Consult the `LICENSE.txt` file for details.
________________________________________________________________________


% start by loading the example:

| ?- {integration2d(loader)}.
...


% integrate the function "circle" using the 2d split&spawn adaptive quadrature method

?- time(quadsplit2d(1)::integrate(circle, -2, 2, -2, 2, 2, 2.5e-10, Integral)).
% 35,302,093 inferences, 19.83 CPU in 20.52 seconds (97% CPU, 1780237 Lips)
Integral = -21.3333.

?- time(quadsplit2d(4)::integrate(circle, -2, 2, -2, 2, 2, 2.5e-10, Integral)). 
% 119 inferences, 20.27 CPU in 5.57 seconds (364% CPU, 6 Lips)
Integral = -21.3333.

?- time(quadsplit2d(16)::integrate(circle, -2, 2, -2, 2, 2, 2.5e-10, Integral)).
% 383 inferences, 84.60 CPU in 13.53 seconds (625% CPU, 5 Lips)
Integral = -21.3333.


% integrate the function "circle" using the 2d recursive adaptive quadrature method

?- time(quadrec2d(1)::integrate(circle, -2, 2, -2, 2, 2, 2.5e-10, Integral)).
% 35,302,078 inferences, 19.90 CPU in 20.59 seconds (97% CPU, 1773974 Lips)
Integral = -21.3333.

?- time(quadrec2d(4)::integrate(circle, -2, 2, -2, 2, 2, 2.5e-10, Integral)).
% 229 inferences, 20.28 CPU in 5.56 seconds (365% CPU, 11 Lips)
Integral = -21.3333.

?- time(quadrec2d(16)::integrate(circle, -2, 2, -2, 2, 2, 2.5e-10, Integral)).
% 228 inferences, 21.14 CPU in 3.40 seconds (622% CPU, 11 Lips)
Integral = -21.3333.


% integrate the function "i15" using the 2d recursive adaptive quadrature method

?- time(quadrec2d(1)::integrate(i15, -2,2,-2,2, 2, 1.0e-4, Integral)).
% 4,754,844 inferences, 2.71 CPU in 2.82 seconds (96% CPU, 1754555 Lips)
Integral = 7.73592.

?- time(quadrec2d(4)::integrate(i15, -2,2,-2,2, 2, 1.0e-4, Integral)).
% 229 inferences, 2.77 CPU in 0.77 seconds (360% CPU, 83 Lips)
Integral = 7.73592.

?- time(quadrec2d(16)::integrate(i15, -2,2,-2,2, 2, 1.0e-4, Integral)).
% 229 inferences, 2.88 CPU in 0.51 seconds (562% CPU, 80 Lips)
Integral = 7.73592.


% NOTE for Testing.

% Single Threaded - All Examples using the quadrec2d object

time(quadrec2d(1)::integrate( circle, 	-2, 2, -2, 2, 3, 1e-5, Integral)).
time(quadrec2d(1)::integrate( i14,	 	-2, 2, -2, 2, 3, 1e-5, Integral)).
time(quadrec2d(1)::integrate( i15,	 	-2, 2, -2, 2, 3, 1e-5, Integral)).

time(quadrec2d(1)::integrate( bailey1, 0.0, 1.0, 0.0, 1.0, 3, 1e-5, Integral)).
time(quadrec2d(1)::integrate( bailey2, 0.0, 1.0, 0.0, 1.0, 3, 1e-5, Integral)).
time(quadrec2d(1)::integrate( bailey3, -1.0, 1.0, -1.0, 1.0, 3, 1e-5, Integral)).


% more difficult cases:

time(quadrec2d(1)::integrate( bailey4, 1.0e-6, pi, 0.0, pi,3, 1e-3, Integral)).

time(quadrec2d(1)::integrate( bailey5, 0.0, 100, 0.0, 100, 3, 1e-6, Integral)).


% Single Threaded - All Examples using the quadsplit2d object

time(quadsplit2d(1)::integrate( circle, 	-2, 2, -2, 2, 3, 1e-5, Integral)).
time(quadsplit2d(1)::integrate( i14,	 	-2, 2, -2, 2, 3, 1e-5, Integral)).
time(quadsplit2d(1)::integrate( i15,	 	-2, 2, -2, 2, 3, 1e-5, Integral)).

time(quadsplit2d(1)::integrate( bailey1, 0.0, 1.0, 0.0, 1.0, 3, 1e-5, Integral)).
time(quadsplit2d(1)::integrate( bailey2, 0.0, 1.0, 0.0, 1.0, 3, 1e-5, Integral)).
time(quadsplit2d(1)::integrate( bailey3, -1.0, 1.0, -1.0, 1.0, 3, 1e-5, Integral)).


% more difficult cases:

time(quadsplit2d(1)::integrate( bailey4, 1.0e-6, pi, 0.0, pi, 3, 1e-3, Integral)).

time(quadsplit2d(1)::integrate( bailey5, 0.0, 100, 0.0, 100, 3, 1e-6, Integral)).
