The equivalent of this routine in SLATEC is PDA_DP1VLU. The NAG code would look like
INTEGER I, K, K2, NROWS, IFAIL DOUBLE PRECISION A1(NROWS,K+1) DOUBLE PRECISION A2(K2+1), XX, XCAP, P DO 1 I = 1, K2+1 A2(I) = A1(K2+1,I) 1 CONTINUE XCAP = ( ( XX - MIN(X()) ) - ( MAX(X()) - XX ) ) : / ( MAX(X()) - MIN(X()) ) IFAIL = 1 CALL E02AEF( K2+1, A2, XCAP, P, IFAIL ) IF ( IFAIL .NE. 0 ) THEN An error has occurred END IF
Here A1 is the coefficient matrix returned by E02ADF, A2 is the column extracted for the required degree. XX is the x value for which an evaluation is required, it must be scaled into the range 1 ... +1, using the original extreme x values passed to E02ADF. P returns the function value.
PDA_DP1VLU returns any number of derivatives in addition to the function value. The second argument specifies how many derivatives are required. No scaling of XX is necessary, and no processing of the coefficients A3 as returned by PDA_DPOLFT.
INTEGER K, K2, IFAIL DOUBLE PRECISION A3( 3*M + 3*(K+1) ) DOUBLE PRECISION XX, P, DUMMY IFAIL = 0 CALL PDA_DP1VLU( K2, 0, XX, P, DUMMY, A3, IFAIL ) IF ( IFAIL .NE. 0 ) THEN An error has occurred END IF