Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/adjtrans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ function _dot_nonrecursive(u, v)
end
end

rmul!(X::AdjOrTrans, s::Number) = (lmul!(wrapperop(X)(s), parent(X)); X)
lmul!(s::Number, X::AdjOrTrans) = (rmul!(parent(X), wrapperop(X)(s)); X)

# Adjoint/Transpose-vector * vector
*(u::AdjointAbsVec{<:Number}, v::AbstractVector{<:Number}) = dot(u.parent, v)
*(u::TransposeAbsVec{T}, v::AbstractVector{T}) where {T<:Real} = dot(u.parent, v)
Expand Down
19 changes: 19 additions & 0 deletions test/adjtrans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -809,4 +809,23 @@ end
end
end

@testset "lmul!/rmul! by numbers" begin
@testset "$(eltype(A))" for A in (rand(4, 4), rand(ComplexF64,4,4),
fill([1 2; 3 4], 4, 4))
B = copy(A)
@testset for op in (transpose, adjoint)
A .= B
@test lmul!(2, op(A)) == 2 * op(B)
A .= B
@test rmul!(op(A), 2) == op(B) * 2
if eltype(A) <: Complex
A .= B
@test lmul!(-2im, op(A)) == -2im * op(B)
A .= B
@test rmul!(op(A), -2im) == op(B) * -2im
end
end
end
end

end # module TestAdjointTranspose