Did you know ... | Search Documentation: |
![]() | Pack logtalk -- logtalk-3.81.0/examples/threads/integration2d/SCRIPT.txt |
This file is part of Logtalk https://logtalk.org/ SPDX-FileCopyrightText: 1998-2023 Paulo Moura <pmoura@logtalk.org> SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
% 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)
).