Skip to content

Commit

Permalink
Merge pull request #17841 from JuliaLang/ksh/docspecial
Browse files Browse the repository at this point in the history
Move trig and gamma docs out of helpDB, make them less verbose.
  • Loading branch information
tkelman authored Aug 6, 2016
2 parents 2d30203 + 0aac966 commit 3a9748a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 149 deletions.
144 changes: 0 additions & 144 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ tab-delimited text to `f` by either `writedlm(f, [x y])` or by `writedlm(f, zip(
"""
writedlm

"""
digamma(x)
Compute the digamma function of `x` (the logarithmic derivative of `gamma(x)`)
"""
digamma

"""
fill!(A, x)
Expand Down Expand Up @@ -523,13 +516,6 @@ A string giving the literal bit representation of a number.
"""
bits

"""
invdigamma(x)
Compute the inverse digamma function of `x`.
"""
invdigamma

"""
getindex(type[, elements...])
Expand Down Expand Up @@ -609,13 +595,6 @@ used as the final delimiter instead of `delim`.
"""
join(io, items, delim, last)

"""
lfact(x)
Compute the logarithmic factorial of `x`
"""
lfact

"""
deconv(b,a)
Expand Down Expand Up @@ -1007,15 +986,6 @@ Test whether a matrix is lower triangular.
"""
istril

"""
lgamma(x)
Compute the logarithm of the absolute value of [`gamma`](:func:`gamma`) for
[`Real`](:obj:`Real`) `x`, while for [`Complex`](:obj:`Complex`) `x` it computes the
logarithm of `gamma(x)`.
"""
lgamma

"""
bin(n, [pad])
Expand Down Expand Up @@ -1445,13 +1415,6 @@ Close an I/O stream. Performs a `flush` first.
"""
close(stream::IO)

"""
cospi(x)
Compute ``\\cos(\\pi x)`` more accurately than `cos(pi*x)`, especially for large `x`.
"""
cospi

"""
parentindexes(A)
Expand Down Expand Up @@ -2420,13 +2383,6 @@ Bessel function of the first kind of order 1, ``J_1(x)``.
"""
besselj1

"""
sinpi(x)
Compute ``\\sin(\\pi x)`` more accurately than `sin(pi*x)`, especially for large `x`.
"""
sinpi

"""
select!(v, k, [by=<transform>,] [lt=<comparison>,] [rev=false])
Expand Down Expand Up @@ -2872,13 +2828,6 @@ Seek a stream to the given position.
"""
seek

"""
acosd(x)
Compute the inverse cosine of `x`, where the output is in degrees.
"""
acosd

"""
triu(M)
Expand Down Expand Up @@ -3013,13 +2962,6 @@ Equivalent to `stat(file).size`.
"""
filesize

"""
sinc(x)
Compute ``\\sin(\\pi x) / (\\pi x)`` if ``x \\neq 0``, and ``1`` if ``x = 0``.
"""
sinc

"""
cglobal((symbol, library) [, type=Void])
Expand Down Expand Up @@ -3650,13 +3592,6 @@ Returns the smallest eigenvalue of `A`.
"""
eigmin

"""
acscd(x)
Compute the inverse cosecant of `x`, where the output is in degrees.
"""
acscd

"""
ltoh(x)
Expand Down Expand Up @@ -4142,13 +4077,6 @@ is `-1` the corresponding ID will not change. Only integer `owner`s and `group`s
"""
chown

"""
gamma(x)
Compute the gamma function of `x`.
"""
gamma

"""
sin(x)
Expand Down Expand Up @@ -4855,13 +4783,6 @@ For more information, see [^issue8859], [^B96], [^S84], [^KY88].
"""
pinv

"""
asecd(x)
Compute the inverse secant of `x`, where the output is in degrees.
"""
asecd

"""
readbytes!(stream::IO, b::AbstractVector{UInt8}, nb=length(b); all=true)
Expand All @@ -4888,13 +4809,6 @@ descriptive error string.
"""
ArgumentError

"""
atand(x)
Compute the inverse tangent of `x`, where the output is in degrees.
"""
atand

"""
KeyError(key)
Expand Down Expand Up @@ -5062,13 +4976,6 @@ Test whether a matrix is Hermitian.
"""
ishermitian

"""
sind(x)
Compute sine of `x`, where `x` is in degrees.
"""
sind

"""
min(x, y, ...)
Expand Down Expand Up @@ -5380,14 +5287,6 @@ two strings. For example
"""
join(strings, delim, last)

"""
polygamma(m, x)
Compute the polygamma function of order `m` of argument `x` (the `(m+1)th` derivative of the
logarithm of `gamma(x)`)
"""
polygamma

"""
isless(x, y)
Expand Down Expand Up @@ -6055,13 +5954,6 @@ Returns `string` with all characters converted to uppercase.
"""
uppercase

"""
cosd(x)
Compute cosine of `x`, where `x` is in degrees.
"""
cosd

"""
cycle(iter)
Expand Down Expand Up @@ -6500,13 +6392,6 @@ lengths of dimensions you asked for.
"""
size

"""
trigamma(x)
Compute the trigamma function of `x` (the logarithmic second derivative of `gamma(x)`).
"""
trigamma

"""
findmin(A, dims) -> (minval, index)
Expand Down Expand Up @@ -7188,13 +7073,6 @@ but throws an error for unordered arguments.
"""
cmp

"""
tand(x)
Compute tangent of `x`, where `x` is in degrees.
"""
tand

"""
issorted(v, [by=<transform>,] [lt=<comparison>,] [rev=false])
Expand Down Expand Up @@ -7583,14 +7461,6 @@ Test whether any values along the given dimensions of an array are `true`.
"""
any(::AbstractArray,dims)

"""
cosc(x)
Compute ``\\cos(\\pi x) / x - \\sin(\\pi x) / (\\pi x^2)`` if ``x \\neq 0``, and ``0`` if
``x = 0``. This is the derivative of `sinc(x)`.
"""
cosc

"""
getkey(collection, key, default)
Expand All @@ -7612,13 +7482,6 @@ For matrices or vectors ``A`` and ``B``, calculates ``Aᴴ Bᴴ``.
"""
Ac_mul_Bc

"""
acotd(x)
Compute the inverse cotangent of `x`, where the output is in degrees.
"""
acotd

"""
zeros(type, dims)
Expand Down Expand Up @@ -8313,13 +8176,6 @@ julia> f(apple)
"""
:@enum

"""
asind(x)
Compute the inverse sine of `x`, where the output is in degrees.
"""
asind

"""
widemul(x, y)
Expand Down
40 changes: 40 additions & 0 deletions base/special/gamma.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

gamma(x::Float64) = nan_dom_err(ccall((:tgamma,libm), Float64, (Float64,), x), x)
gamma(x::Float32) = nan_dom_err(ccall((:tgammaf,libm), Float32, (Float32,), x), x)

"""
gamma(x)
Compute the gamma function of `x`.
"""
gamma(x::Real) = gamma(float(x))
@vectorize_1arg Number gamma

Expand All @@ -19,6 +25,11 @@ lgamma_r(x::Real) = lgamma_r(float(x))
lgamma_r(x::Number) = lgamma(x), 1 # lgamma does not take abs for non-real x
"`lgamma_r(x)`: return L,s such that `gamma(x) = s * exp(L)`" lgamma_r

"""
lfact(x)
Compute the logarithmic factorial of `x`
"""
lfact(x::Real) = (x<=1 ? zero(float(x)) : lgamma(x+one(x)))
@vectorize_1arg Number lfact

Expand Down Expand Up @@ -47,6 +58,13 @@ function clgamma_lanczos(z)
return log(zz) - temp
end

"""
lgamma(x)
Compute the logarithm of the absolute value of [`gamma`](:func:`gamma`) for
[`Real`](:obj:`Real`) `x`, while for [`Complex`](:obj:`Complex`) `x` it computes the
logarithm of `gamma(x)`.
"""
function lgamma(z::Complex)
if real(z) <= 0.5
a = clgamma_lanczos(1-z)
Expand All @@ -69,6 +87,11 @@ gamma(z::Complex) = exp(lgamma(z))
# const A002445 = [1,6,30,42,30,66,2730,6,510,798,330,138,2730,6,870,14322,510,6,1919190,6,13530]
# const bernoulli = A000367 .// A002445 # even-index Bernoulli numbers

"""
digamma(x)
Compute the digamma function of `x` (the logarithmic derivative of `gamma(x)`)
"""
function digamma(z::Union{Float64,Complex{Float64}})
# Based on eq. (12), without looking at the accompanying source
# code, of: K. S. Kölbig, "Programs for computing the logarithm of
Expand Down Expand Up @@ -98,6 +121,11 @@ function digamma(z::Union{Float64,Complex{Float64}})
ψ -= t * @evalpoly(t,0.08333333333333333,-0.008333333333333333,0.003968253968253968,-0.004166666666666667,0.007575757575757576,-0.021092796092796094,0.08333333333333333,-0.4432598039215686)
end

"""
trigamma(x)
Compute the trigamma function of `x` (the logarithmic second derivative of `gamma(x)`).
"""
function trigamma(z::Union{Float64,Complex{Float64}})
# via the derivative of the Kölbig digamma formulation
x = real(z)
Expand Down Expand Up @@ -360,6 +388,12 @@ function zeta(s::Union{Int,Float64,Complex{Float64}},
return ζ
end

"""
polygamma(m, x)
Compute the polygamma function of order `m` of argument `x` (the `(m+1)th` derivative of the
logarithm of `gamma(x)`)
"""
function polygamma(m::Integer, z::Union{Float64,Complex{Float64}})
m == 0 && return digamma(z)
m == 1 && return trigamma(z)
Expand Down Expand Up @@ -445,6 +479,12 @@ function invdigamma(y::Float64)
return x_new
end
invdigamma(x::Float32) = Float32(invdigamma(Float64(x)))

"""
invdigamma(x)
Compute the inverse digamma function of `x`.
"""
invdigamma(x::Real) = invdigamma(Float64(x))
@vectorize_1arg Real invdigamma

Expand Down
Loading

0 comments on commit 3a9748a

Please sign in to comment.