dplint.f 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. *DECK DPLINT
  2. SUBROUTINE DPLINT (N, X, Y, C)
  3. C***BEGIN PROLOGUE DPLINT
  4. C***PURPOSE Produce the polynomial which interpolates a set of discrete
  5. C data points.
  6. C***LIBRARY SLATEC
  7. C***CATEGORY E1B
  8. C***TYPE DOUBLE PRECISION (POLINT-S, DPLINT-D)
  9. C***KEYWORDS POLYNOMIAL INTERPOLATION
  10. C***AUTHOR Huddleston, R. E., (SNLL)
  11. C***DESCRIPTION
  12. C
  13. C Abstract
  14. C Subroutine DPLINT is designed to produce the polynomial which
  15. C interpolates the data (X(I),Y(I)), I=1,...,N. DPLINT sets up
  16. C information in the array C which can be used by subroutine DPOLVL
  17. C to evaluate the polynomial and its derivatives and by subroutine
  18. C DPOLCF to produce the coefficients.
  19. C
  20. C Formal Parameters
  21. C *** All TYPE REAL variables are DOUBLE PRECISION ***
  22. C N - the number of data points (N .GE. 1)
  23. C X - the array of abscissas (all of which must be distinct)
  24. C Y - the array of ordinates
  25. C C - an array of information used by subroutines
  26. C ******* Dimensioning Information *******
  27. C Arrays X,Y, and C must be dimensioned at least N in the calling
  28. C program.
  29. C
  30. C***REFERENCES L. F. Shampine, S. M. Davenport and R. E. Huddleston,
  31. C Curve fitting by polynomials in one variable, Report
  32. C SLA-74-0270, Sandia Laboratories, June 1974.
  33. C***ROUTINES CALLED XERMSG
  34. C***REVISION HISTORY (YYMMDD)
  35. C 740601 DATE WRITTEN
  36. C 891006 Cosmetic changes to prologue. (WRB)
  37. C 891006 REVISION DATE from Version 3.2
  38. C 891214 Prologue converted to Version 4.0 format. (BAB)
  39. C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  40. C 920501 Reformatted the REFERENCES section. (WRB)
  41. C***END PROLOGUE DPLINT
  42. INTEGER I,K,KM1,N
  43. DOUBLE PRECISION DIF,C(*),X(*),Y(*)
  44. C***FIRST EXECUTABLE STATEMENT DPLINT
  45. IF (N .LE. 0) GO TO 91
  46. C(1)=Y(1)
  47. IF(N .EQ. 1) RETURN
  48. DO 10010 K=2,N
  49. C(K)=Y(K)
  50. KM1=K-1
  51. DO 10010 I=1,KM1
  52. C CHECK FOR DISTINCT X VALUES
  53. DIF = X(I)-X(K)
  54. IF (DIF .EQ. 0.0) GO TO 92
  55. C(K) = (C(I)-C(K))/DIF
  56. 10010 CONTINUE
  57. RETURN
  58. 91 CALL XERMSG ('SLATEC', 'DPLINT', 'N IS ZERO OR NEGATIVE.', 2, 1)
  59. RETURN
  60. 92 CALL XERMSG ('SLATEC', 'DPLINT',
  61. + 'THE ABSCISSAS ARE NOT DISTINCT.', 2, 1)
  62. RETURN
  63. END