Skip to content

Commit 1154539

Browse files
committed
small fixes
1 parent 46b91eb commit 1154539

File tree

1 file changed

+10
-5
lines changed
  • stdlib/LinearAlgebra/src

1 file changed

+10
-5
lines changed

stdlib/LinearAlgebra/src/qr.jl

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ QRCompactWYQ{S}(Q::QRCompactWYQ) where {S} = QRCompactWYQ(convert(AbstractMatrix
580580
AbstractMatrix{S}(Q::QRCompactWYQ{S}) where {S} = Q
581581
AbstractMatrix{S}(Q::QRCompactWYQ) where {S} = QRCompactWYQ{S}(Q)
582582
Matrix{T}(Q::AbstractQ{S}) where {T,S} = convert(Matrix{T}, lmul!(Q, Matrix{S}(I, size(Q, 1), min(size(Q.factors)...))))
583+
Matrix{T}(adjQ::AdjointQ{S}) where {T,S} = convert(Matrix{T}, lmul!(adjQ, Matrix{S}(I, size(adjQ))))
583584
Matrix(Q::AbstractQ{T}) where {T} = Matrix{T}(Q)
584585
Array{T}(Q::AbstractQ) where {T} = Matrix{T}(Q)
585586
Array(Q::AbstractQ) = Matrix(Q)
@@ -592,14 +593,14 @@ convert(::Type{AbstractQ{T}}, Q::QRPackedQ) where {T} = QRPackedQ{T}(Q)
592593
convert(::Type{AbstractQ{T}}, Q::QRCompactWYQ) where {T} = QRCompactWYQ{T}(Q)
593594
convert(::Type{AbstractQ{T}}, adjQ::AdjointQ) where {T} = adjoint(convert(AbstractQ{T}, adjQ.Q))
594595

595-
size(F::Union{QR,QRCompactWY,QRPivoted}, dim::Integer) = size(getfield(F, :factors), dim)
596596
size(F::Union{QR,QRCompactWY,QRPivoted}) = size(getfield(F, :factors))
597+
size(F::Union{QR,QRCompactWY,QRPivoted}, dim::Integer) = size(getfield(F, :factors), dim)
598+
size(Q::AbstractQ, dim::Integer) = dim in (1, 2) ? size(Q)[dim] : 1
597599
size(Q::Union{QRCompactWYQ,QRPackedQ}, dim::Integer) =
598-
size(getfield(Q, :factors), dim == 2 ? 1 : dim)
599-
size(Q::Union{QRCompactWYQ,QRPackedQ}) = size(Q, 1), size(Q, 1)
600+
size(Q.factors, dim == 2 ? 1 : dim)
601+
size(Q::Union{QRCompactWYQ,QRPackedQ}) = (n = size(Q.factors, 1); (n, n))
600602
size(adjQ::AdjointQ) = size(adjQ.Q, 2), size(adjQ.Q, 1)
601-
size(adjQ::AdjointQ, dim::Integer) = dim in (1, 2) ? size(adjQ)[dim] : 1
602-
# pseudo-array behvaiour, required for indexing with `begin` or `end`
603+
# pseudo-array behaviour, required for indexing with `begin` or `end`
603604
axes(Q::AbstractQ) = map(Base.OneTo, size(Q))
604605
axes(Q::AbstractQ, d::Integer) = d in (1, 2) ? axes(Q)[d] : Base.OneTo(1)
605606

@@ -878,6 +879,10 @@ function *(adjA::Adjoint{<:Any,<:AbstractVecOrMat}, adjQ::AdjointQ)
878879
return rmul!(Ac, convert(AbstractQ{TAQ}, adjQ))
879880
end
880881

882+
### QQ (including adjoints)
883+
*(Q::AbstractQ, P::AbstractQ) = Q * (P*I)
884+
mul!(C::StridedVecOrMat{T}, Q::AbstractQ{T}, B::AbstractQ{T}) where {T} = mul!(C, Q, B*I)
885+
881886
### mul!
882887
function mul!(C::StridedVecOrMat{T}, Q::AbstractQ{T}, B::AbstractVecOrMat{T}) where {T}
883888
require_one_based_indexing(C, B)

0 commit comments

Comments
 (0)