************80
! R8VEC_EXPAND_LINEAR linearly interpolates new data into an R8VEC.
Discussion:
This routine copies the old data, and inserts NFAT new values
between each pair of old data values. This would be one way to
determine places to evenly sample a curve, given the (unevenly
spaced) points at which it was interpolated.
An R8VEC is an array of double precision real values.
Example:
N = 3
NFAT = 2
X(1:N) = (/ 0.0, 6.0, 7.0 /)
XFAT(1:2*3+1) = (/ 0.0, 2.0, 4.0, 6.0, 6.33, 6.66, 7.0 /)
Licensing:
This code is distributed under the GNU LGPL license.
Modified:
10 October 2001
Author:
John Burkardt
Parameters:
Input, integer ( kind = 4 ) N, the number of input data values.
Input, real ( kind = 8 ) X(N), the original data.
Input, integer ( kind = 4 ) FAT, the number of data values to interpolate
between each pair of original data values.
Output, real ( kind = 8 ) XFAT((N-1)*(FAT+1)+1), the "fattened" data.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=4) | :: | n | ||||
real(kind=8) | :: | x(n) | ||||
integer(kind=4) | :: | fat | ||||
real(kind=8) | :: | xfat((n-1)*(fat+1)+1) |
subroutine r8vec_expand_linear ( n, x, fat, xfat ) !*****************************************************************************80 ! !! R8VEC_EXPAND_LINEAR linearly interpolates new data into an R8VEC. ! ! Discussion: ! ! This routine copies the old data, and inserts NFAT new values ! between each pair of old data values. This would be one way to ! determine places to evenly sample a curve, given the (unevenly ! spaced) points at which it was interpolated. ! ! An R8VEC is an array of double precision real values. ! ! Example: ! ! N = 3 ! NFAT = 2 ! ! X(1:N) = (/ 0.0, 6.0, 7.0 /) ! XFAT(1:2*3+1) = (/ 0.0, 2.0, 4.0, 6.0, 6.33, 6.66, 7.0 /) ! ! Licensing: ! ! This code is distributed under the GNU LGPL license. ! ! Modified: ! ! 10 October 2001 ! ! Author: ! ! John Burkardt ! ! Parameters: ! ! Input, integer ( kind = 4 ) N, the number of input data values. ! ! Input, real ( kind = 8 ) X(N), the original data. ! ! Input, integer ( kind = 4 ) FAT, the number of data values to interpolate ! between each pair of original data values. ! ! Output, real ( kind = 8 ) XFAT((N-1)*(FAT+1)+1), the "fattened" data. ! implicit none integer ( kind = 4 ) fat integer ( kind = 4 ) n integer ( kind = 4 ) i integer ( kind = 4 ) j integer ( kind = 4 ) k real ( kind = 8 ) x(n) real ( kind = 8 ) xfat((n-1)*(fat+1)+1) k = 0 do i = 1, n - 1 k = k + 1 xfat(k) = x(i) do j = 1, fat k = k + 1 xfat(k) = ( real ( fat - j + 1, kind = 8 ) * x(i) & + real ( j, kind = 8 ) * x(i+1) ) & / real ( fat + 1, kind = 8 ) end do end do k = k + 1 xfat(k) = x(n) return end subroutine r8vec_expand_linear