From 259cf83c76427bbd8c343ba982447135e91bbb9d Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Sat, 4 Oct 2025 14:47:16 +0100 Subject: [PATCH 01/12] Overload lmul!, rmul! for AbstractQ --- src/factorizations.jl | 4 ++-- src/lmul.jl | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/factorizations.jl b/src/factorizations.jl index 096c220..054c333 100644 --- a/src/factorizations.jl +++ b/src/factorizations.jl @@ -152,8 +152,8 @@ function copyto!(dest::AbstractArray, M::Ldiv{<:AbstractQLayout}) ldiv!(A,dest) end -materialize!(M::Lmul{LAY}) where LAY<:AbstractQLayout = error(LazyString("Overload materialize!(::Lmul{", LAY, "})")) -materialize!(M::Rmul{LAY}) where LAY<:AbstractQLayout = error(LazyString("Overload materialize!(::Rmul{", LAY, "})")) +materialize!(M::Lmul{LAY, LAY2}) where {LAY<:AbstractQLayout,LAY2} = error(LazyString("Overload materialize!(::Lmul{", LAY, ", ", LAY2, "})")) +materialize!(M::Rmul{LAY1, LAY}) where {LAY<:AbstractQLayout,LAY1} = error(LazyString("Overload materialize!(::Rmul{", LAY1, ", ", LAY, "})")) materialize!(M::Ldiv{<:AbstractQLayout}) = materialize!(Lmul(M.A',M.B)) diff --git a/src/lmul.jl b/src/lmul.jl index 37b938f..a1896c5 100644 --- a/src/lmul.jl +++ b/src/lmul.jl @@ -28,13 +28,13 @@ end const MatLmulVec{StyleA,StyleB} = Lmul{StyleA,StyleB,<:Union{AbstractMatrix,AbstractQ},<:AbstractVector} -const MatLmulMat{StyleA,StyleB} = Lmul{StyleA,StyleB,<:AbstractMatrix,<:AbstractMatrix} +const MatLmulMat{StyleA,StyleB} = Lmul{StyleA,StyleB,<:Union{AbstractMatrix,AbstractQ},<:Union{AbstractMatrix,AbstractQ}} const BlasMatLmulVec{StyleA,StyleB,T<:BlasFloat} = Lmul{StyleA,StyleB,<:Union{AbstractMatrix{T},AbstractQ{T}},<:AbstractVector{T}} -const BlasMatLmulMat{StyleA,StyleB,T<:BlasFloat} = Lmul{StyleA,StyleB,<:AbstractMatrix{T},<:AbstractMatrix{T}} +const BlasMatLmulMat{StyleA,StyleB,T<:BlasFloat} = Lmul{StyleA,StyleB,<:Union{AbstractMatrix{T},AbstractQ{T}},<:Union{AbstractMatrix{T},AbstractQ{T}}} const MatRmulMat{StyleA,StyleB} = Rmul{StyleA,StyleB,<:AbstractMatrix,<:AbstractMatrix} -const BlasMatRmulMat{StyleA,StyleB,T<:BlasFloat} = Rmul{StyleA,StyleB,<:AbstractMatrix{T},<:AbstractMatrix{T}} +const BlasMatRmulMat{StyleA,StyleB,T<:BlasFloat} = Rmul{StyleA,StyleB,<:Union{AbstractMatrix{T},AbstractQ{T}},<:Union{AbstractMatrix{T},AbstractQ{T}}} #### @@ -153,3 +153,10 @@ macro layoutrmul(Typ) ArrayLayouts.@_layoutrmul UnitLowerTriangular{T, <:Transpose{T,<:$Typ{T}}} where T end) end + + +LinearAlgebra.lmul!(Q::AbstractQ, v::LayoutVecOrMat) = lmul!(Q, v) +LinearAlgebra.lmul!(Q::Adjoint{<:Any,<:AbstractQ}, v::LayoutVecOrMat) = lmul!(Q, v) + +LinearAlgebra.rmul!(A::LayoutMatrix, Q::AbstractQ) = rmul!(A, Q) +LinearAlgebra.rmul!(A::LayoutMatrix, Q::Adjoint{<:Any,<:AbstractQ}) = rmul!(A, Q) \ No newline at end of file From d200d0fbccd73aeb71cf314a0a8a2611c921f917 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Sat, 4 Oct 2025 14:47:54 +0100 Subject: [PATCH 02/12] v1.11.3 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index fbf1532..e72c960 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ArrayLayouts" uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" authors = ["Sheehan Olver "] -version = "1.11.2" +version = "1.11.3" [deps] FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" From baac056273b168401540fc1776e5756e62314947 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Sat, 4 Oct 2025 14:49:19 +0100 Subject: [PATCH 03/12] Update ArrayLayouts.jl --- src/ArrayLayouts.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ArrayLayouts.jl b/src/ArrayLayouts.jl index b4c69c9..0b83065 100644 --- a/src/ArrayLayouts.jl +++ b/src/ArrayLayouts.jl @@ -81,6 +81,9 @@ end abstract type LayoutArray{T,N} <: AbstractArray{T,N} end const LayoutMatrix{T} = LayoutArray{T,2} const LayoutVector{T} = LayoutArray{T,1} +const LayoutVecOrMat{T} = Union{LayoutVector{T},LayoutMatrix{T}} +const LayoutVecOrMats{T} = Union{LayoutVecOrMat{T},SubArray{T,1,<:LayoutVecOrMat},SubArray{T,2,<:LayoutVecOrMat}} + ## TODO: Following are type piracy which may be removed in Julia v1.5 ## No, it can't, because strides(::AdjointAbsMat) is defined only for real eltype! @@ -374,9 +377,6 @@ end # printing ### -const LayoutVecOrMat{T} = Union{LayoutVector{T},LayoutMatrix{T}} -const LayoutVecOrMats{T} = Union{LayoutVecOrMat{T},SubArray{T,1,<:LayoutVecOrMat},SubArray{T,2,<:LayoutVecOrMat}} - layout_replace_in_print_matrix(_, A, i, j, s) = i in colsupport(A,j) ? s : Base.replace_with_centered_mark(s) From 508a32883e2817f1cef6a12014556a4c91ed7330 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Sat, 4 Oct 2025 16:01:36 +0100 Subject: [PATCH 04/12] fix AbstractQ ambiguituies --- src/ArrayLayouts.jl | 3 ++- src/factorizations.jl | 2 ++ src/lmul.jl | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/ArrayLayouts.jl b/src/ArrayLayouts.jl index 0b83065..b099de9 100644 --- a/src/ArrayLayouts.jl +++ b/src/ArrayLayouts.jl @@ -82,7 +82,8 @@ abstract type LayoutArray{T,N} <: AbstractArray{T,N} end const LayoutMatrix{T} = LayoutArray{T,2} const LayoutVector{T} = LayoutArray{T,1} const LayoutVecOrMat{T} = Union{LayoutVector{T},LayoutMatrix{T}} -const LayoutVecOrMats{T} = Union{LayoutVecOrMat{T},SubArray{T,1,<:LayoutVecOrMat},SubArray{T,2,<:LayoutVecOrMat}} +const LayoutMatrices{T} = Union{LayoutMatrix{T}, SubArray{T,2,<:LayoutVecOrMat}} +const LayoutVecOrMats{T} = Union{LayoutVecOrMat{T}, SubArray{T,1,<:LayoutVecOrMat}, SubArray{T,2,<:LayoutVecOrMat}} ## TODO: Following are type piracy which may be removed in Julia v1.5 diff --git a/src/factorizations.jl b/src/factorizations.jl index 054c333..2cfc3cd 100644 --- a/src/factorizations.jl +++ b/src/factorizations.jl @@ -134,6 +134,8 @@ mulreduce(M::Mul{<:AbstractQLayout}) = Lmul(M) mulreduce(M::Mul{<:Any,<:AbstractQLayout}) = Rmul(M) mulreduce(M::Mul{<:TriangularLayout,<:AbstractQLayout}) = Rmul(M) mulreduce(M::Mul{<:AbstractQLayout,<:TriangularLayout}) = Lmul(M) +mulreduce(M::Mul{<:DiagonalLayout, <:AbstractQLayout}) = Lmul(M) +mulreduce(M::Mul{<:AbstractQLayout, <:DiagonalLayout}) = Rmul(M) function copyto!(dest::AbstractArray{T}, M::Lmul{<:AbstractQLayout}) where T A,B = M.A,M.B diff --git a/src/lmul.jl b/src/lmul.jl index a1896c5..f81cac9 100644 --- a/src/lmul.jl +++ b/src/lmul.jl @@ -155,8 +155,8 @@ macro layoutrmul(Typ) end -LinearAlgebra.lmul!(Q::AbstractQ, v::LayoutVecOrMat) = lmul!(Q, v) -LinearAlgebra.lmul!(Q::Adjoint{<:Any,<:AbstractQ}, v::LayoutVecOrMat) = lmul!(Q, v) +LinearAlgebra.lmul!(Q::AbstractQ, v::LayoutVecOrMats) = lmul!(Q, v) +LinearAlgebra.lmul!(Q::Adjoint{<:Any,<:AbstractQ}, v::LayoutVecOrMats) = lmul!(Q, v) -LinearAlgebra.rmul!(A::LayoutMatrix, Q::AbstractQ) = rmul!(A, Q) -LinearAlgebra.rmul!(A::LayoutMatrix, Q::Adjoint{<:Any,<:AbstractQ}) = rmul!(A, Q) \ No newline at end of file +LinearAlgebra.rmul!(A::LayoutMatrices, Q::AbstractQ) = rmul!(A, Q) +LinearAlgebra.rmul!(A::LayoutMatrices, Q::Adjoint{<:Any,<:AbstractQ}) = rmul!(A, Q) \ No newline at end of file From c388a0b2f164ba31c64cbe8f2af32f993725b873 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 09:26:09 +0100 Subject: [PATCH 05/12] more mul --- src/ArrayLayouts.jl | 2 +- src/lmul.jl | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ArrayLayouts.jl b/src/ArrayLayouts.jl index b099de9..be03e08 100644 --- a/src/ArrayLayouts.jl +++ b/src/ArrayLayouts.jl @@ -17,7 +17,7 @@ import Base.Broadcast: BroadcastStyle, broadcastable, instantiate, materialize, using LinearAlgebra: AbstractQ, AbstractTriangular, AdjOrTrans, AdjointAbsVec, HermOrSym, HessenbergQ, QRCompactWYQ, QRPackedQ, RealHermSymComplexHerm, TransposeAbsVec, _apply_ipiv_rows!, checknonsingular, - checksquare, chkfullrank, cholcopy, ipiv2perm + checksquare, chkfullrank, cholcopy, ipiv2perm, QRCompactWYQ, AdjointQ, QRPackedQ using LinearAlgebra.BLAS: BlasComplex, BlasFloat, BlasReal diff --git a/src/lmul.jl b/src/lmul.jl index f81cac9..9e54536 100644 --- a/src/lmul.jl +++ b/src/lmul.jl @@ -156,7 +156,15 @@ end LinearAlgebra.lmul!(Q::AbstractQ, v::LayoutVecOrMats) = lmul!(Q, v) -LinearAlgebra.lmul!(Q::Adjoint{<:Any,<:AbstractQ}, v::LayoutVecOrMats) = lmul!(Q, v) +LinearAlgebra.lmul!(Q::AdjointQ, v::LayoutVecOrMats) = lmul!(Q, v) + +for Typ in (:QRCompactWYQ, :QRPackedQ) + @eval begin + LinearAlgebra.lmul!(Q::$Typ{<:Any,<:LayoutMatrix}, v::LayoutVecOrMats) = lmul!(Q, v) + LinearAlgebra.lmul!(Q::$Typ{<:Any,<:LayoutMatrix}, v::AbstractVecOrMat) = lmul!(Q, v) + LinearAlgebra.lmul!(Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}, v::LayoutVecOrMats) = lmul!(Q, v) + LinearAlgebra.lmul!(Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}, v::AbstractVecOrMat) = lmul!(Q, v) + end LinearAlgebra.rmul!(A::LayoutMatrices, Q::AbstractQ) = rmul!(A, Q) LinearAlgebra.rmul!(A::LayoutMatrices, Q::Adjoint{<:Any,<:AbstractQ}) = rmul!(A, Q) \ No newline at end of file From f9147cd8e2bb6716aac6541a0cd1501560dccd36 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 09:26:18 +0100 Subject: [PATCH 06/12] Update lmul.jl --- src/lmul.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lmul.jl b/src/lmul.jl index 9e54536..b60ebd5 100644 --- a/src/lmul.jl +++ b/src/lmul.jl @@ -165,6 +165,7 @@ for Typ in (:QRCompactWYQ, :QRPackedQ) LinearAlgebra.lmul!(Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}, v::LayoutVecOrMats) = lmul!(Q, v) LinearAlgebra.lmul!(Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}, v::AbstractVecOrMat) = lmul!(Q, v) end +end LinearAlgebra.rmul!(A::LayoutMatrices, Q::AbstractQ) = rmul!(A, Q) LinearAlgebra.rmul!(A::LayoutMatrices, Q::Adjoint{<:Any,<:AbstractQ}) = rmul!(A, Q) \ No newline at end of file From b402c149aa44c6d7831c633906c9bc88e4df6767 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 09:36:37 +0100 Subject: [PATCH 07/12] Update lmul.jl --- src/lmul.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lmul.jl b/src/lmul.jl index b60ebd5..e29f75f 100644 --- a/src/lmul.jl +++ b/src/lmul.jl @@ -33,7 +33,7 @@ const MatLmulMat{StyleA,StyleB} = Lmul{StyleA,StyleB,<:Union{AbstractMatrix,Abst const BlasMatLmulVec{StyleA,StyleB,T<:BlasFloat} = Lmul{StyleA,StyleB,<:Union{AbstractMatrix{T},AbstractQ{T}},<:AbstractVector{T}} const BlasMatLmulMat{StyleA,StyleB,T<:BlasFloat} = Lmul{StyleA,StyleB,<:Union{AbstractMatrix{T},AbstractQ{T}},<:Union{AbstractMatrix{T},AbstractQ{T}}} -const MatRmulMat{StyleA,StyleB} = Rmul{StyleA,StyleB,<:AbstractMatrix,<:AbstractMatrix} +const MatRmulMat{StyleA,StyleB} = Rmul{StyleA,StyleB,<:Union{AbstractMatrix,AbstractQ},<:Union{AbstractMatrix,AbstractQ}} const BlasMatRmulMat{StyleA,StyleB,T<:BlasFloat} = Rmul{StyleA,StyleB,<:Union{AbstractMatrix{T},AbstractQ{T}},<:Union{AbstractMatrix{T},AbstractQ{T}}} @@ -156,7 +156,6 @@ end LinearAlgebra.lmul!(Q::AbstractQ, v::LayoutVecOrMats) = lmul!(Q, v) -LinearAlgebra.lmul!(Q::AdjointQ, v::LayoutVecOrMats) = lmul!(Q, v) for Typ in (:QRCompactWYQ, :QRPackedQ) @eval begin @@ -167,5 +166,4 @@ for Typ in (:QRCompactWYQ, :QRPackedQ) end end -LinearAlgebra.rmul!(A::LayoutMatrices, Q::AbstractQ) = rmul!(A, Q) -LinearAlgebra.rmul!(A::LayoutMatrices, Q::Adjoint{<:Any,<:AbstractQ}) = rmul!(A, Q) \ No newline at end of file +LinearAlgebra.rmul!(A::LayoutMatrices, Q::AbstractQ) = rmul!(A, Q) \ No newline at end of file From 90c94970ee740e30b0668a63425332df81231f42 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 09:47:13 +0100 Subject: [PATCH 08/12] simplify LayoutMatrices --- src/ArrayLayouts.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ArrayLayouts.jl b/src/ArrayLayouts.jl index be03e08..c037a60 100644 --- a/src/ArrayLayouts.jl +++ b/src/ArrayLayouts.jl @@ -82,8 +82,8 @@ abstract type LayoutArray{T,N} <: AbstractArray{T,N} end const LayoutMatrix{T} = LayoutArray{T,2} const LayoutVector{T} = LayoutArray{T,1} const LayoutVecOrMat{T} = Union{LayoutVector{T},LayoutMatrix{T}} -const LayoutMatrices{T} = Union{LayoutMatrix{T}, SubArray{T,2,<:LayoutVecOrMat}} -const LayoutVecOrMats{T} = Union{LayoutVecOrMat{T}, SubArray{T,1,<:LayoutVecOrMat}, SubArray{T,2,<:LayoutVecOrMat}} +const LayoutMatrices{T} = Union{LayoutMatrix{T}, SubArray{T,2,<:LayoutMatrix}} +const LayoutVecOrMats{T} = Union{LayoutVecOrMat{T}, SubArray{T,1,<:LayoutVecOrMat}, SubArray{T,2,<:LayoutMatrix}} ## TODO: Following are type piracy which may be removed in Julia v1.5 From 6c090ffd66af0fdc42675df572feca9f647ebf67 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 09:59:08 +0100 Subject: [PATCH 09/12] Update lmul.jl --- src/lmul.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lmul.jl b/src/lmul.jl index e29f75f..1e0b2c3 100644 --- a/src/lmul.jl +++ b/src/lmul.jl @@ -155,7 +155,8 @@ macro layoutrmul(Typ) end -LinearAlgebra.lmul!(Q::AbstractQ, v::LayoutVecOrMats) = lmul!(Q, v) +# TODO: uncomment out. commented for now due to ambiguities +# LinearAlgebra.lmul!(Q::AbstractQ, v::LayoutVecOrMats) = lmul!(Q, v) for Typ in (:QRCompactWYQ, :QRPackedQ) @eval begin From a4de9adb3da9d9053e174e2dfedae7626073e606 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 11:02:51 +0100 Subject: [PATCH 10/12] increase cov --- src/lmul.jl | 7 +++++-- test/test_layoutarray.jl | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/lmul.jl b/src/lmul.jl index 1e0b2c3..5d728fa 100644 --- a/src/lmul.jl +++ b/src/lmul.jl @@ -157,6 +157,7 @@ end # TODO: uncomment out. commented for now due to ambiguities # LinearAlgebra.lmul!(Q::AbstractQ, v::LayoutVecOrMats) = lmul!(Q, v) +# LinearAlgebra.rmul!(A::LayoutMatrices, Q::AbstractQ) = rmul!(A, Q) for Typ in (:QRCompactWYQ, :QRPackedQ) @eval begin @@ -164,7 +165,9 @@ for Typ in (:QRCompactWYQ, :QRPackedQ) LinearAlgebra.lmul!(Q::$Typ{<:Any,<:LayoutMatrix}, v::AbstractVecOrMat) = lmul!(Q, v) LinearAlgebra.lmul!(Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}, v::LayoutVecOrMats) = lmul!(Q, v) LinearAlgebra.lmul!(Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}, v::AbstractVecOrMat) = lmul!(Q, v) + LinearAlgebra.rmul!(V::LayoutMatrices, Q::$Typ{<:Any,<:LayoutMatrix}) = rmul!(V, Q) + LinearAlgebra.rmul!(V::AbstractMatrix, Q::$Typ{<:Any,<:LayoutMatrix}) = rmul!(V, Q) + LinearAlgebra.rmul!(V::LayoutMatrices, Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}) = rmul!(V, Q) + LinearAlgebra.rmul!(V::AbstractMatrix, Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}) = rmul!(V, Q) end end - -LinearAlgebra.rmul!(A::LayoutMatrices, Q::AbstractQ) = rmul!(A, Q) \ No newline at end of file diff --git a/test/test_layoutarray.jl b/test/test_layoutarray.jl index 60a664a..9c0afed 100644 --- a/test/test_layoutarray.jl +++ b/test/test_layoutarray.jl @@ -602,6 +602,23 @@ Base.copy(A::MyVector) = MyVector(copy(A.A)) @test mul!(copy(B), D, A, 2.0, 3.0) ≈ mul!(copy(B), D, V, 2.0, 3.0) ≈ 2D * A + 3B @test mul!(copy(B), A, D, 2.0, 3.0) ≈ mul!(copy(B), V, D, 2.0, 3.0) ≈ 2A * D + 3B end + + @testset "QR" begin + A = randn(10,5) + Q̃ = qr(A).Q + Q = LinearAlgebra.QRCompactWYQ(MyMatrix(Q̃.factors), Q̃.T) + b = randn(10) + B = randn(10,3) + @test Q*b ≈ Q̃*b ≈ lmul!(Q, copy(b)) ≈ lmul!(Q, MyVector(copy(b))) + @test Q'b ≈ Q̃'b ≈ lmul!(Q', copy(b)) ≈ lmul!(Q', MyVector(copy(b))) + @test Q*B ≈ Q̃*B ≈ lmul!(Q, copy(B)) ≈ lmul!(Q, MyMatrix(copy(B))) + @test Q'B ≈ Q̃'B ≈ lmul!(Q', copy(B)) ≈ lmul!(Q', MyMatrix(copy(B))) + + @test B'Q ≈ B'Q̃ ≈ rmul!(copy(B'),Q) ≈ rmul!(MyMatrix(copy(B')), Q) + @test B'Q' ≈ B'Q̃' ≈ rmul!(copy(B'),Q') ≈ rmul!(MyMatrix(copy(B')), Q') + + @test_broken Q*b ≈ lmul!(Q̃, MyVector(copy(b))) # broken due to commented out code for ambiguity with MatrixFactorizations.jl + end end struct MyUpperTriangular{T} <: AbstractMatrix{T} From edcf0602c461366227ecb51e25622188fb5cffde Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 11:05:58 +0100 Subject: [PATCH 11/12] v1.12 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index e72c960..7334259 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ArrayLayouts" uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" authors = ["Sheehan Olver "] -version = "1.11.3" +version = "1.12" [deps] FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" From aeb6ef292fe43c4aa0b68dee15c989902100f37f Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 6 Oct 2025 11:21:22 +0100 Subject: [PATCH 12/12] increase coverage --- src/lmul.jl | 1 + test/test_layoutarray.jl | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lmul.jl b/src/lmul.jl index 5d728fa..0c9e26b 100644 --- a/src/lmul.jl +++ b/src/lmul.jl @@ -169,5 +169,6 @@ for Typ in (:QRCompactWYQ, :QRPackedQ) LinearAlgebra.rmul!(V::AbstractMatrix, Q::$Typ{<:Any,<:LayoutMatrix}) = rmul!(V, Q) LinearAlgebra.rmul!(V::LayoutMatrices, Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}) = rmul!(V, Q) LinearAlgebra.rmul!(V::AbstractMatrix, Q::AdjointQ{<:Any,<:$Typ{<:Any,<:LayoutMatrix}}) = rmul!(V, Q) + LinearAlgebra.rmul!(V::StridedVecOrMat{T}, Q::AdjointQ{<:Any,<:$Typ{T,<:LayoutMatrix}}) where T<:BlasReal = rmul!(V, Q) end end diff --git a/test/test_layoutarray.jl b/test/test_layoutarray.jl index 9c0afed..ce260fd 100644 --- a/test/test_layoutarray.jl +++ b/test/test_layoutarray.jl @@ -603,6 +603,15 @@ Base.copy(A::MyVector) = MyVector(copy(A.A)) @test mul!(copy(B), A, D, 2.0, 3.0) ≈ mul!(copy(B), V, D, 2.0, 3.0) ≈ 2A * D + 3B end + @testset "Diagonal * Q" begin + A = randn(10,5) + Q̃ = qr(A).Q + Q = LinearAlgebra.QRCompactWYQ(MyMatrix(Q̃.factors), Q̃.T) + D = Diagonal(1:10) + @test ArrayLayouts.mul(D, Q) ≈ ArrayLayouts.mul(D, Q̃) ≈ D*Q + @test ArrayLayouts.mul(Q, D) ≈ ArrayLayouts.mul(Q̃, D) ≈ Q*D + end + @testset "QR" begin A = randn(10,5) Q̃ = qr(A).Q @@ -616,7 +625,12 @@ Base.copy(A::MyVector) = MyVector(copy(A.A)) @test B'Q ≈ B'Q̃ ≈ rmul!(copy(B'),Q) ≈ rmul!(MyMatrix(copy(B')), Q) @test B'Q' ≈ B'Q̃' ≈ rmul!(copy(B'),Q') ≈ rmul!(MyMatrix(copy(B')), Q') - + + @test_throws ErrorException lmul!(Q, big.(B)) + @test_throws ErrorException lmul!(Q', big.(B)) + @test_throws ErrorException rmul!(big.(B'),Q') + @test_throws ErrorException rmul!(big.(B'),Q) + @test_broken Q*b ≈ lmul!(Q̃, MyVector(copy(b))) # broken due to commented out code for ambiguity with MatrixFactorizations.jl end end