Skip to content

Commit 804015f

Browse files
author
Michael Abbott
committed
one more
1 parent 1b7307f commit 804015f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/rulesets/LinearAlgebra/norm.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ end
108108

109109
function _normp_back_x(x, p, y, Δy)
110110
c = real(Δy) / y
111-
∂x = broadcast(x) do xi
111+
T = promote_type(eltype(x), typeof(c))
112+
∂x = similar(x, T) # same comment as _norm1_back about allocation and type-stability.
113+
∂x = broadcast!(∂x, x) do xi
112114
a = norm(xi)
113115
∂xi = xi * ((a / y)^(p - 2) * c)
114116
return ifelse(isfinite(∂xi), ∂xi, zero(∂xi))

0 commit comments

Comments
 (0)