Skip to content

Commit

Permalink
Add single-term multiplication for AbstractQ on v1.10 and above (#5…
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub authored Dec 5, 2023
1 parent 0a4b810 commit 150c1ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stdlib/LinearAlgebra/src/abstractq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ qsize_check(Q::AbstractQ, P::AbstractQ) =
size(Q, 2) == size(P, 1) ||
throw(DimensionMismatch("second dimension of A, $(size(Q,2)), must coincide with first dimension of B, $(size(P,1))"))

# mimic the AbstractArray fallback
*(Q::AbstractQ{<:Number}) = Q

(*)(Q::AbstractQ, J::UniformScaling) = Q*J.λ
function (*)(Q::AbstractQ, b::Number)
T = promote_type(eltype(Q), typeof(b))
Expand Down
1 change: 1 addition & 0 deletions stdlib/LinearAlgebra/test/abstractq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ n = 5
T <: Complex && @test_throws ErrorException transpose(Q)
@test convert(AbstractQ{complex(T)}, Q) isa MyQ{complex(T)}
@test convert(AbstractQ{complex(T)}, Q') isa AdjointQ{<:complex(T),<:MyQ{complex(T)}}
@test *(Q) == Q
@test Q*I Q.Q*I rtol=2eps(real(T))
@test Q'*I Q.Q'*I rtol=2eps(real(T))
@test I*Q Q.Q*I rtol=2eps(real(T))
Expand Down

0 comments on commit 150c1ad

Please sign in to comment.