Skip to content

Commit e9dd10e

Browse files
committed
=Fix whitespace and line wrap
1 parent 508f33d commit e9dd10e

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

base/special/gamma.jl

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ function lgamma(z::Complex{Float64})
7373
else
7474
return Complex(NaN, NaN)
7575
end
76-
elseif x > 7 || yabs > 7 # use the Stirling asymptotic series for sufficiently large x or |y|
76+
elseif x > 7 || yabs > 7
77+
# use the Stirling asymptotic series for sufficiently large x or |y|
7778
return lgamma_asymptotic(z)
7879
elseif x < 0.1 # use reflection formula to transform to x > 0
7980
if x == 0 && y == 0 # return Inf with the correct imaginary part for z == 0
@@ -107,7 +108,8 @@ function lgamma(z::Complex{Float64})
107108
-2.2315475845357937976132853e-04,9.9457512781808533714662972e-05,
108109
-4.4926236738133141700224489e-05,2.0507212775670691553131246e-05)
109110
end
110-
# use recurrence relation lgamma(z) = lgamma(z+1) - log(z) to shift to x > 7 for asymptotic series
111+
# use recurrence relation lgamma(z) = lgamma(z+1) - log(z )
112+
# to shift to x > 7 for asymptotic series
111113
shiftprod = Complex(x,yabs)
112114
x += 1
113115
sb = false # == signbit(imag(shiftprod)) == signbit(yabs)
@@ -394,7 +396,8 @@ function zeta(s::Union{Int, ComplexOrReal{Float64}},
394396
minus_z = -z
395397
ζ += pow_oftype(ζ, minus_z, minus_s) # ν = 0 term
396398
if xf != z
397-
ζ += pow_oftype(ζ, z - nx, minus_s) # real(z - nx) > 0, so use correct branch cut
399+
ζ += pow_oftype(ζ, z - nx, minus_s)
400+
# real(z - nx) > 0, so use correct branch cut
398401
# otherwise, if xf==z, then the definition skips this term
399402
end
400403
# do loop in different order, depending on the sign of s,
@@ -447,8 +450,8 @@ end
447450
"""
448451
polygamma(m, x)
449452
450-
Compute the polygamma function of order `m` of argument `x` (the `(m+1)th` derivative of the
451-
logarithm of `gamma(x)`)
453+
Compute the polygamma function of order `m` of argument `x`
454+
(the `(m+1)th` derivative of the logarithm of `gamma(x)`)
452455
"""
453456
function polygamma(m::Integer, z::ComplexOrReal{Float64})
454457
m == 0 && return digamma(z)
@@ -511,7 +514,8 @@ end
511514
"""
512515
beta(x, y)
513516
514-
Euler integral of the first kind ``\\operatorname{B}(x,y) = \\Gamma(x)\\Gamma(y)/\\Gamma(x+y)``.
517+
Euler integral of the first kind
518+
``\\operatorname{B}(x,y) = \\Gamma(x)\\Gamma(y)/\\Gamma(x+y)``.
515519
"""
516520
function beta(x::Number, w::Number)
517521
yx, sx = lgamma_r(x)
@@ -611,10 +615,11 @@ end
611615
# and if we really cared about half precision, we could make a faster
612616
# Float16 version, by using a precomputed table look-up.
613617

614-
# Float16, and Float32 and their Complex equivalents can be cast to Float64
615-
# and results cast back. Similar for BitIntegers (eg Int32), but no casting back
618+
# Float16, and Float32 and their Complex equivalents can be converted to Float64
619+
# and results converted back. Similar for BitIntegers (eg Int32), but no converting back
616620
# Otherwise, we need to make things use their own `float` converting methods
617-
# and in those cases, we do not cast back either.
621+
# and in those cases, we do not convert back either as we assume
622+
# they also implement there own versions of the functions
618623

619624

620625
ofpromotedtype(as::Tuple, c) = convert(promote_type(typeof.(as)...), c)
@@ -632,19 +637,19 @@ for f in (:digamma, :trigamma, :zeta, :eta, :invdigamma)
632637
@eval begin
633638
$f(z::ComplexOrRealUnion(Base.BitInteger.types...)) = $f(f64(z))
634639
$f(z::ComplexOrRealUnion(Float16,Float32)) = oftype(z, $f(f64(z)))
635-
640+
636641
function $f(z::Number)
637642
x = float(z)
638643
typeof(x) == typeof(z) && throw(MethodError($f, (z,)))
639-
# There is nothing to fallback to, since this didn't work
644+
# There is nothing to fallback to, since this didn't change the argument types
640645
$f(x)
641646
end
642647
end
643648
end
644649

645-
646-
polygamma(m::Integer, z::ComplexOrRealUnion(Float16,Float32)) = oftype(z, polygamma(m, f64(z)))
647-
650+
function polygamma(m::Integer, z::ComplexOrRealUnion(Float16,Float32))
651+
oftype(z, polygamma(m, f64(z)))
652+
end
648653

649654
for T1 in types_le_Float64, T2 in types_le_Float64
650655
if (T1 == T2 == Float64) || (T1 == Int && T2 == Float64)
@@ -664,12 +669,12 @@ for T1 in types_le_Float64, T2 in types_le_Float64
664669
end
665670
end
666671

667-
# this is the one definition that is skipped
672+
# this is the one definition that is skipped
668673
function zeta(s::Complex{Int}, z::ComplexOrReal{Float64})::Complex{Float64}
669674
zeta(f64(s), f64(z))
670675
end
671676

672-
function zeta(s::Integer, z::Number)
677+
function zeta(s::Integer, z::Number)
673678
x = float(z)
674679
t = Int(s) # One could worry here about converting a BigInteger into a Int32/Int64
675680
if typeof(x) === typeof(z) && typeof(t) === typeof(s)
@@ -680,7 +685,7 @@ function zeta(s::Integer, z::Number)
680685
end
681686

682687

683-
function zeta(s::Number, z::Number)
688+
function zeta(s::Number, z::Number)
684689
x = float(z)
685690
t = float(s)
686691
if typeof(x) === typeof(z) && typeof(t) === typeof(s)

0 commit comments

Comments
 (0)