diff --git a/stdlib/LinearAlgebra/src/abstractq.jl b/stdlib/LinearAlgebra/src/abstractq.jl index 2aa333beef2b2..b0d53320f4aa3 100644 --- a/stdlib/LinearAlgebra/src/abstractq.jl +++ b/stdlib/LinearAlgebra/src/abstractq.jl @@ -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)) diff --git a/stdlib/LinearAlgebra/test/abstractq.jl b/stdlib/LinearAlgebra/test/abstractq.jl index 83a26c6050484..19b872d685668 100644 --- a/stdlib/LinearAlgebra/test/abstractq.jl +++ b/stdlib/LinearAlgebra/test/abstractq.jl @@ -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))