subroutine imtqlx ( n, d, e, z ) !*****************************************************************************80 ! !! imtqlx() diagonalizes a symmetric tridiagonal matrix. ! ! Discussion: ! ! This routine is a slightly modified version of the EISPACK routine to ! perform the implicit QL algorithm on a symmetric tridiagonal matrix. ! ! The authors thank the authors of EISPACK for permission to use this ! routine. ! ! It has been modified to produce the product Q' * Z, where Z is an input ! vector and Q is the orthogonal matrix diagonalizing the input matrix. ! The changes consist (essentially) of applying the orthogonal ! transformations directly to Z as they are generated. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 27 December 2009 ! ! Author: ! ! Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky. ! FORTRAN90 version by John Burkardt. ! ! Reference: ! ! Sylvan Elhay, Jaroslav Kautsky, ! Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of ! Interpolatory Quadrature, ! ACM Transactions on Mathematical Software, ! Volume 13, Number 4, December 1987, pages 399-415. ! ! Roger Martin, James Wilkinson, ! The Implicit QL Algorithm, ! Numerische Mathematik, ! Volume 12, Number 5, December 1968, pages 377-383. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the order of the matrix. ! ! Input/output, real ( kind = rk ) D(N), the diagonal entries of the matrix. ! On output, the information in D has been overwritten. ! ! Input/output, real ( kind = rk ) E(N), the subdiagonal entries of the ! matrix, in entries E(1) through E(N-1). On output, the information in ! E has been overwritten. ! ! Input/output, real ( kind = rk ) Z(N). On input, a vector. On output, ! the value of Q' * Z, where Q is the matrix that diagonalizes the ! input symmetric tridiagonal matrix. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) b real ( kind = rk ) c real ( kind = rk ) d(n) real ( kind = rk ) e(n) real ( kind = rk ) f real ( kind = rk ) g integer ( kind = 4 ) i integer ( kind = 4 ) ii integer ( kind = 4 ), parameter :: itn = 30 integer ( kind = 4 ) j integer ( kind = 4 ) k integer ( kind = 4 ) l integer ( kind = 4 ) m integer ( kind = 4 ) mml real ( kind = rk ) p real ( kind = rk ) prec real ( kind = rk ) r real ( kind = rk ) s real ( kind = rk ) z(n) prec = epsilon ( prec ) if ( n == 1 ) then return end if e(n) = 0.0D+00 do l = 1, n j = 0 do do m = l, n if ( m == n ) then exit end if if ( abs ( e(m) ) <= prec * ( abs ( d(m) ) + abs ( d(m+1) ) ) ) then exit end if end do p = d(l) if ( m == l ) then exit end if if ( itn <= j ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'IMTQLX - Fatal error!' write ( *, '(a)' ) ' Iteration limit exceeded.' write ( *, '(a,i8)' ) ' J = ', j write ( *, '(a,i8)' ) ' L = ', l write ( *, '(a,i8)' ) ' M = ', m write ( *, '(a,i8)' ) ' N = ', n stop end if j = j + 1 g = ( d(l+1) - p ) / ( 2.0D+00 * e(l) ) r = sqrt ( g * g + 1.0D+00 ) g = d(m) - p + e(l) / ( g + sign ( r, g ) ) s = 1.0D+00 c = 1.0D+00 p = 0.0D+00 mml = m - l do ii = 1, mml i = m - ii f = s * e(i) b = c * e(i) if ( abs ( g ) <= abs ( f ) ) then c = g / f r = sqrt ( c * c + 1.0D+00 ) e(i+1) = f * r s = 1.0D+00 / r c = c * s else s = f / g r = sqrt ( s * s + 1.0D+00 ) e(i+1) = g * r c = 1.0D+00 / r s = s * c end if g = d(i+1) - p r = ( d(i) - g ) * s + 2.0D+00 * c * b p = s * r d(i+1) = g + p g = c * r - b f = z(i+1) z(i+1) = s * z(i) + c * f z(i) = c * z(i) - s * f end do d(l) = d(l) - p e(l) = g e(m) = 0.0D+00 end do end do ! ! Sorting. ! do ii = 2, n i = ii - 1 k = i p = d(i) do j = ii, n if ( d(j) < p ) then k = j p = d(j) end if end do if ( k /= i ) then d(k) = d(i) d(i) = p p = z(i) z(i) = z(k) z(k) = p end if end do return end subroutine l_exponential_product ( p, b, table ) !*****************************************************************************80 ! !! L_EXPONENTIAL_PRODUCT: exponential product table for L(n,x). ! ! Discussion: ! ! Let L(n,x) represent the Laguerre polynomial of degree n. ! ! For polynomial chaos applications, it is of interest to know the ! value of the integrals of products of exp(B*X) with every possible pair ! of basis functions. That is, we'd like to form ! ! Tij = Integral ( 0 <= X < +oo ) exp(b*x) * L(i,x) * L(j,x) * exp (-x) dx ! ! Because of the exponential factor, the quadrature will not be exact. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 26 August 2013 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) P, the maximum degree of the polyonomial ! factors. 0 <= P. ! ! Input, real ( kind = rk ) B, the coefficient of X in the exponential factor. ! ! Output, real ( kind = rk ) TABLE(0:P,0:P), the table of integrals. ! TABLE(I,J) represents the weighted integral of exp(B*X) * L(i,x) * L(j,x). ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) p real ( kind = rk ) b integer ( kind = 4 ) i integer ( kind = 4 ) j integer ( kind = 4 ) k real ( kind = rk ), allocatable :: l_table(:) integer ( kind = 4 ) order real ( kind = rk ) table(0:p,0:p) real ( kind = rk ), allocatable :: w_table(:) real ( kind = rk ) x real ( kind = rk ), allocatable :: x_table(:) table(0:p,0:p) = 0.0D+00 order = ( 3 * p + 4 ) / 2 allocate ( x_table(1:order) ) allocate ( w_table(1:order) ) call l_quadrature_rule ( order, x_table, w_table ) allocate ( l_table(0:p) ) do k = 1, order x = x_table(k) call l_polynomial ( 1, p, x_table(k), l_table ) do j = 0, p do i = 0, p table(i,j) = table(i,j) & + w_table(k) * exp ( b * x ) * l_table(i) * l_table(j) end do end do end do deallocate ( l_table ) deallocate ( w_table ) deallocate ( x_table ) return end subroutine l_integral ( n, exact ) !*****************************************************************************80 ! !! L_INTEGRAL evaluates a monomial integral associated with L(n,x). ! ! Discussion: ! ! The integral: ! ! integral ( 0 <= x < +oo ) x^n * exp ( -x ) dx ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 07 March 2012 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the exponent. ! 0 <= N. ! ! Output, real ( kind = rk ) EXACT, the value of the integral. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) real ( kind = rk ) exact integer ( kind = 4 ) n real ( kind = rk ) r8_factorial exact = r8_factorial ( n ) return end subroutine l_polynomial ( m, n, x, v ) !*****************************************************************************80 ! !! L_POLYNOMIAL evaluates the Laguerre polynomial L(n,x). ! ! First terms: ! ! 1 ! -X + 1 ! ( X^2 - 4 X + 2 ) / 2 ! ( -X^3 + 9 X^2 - 18 X + 6 ) / 6 ! ( X^4 - 16 X^3 + 72 X^2 - 96 X + 24 ) / 24 ! ( -X^5 + 25 X^4 - 200 X^3 + 600 X^2 - 600 X + 120 ) / 120 ! ( X^6 - 36 X^5 + 450 X^4 - 2400 X^3 + 5400 X^2 - 4320 X + 720 ) ! / 720 ! ( -X^7 + 49 X^6 - 882 X^5 + 7350 X^4 - 29400 X^3 + 52920 X^2 - 35280 X ! + 5040 ) / 5040 ! ! Recursion: ! ! L(0,X) = 1 ! L(1,X) = 1 - X ! L(N,X) = (2*N-1-X)/N * L(N-1,X) - (N-1)/N * L(N-2,X) ! ! Orthogonality: ! ! Integral ( 0 <= X < oo ) exp ( - X ) * L(N,X) * L(M,X) dX = delta ( M, N ) ! ! Relations: ! ! L(N,X) = (-1)^N / N! * exp ( x ) * (d/dx)^n ( exp ( - x ) * x^n ) ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 07 March 2012 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Milton Abramowitz, Irene Stegun, ! Handbook of Mathematical Functions, ! National Bureau of Standards, 1964, ! ISBN: 0-486-61272-4, ! LC: QA47.A34. ! ! Parameters: ! ! Input, integer ( kind = 4 ) M, the number of evaluation points. ! ! Input, integer ( kind = 4 ) N, the highest order polynomial to compute. ! Note that polynomials 0 through N will be computed. ! ! Input, real ( kind = rk ) X(M), the evaluation points. ! ! Output, real ( kind = rk ) V(M,0:N), the function values. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) m integer ( kind = 4 ) n integer ( kind = 4 ) j real ( kind = rk ) v(m,0:n) real ( kind = rk ) x(m) if ( n < 0 ) then return end if v(1:m,0) = 1.0D+00 if ( n == 0 ) then return end if v(1:m,1) = 1.0D+00 - x(1:m) do j = 2, n v(1:m,j) = ( ( real ( 2 * j - 1, kind = rk ) - x(1:m) ) * v(1:m,j-1) & - real ( j - 1, kind = rk ) * v(1:m,j-2) ) & / real ( j, kind = rk ) end do return end subroutine l_polynomial_coefficients ( n, c ) !*****************************************************************************80 ! !! L_POLYNOMIAL_COEFFICIENTS: coefficients of the Laguerre polynomial L(n,x). ! ! First terms: ! ! 0: 1 ! 1: 1 -1 ! 2: 1 -2 1/2 ! 3: 1 -3 3/2 1/6 ! 4: 1 -4 4 -2/3 1/24 ! 5: 1 -5 5 -5/3 5/24 -1/120 ! ! Recursion: ! ! L(0) = ( 1, 0, 0, ..., 0 ) ! L(1) = ( 1, -1, 0, ..., 0 ) ! L(N) = (2*N-1-X) * L(N-1) - (N-1) * L(N-2) / N ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 01 February 2003 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Milton Abramowitz, Irene Stegun, ! Handbook of Mathematical Functions, ! National Bureau of Standards, 1964, ! ISBN: 0-486-61272-4, ! LC: QA47.A34. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the highest order polynomial to compute. ! Note that polynomials 0 through N will be computed. ! ! Output, real ( kind = rk ) C(0:N,0:N), the coefficients of the ! Laguerre polynomials of degree 0 through N. Each polynomial ! is stored as a row. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) c(0:n,0:n) integer ( kind = 4 ) i if ( n < 0 ) then return end if c(0:n,0:n) = 0.0D+00 c(0:n,0) = 1.0D+00 if ( n == 0 ) then return end if c(1,1) = -1.0D+00 do i = 2, n c(i,1:n) = ( & real ( 2 * i - 1, kind = rk ) * c(i-1,1:n) & + real ( - i + 1, kind = rk ) * c(i-2,1:n) & - c(i-1,0:n-1) ) & / real ( i, kind = rk ) end do return end subroutine l_polynomial_values ( n_data, n, x, fx ) !*****************************************************************************80 ! !! L_POLYNOMIAL_VALUES: some values of the Laguerre polynomial L(n,x). ! ! Discussion: ! ! In Mathematica, the function can be evaluated by: ! ! LaguerreL[n,x] ! ! Differential equation: ! ! X * Y'' + (1-X) * Y' + N * Y = 0 ! ! First terms: ! ! 1 ! -X + 1 ! ( X^2 - 4 X + 2 ) / 2 ! ( -X^3 + 9 X^2 - 18 X + 6 ) / 6 ! ( X^4 - 16 X^3 + 72 X^2 - 96 X + 24 ) / 24 ! ( -X^5 + 25 X^4 - 200 X^3 + 600 X^2 - 600 x + 120 ) / 120 ! ( X^6 - 36 X^5 + 450 X^4 - 2400 X^3 + 5400 X^2 - 4320 X + 720 ) / 720 ! ( -X^7 + 49 X^6 - 882 X^5 + 7350 X^4 - 29400 X^3 + 52920 X^2 - 35280 X ! + 5040 ) / 5040 ! ! Recursion: ! ! L(0,X) = 1, ! L(1,X) = 1-X, ! N * L(N,X) = (2*N-1-X) * L(N-1,X) - (N-1) * L(N-2,X) ! ! Orthogonality: ! ! Integral ( 0 <= X < oo ) exp ( - X ) * L(N,X) * L(M,X) dX ! = 0 if N /= M ! = 1 if N == M ! ! Special values: ! ! L(N,0) = 1. ! ! Relations: ! ! L(N,X) = (-1)^N / N! * exp ( x ) * (d/dx)^n ( exp ( - x ) * x^n ) ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 17 August 2004 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Milton Abramowitz, Irene Stegun, ! Handbook of Mathematical Functions, ! National Bureau of Standards, 1964, ! ISBN: 0-486-61272-4, ! LC: QA47.A34. ! ! Stephen Wolfram, ! The Mathematica Book, ! Fourth Edition, ! Cambridge University Press, 1999, ! ISBN: 0-521-64314-7, ! LC: QA76.95.W65. ! ! Parameters: ! ! Input/output, integer ( kind = 4 ) N_DATA. The user sets N_DATA to 0 ! before the first call. On each call, the routine increments N_DATA by 1, ! and returns the corresponding data; when there is no more data, the ! output value of N_DATA will be 0 again. ! ! Output, integer ( kind = 4 ) N, the order of the polynomial. ! ! Output, real ( kind = rk ) X, the point where the polynomial is evaluated. ! ! Output, real ( kind = rk ) FX, the value of the function. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ), parameter :: n_max = 17 real ( kind = rk ) fx real ( kind = rk ), save, dimension ( n_max ) :: fx_vec = (/ & 0.1000000000000000D+01, & 0.0000000000000000D+00, & -0.5000000000000000D+00, & -0.6666666666666667D+00, & -0.6250000000000000D+00, & -0.4666666666666667D+00, & -0.2569444444444444D+00, & -0.4047619047619048D-01, & 0.1539930555555556D+00, & 0.3097442680776014D+00, & 0.4189459325396825D+00, & 0.4801341790925124D+00, & 0.4962122235082305D+00, & -0.4455729166666667D+00, & 0.8500000000000000D+00, & -0.3166666666666667D+01, & 0.3433333333333333D+02 /) integer ( kind = 4 ) n integer ( kind = 4 ) n_data integer ( kind = 4 ), save, dimension ( n_max ) :: n_vec = (/ & 0, 1, 2, & 3, 4, 5, & 6, 7, 8, & 9, 10, 11, & 12, 5, 5, & 5, 5 /) real ( kind = rk ) x real ( kind = rk ), save, dimension ( n_max ) :: x_vec = (/ & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 1.0D+00, & 0.5D+00, & 3.0D+00, & 5.0D+00, & 1.0D+01 /) if ( n_data < 0 ) then n_data = 0 end if n_data = n_data + 1 if ( n_max < n_data ) then n_data = 0 n = 0 x = 0.0D+00 fx = 0.0D+00 else n = n_vec(n_data) x = x_vec(n_data) fx = fx_vec(n_data) end if return end subroutine l_polynomial_zeros ( n, x ) !*****************************************************************************80 ! !! L_POLYNOMIAL_ZEROS: zeros of the Laguerre polynomial L(n,x). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 07 March 2012 ! ! Author: ! ! Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky. ! FORTRAN90 version by John Burkardt. ! ! Reference: ! ! Sylvan Elhay, Jaroslav Kautsky, ! Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of ! Interpolatory Quadrature, ! ACM Transactions on Mathematical Software, ! Volume 13, Number 4, December 1987, pages 399-415. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the order of the polynomial. ! ! Output, real ( kind = rk ) X(N), the zeros. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) bj(n) integer ( kind = 4 ) i real ( kind = rk ) w(n) real ( kind = rk ) x(n) real ( kind = rk ) zemu ! ! Define the zero-th moment. ! zemu = 1.0D+00 ! ! Define the Jacobi matrix. ! do i = 1, n bj(i) = real ( i, kind = rk ) end do do i = 1, n x(i) = real ( 2 * i - 1, kind = rk ) end do w(1) = sqrt ( zemu ) w(2:n) = 0.0D+00 ! ! Diagonalize the Jacobi matrix. ! call imtqlx ( n, x, bj, w ) return end subroutine l_power_product ( p, e, table ) !*****************************************************************************80 ! !! L_POWER_PRODUCT: power product table for L(n,x). ! ! Discussion: ! ! Let L(n,x) represent the Laguerre polynomial of degree n. ! ! For polynomial chaos applications, it is of interest to know the ! value of the integrals of products of X^E with every possible pair ! of basis functions. That is, we'd like to form ! ! Tij = Integral ( 0 <= X < +oo ) x^e * L(i,x) * L(j,x) * exp (-x) dx ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 26 August 2013 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) P, the maximum degree of the polyonomial ! factors. 0 <= P. ! ! Input, integer ( kind = 4 ) E, the exponent of X. ! 0 <= E. ! ! Output, real ( kind = rk ) TABLE(0:P,0:P), the table of integrals. ! TABLE(I,J) represents the weighted integral of x^E * L(i,x) * L(j,x). ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) p integer ( kind = 4 ) e integer ( kind = 4 ) i integer ( kind = 4 ) j integer ( kind = 4 ) k real ( kind = rk ), allocatable :: l_table(:) integer ( kind = 4 ) order real ( kind = rk ) table(0:p,0:p) real ( kind = rk ), allocatable :: w_table(:) real ( kind = rk ) x real ( kind = rk ), allocatable :: x_table(:) table(0:p,0:p) = 0.0D+00 order = p + 1 + ( e + 1 ) / 2 allocate ( x_table(1:order) ) allocate ( w_table(1:order) ) call l_quadrature_rule ( order, x_table, w_table ) allocate ( l_table(0:p) ) do k = 1, order x = x_table(k) call l_polynomial ( 1, p, x_table(k), l_table ) if ( e == 0 ) then do j = 0, p do i = 0, p table(i,j) = table(i,j) + w_table(k) * l_table(i) * l_table(j) end do end do else do j = 0, p do i = 0, p table(i,j) = table(i,j) & + w_table(k) * ( x ** e ) * l_table(i) * l_table(j) end do end do end if end do deallocate ( l_table ) deallocate ( w_table ) deallocate ( x_table ) return end subroutine l_quadrature_rule ( n, x, w ) !*****************************************************************************80 ! !! L_QUADRATURE_RULE: Gauss-Laguerre quadrature based on L(n,x). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 07 March 2012 ! ! Author: ! ! Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky. ! FORTRAN90 version by John Burkardt. ! ! Reference: ! ! Sylvan Elhay, Jaroslav Kautsky, ! Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of ! Interpolatory Quadrature, ! ACM Transactions on Mathematical Software, ! Volume 13, Number 4, December 1987, pages 399-415. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the order. ! ! Output, real ( kind = rk ) X(N), the abscissas. ! ! Output, real ( kind = rk ) W(N), the weights. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) bj(n) integer ( kind = 4 ) i real ( kind = rk ) w(n) real ( kind = rk ) x(n) real ( kind = rk ) zemu ! ! Define the zero-th moment. ! zemu = 1.0D+00 ! ! Define the Jacobi matrix. ! do i = 1, n bj(i) = real ( i, kind = rk ) end do do i = 1, n x(i) = real ( 2 * i - 1, kind = rk ) end do w(1) = sqrt ( zemu ) w(2:n) = 0.0D+00 ! ! Diagonalize the Jacobi matrix. ! call imtqlx ( n, x, bj, w ) w(1:n) = w(1:n)**2 return end subroutine lf_function ( m, n, alpha, x, cx ) !*****************************************************************************80 ! !! LF_FUNCTION evaluates the Laguerre function Lf(n,alpha,x). ! ! Recursion: ! ! Lf(0,ALPHA,X) = 1 ! Lf(1,ALPHA,X) = 1+ALPHA-X ! ! Lf(N,ALPHA,X) = (2*N-1+ALPHA-X)/N * Lf(N-1,ALPHA,X) ! - (N-1+ALPHA)/N * Lf(N-2,ALPHA,X) ! ! Restrictions: ! ! -1 < ALPHA ! ! Special values: ! ! Lf(N,0,X) = L(N,X). ! Lf(N,ALPHA,X) = LM(N,ALPHA,X) for ALPHA integral. ! ! Norm: ! ! Integral ( 0 <= X < +oo ) exp ( - X ) * Lf(N,ALPHA,X)^2 dX ! = Gamma ( N + ALPHA + 1 ) / N! ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 10 March 2012 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Milton Abramowitz, Irene Stegun, ! Handbook of Mathematical Functions, ! National Bureau of Standards, 1964, ! ISBN: 0-486-61272-4, ! LC: QA47.A34. ! ! Parameters: ! ! Input, integer ( kind = 4 ) M, the number of evaluation points. ! ! Input, integer ( kind = 4 ) N, the highest order function to compute. ! ! Input, real ( kind = rk ) ALPHA, the parameter. -1 < ALPHA is required. ! ! Input, real ( kind = rk ) X(M), the evaluation points. ! ! Output, real ( kind = rk ) CX(1:M,0:N), the functions of ! degrees 0 through N evaluated at the points X. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) m integer ( kind = 4 ) n real ( kind = rk ) alpha real ( kind = rk ) cx(1:m,0:n) integer ( kind = 4 ) i real ( kind = rk ) x(1:m) if ( alpha <= -1.0D+00 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'LF_FUNCTION - Fatal error!' write ( *, '(a,g14.6)' ) ' The input value of ALPHA is ', alpha write ( *, '(a)' ) ' but ALPHA must be greater than -1.' stop end if if ( n < 0 ) then return end if cx(1:m,0) = 1.0D+00 if ( n == 0 ) then return end if cx(1:m,1) = 1.0D+00 + alpha - x(1:m) do i = 2, n cx(1:m,i) = ( & ( real ( 2 * i - 1, kind = rk ) + alpha - x(1:m) ) * cx(1:m,i-1) & + ( real ( - i + 1, kind = rk ) - alpha ) * cx(1:m,i-2) ) & / real ( i, kind = rk ) end do return end subroutine lf_function_values ( n_data, n, a, x, fx ) !*****************************************************************************80 ! !! LF_FUNCTION_VALUES returns values of the Laguerre function Lf(n,alpha,x). ! ! Discussion: ! ! In Mathematica, the function can be evaluated by: ! ! LaguerreL[n,a,x] ! ! The functions satisfy the following differential equation: ! ! X * Y'' + (ALPHA+1-X) * Y' + N * Y = 0 ! ! Function values can be generated by the recursion: ! ! Lf(0,ALPHA,X) = 1 ! Lf(1,ALPHA,X) = 1+ALPHA-X ! ! Lf(N,ALPHA,X) = ( (2*N-1+ALPHA-X) * Lf(N-1,ALPHA,X) ! - (N-1+ALPHA) * Lf(N-2,ALPHA,X) ) / N ! ! The parameter ALPHA is required to be greater than -1. ! ! For ALPHA = 0, the generalized Laguerre function Lf(N,ALPHA,X) ! is equal to the Laguerre polynomial L(N,X). ! ! For ALPHA integral, the generalized Laguerre function ! Lf(N,ALPHA,X) equals the associated Laguerre polynomial Lm(N,ALPHA,X). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 21 August 2004 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Stephen Wolfram, ! The Mathematica Book, ! Fourth Edition, ! Cambridge University Press, 1999, ! ISBN: 0-521-64314-7, ! LC: QA76.95.W65. ! ! Parameters: ! ! Input/output, integer ( kind = 4 ) N_DATA. The user sets N_DATA to 0 ! before the first call. On each call, the routine increments N_DATA by 1, ! and returns the corresponding data; when there is no more data, the ! output value of N_DATA will be 0 again. ! ! Output, integer ( kind = 4 ) N, the order of the function. ! ! Output, real ( kind = rk ) A, the parameter. ! ! Output, real ( kind = rk ) X, the point where the function is evaluated. ! ! Output, real ( kind = rk ) FX, the value of the function. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ), parameter :: n_max = 20 real ( kind = rk ) a real ( kind = rk ), save, dimension ( n_max ) :: a_vec = (/ & 0.00D+00, & 0.25D+00, & 0.50D+00, & 0.75D+00, & 1.50D+00, & 2.50D+00, & 5.00D+00, & 1.20D+00, & 1.20D+00, & 1.20D+00, & 1.20D+00, & 1.20D+00, & 1.20D+00, & 5.20D+00, & 5.20D+00, & 5.20D+00, & 5.20D+00, & 5.20D+00, & 5.20D+00, & 5.20D+00 /) real ( kind = rk ) fx real ( kind = rk ), save, dimension ( n_max ) :: fx_vec = (/ & 0.3726399739583333D-01, & 0.3494791666666667D+00, & 0.8710042317708333D+00, & 0.1672395833333333D+01, & 0.6657625325520833D+01, & 0.2395726725260417D+02, & 0.2031344319661458D+03, & 0.1284193996800000D+02, & 0.5359924801587302D+01, & 0.9204589064126984D+00, & -0.1341585114857143D+01, & -0.2119726307555556D+01, & -0.1959193658349206D+01, & 0.1000000000000000D+01, & 0.5450000000000000D+01, & 0.1720125000000000D+02, & 0.4110393750000000D+02, & 0.8239745859375000D+02, & 0.1460179186171875D+03, & 0.2359204608298828D+03 /) integer ( kind = 4 ) n integer ( kind = 4 ) n_data integer ( kind = 4 ), save, dimension ( n_max ) :: n_vec = (/ & 5, & 5, & 5, & 5, & 5, & 5, & 5, & 8, & 8, & 8, & 8, & 8, & 8, & 0, & 1, & 2, & 3, & 4, & 5, & 6 /) real ( kind = rk ) x real ( kind = rk ), save, dimension ( n_max ) :: x_vec = (/ & 0.25D+00, & 0.25D+00, & 0.25D+00, & 0.25D+00, & 0.25D+00, & 0.25D+00, & 0.25D+00, & 0.00D+00, & 0.20D+00, & 0.40D+00, & 0.60D+00, & 0.80D+00, & 1.00D+00, & 0.75D+00, & 0.75D+00, & 0.75D+00, & 0.75D+00, & 0.75D+00, & 0.75D+00, & 0.75D+00 /) if ( n_data < 0 ) then n_data = 0 end if n_data = n_data + 1 if ( n_max < n_data ) then n_data = 0 n = 0 a = 0.0D+00 x = 0.0D+00 fx = 0.0D+00 else n = n_vec(n_data) a = a_vec(n_data) x = x_vec(n_data) fx = fx_vec(n_data) end if return end subroutine lf_function_zeros ( n, alpha, x ) !*****************************************************************************80 ! !! LF_FUNCTION_ZEROS returns the zeros of Lf(n,alpha,x). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 07 March 2012 ! ! Author: ! ! Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky. ! FORTRAN90 version by John Burkardt. ! ! Reference: ! ! Sylvan Elhay, Jaroslav Kautsky, ! Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of ! Interpolatory Quadrature, ! ACM Transactions on Mathematical Software, ! Volume 13, Number 4, December 1987, pages 399-415. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the order. ! ! Input, real ( kind = rk ) ALPHA, the exponent of the X factor. ! ALPHA must be nonnegative. ! ! Output, real ( kind = rk ) X(N), the zeros. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) alpha real ( kind = rk ) bj(n) integer ( kind = 4 ) i real ( kind = rk ) i_r8 real ( kind = rk ) w(n) real ( kind = rk ) x(n) real ( kind = rk ) zemu ! ! Define the zero-th moment. ! zemu = gamma ( alpha + 1.0D+00 ) ! ! Define the Jacobi matrix. ! do i = 1, n i_r8 = real ( i, kind = rk ) bj(i) = i_r8 * ( i_r8 + alpha ) end do bj(1:n) = sqrt ( bj(1:n) ) do i = 1, n i_r8 = real ( i, kind = rk ) x(i) = 2.0D+00 * i_r8 - 1.0D+00 + alpha end do w(1) = sqrt ( zemu ) w(2:n) = 0.0D+00 ! ! Diagonalize the Jacobi matrix. ! call imtqlx ( n, x, bj, w ) return end subroutine lf_integral ( n, alpha, exact ) !*****************************************************************************80 ! !! LF_INTEGRAL evaluates a monomial integral associated with Lf(n,alpha,x). ! ! Discussion: ! ! The integral: ! ! integral ( 0 <= x < +oo ) x^n * x^alpha * exp ( -x ) dx ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 07 March 2012 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the exponent. ! 0 <= N. ! ! Input, real ( kind = rk ) ALPHA, the exponent of X in the weight function. ! ! Output, real ( kind = rk ) EXACT, the value of the integral. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) real ( kind = rk ) alpha real ( kind = rk ) arg real ( kind = rk ) exact integer ( kind = 4 ) n arg = alpha + real ( n + 1, kind = rk ) exact = gamma ( arg ) return end subroutine lf_quadrature_rule ( n, alpha, x, w ) !*****************************************************************************80 ! !! LF_QUADRATURE_RULE: Gauss-Laguerre quadrature rule for Lf(n,alpha,x); ! ! Discussion: ! ! The integral: ! ! integral ( 0 <= x < +oo ) exp ( - x ) * x^alpha * f(x) dx ! ! The quadrature rule: ! ! sum ( 1 <= i <= n ) w(i) * f ( x(i) ) ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 23 April 2011 ! ! Author: ! ! Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky. ! FORTRAN90 version by John Burkardt. ! ! Reference: ! ! Sylvan Elhay, Jaroslav Kautsky, ! Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of ! Interpolatory Quadrature, ! ACM Transactions on Mathematical Software, ! Volume 13, Number 4, December 1987, pages 399-415. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the order. ! ! Input, real ( kind = rk ) ALPHA, the exponent of the X factor. ! ALPHA must be nonnegative. ! ! Output, real ( kind = rk ) X(N), the abscissas. ! ! Output, real ( kind = rk ) W(N), the weights. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) alpha real ( kind = rk ) bj(n) integer ( kind = 4 ) i real ( kind = rk ) i_r8 real ( kind = rk ) w(n) real ( kind = rk ) x(n) real ( kind = rk ) zemu ! ! Define the zero-th moment. ! zemu = gamma ( alpha + 1.0D+00 ) ! ! Define the Jacobi matrix. ! do i = 1, n i_r8 = real ( i, kind = rk ) bj(i) = i_r8 * ( i_r8 + alpha ) end do bj(1:n) = sqrt ( bj(1:n) ) do i = 1, n i_r8 = real ( i, kind = rk ) x(i) = 2.0D+00 * i_r8 - 1.0D+00 + alpha end do w(1) = sqrt ( zemu ) w(2:n) = 0.0D+00 ! ! Diagonalize the Jacobi matrix. ! call imtqlx ( n, x, bj, w ) w(1:n) = w(1:n)**2 return end subroutine lm_integral ( n, m, exact ) !*****************************************************************************80 ! !! LM_INTEGRAL evaluates a monomial integral associated with Lm(n,m,x). ! ! Discussion: ! ! The integral: ! ! integral ( 0 <= x < +oo ) x^n * x^m * exp ( -x ) dx ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 07 March 2012 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the exponent. ! 0 <= N. ! ! Input, integer ( kind = 4 ) M, the parameter. ! 0 <= M. ! ! Output, real ( kind = rk ) EXACT, the value of the integral. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) real ( kind = rk ) exact integer ( kind = 4 ) m integer ( kind = 4 ) n real ( kind = rk ) r8_factorial exact = r8_factorial ( n + m ) return end subroutine lm_polynomial ( mm, n, m, x, cx ) !*****************************************************************************80 ! !! LM_POLYNOMIAL evaluates Laguerre polynomials Lm(n,m,x). ! ! First terms: ! ! M = 0 ! ! Lm(0,0,X) = 1 ! Lm(1,0,X) = -X + 1 ! Lm(2,0,X) = X^2 - 4 X + 2 ! Lm(3,0,X) = -X^3 + 9 X^2 - 18 X + 6 ! Lm(4,0,X) = X^4 - 16 X^3 + 72 X^2 - 96 X + 24 ! Lm(5,0,X) = -X^5 + 25 X^4 - 200 X^3 + 600 X^2 - 600 x + 120 ! Lm(6,0,X) = X^6 - 36 X^5 + 450 X^4 - 2400 X^3 + 5400 X^2 - 4320 X + 720 ! ! M = 1 ! ! Lm(0,1,X) = 0 ! Lm(1,1,X) = -1, ! Lm(2,1,X) = 2 X - 4, ! Lm(3,1,X) = -3 X^2 + 18 X - 18, ! Lm(4,1,X) = 4 X^3 - 48 X^2 + 144 X - 96 ! ! M = 2 ! ! Lm(0,2,X) = 0 ! Lm(1,2,X) = 0, ! Lm(2,2,X) = 2, ! Lm(3,2,X) = -6 X + 18, ! Lm(4,2,X) = 12 X^2 - 96 X + 144 ! ! M = 3 ! ! Lm(0,3,X) = 0 ! Lm(1,3,X) = 0, ! Lm(2,3,X) = 0, ! Lm(3,3,X) = -6, ! Lm(4,3,X) = 24 X - 96 ! ! M = 4 ! ! Lm(0,4,X) = 0 ! Lm(1,4,X) = 0 ! Lm(2,4,X) = 0 ! Lm(3,4,X) = 0 ! Lm(4,4,X) = 24 ! ! Recursion: ! ! Lm(0,M,X) = 1 ! Lm(1,M,X) = (M+1-X) ! ! if 2 <= N: ! ! Lm(N,M,X) = ( (M+2*N-1-X) * Lm(N-1,M,X) ! + (1-M-N) * Lm(N-2,M,X) ) / N ! ! Special values: ! ! For M = 0, the associated Laguerre polynomials Lm(N,M,X) are equal ! to the Laguerre polynomials L(N,X). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 08 February 2003 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Milton Abramowitz, Irene Stegun, ! Handbook of Mathematical Functions, ! National Bureau of Standards, 1964, ! ISBN: 0-486-61272-4, ! LC: QA47.A34. ! ! Parameters: ! ! Input, integer ( kind = 4 ) MM, the number of evaluation points. ! ! Input, integer ( kind = 4 ) N, the highest order polynomial to compute. ! Note that polynomials 0 through N will be computed. ! ! Input, integer ( kind = 4 ) M, the parameter. M must be nonnegative. ! ! Input, real ( kind = rk ) X(MM), the evaluation points. ! ! Output, real ( kind = rk ) CX(MM,0:N), the associated Laguerre polynomials ! of degrees 0 through N evaluated at the evaluation points. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) mm integer ( kind = 4 ) n real ( kind = rk ) cx(mm,0:n) integer ( kind = 4 ) i integer ( kind = 4 ) m real ( kind = rk ) x(mm) if ( m < 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) 'LM_POLYNOMIAL - Fatal error!' write ( *, '(a,i8)' ) ' Input value of M = ', m write ( *, '(a)' ) ' but M must be nonnegative.' stop end if if ( n < 0 ) then return end if cx(1:mm,0) = 1.0D+00 if ( n == 0 ) then return end if cx(1:mm,1) = real ( m + 1, kind = rk ) - x(1:mm) do i = 2, n cx(1:mm,i) = & ( ( real ( m + 2 * i - 1, kind = rk ) - x(1:mm) ) * cx(1:mm,i-1) & + real ( - m - i + 1, kind = rk ) * cx(1:mm,i-2) ) & / real ( i, kind = rk ) end do return end subroutine lm_polynomial_coefficients ( n, m, c ) !*****************************************************************************80 ! !! LM_POLYNOMIAL_COEFFICIENTS: coefficients of Laguerre polynomial Lm(n,m,x). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 26 August 2013 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Milton Abramowitz, Irene Stegun, ! Handbook of Mathematical Functions, ! National Bureau of Standards, 1964, ! ISBN: 0-486-61272-4, ! LC: QA47.A34. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the highest order polynomial to compute. ! Note that polynomials 0 through N will be computed. ! ! Input, integer ( kind = 4 ) M, the parameter. ! ! Output, real ( kind = rk ) C(0:N,0:N), the coefficients of the ! Laguerre polynomials of degree 0 through N. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) c(0:n,0:n) integer ( kind = 4 ) i integer ( kind = 4 ) m if ( n < 0 ) then return end if c(0:n,0:n) = 0.0D+00 c(0,0) = 1.0D+00 if ( n == 0 ) then return end if c(1,0) = real ( m + 1, kind = rk ) c(1,1) = -1.0D+00 do i = 2, n c(i,0:i) = ( real ( m + 2 * i - 1, kind = rk ) * c(i-1,0:i) & + real ( - m - i + 1, kind = rk ) * c(i-2,0:i) ) & / real ( i, kind = rk ) c(i,1:i) = c(i,1:i) - c(i-1,0:i-1) / real ( i, kind = rk ) end do return end subroutine lm_polynomial_values ( n_data, n, m, x, fx ) !*****************************************************************************80 ! !! LM_POLYNOMIAL_VALUES returns values of Laguerre polynomials Lm(n,m,x). ! ! Discussion: ! ! In Mathematica, the function can be evaluated by: ! ! LaguerreL[n,m,x] ! ! The associated Laguerre polynomials may be generalized so that the ! parameter M is allowed to take on arbitrary noninteger values. ! The resulting function is known as the generalized Laguerre function. ! ! The polynomials satisfy the differential equation: ! ! X * Y'' + (M+1-X) * Y' + (N-M) * Y = 0 ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 19 August 2004 ! ! Author: ! ! John Burkardt ! ! Reference: ! ! Stephen Wolfram, ! The Mathematica Book, ! Fourth Edition, ! Cambridge University Press, 1999, ! ISBN: 0-521-64314-7, ! LC: QA76.95.W65. ! ! Parameters: ! ! Input/output, integer ( kind = 4 ) N_DATA. The user sets N_DATA to 0 ! before the first call. On each call, the routine increments N_DATA by 1, ! and returns the corresponding data; when there is no more data, the ! output value of N_DATA will be 0 again. ! ! Output, integer ( kind = 4 ) N, the order of the function. ! ! Output, integer ( kind = 4 ) M, the parameter. ! ! Output, real ( kind = rk ) X, the point where the function is evaluated. ! ! Output, real ( kind = rk ) FX, the value of the function. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ), parameter :: n_max = 20 real ( kind = rk ) fx real ( kind = rk ), save, dimension ( n_max ) :: fx_vec = (/ & 0.1000000000000000D+01, & 0.1000000000000000D+01, & 0.1000000000000000D+01, & 0.1000000000000000D+01, & 0.1000000000000000D+01, & 0.1500000000000000D+01, & 0.1625000000000000D+01, & 0.1479166666666667D+01, & 0.1148437500000000D+01, & 0.4586666666666667D+00, & 0.2878666666666667D+01, & 0.8098666666666667D+01, & 0.1711866666666667D+02, & 0.1045328776041667D+02, & 0.1329019368489583D+02, & 0.5622453647189670D+02, & 0.7484729341779436D+02, & 0.3238912982762806D+03, & 0.4426100000097533D+03, & 0.1936876572288250D+04 /) integer ( kind = 4 ) m integer ( kind = 4 ), save, dimension ( n_max ) :: m_vec = (/ & 0, 0, 0, 0, & 0, 1, 1, 1, & 1, 0, 1, 2, & 3, 2, 2, 3, & 3, 4, 4, 5 /) integer ( kind = 4 ) n integer ( kind = 4 ) n_data integer ( kind = 4 ), save, dimension ( n_max ) :: n_vec = (/ & 1, 2, 3, 4, & 5, 1, 2, 3, & 4, 3, 3, 3, & 3, 4, 5, 6, & 7, 8, 9, 10 /) real ( kind = rk ) x real ( kind = rk ), save, dimension ( n_max ) :: x_vec = (/ & 0.00D+00, & 0.00D+00, & 0.00D+00, & 0.00D+00, & 0.00D+00, & 0.50D+00, & 0.50D+00, & 0.50D+00, & 0.50D+00, & 0.20D+00, & 0.20D+00, & 0.20D+00, & 0.20D+00, & 0.25D+00, & 0.25D+00, & 0.25D+00, & 0.25D+00, & 0.25D+00, & 0.25D+00, & 0.25D+00 /) if ( n_data < 0 ) then n_data = 0 end if n_data = n_data + 1 if ( n_max < n_data ) then n_data = 0 n = 0 m = 0 x = 0.0D+00 fx = 0.0D+00 else n = n_vec(n_data) m = m_vec(n_data) x = x_vec(n_data) fx = fx_vec(n_data) end if return end subroutine lm_polynomial_zeros ( n, m, x ) !*****************************************************************************80 ! !! LM_POLYNOMIAL_ZEROS returns the zeros for Lm(n,m,x). ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 07 March 2012 ! ! Author: ! ! Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky. ! FORTRAN90 version by John Burkardt. ! ! Reference: ! ! Sylvan Elhay, Jaroslav Kautsky, ! Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of ! Interpolatory Quadrature, ! ACM Transactions on Mathematical Software, ! Volume 13, Number 4, December 1987, pages 399-415. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the order. ! ! Input, integer ( kind = 4 ) M, the parameter. ! 0 <= M. ! ! Output, real ( kind = rk ) X(N), the zeros. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) bj(n) integer ( kind = 4 ) i integer ( kind = 4 ) m real ( kind = rk ) r8_factorial real ( kind = rk ) w(n) real ( kind = rk ) x(n) real ( kind = rk ) zemu ! ! Define the zero-th moment. ! zemu = r8_factorial ( m ) ! ! Define the Jacobi matrix. ! do i = 1, n bj(i) = real ( i * ( i + m ), kind = rk ) end do bj(1:n) = sqrt ( bj(1:n) ) do i = 1, n x(i) = real ( 2 * i - 1 + m, kind = rk ) end do w(1) = sqrt ( zemu ) w(2:n) = 0.0D+00 ! ! Diagonalize the Jacobi matrix. ! call imtqlx ( n, x, bj, w ) return end subroutine lm_quadrature_rule ( n, m, x, w ) !*****************************************************************************80 ! !! LM_QUADRATURE_RULE: Gauss-Laguerre quadrature rule for Lm(n,m,x); ! ! Discussion: ! ! The integral: ! ! integral ( 0 <= x < +oo ) exp ( - x ) * x^m * f(x) dx ! ! The quadrature rule: ! ! sum ( 1 <= i <= n ) w(i) * f ( x(i) ) ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 07 March 2012 ! ! Author: ! ! Original FORTRAN77 version by Sylvan Elhay, Jaroslav Kautsky. ! FORTRAN90 version by John Burkardt. ! ! Reference: ! ! Sylvan Elhay, Jaroslav Kautsky, ! Algorithm 655: IQPACK, FORTRAN Subroutines for the Weights of ! Interpolatory Quadrature, ! ACM Transactions on Mathematical Software, ! Volume 13, Number 4, December 1987, pages 399-415. ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the order. ! ! Input, integer ( kind = 4 ) M, the parameter. ! 0 <= M. ! ! Output, real ( kind = rk ) X(N), the abscissas. ! ! Output, real ( kind = rk ) W(N), the weights. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) bj(n) integer ( kind = 4 ) i integer ( kind = 4 ) m real ( kind = rk ) r8_factorial real ( kind = rk ) w(n) real ( kind = rk ) x(n) real ( kind = rk ) zemu ! ! Define the zero-th moment. ! zemu = r8_factorial ( m ) ! ! Define the Jacobi matrix. ! do i = 1, n bj(i) = real ( i * ( i + m ), kind = rk ) end do bj(1:n) = sqrt ( bj(1:n) ) do i = 1, n x(i) = real ( 2 * i - 1 + m, kind = rk ) end do w(1) = sqrt ( zemu ) w(2:n) = 0.0D+00 ! ! Diagonalize the Jacobi matrix. ! call imtqlx ( n, x, bj, w ) w(1:n) = w(1:n)**2 return end function r8_factorial ( n ) !*****************************************************************************80 ! !! R8_FACTORIAL computes the factorial of N. ! ! Discussion: ! ! factorial ( n ) = product ( 1 <= i <= n ) i ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 16 January 1999 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the argument of the factorial function. ! If N is less than 1, the function value is returned as 1. ! ! Output, real ( kind = rk ) R8_FACTORIAL, the factorial of N. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) real ( kind = rk ) r8_factorial integer ( kind = 4 ) i integer ( kind = 4 ) n r8_factorial = 1.0D+00 do i = 1, n r8_factorial = r8_factorial * real ( i, kind = rk ) end do return end subroutine r8mat_print ( m, n, a, title ) !*****************************************************************************80 ! !! R8MAT_PRINT prints an R8MAT. ! ! Discussion: ! ! An R8MAT is an MxN array of R8's, stored by (I,J) -> [I+J*M]. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 12 September 2004 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) M, the number of rows in A. ! ! Input, integer ( kind = 4 ) N, the number of columns in A. ! ! Input, real ( kind = rk ) A(M,N), the matrix. ! ! Input, character ( len = * ) TITLE, a title. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) m integer ( kind = 4 ) n real ( kind = rk ) a(m,n) character ( len = * ) title call r8mat_print_some ( m, n, a, 1, 1, m, n, title ) return end subroutine r8mat_print_some ( m, n, a, ilo, jlo, ihi, jhi, title ) !*****************************************************************************80 ! !! R8MAT_PRINT_SOME prints some of an R8MAT. ! ! Discussion: ! ! An R8MAT is an MxN array of R8's, stored by (I,J) -> [I+J*M]. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 10 September 2009 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) M, N, the number of rows and columns. ! ! Input, real ( kind = rk ) A(M,N), an M by N matrix to be printed. ! ! Input, integer ( kind = 4 ) ILO, JLO, the first row and column to print. ! ! Input, integer ( kind = 4 ) IHI, JHI, the last row and column to print. ! ! Input, character ( len = * ) TITLE, a title. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ), parameter :: incx = 5 integer ( kind = 4 ) m integer ( kind = 4 ) n real ( kind = rk ) a(m,n) character ( len = 14 ) ctemp(incx) integer ( kind = 4 ) i integer ( kind = 4 ) i2hi integer ( kind = 4 ) i2lo integer ( kind = 4 ) ihi integer ( kind = 4 ) ilo integer ( kind = 4 ) inc integer ( kind = 4 ) j integer ( kind = 4 ) j2 integer ( kind = 4 ) j2hi integer ( kind = 4 ) j2lo integer ( kind = 4 ) jhi integer ( kind = 4 ) jlo character ( len = * ) title write ( *, '(a)' ) ' ' write ( *, '(a)' ) trim ( title ) if ( m <= 0 .or. n <= 0 ) then write ( *, '(a)' ) ' ' write ( *, '(a)' ) ' (None)' return end if do j2lo = max ( jlo, 1 ), min ( jhi, n ), incx j2hi = j2lo + incx - 1 j2hi = min ( j2hi, n ) j2hi = min ( j2hi, jhi ) inc = j2hi + 1 - j2lo write ( *, '(a)' ) ' ' do j = j2lo, j2hi j2 = j + 1 - j2lo write ( ctemp(j2), '(i8,6x)' ) j end do write ( *, '('' Col '',5a14)' ) ctemp(1:inc) write ( *, '(a)' ) ' Row' write ( *, '(a)' ) ' ' i2lo = max ( ilo, 1 ) i2hi = min ( ihi, m ) do i = i2lo, i2hi do j2 = 1, inc j = j2lo - 1 + j2 if ( a(i,j) == real ( int ( a(i,j) ), kind = rk ) ) then write ( ctemp(j2), '(f8.0,6x)' ) a(i,j) else write ( ctemp(j2), '(g14.6)' ) a(i,j) end if end do write ( *, '(i5,a,5a14)' ) i, ':', ( ctemp(j), j = 1, inc ) end do end do return end subroutine r8vec_print ( n, a, title ) !*****************************************************************************80 ! !! R8VEC_PRINT prints an R8VEC. ! ! Discussion: ! ! An R8VEC is a vector of R8's. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 22 August 2000 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the number of components of the vector. ! ! Input, real ( kind = rk ) A(N), the vector to be printed. ! ! Input, character ( len = * ) TITLE, a title. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) a(n) integer ( kind = 4 ) i character ( len = * ) title write ( *, '(a)' ) ' ' write ( *, '(a)' ) trim ( title ) write ( *, '(a)' ) ' ' do i = 1, n write ( *, '(2x,i8,a,1x,g16.8)' ) i, ':', a(i) end do return end subroutine r8vec2_print ( n, a1, a2, title ) !*****************************************************************************80 ! !! R8VEC2_PRINT prints an R8VEC2. ! ! Discussion: ! ! An R8VEC2 is a dataset consisting of N pairs of R8's, stored ! as two separate vectors A1 and A2. ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 13 December 2004 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the number of components of the vector. ! ! Input, real ( kind = rk ) A1(N), A2(N), the vectors to be printed. ! ! Input, character ( len = * ) TITLE, a title. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer ( kind = 4 ) n real ( kind = rk ) a1(n) real ( kind = rk ) a2(n) integer ( kind = 4 ) i character ( len = * ) title write ( *, '(a)' ) ' ' write ( *, '(a)' ) trim ( title ) write ( *, '(a)' ) ' ' do i = 1, n write ( *, '(2x,i4,2x,g14.6,2x,g14.6)' ) i, a1(i), a2(i) end do return end subroutine timestamp ( ) !*****************************************************************************80 ! !! TIMESTAMP prints the current YMDHMS date as a time stamp. ! ! Example: ! ! 31 May 2001 9:45:54.872 AM ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 18 May 2013 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! None ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) character ( len = 8 ) ampm integer ( kind = 4 ) d integer ( kind = 4 ) h integer ( kind = 4 ) m integer ( kind = 4 ) mm character ( len = 9 ), parameter, dimension(12) :: month = (/ & 'January ', 'February ', 'March ', 'April ', & 'May ', 'June ', 'July ', 'August ', & 'September', 'October ', 'November ', 'December ' /) integer ( kind = 4 ) n integer ( kind = 4 ) s integer ( kind = 4 ) values(8) integer ( kind = 4 ) y call date_and_time ( values = values ) y = values(1) m = values(2) d = values(3) h = values(5) n = values(6) s = values(7) mm = values(8) if ( h < 12 ) then ampm = 'AM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Noon' else ampm = 'PM' end if else h = h - 12 if ( h < 12 ) then ampm = 'PM' else if ( h == 12 ) then if ( n == 0 .and. s == 0 ) then ampm = 'Midnight' else ampm = 'AM' end if end if end if write ( *, '(i2,1x,a,1x,i4,2x,i2,a1,i2.2,a1,i2.2,a1,i3.3,1x,a)' ) & d, trim ( month(m) ), y, h, ':', n, ':', s, '.', mm, trim ( ampm ) return end