Partial Evaluation of the Euclidian Algorithm (Extended Version)

Olivier Danvy, Mayer Goldberg
1997 BRICS Report Series  
Some programs are easily amenable to partial evaluation because<br />their control flow clearly depends on one of their parameters. Specializing<br />such programs with respect to this parameter eliminates the<br />associated interpretive overhead. Some other programs, however, do<br />not exhibit this interpreter-like behavior. Each of them presents a challenge<br />for partial evaluation. The Euclidian algorithm is one of them,<br />and in this article, we make it amenable to partial
more » ... n.<br />We observe that the number of iterations in the Euclidian algorithm<br />is bounded by a number that can be computed given either of the two<br />arguments. We thus rephrase this algorithm using bounded recursion.<br />The resulting program is better suited for automatic unfolding and<br />thus for partial evaluation. Its specialization is efficient.<br />Keywords: partial evaluation, scientific computation.
doi:10.7146/brics.v4i1.18780 fatcat:sfii2n6lfbhongcyhyxjttxs4e