pcoef.f 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. *DECK PCOEF
  2. SUBROUTINE PCOEF (L, C, TC, A)
  3. C***BEGIN PROLOGUE PCOEF
  4. C***PURPOSE Convert the POLFIT coefficients to Taylor series form.
  5. C***LIBRARY SLATEC
  6. C***CATEGORY K1A1A2
  7. C***TYPE SINGLE PRECISION (PCOEF-S, DPCOEF-D)
  8. C***KEYWORDS CURVE FITTING, DATA FITTING, LEAST SQUARES, POLYNOMIAL FIT
  9. C***AUTHOR Shampine, L. F., (SNLA)
  10. C Davenport, S. M., (SNLA)
  11. C***DESCRIPTION
  12. C
  13. C Written BY L. F. Shampine and S. M. Davenport.
  14. C
  15. C Abstract
  16. C
  17. C POLFIT computes the least squares polynomial fit of degree L as
  18. C a sum of orthogonal polynomials. PCOEF changes this fit to its
  19. C Taylor expansion about any point C , i.e. writes the polynomial
  20. C as a sum of powers of (X-C). Taking C=0. gives the polynomial
  21. C in powers of X, but a suitable non-zero C often leads to
  22. C polynomials which are better scaled and more accurately evaluated.
  23. C
  24. C The parameters for PCOEF are
  25. C
  26. C INPUT --
  27. C L - Indicates the degree of polynomial to be changed to
  28. C its Taylor expansion. To obtain the Taylor
  29. C coefficients in reverse order, input L as the
  30. C negative of the degree desired. The absolute value
  31. C of L must be less than or equal to NDEG, the highest
  32. C degree polynomial fitted by POLFIT .
  33. C C - The point about which the Taylor expansion is to be
  34. C made.
  35. C A - Work and output array containing values from last
  36. C call to POLFIT .
  37. C
  38. C OUTPUT --
  39. C TC - Vector containing the first LL+1 Taylor coefficients
  40. C where LL=ABS(L). If L.GT.0 , the coefficients are
  41. C in the usual Taylor series order, i.e.
  42. C P(X) = TC(1) + TC(2)*(X-C) + ... + TC(N+1)*(X-C)**N
  43. C If L .LT. 0, the coefficients are in reverse order,
  44. C i.e.
  45. C P(X) = TC(1)*(X-C)**N + ... + TC(N)*(X-C) + TC(N+1)
  46. C
  47. C***REFERENCES L. F. Shampine, S. M. Davenport and R. E. Huddleston,
  48. C Curve fitting by polynomials in one variable, Report
  49. C SLA-74-0270, Sandia Laboratories, June 1974.
  50. C***ROUTINES CALLED PVALUE
  51. C***REVISION HISTORY (YYMMDD)
  52. C 740601 DATE WRITTEN
  53. C 890531 Changed all specific intrinsics to generic. (WRB)
  54. C 890531 REVISION DATE from Version 3.2
  55. C 891214 Prologue converted to Version 4.0 format. (BAB)
  56. C 920501 Reformatted the REFERENCES section. (WRB)
  57. C***END PROLOGUE PCOEF
  58. C
  59. DIMENSION A(*), TC(*)
  60. C***FIRST EXECUTABLE STATEMENT PCOEF
  61. LL = ABS(L)
  62. LLP1 = LL + 1
  63. CALL PVALUE (LL,LL,C,TC(1),TC(2),A)
  64. IF (LL .LT. 2) GO TO 2
  65. FAC = 1.0
  66. DO 1 I = 3,LLP1
  67. FAC = FAC*(I-1)
  68. 1 TC(I) = TC(I)/FAC
  69. 2 IF (L .GE. 0) GO TO 4
  70. NR = LLP1/2
  71. LLP2 = LL + 2
  72. DO 3 I = 1,NR
  73. SAVE = TC(I)
  74. NEW = LLP2 - I
  75. TC(I) = TC(NEW)
  76. 3 TC(NEW) = SAVE
  77. 4 RETURN
  78. END