@@ -22,9 +22,14 @@ promote_rule(::Type{<:AbstractMatrix{T}}, ::Type{<:AbstractQ{T}}) where {T} =
22
22
(@inline ; Union{AbstractMatrix{T},AbstractQ{T}})
23
23
24
24
# conversion
25
- AbstractQ {S} (Q:: AbstractQ{S} ) where {S} = Q
26
- # the following eltype promotion needs to be defined for each subtype
25
+ # the following eltype promotion should be defined for each subtype `QType`
27
26
# convert(::Type{AbstractQ{T}}, Q::QType) where {T} = QType{T}(Q)
27
+ # and then care has to be taken that
28
+ # QType{T}(Q::QType{T}) where T = ...
29
+ # is implemented as a no-op
30
+
31
+ # the following conversion method ensures functionality when the above method is not defined
32
+ # (as for HessenbergQ), but no eltype conversion is required either (say, in multiplication)
28
33
convert (:: Type{AbstractQ{T}} , Q:: AbstractQ{T} ) where {T} = Q
29
34
convert (:: Type{AbstractQ{T}} , adjQ:: AdjointQ{T} ) where {T} = adjQ
30
35
convert (:: Type{AbstractQ{T}} , adjQ:: AdjointQ ) where {T} = convert (AbstractQ{T}, adjQ. Q)'
@@ -36,7 +41,6 @@ Matrix(Q::AbstractQ{T}) where {T} = Matrix{T}(Q)
36
41
Array {T} (Q:: AbstractQ ) where {T} = Matrix {T} (Q)
37
42
Array (Q:: AbstractQ ) = Matrix (Q)
38
43
convert (:: Type{T} , Q:: AbstractQ ) where {T<: Array } = T (Q)
39
- convert (:: Type{T} , Q:: AbstractQ ) where {T<: Matrix } = T (Q)
40
44
# legacy
41
45
@deprecate (convert (:: Type{AbstractMatrix{T}} , Q:: AbstractQ ) where {T},
42
46
convert (LinearAlgebra. AbstractQ{T}, Q))
@@ -227,11 +231,9 @@ QRCompactWYQ{S}(factors::AbstractMatrix, T::AbstractMatrix) where {S} =
227
231
@deprecate (QRCompactWYQ {S,M} (factors:: AbstractMatrix{S} , T:: AbstractMatrix{S} ) where {S,M},
228
232
QRCompactWYQ {S,M,typeof(T)} (factors, T), false )
229
233
230
- QRPackedQ {T} (Q:: QRPackedQ ) where {T} = QRPackedQ (convert (AbstractMatrix{T}, Q. factors), convert (Vector {T}, Q. τ))
234
+ QRPackedQ {T} (Q:: QRPackedQ ) where {T} = QRPackedQ (convert (AbstractMatrix{T}, Q. factors), convert (AbstractVector {T}, Q. τ))
231
235
QRCompactWYQ {S} (Q:: QRCompactWYQ ) where {S} = QRCompactWYQ (convert (AbstractMatrix{S}, Q. factors), convert (AbstractMatrix{S}, Q. T))
232
236
233
- AbstractQ {S} (Q:: QRPackedQ ) where {S} = QRPackedQ {S} (Q)
234
- AbstractQ {S} (Q:: QRCompactWYQ ) where {S} = QRCompactWYQ {S} (Q)
235
237
# override generic square fallback
236
238
Matrix {T} (Q:: Union{QRCompactWYQ{S},QRPackedQ{S}} ) where {T,S} =
237
239
convert (Matrix{T}, lmul! (Q, Matrix {S} (I, size (Q, 1 ), min (size (Q. factors)... ))))
@@ -505,7 +507,7 @@ struct LQPackedQ{T,S<:AbstractMatrix{T},C<:AbstractVector{T}} <: AbstractQ{T}
505
507
τ:: C
506
508
end
507
509
508
- LQPackedQ {T} (Q:: LQPackedQ ) where {T} = LQPackedQ (convert (AbstractMatrix{T}, Q. factors), convert (Vector {T}, Q. τ))
510
+ LQPackedQ {T} (Q:: LQPackedQ ) where {T} = LQPackedQ (convert (AbstractMatrix{T}, Q. factors), convert (AbstractVector {T}, Q. τ))
509
511
@deprecate (AbstractMatrix {T} (Q:: LQPackedQ ) where {T},
510
512
convert (AbstractQ{T}, Q),
511
513
false )
0 commit comments