Download Numerical Computation Guide

Transcript
CODE EXAMPLE A-17
Evaluating a Continued Fraction and Its Derivative Using
Presubstitution – SPARC (Continued)
structure /fex_info_t/
integer op, flags
record /fex_numeric_t/ op1, op2, res
end structure
integer ex
record /fex_info_t/ info
common /presub/ p
double precision p, d_infinity
volatile
p
c 4 = fex_double; see <fenv.h> for this and other constants
info.res.type = 4
c x'80' = FEX_INV_ZMI
if (loc(ex) .eq. x'80') then
info.res.d = p
else
info.res.d = d_infinity()
endif
return
end
c
c Evaluate the continued fraction given by coefficients a(j) and
c b(j) at the point x; return the function value in f and the
c derivative in f1
c
subroutine continued_fraction(n, a, b, x, f, f1)
integer
double precision
n
a(*), b(*), x, f, f1
common
/presub/ p
integer
j, oldhdl
dimension
oldhdl(24)
double precision d, d1, q, p, t
volatile
p, t
Appendix A
Examples
157