dpolcf.f 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. *DECK DPOLCF
  2. SUBROUTINE DPOLCF (XX, N, X, C, D, WORK)
  3. C***BEGIN PROLOGUE DPOLCF
  4. C***PURPOSE Compute the coefficients of the polynomial fit (including
  5. C Hermite polynomial fits) produced by a previous call to
  6. C POLINT.
  7. C***LIBRARY SLATEC
  8. C***CATEGORY E1B
  9. C***TYPE DOUBLE PRECISION (POLCOF-S, DPOLCF-D)
  10. C***KEYWORDS COEFFICIENTS, POLYNOMIAL
  11. C***AUTHOR Huddleston, R. E., (SNLL)
  12. C***DESCRIPTION
  13. C
  14. C Abstract
  15. C Subroutine DPOLCF computes the coefficients of the polynomial
  16. C fit (including Hermite polynomial fits ) produced by a previous
  17. C call to DPLINT. The coefficients of the polynomial, expanded
  18. C about XX, are stored in the array D. The expansion is of the form
  19. C P(Z) = D(1) + D(2)*(Z-XX) +D(3)*((Z-XX)**2) + ... +
  20. C D(N)*((Z-XX)**(N-1)).
  21. C Between the call to DPLINT and the call to DPOLCF the variable N
  22. C and the arrays X and C must not be altered.
  23. C
  24. C ***** INPUT PARAMETERS
  25. C *** All TYPE REAL variables are DOUBLE PRECISION ***
  26. C
  27. C XX - The point about which the Taylor expansion is to be made.
  28. C
  29. C N - ****
  30. C * N, X, and C must remain unchanged between the
  31. C X - * call to DPLINT and the call to DPOLCF.
  32. C C - ****
  33. C
  34. C ***** OUTPUT PARAMETER
  35. C *** All TYPE REAL variables are DOUBLE PRECISION ***
  36. C
  37. C D - The array of coefficients for the Taylor expansion as
  38. C explained in the abstract
  39. C
  40. C ***** STORAGE PARAMETER
  41. C
  42. C WORK - This is an array to provide internal working storage. It
  43. C must be dimensioned by at least 2*N in the calling program.
  44. C
  45. C
  46. C **** Note - There are two methods for evaluating the fit produced
  47. C by DPLINT. You may call DPOLVL to perform the task, or you may
  48. C call DPOLCF to obtain the coefficients of the Taylor expansion and
  49. C then write your own evaluation scheme. Due to the inherent errors
  50. C in the computations of the Taylor expansion from the Newton
  51. C coefficients produced by DPLINT, much more accuracy may be
  52. C expected by calling DPOLVL as opposed to writing your own scheme.
  53. C
  54. C***REFERENCES (NONE)
  55. C***ROUTINES CALLED (NONE)
  56. C***REVISION HISTORY (YYMMDD)
  57. C 890213 DATE WRITTEN
  58. C 891006 Cosmetic changes to prologue. (WRB)
  59. C 891024 Corrected KEYWORD section. (WRB)
  60. C 891024 REVISION DATE from Version 3.2
  61. C 891214 Prologue converted to Version 4.0 format. (BAB)
  62. C***END PROLOGUE DPOLCF
  63. C
  64. INTEGER I,IM1,K,KM1,KM1PI,KM2N,KM2NPI,N,NM1,NMKP1,NPKM1
  65. DOUBLE PRECISION C(*),D(*),PONE,PTWO,X(*),XX,WORK(*)
  66. C***FIRST EXECUTABLE STATEMENT DPOLCF
  67. DO 10010 K=1,N
  68. D(K)=C(K)
  69. 10010 CONTINUE
  70. IF (N.EQ.1) RETURN
  71. WORK(1)=1.0D0
  72. PONE=C(1)
  73. NM1=N-1
  74. DO 10020 K=2,N
  75. KM1=K-1
  76. NPKM1=N+K-1
  77. WORK(NPKM1)=XX-X(KM1)
  78. WORK(K)=WORK(NPKM1)*WORK(KM1)
  79. PTWO=PONE+WORK(K)*C(K)
  80. PONE=PTWO
  81. 10020 CONTINUE
  82. D(1)=PTWO
  83. IF (N.EQ.2) RETURN
  84. DO 10030 K=2,NM1
  85. KM1=K-1
  86. KM2N=K-2+N
  87. NMKP1=N-K+1
  88. DO 10030 I=2,NMKP1
  89. KM2NPI=KM2N+I
  90. IM1=I-1
  91. KM1PI=KM1+I
  92. WORK(I)=WORK(KM2NPI)*WORK(IM1)+WORK(I)
  93. D(K)=D(K)+WORK(I)*D(KM1PI)
  94. 10030 CONTINUE
  95. RETURN
  96. END