From 02f2d79887238d51bbd2dbe236a5f3eae4f6d759 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Tue, 22 Aug 2023 13:24:09 +0100 Subject: [PATCH] =?UTF-8?q?Support=20copymutable=20dispatching=20on=20size?= =?UTF-8?q?,=20used=20in=20InfiniteLinearAlgebr=E2=80=A6=20(#53)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Support copymutable dispatching on size, used in InfiniteLinearAlgebra.jl * Update MatrixFactorizations.jl * Update runtests.jl --- Project.toml | 2 +- src/MatrixFactorizations.jl | 3 +++ test/runtests.jl | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index e1153b0..1872b6a 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "MatrixFactorizations" uuid = "a3b82374-2e81-5b9e-98ce-41277c0e4c87" -version = "2.0.1" +version = "2.1" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/MatrixFactorizations.jl b/src/MatrixFactorizations.jl index c073e5d..f80360a 100644 --- a/src/MatrixFactorizations.jl +++ b/src/MatrixFactorizations.jl @@ -50,6 +50,9 @@ abstract type LayoutQ{T} <: AbstractQ{T} end @_layoutrmul LayoutQ @_layoutrmul AdjointQtype{<:Any,<:LayoutQ} +LinearAlgebra.copymutable(Q::LayoutQ) = copymutable_size(size(Q), Q) +copymutable_size(sz, Q) = lmul!(Q, Matrix{eltype(Q)}(I, sz)) + (*)(Q::LayoutQ, b::AbstractVector) = _mul(Q, b) (*)(Q::LayoutQ, b::LayoutVector) = ArrayLayouts.mul(Q, b) # disambiguation w/ ArrayLayouts.jl function _mul(Q::LayoutQ, b::AbstractVector) diff --git a/test/runtests.jl b/test/runtests.jl index 77d1c66..7927a5d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -436,6 +436,14 @@ end @test Q' * LowerTriangular(L) ≈ Q' * L @test LowerTriangular(L)' * Q' ≈ A' end + + @testset "row/col slices via copymutable" begin + n = 5 + A = randn(n,n) + Q, L = ql(A) + @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 end include("test_rq.jl")