Skip to content

Commit 51dc733

Browse files
authored
Fix QLayout (#16)
1 parent 04c8226 commit 51dc733

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ArrayLayouts"
22
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
33
authors = ["Sheehan Olver <[email protected]>"]
4-
version = "0.2.5"
4+
version = "0.2.6"
55

66
[deps]
77
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"

src/factorizations.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ function copyto!(dest::AbstractArray, M::Ldiv{<:AbstractQLayout})
2626
end
2727

2828
materialize!(M::Lmul{LAY}) where LAY<:AbstractQLayout = error("Overload materialize!(::Lmul{$(LAY)})")
29-
materialize!(M::Rmul{LAY}) where LAY<:AbstractQLayout = error("Overload materialize!(::Lmul{$(LAY)})")
29+
materialize!(M::Rmul{LAY}) where LAY<:AbstractQLayout = error("Overload materialize!(::Rmul{$(LAY)})")
30+
31+
materialize!(M::Lmul{QLayout}) = LinearAlgebra.lmul!(M.A, M.B)
32+
33+
3034
materialize!(M::Ldiv{<:AbstractQLayout}) = materialize!(Lmul(M.A',M.B))
3135

36+
3237
_qr(layout, axes, A; kwds...) = Base.invoke(qr, Tuple{AbstractMatrix{eltype(A)}}, A; kwds...)
3338
_qr(layout, axes, A, pivot::P; kwds...) where P = Base.invoke(qr, Tuple{AbstractMatrix{eltype(A)},P}, A, pivot; kwds...)
3439
_lu(layout, axes, A; kwds...) = Base.invoke(lu, Tuple{AbstractMatrix{eltype(A)}}, A; kwds...)

src/lmul.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ end
5858
materialize!(Rmul(dest,M.B))
5959
end
6060

61-
materialize!(M::Lmul) = lmul!(M.A,M.B)
62-
materialize!(M::Rmul) = rmul!(M.A,M.B)
61+
materialize!(M::Lmul) = LinearAlgebra.lmul!(M.A,M.B)
62+
materialize!(M::Rmul) = LinearAlgebra.rmul!(M.A,M.B)
6363

6464

6565

src/triangular.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ BLAS.trmm!('L', 'L', 'C', UNIT, one(T), triangulardata(A)', x)
7171
end
7272

7373

74-
materialize!(M::MatLmulMat{<:TriangularLayout}) = lmul!(M.A, M.B)
74+
materialize!(M::MatLmulMat{<:TriangularLayout}) = LinearAlgebra.lmul!(M.A, M.B)
7575

7676
###
7777
# Rmul

test/runtests.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
using ArrayLayouts, Test
1+
using ArrayLayouts, Random, Test
22
import ArrayLayouts: MemoryLayout, @_layoutlmul, triangulardata
33

4+
Random.seed!(0)
5+
46
include("test_layouts.jl")
57
include("test_muladd.jl")
68
include("test_ldiv.jl")
@@ -83,4 +85,12 @@ triangulardata(A::MyUpperTriangular) = triangulardata(A.A)
8385
@test lmul!(U, copy(B)) U * B
8486

8587
@test_skip lmul!(U,view(copy(B),collect(1:5),1:5)) U * B
88+
end
89+
90+
@testset "AbstractQ" begin
91+
Q = qr(randn(5,5)).Q
92+
b = randn(5)
93+
@test MemoryLayout(Q) isa QLayout
94+
@test all(materialize!(Lmul(Q,copy(b))) .=== lmul!(Q,copy(b)))
95+
@test all(materialize!(Lmul(Q',copy(b))) .=== lmul!(Q',copy(b)))
8696
end

0 commit comments

Comments
 (0)