Skip to content

Commit d367a85

Browse files
committed
Specialize lmul!/rmul! for adjoint/transpose
1 parent c5d7122 commit d367a85

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/adjtrans.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ 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)
518+
516519
# Adjoint/Transpose-vector * vector
517520
*(u::AdjointAbsVec{<:Number}, v::AbstractVector{<:Number}) = dot(u.parent, v)
518521
*(u::TransposeAbsVec{T}, v::AbstractVector{T}) where {T<:Real} = dot(u.parent, v)

test/adjtrans.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,4 +809,14 @@ end
809809
end
810810
end
811811

812+
@testset "lmul!/rmul! by numbers" begin
813+
for A in (rand(4, 4), rand(ComplexF64,4,4),
814+
fill([1 2; 3 4], 4, 4))
815+
B = copy(A)
816+
@test lmul!(2, B) == 2 * A
817+
B .= A
818+
@test rmul!(B, 2) == A * 2
819+
end
820+
end
821+
812822
end # module TestAdjointTranspose

0 commit comments

Comments
 (0)