Skip to content

Commit de35d8c

Browse files
committed
Add complex tests
1 parent 11584d4 commit de35d8c

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/adjtrans.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,8 @@ function _dot_nonrecursive(u, v)
513513
end
514514
end
515515

516-
rmul!(X::AdjOrTrans, s::Number) = (rmul!(parent(X), s); X)
517-
lmul!(s::Number, X::AdjOrTrans) = (lmul!(s, parent(X)); X)
516+
rmul!(X::AdjOrTrans, s::Number) = (lmul!(wrapperop(X)(s), parent(X)); X)
517+
lmul!(s::Number, X::AdjOrTrans) = (rmul!(parent(X), wrapperop(X)(s)); X)
518518

519519
# Adjoint/Transpose-vector * vector
520520
*(u::AdjointAbsVec{<:Number}, v::AbstractVector{<:Number}) = dot(u.parent, v)

test/adjtrans.jl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,12 +799,21 @@ end
799799
end
800800

801801
@testset "lmul!/rmul! by numbers" begin
802-
for A in (rand(4, 4), rand(ComplexF64,4,4),
802+
@testset "$(eltype(A))" for A in (rand(4, 4), rand(ComplexF64,4,4),
803803
fill([1 2; 3 4], 4, 4))
804804
B = copy(A)
805-
@test lmul!(2, B) == 2 * A
806-
B .= A
807-
@test rmul!(B, 2) == A * 2
805+
@testset for op in (transpose, adjoint)
806+
A .= B
807+
@test lmul!(2, op(A)) == 2 * op(B)
808+
A .= B
809+
@test rmul!(op(A), 2) == op(B) * 2
810+
if eltype(A) <: Complex
811+
A .= B
812+
@test lmul!(-2im, op(A)) == -2im * op(B)
813+
A .= B
814+
@test rmul!(op(A), -2im) == op(B) * -2im
815+
end
816+
end
808817
end
809818
end
810819

0 commit comments

Comments
 (0)