JuliaLang/julia — pull request #7146 by stevengj (2014-06-05 19:57:44+00:00)
Title: export @evalpoly macro (née @chorner)

This exports the `@evalpoly(z, c...)` macro for efficient inline evaluation of polynomials (either by Horner's rule or, for complex `z`, using a more efficient algorithm due to Knuth). Discussed in #7033 and commit 76a73350a658563beed46ba46762f814ba68f676.

This should probably *not* be merged until `isa(x, Complex)` is evaluated statically, as discussed in #7060, as otherwise it will cause a performance regression.

In Matlab, the analogous function is called `polyval`, but I intentionally did *not* use that name since the arguments are different: in Matlab you call`polyval(c, z)`, and the coefficients are in reverse order.

It might also be worth providing an `evalpoly(z, c)` function that does the same thing but at runtime.

cc: @StefanKarpinski, @jiahao