Skip to content

Commit 278286c

Browse files
committed
Merge generic_normp methods
1 parent ec1d2a5 commit 278286c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/generic.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -597,18 +597,14 @@ end
597597
# Compute L_p norm ‖x‖ₚ = sum(abs(x).^p)^(1/p)
598598
# (Not technically a "norm" for p < 1.)
599599
function generic_normp(x, p)
600+
(v, s) = iterate(x)::Tuple
600601
if p > 1 || p < -1 # might need to rescale to avoid overflow
601602
maxabs = p > 1 ? normInf(x) : normMinusInf(x)
602603
(ismissing(maxabs) || iszero(maxabs) || isinf(maxabs)) && return maxabs
603-
return _generic_normp(x, p, maxabs)
604+
T = typeof(maxabs)
604605
else
605-
return _generic_normp(x, p)
606+
T = typeof(float(norm(v)))
606607
end
607-
end
608-
609-
function _generic_normp(x, p, maxabs::TM = nothing) where {TM}
610-
(v, s) = iterate(x)::Tuple
611-
T = isnothing(maxabs) ? typeof(float(norm(v))) : TM
612608
spp::promote_type(Float64, T) = p
613609
if -1 <= p <= 1 || (isfinite(length(x)*maxabs^spp) && !iszero(maxabs^spp)) # scaling not necessary
614610
sum::promote_type(Float64, T) = norm(v)^spp

0 commit comments

Comments
 (0)