From 86bfdaa11b292447597892859d104bb317497c7e Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Sun, 7 Apr 2024 17:31:31 +0200 Subject: [PATCH] Fix multiplication of Layout Q matrices --- Project.toml | 2 +- src/MatrixFactorizations.jl | 1 + test/runtests.jl | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 1872b6a..4e6f9af 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "MatrixFactorizations" uuid = "a3b82374-2e81-5b9e-98ce-41277c0e4c87" -version = "2.1" +version = "2.1.1" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/MatrixFactorizations.jl b/src/MatrixFactorizations.jl index f80360a..3703c36 100644 --- a/src/MatrixFactorizations.jl +++ b/src/MatrixFactorizations.jl @@ -67,6 +67,7 @@ function _mul(Q::LayoutQ, b::AbstractVector) lmul!(convert(AbstractQtype{T}, Q), bnew) end (*)(Q::LayoutQ, B::AbstractMatrix) = _mul(Q, B) +(*)(Q::LayoutQ, B::LayoutQ) = ArrayLayouts.mul(Q, B) (*)(Q::LayoutQ, B::LayoutMatrix) = ArrayLayouts.mul(Q, B) # disambiguation w/ ArrayLayouts.jl function _mul(Q::LayoutQ, B::AbstractMatrix) T = promote_type(eltype(Q), eltype(B)) diff --git a/test/runtests.jl b/test/runtests.jl index 7927a5d..f97f403 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -444,6 +444,11 @@ end @test Q[2,3:4] == [Q[2,k] for k=3:4] @test Q[3:4,2] == [Q[k,2] for k=3:4] end + + @testset "Q * Q" begin + Q = ql(randn(5,5)).Q + @test Q*Q ≈ Matrix(Q)^2 + end end include("test_rq.jl")