Skip to content

Commit a359c7c

Browse files
committed
Add complex tests
1 parent d367a85 commit a359c7c

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
@@ -810,12 +810,21 @@ end
810810
end
811811

812812
@testset "lmul!/rmul! by numbers" begin
813-
for A in (rand(4, 4), rand(ComplexF64,4,4),
813+
@testset "$(eltype(A))" for A in (rand(4, 4), rand(ComplexF64,4,4),
814814
fill([1 2; 3 4], 4, 4))
815815
B = copy(A)
816-
@test lmul!(2, B) == 2 * A
817-
B .= A
818-
@test rmul!(B, 2) == A * 2
816+
@testset for op in (transpose, adjoint)
817+
A .= B
818+
@test lmul!(2, op(A)) == 2 * op(B)
819+
A .= B
820+
@test rmul!(op(A), 2) == op(B) * 2
821+
if eltype(A) <: Complex
822+
A .= B
823+
@test lmul!(-2im, op(A)) == -2im * op(B)
824+
A .= B
825+
@test rmul!(op(A), -2im) == op(B) * -2im
826+
end
827+
end
819828
end
820829
end
821830

0 commit comments

Comments
 (0)