next up previous 196
Next: Two-dimensional Interpolation and Fitting
Up: One-dimensional Interpolation and Fitting, Splines
Previous: Replacing calls to E02AKF


Replacing calls to GEN_CHB2NO

This is not a NAG routine, but a routine in Figaro's GEN library. It converts the vector of Chebyshev coefficients into a vector of coefficients of an ordinary polynomial. This is particularly useful when these are to be written to output files. In future the routine will still be needed to read old files that contain Chebyshev coefficients.

This routine is mentioned here really, because it has an equivalent in SLATEC named PDA_DPCOEF. PDA_DPCOEF is more general, in that it returns coefficients for a Taylor series, i.e. a polynomial in (XX-X0) for given expansion point X0.

The old code would look like

      INTEGER I, K, K2, NROWS
      DOUBLE PRECISION A1(NROWS,K+1)
      DOUBLE PRECISION A2(K2+1), C(K2+1)
      DO 1 I = 1, K2+1
         A2(I) = A1(K2+1,I)
    1 CONTINUE
      CALL GEN_CHB2NO( K2, MIN(X()), MAX(X()), A2, C )

This would be replaced by

      INTEGER K, K2, IFAIL
      DOUBLE PRECISION A3( 3*M + 3*(K+1) )
      DOUBLE PRECISION C(K2+1)
      IFAIL = 0
      CALL PDA_DPCOEF( K2, 0D0, C, A3, IFAIL )
      IF ( IFAIL .NE. 0 ) THEN
         An error has occurred
      END IF

Just in case you are tempted to evaluate the polynomial yourself rather than use PDA_DP1VLU, here is a piece of code to get P = f(XX):

      INTEGER I, K2
      DOUBLE PRECISION XX, P
      DOUBLE PRECISION C(K2+1)
      P = C(K2+1)
      DO 2 I = K2, 1, -1
         P = P * XX
         P = P + C(I)
    2 CONTINUE



next up previous 196
Next: Two-dimensional Interpolation and Fitting
Up: One-dimensional Interpolation and Fitting, Splines
Previous: Replacing calls to E02AKF

PDA [1ex
Starlink User Note 194
H. Meyerdierks, D. Berry, P. W. Draper, G. Privett, M. Currie
12th October 2005
E-mail:ussc@star.rl.ac.uk

Copyright © 2009 Science and Technology Facilities Council