diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /pkg/utilities/nttools/trebin/tuiep3.f | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/utilities/nttools/trebin/tuiep3.f')
-rw-r--r-- | pkg/utilities/nttools/trebin/tuiep3.f | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/trebin/tuiep3.f b/pkg/utilities/nttools/trebin/tuiep3.f new file mode 100644 index 00000000..58f81a99 --- /dev/null +++ b/pkg/utilities/nttools/trebin/tuiep3.f @@ -0,0 +1,71 @@ + subroutine tuiep3 (xa, ya, x, y, dy) +C +C Evaluate a cubic polynomial interpolation function at X. +C xa(klo) <= x <= xa(klo+1) +C This routine was copied with slight modifications from the POLINT +C subroutine in Numerical Recipes by Press, Flannery, Teukolsky and +C Vetterling. +C +C XA i: array of four independent-variable values +C YA i: array of four dependent-variable values +C X i: the independent variable +C Y o: the result of interpolations +C DY o: an estimate of the error of interpolation +C +CH Phil Hodge, 18-Apr-1988 Subroutine copied from Numerical Recipes POLINT. +C + double precision xa(4), ya(4), x, y, dy +C-- + integer n +C four-point interpolation + parameter (n = 4) + + double precision c(n), d(n), dif, dift, den + double precision ho, hp, w + integer i, m, ns + + do 10 i = 1, n + if (x .eq. xa(i)) then + y = ya(i) + return + endif + 10 continue + + ns = 1 + dif = abs (x - xa(1)) + + do 20 i = 1, n + dift = abs (x - xa(i)) + if (dift .lt. dif) then + ns = i + dif = dift + endif + c(i) = ya(i) + d(i) = ya(i) + 20 continue + + y = ya(ns) + ns = ns - 1 + + do 40 m = 1, n-1 + + do 30 i = 1, n-m + ho = xa(i) - x + hp = xa(i+m) - x + w = c(i+1) - d(i) + den = w / (ho - hp) + d(i) = hp * den + c(i) = ho * den + 30 continue + + if (2*ns .lt. n-m) then + dy = c(ns+1) + else + dy = d(ns) + ns = ns - 1 + endif + y = y + dy + 40 continue + + return + end |