program main !*****************************************************************************80 ! !! MAIN is the main program for DISK01_INTEGRALS_TEST. ! ! Discussion: ! ! DISK01_INTEGRALS_TEST tests the DISK01_INTEGRALS library. ! ! Licensing: ! ! This code is distributed under the GNU LGPL license. ! ! Modified: ! ! 08 January 2014 ! ! Author: ! ! John Burkardt ! implicit none call timestamp ( ) write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'DISK01_INTEGRALS_TEST' write ( *, '(a)' ) ' FORTRAN90 version' write ( *, '(a)' ) ' Test the DISK01_INTEGRALS library.' call test01 ( ) ! ! Terminate. ! write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'DISK01_INTEGRALS_TEST' write ( *, '(a)' ) ' Normal end of execution.' write ( *, '(a)' ) ' ' call timestamp ( ) stop 0 end subroutine test01 ( ) !*****************************************************************************80 ! !! TEST01 uses DISK01_SAMPLE to compare exact and estimated monomial integrals. ! ! Licensing: ! ! This code is distributed under the GNU LGPL license. ! ! Modified: ! ! 07 January 2014 ! ! Author: ! ! John Burkardt ! implicit none integer ( kind = 4 ), parameter :: m = 2 integer ( kind = 4 ), parameter :: n = 4192 real ( kind = 8 ) disk01_area integer ( kind = 4 ) e(m) real ( kind = 8 ) error real ( kind = 8 ) exact real ( kind = 8 ) result integer ( kind = 4 ) seed integer ( kind = 4 ) test integer ( kind = 4 ), parameter :: test_num = 20 real ( kind = 8 ) value(n) real ( kind = 8 ) x(m,n) write ( *, '(a)' ) '' write ( *, '(a)' ) 'TEST01' write ( *, '(a)' ) ' Estimate monomial integrals using Monte Carlo' write ( *, '(a)' ) ' over the interior of the unit disk in 2D.' ! ! Get sample points. ! seed = 123456789 call disk01_sample ( n, seed, x ) write ( *, '(a)' ) '' write ( *, '(a,i6)' ) ' Number of sample points used is ', n ! ! Randomly choose X,Y exponents between 0 and 8. ! write ( *, '(a)' ) '' write ( *, '(a)' ) ' If any exponent is odd, the integral is zero.' write ( *, '(a)' ) ' We will restrict this test to randomly chosen even exponents.' write ( *, '(a)' ) '' write ( *, '(a)' ) ' Ex Ey MC-Estimate Exact Error' write ( *, '(a)' ) '' do test = 1, test_num call i4vec_uniform_ab ( m, 0, 4, seed, e ) e(1:m) = e(1:m) * 2 call monomial_value ( m, n, e, x, value ) result = disk01_area ( ) * sum ( value(1:n) ) & / real ( n, kind = 8 ) call disk01_monomial_integral ( e, exact ) error = abs ( result - exact ) write ( *, '(2x,i2,2x,i2,2x,g14.6,2x,g14.6,2x,e10.2)' ) & e(1:m), result, exact, error end do return end