polcof.f 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. *DECK POLCOF
  2. SUBROUTINE POLCOF (XX, N, X, C, D, WORK)
  3. C***BEGIN PROLOGUE POLCOF
  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 SINGLE PRECISION (POLCOF-S, DPOLCF-D)
  10. C***KEYWORDS COEFFICIENTS, POLYNOMIAL
  11. C***AUTHOR Huddleston, R. E., (SNLL)
  12. C***DESCRIPTION
  13. C
  14. C Written by Robert E. Huddleston, Sandia Laboratories, Livermore
  15. C
  16. C Abstract
  17. C Subroutine POLCOF computes the coefficients of the polynomial
  18. C fit (including Hermite polynomial fits ) produced by a previous
  19. C call to POLINT. The coefficients of the polynomial, expanded about
  20. C XX, are stored in the array D. The expansion is of the form
  21. C P(Z) = D(1) + D(2)*(Z-XX) +D(3)*((Z-XX)**2) + ... +
  22. C D(N)*((Z-XX)**(N-1)).
  23. C Between the call to POLINT and the call to POLCOF the variable N
  24. C and the arrays X and C must not be altered.
  25. C
  26. C ***** INPUT PARAMETERS
  27. C
  28. C XX - The point about which the Taylor expansion is to be made.
  29. C
  30. C N - ****
  31. C * N, X, and C must remain unchanged between the
  32. C X - * call to POLINT or the call to POLCOF.
  33. C C - ****
  34. C
  35. C ***** OUTPUT PARAMETER
  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 POLINT. You may call POLYVL to perform the task, or you may
  48. C call POLCOF 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 POLINT, much more accuracy may be
  52. C expected by calling POLYVL 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 891024 Corrected KEYWORD section. (WRB)
  59. C 891024 REVISION DATE from Version 3.2
  60. C 891214 Prologue converted to Version 4.0 format. (BAB)
  61. C***END PROLOGUE POLCOF
  62. C
  63. DIMENSION X(*), C(*), D(*), WORK(*)
  64. C***FIRST EXECUTABLE STATEMENT POLCOF
  65. DO 10010 K=1,N
  66. D(K)=C(K)
  67. 10010 CONTINUE
  68. IF (N.EQ.1) RETURN
  69. WORK(1)=1.0
  70. PONE=C(1)
  71. NM1=N-1
  72. DO 10020 K=2,N
  73. KM1=K-1
  74. NPKM1=N+K-1
  75. WORK(NPKM1)=XX-X(KM1)
  76. WORK(K)=WORK(NPKM1)*WORK(KM1)
  77. PTWO=PONE+WORK(K)*C(K)
  78. PONE=PTWO
  79. 10020 CONTINUE
  80. D(1)=PTWO
  81. IF (N.EQ.2) RETURN
  82. DO 10030 K=2,NM1
  83. KM1=K-1
  84. KM2N=K-2+N
  85. NMKP1=N-K+1
  86. DO 10030 I=2,NMKP1
  87. KM2NPI=KM2N+I
  88. IM1=I-1
  89. KM1PI=KM1+I
  90. WORK(I)=WORK(KM2NPI)*WORK(IM1)+WORK(I)
  91. D(K)=D(K)+WORK(I)*D(KM1PI)
  92. 10030 CONTINUE
  93. RETURN
  94. END