dpcoef.f 3.1 KB

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