subroutine line_grid ( n, a, b, c, x ) !*****************************************************************************80 ! !! LINE_GRID: grid points over the interior of a line segment in 1D. ! ! Discussion: ! ! In 1D, a grid is to be created, using N points. ! ! Over the interval [A,B], we have 5 choices for grid centering: ! 1: 0, 1/3, 2/3, 1 ! 2: 1/5, 2/5, 3/5, 4/5 ! 3: 0, 1/4, 2/4, 3/4 ! 4: 1/4, 2/4, 3/4, 1 ! 5: 1/8, 3/8, 5/8, 7/8 ! ! Licensing: ! ! This code is distributed under the MIT license. ! ! Modified: ! ! 31 August 2014 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer N, the number of points. ! ! Input, real ( kind = rk ) A, B, the endpoints. ! ! Input, integer C, the grid centering. ! 1 <= C <= 5. ! ! Output, real ( kind = rk ) X(N), the points. ! implicit none integer, parameter :: rk = kind ( 1.0D+00 ) integer n real ( kind = rk ) a real ( kind = rk ) b integer c integer j real ( kind = rk ) x(n) do j = 1, n if ( c == 1 ) then if ( n == 1 ) then x(j) = 0.5D+00 * ( a + b ) else x(j) = ( real ( n - j, kind = rk ) * a & + real ( j - 1, kind = rk ) * b ) & / real ( n - 1, kind = rk ) end if else if ( c == 2 ) then x(j) = ( real ( n - j + 1, kind = rk ) * a & + real ( j, kind = rk ) * b ) & / real ( n + 1, kind = rk ) else if ( c == 3 ) then x(j) = ( real ( n - j + 1, kind = rk ) * a & + real ( j - 1, kind = rk ) * b ) & / real ( n, kind = rk ) else if ( c == 4 ) then x(j) = ( real ( n - j, kind = rk ) * a & + real ( j, kind = rk ) * b ) & / real ( n, kind = rk ) else if ( c == 5 ) then x(j) = ( real ( 2 * n - 2 * j + 1, kind = rk ) * a & + real ( 2 * j - 1, kind = rk ) * b ) & / real ( 2 * n, kind = rk ) end if 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 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 n real ( kind = rk ) a(n) integer 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