Skip to content

Commit cc95725

Browse files
authored
Add single-term multiplication for AbstractQ on v1.10 and above (#52342)
1 parent 7316c82 commit cc95725

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/abstractq.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ qsize_check(Q::AbstractQ, P::AbstractQ) =
157157
size(Q, 2) == size(P, 1) ||
158158
throw(DimensionMismatch("second dimension of A, $(size(Q,2)), must coincide with first dimension of B, $(size(P,1))"))
159159

160+
# mimic the AbstractArray fallback
161+
*(Q::AbstractQ{<:Number}) = Q
162+
160163
(*)(Q::AbstractQ, J::UniformScaling) = Q*J.λ
161164
function (*)(Q::AbstractQ, b::Number)
162165
T = promote_type(eltype(Q), typeof(b))

test/abstractq.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ n = 5
3434
T <: Complex && @test_throws ErrorException transpose(Q)
3535
@test convert(AbstractQ{complex(T)}, Q) isa MyQ{complex(T)}
3636
@test convert(AbstractQ{complex(T)}, Q') isa AdjointQ{<:complex(T),<:MyQ{complex(T)}}
37+
@test *(Q) == Q
3738
@test Q*I Q.Q*I rtol=2eps(real(T))
3839
@test Q'*I Q.Q'*I rtol=2eps(real(T))
3940
@test I*Q Q.Q*I rtol=2eps(real(T))

0 commit comments

Comments
 (0)