Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: add complex polygamma and Hurwitz zeta functions #7125

Merged
merged 3 commits into from
Jun 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ Library improvements

* Broadcasting `.//` is now included ([#7094]).

* `prevfloat` and `nextfloat` now saturate at -Inf and Inf,
respectively, and have otherwise been fixed to follow the IEEE-754
standard functions `nextDown` and `nextUp` ([#5025]).

* New function `widen` for widening numeric types and values, and `widemul`
for multiplying to a larger type ([#6169]).

* `polygamma`, `digamma`, and `trigamma` now accept complex
arguments, and `zeta(s, z)` now provides the Hurwitz zeta ([#7125]).

* `String` improvements

* Triple-quoted regex strings, `r"""..."""` ([#4934]).
Expand Down Expand Up @@ -258,10 +268,6 @@ Library improvements
* New function `deleteat!` deletes a specified index or indices and
returns the updated collection

* `prevfloat` and `nextfloat` now saturate at -Inf and Inf, respectively, and
have otherwise been fixed to follow the IEEE-754 standard functions `nextDown`
and `nextUp` ([#5025]).

* The `setenv` function for external processes now accepts a `dir` keyword
argument for specifying the directory to start the child process in ([#4888]).

Expand All @@ -271,9 +277,6 @@ Library improvements
* Ranges and arrays with the same elements are now unequal. This allows hashing
and comparing ranges to be faster. ([#5778])

* New function `widen` for widening numeric types and values, and `widemul`
for multiplying to a larger type ([#6169])

* Broadcasting now works on arbitrary `AbstractArrays` ([#5387])

* Reduction functions that accept a pre-allocated output array, including
Expand Down
27 changes: 27 additions & 0 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,33 @@ macro horner(x, p...)
ex
end

# Evaluate p[1] + z*p[2] + z^2*p[3] + ... + z^(n-1)*p[n], assuming
# the p[k] are *real* coefficients. This uses Horner's method if z
# is real, but for complex z it uses a more efficient algorithm described
# in Knuth, TAOCP vol. 2, section 4.6.4, equation (3).
macro chorner(z, p...)
a = :($(esc(p[end])))
b = :($(esc(p[end-1])))
as = {}
for i = length(p)-2:-1:1
ai = symbol(string("a", i))
push!(as, :($ai = $a))
a = :($b + r*$ai)
b = :($(esc(p[i])) - s * $ai)
end
ai = :a0
push!(as, :($ai = $a))
C = Expr(:block,
:(x = real($(esc(z)))),
:(y = imag($(esc(z)))),
:(r = x + x),
:(s = x*x + y*y),
as...,
:($ai * $(esc(z)) + $b))
R = Expr(:macrocall, symbol("@horner"), esc(z), p...)
:(isa($(esc(z)), Real) ? $R : $C)
end

rad2deg(z::Real) = oftype(z, 57.29577951308232*z)
deg2rad(z::Real) = oftype(z, 0.017453292519943295*z)
rad2deg(z::Integer) = rad2deg(float(z))
Expand Down
Loading