diff --git a/src/implementations/LinearAlgebra.jl b/src/implementations/LinearAlgebra.jl index de806ad9..b8115816 100644 --- a/src/implementations/LinearAlgebra.jl +++ b/src/implementations/LinearAlgebra.jl @@ -215,6 +215,13 @@ similar_array_type(::Type{Array{T,N}}, ::Type{S}) where {S,T,N} = Array{S,N} similar_array_type(::Type{BitArray{N}}, ::Type{S}) where {S,N} = Array{S,N} similar_array_type(::Type{BitArray{N}}, ::Type{Bool}) where {N} = BitArray{N} +function similar_array_type( + ::Type{<:SubArray{T,N,<:Array{T}}}, + ::Type{S}, +) where {S,T,N} + return Array{S,N} +end + function promote_operation( op::typeof(*), A::Type{<:AbstractArray{T}}, diff --git a/test/interface.jl b/test/interface.jl index bf75d10f..cfe56abf 100644 --- a/test/interface.jl +++ b/test/interface.jl @@ -206,3 +206,12 @@ end @test MA.mutability(z, *, z, z) == MA.IsNotMutable() @test MA.mutability(z, *, z, z, y) == MA.IsNotMutable() end + +@testset "issue_316_SubArray" begin + y = reshape([1.0], 1, 1, 1) + Y = view(y, :, :, 1) + ret = reshape([1.0], 1, 1) + ret = MA.operate!!(MA.add_mul, ret, 2.0, Y) + @test ret == reshape([3.0], 1, 1) + @test y == reshape([1.0], 1, 1, 1) +end