diff --git a/src/kron.jl b/src/kron.jl index 25ee1174..5e66c5d4 100644 --- a/src/kron.jl +++ b/src/kron.jl @@ -12,15 +12,18 @@ function kron(A :: AbstractLinearOperator, B :: AbstractLinearOperator) p, q = size(B) T = promote_type(eltype(A), eltype(B)) function prod(x) - X = reshape(convert(Vector{T}, x), q, n) + S = promote_type(T, eltype(x)) + X = reshape(convert(Vector{S}, x), q, n) return Matrix(B * X * transpose(A))[:] end function tprod(x) - X = reshape(convert(Vector{T}, x), p, m) + S = promote_type(T, eltype(x)) + X = reshape(convert(Vector{S}, x), p, m) return Matrix(transpose(B) * X * A)[:] end function ctprod(x) - X = reshape(convert(Vector{T}, x), p, m) + S = promote_type(T, eltype(x)) + X = reshape(convert(Vector{S}, x), p, m) return Matrix(B' * X * conj(A))[:] end symm = issymmetric(A) && issymmetric(B) diff --git a/test/test_kron.jl b/test/test_kron.jl index 80bcb180..8fe0dc00 100644 --- a/test/test_kron.jl +++ b/test/test_kron.jl @@ -36,6 +36,15 @@ function test_kron() end end end + + @testset ExtendedTestSet "issue110" begin + A = rand(2, 2) + op = LinearOperator(A) + K = kron(A, op) + x = rand(Complex{Float64}, 4) + y = K * x + @test eltype(y) == Complex{Float64} + end end test_kron()