Skip to content

Commit 05d7c50

Browse files
committed
Update
1 parent 3f29e18 commit 05d7c50

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/implementations/LinearAlgebra.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,14 @@ function operate(
424424
# concrete. Bad things can happen if S or T is abstract and we pick the
425425
# wrong type for C.
426426
if !(isconcretetype(S) && isconcretetype(T))
427-
# We can't use A * B here, because this may StackOverflow via the chain:
428-
# *(A, B) -> mul(A, B) -> operate(*, A, B) -> *(A, B)
429-
# See MutableArithmetics.jl#336
430-
@assert axes(A, 2) == axes(B, 1)
431-
return [sum(A[i, j] * B[j] for j in axes(B, 1)) for i in axes(A, 1)]
427+
if S <: AbstractMutable || T <: AbstractMutable
428+
# We can't use A * B here, because this will StackOverflow via:
429+
# *(A, B) -> mul(A, B) -> operate(*, A, B) -> *(A, B)
430+
# See MutableArithmetics.jl#336
431+
@assert axes(A, 2) == axes(B, 1)
432+
return [sum(A[i, j] * B[j] for j in axes(B, 1)) for i in axes(A, 1)]
433+
end
434+
return A * B
432435
end
433436
C = undef_array(promote_array_mul(typeof(A), typeof(B)), axes(A, 1))
434437
return operate_to!(C, *, A, B)

0 commit comments

Comments
 (0)