From aea984e6bafcd62133ce05848a9c59a186f60fd3 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Fri, 14 Jul 2023 14:17:16 +0530 Subject: [PATCH 1/3] Test on Julia v1.10 (#151) --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab4160f..dae32cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: version: - '1.6' - '1' + - '~1.10.0-0' os: - ubuntu-latest - macOS-latest From ca1152e02fb66563e107231cc2499338f683d778 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 17 Jul 2023 16:11:50 +0100 Subject: [PATCH 2/3] UpperOrLowerTriangular layout mul (#152) * UpperOrLowerTriangular layout mul * Update test_layoutarray.jl --- Project.toml | 2 +- src/ArrayLayouts.jl | 2 +- src/mul.jl | 6 ++++++ src/triangular.jl | 4 ++-- test/test_layoutarray.jl | 9 +++++++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Project.toml b/Project.toml index ba4ccfd..68e21a4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ArrayLayouts" uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" authors = ["Sheehan Olver "] -version = "1.0.11" +version = "1.0.12" [deps] FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" diff --git a/src/ArrayLayouts.jl b/src/ArrayLayouts.jl index e9e4402..f310777 100644 --- a/src/ArrayLayouts.jl +++ b/src/ArrayLayouts.jl @@ -3,7 +3,7 @@ using Base: _typed_hcat using Base, Base.Broadcast, LinearAlgebra, FillArrays, SparseArrays using LinearAlgebra.BLAS -using Base: AbstractCartesianIndex, OneTo, RangeIndex, ReinterpretArray, ReshapedArray, +using Base: AbstractCartesianIndex, OneTo, oneto, RangeIndex, ReinterpretArray, ReshapedArray, Slice, tuple_type_tail, unalias, @propagate_inbounds, @_propagate_inbounds_meta diff --git a/src/mul.jl b/src/mul.jl index 76ba8de..6548464 100644 --- a/src/mul.jl +++ b/src/mul.jl @@ -310,6 +310,12 @@ end *(x::TransposeAbsVec{<:Any,<:Zeros{<:Any,1}}, D::Diagonal, y::LayoutVector) = FillArrays._triple_zeromul(x, D, y) +*(A::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}, B::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}) = mul(A, B) +*(A::UpperOrLowerTriangular{<:Any,<:AdjOrTrans{<:Any,<:LayoutMatrix}}, B::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}) = mul(A, B) +*(A::UpperOrLowerTriangular{<:Any,<:LayoutMatrix}, B::UpperOrLowerTriangular{<:Any,<:AdjOrTrans{<:Any,<:LayoutMatrix}}) = mul(A, B) +*(A::UpperOrLowerTriangular{<:Any,<:AdjOrTrans{<:Any,<:LayoutMatrix}}, B::UpperOrLowerTriangular{<:Any,<:AdjOrTrans{<:Any,<:LayoutMatrix}}) = mul(A, B) + + # mul! for subarray of layout matrix LinearAlgebra.mul!(C::SubArray{<:Any,2,<:LayoutMatrix}, A::SubArray{<:Any,2,<:LayoutMatrix}, B::SubArray{<:Any,2,<:LayoutMatrix}, α::Number, β::Number) = ArrayLayouts.mul!(C, A, B, α, β) diff --git a/src/triangular.jl b/src/triangular.jl index c98663c..70aa0ed 100644 --- a/src/triangular.jl +++ b/src/triangular.jl @@ -1,7 +1,7 @@ colsupport(::TriangularLayout{'L'}, A, j) = isempty(j) ? (1:0) : colsupport(triangulardata(A), j) ∩ (minimum(j):size(A,1)) -colsupport(::TriangularLayout{'U'}, A, j) = isempty(j) ? (1:0) : colsupport(triangulardata(A), j) ∩ OneTo(maximum(j)) +colsupport(::TriangularLayout{'U'}, A, j) = isempty(j) ? (1:0) : colsupport(triangulardata(A), j) ∩ oneto(maximum(j)) rowsupport(::TriangularLayout{'U'}, A, j) = isempty(j) ? (1:0) : rowsupport(triangulardata(A), j) ∩ (minimum(j):size(A,2)) -rowsupport(::TriangularLayout{'L'}, A, j) = isempty(j) ? (1:0) : rowsupport(triangulardata(A), j) ∩ OneTo(maximum(j)) +rowsupport(::TriangularLayout{'L'}, A, j) = isempty(j) ? (1:0) : rowsupport(triangulardata(A), j) ∩ oneto(maximum(j)) diff --git a/test/test_layoutarray.jl b/test/test_layoutarray.jl index e5a6161..56a08e4 100644 --- a/test/test_layoutarray.jl +++ b/test/test_layoutarray.jl @@ -446,6 +446,15 @@ MemoryLayout(::Type{MyVector}) = DenseColumnMajor() @test mul(view(y', :, 1:5), D) isa Adjoint @test mul(view(transpose(y), :, 1:5), D) isa Transpose end + + @testset "Tri * Tri" begin + A = MyMatrix(randn(3,3)) + @test UpperTriangular(A) * LowerTriangular(A) ≈ UpperTriangular(A.A) * LowerTriangular(A.A) + @test UpperTriangular(A) * UnitUpperTriangular(A) ≈ UpperTriangular(A.A) * UnitUpperTriangular(A.A) + @test UpperTriangular(A') * UnitUpperTriangular(A) ≈ UpperTriangular(A.A') * UnitUpperTriangular(A.A) + @test UpperTriangular(A) * UnitUpperTriangular(A') ≈ UpperTriangular(A.A) * UnitUpperTriangular(A.A') + @test UpperTriangular(A') * UnitUpperTriangular(A') ≈ UpperTriangular(A.A') * UnitUpperTriangular(A.A') + end end struct MyUpperTriangular{T} <: AbstractMatrix{T} From 610da35c110c6de462ed524af2ece784344fcb47 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 20 Jul 2023 16:14:47 +0100 Subject: [PATCH 3/3] Support for *Triangular(::AdjOrTrans) (#154) --- Project.toml | 2 +- src/ArrayLayouts.jl | 6 +++++- src/ldiv.jl | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 68e21a4..7ee327c 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ArrayLayouts" uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" authors = ["Sheehan Olver "] -version = "1.0.12" +version = "1.0.13" [deps] FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" diff --git a/src/ArrayLayouts.jl b/src/ArrayLayouts.jl index f310777..95cf902 100644 --- a/src/ArrayLayouts.jl +++ b/src/ArrayLayouts.jl @@ -364,7 +364,11 @@ Base.replace_in_print_matrix(A::Union{LayoutVector, UnitLowerTriangular{<:Any,<:LayoutMatrix}, AdjOrTrans{<:Any,<:LayoutVecOrMat}, HermOrSym{<:Any,<:LayoutMatrix}, - SubArray{<:Any,2,<:LayoutMatrix}}, i::Integer, j::Integer, s::AbstractString) = + SubArray{<:Any,2,<:LayoutMatrix}, + UpperTriangular{<:Any,<:AdjOrTrans{<:Any,<:LayoutMatrix}}, + UnitUpperTriangular{<:Any,<:AdjOrTrans{<:Any,<:LayoutMatrix}}, + LowerTriangular{<:Any,<:AdjOrTrans{<:Any,<:LayoutMatrix}}, + UnitLowerTriangular{<:Any,<:AdjOrTrans{<:Any,<:LayoutMatrix}}}, i::Integer, j::Integer, s::AbstractString) = layout_replace_in_print_matrix(MemoryLayout(A), A, i, j, s) Base.print_matrix_row(io::IO, diff --git a/src/ldiv.jl b/src/ldiv.jl index 9497c26..9c17b4f 100644 --- a/src/ldiv.jl +++ b/src/ldiv.jl @@ -200,6 +200,16 @@ macro layoutldiv(Typ) ArrayLayouts.@_layoutldiv UnitUpperTriangular{T, <:SubArray{T,2,<:$Typ{T}}} where T ArrayLayouts.@_layoutldiv LowerTriangular{T, <:SubArray{T,2,<:$Typ{T}}} where T ArrayLayouts.@_layoutldiv UnitLowerTriangular{T, <:SubArray{T,2,<:$Typ{T}}} where T + + ArrayLayouts.@_layoutldiv UpperTriangular{T, <:Adjoint{T,<:$Typ{T}}} where T + ArrayLayouts.@_layoutldiv UnitUpperTriangular{T, <:Adjoint{T,<:$Typ{T}}} where T + ArrayLayouts.@_layoutldiv LowerTriangular{T, <:Adjoint{T,<:$Typ{T}}} where T + ArrayLayouts.@_layoutldiv UnitLowerTriangular{T, <:Adjoint{T,<:$Typ{T}}} where T + + ArrayLayouts.@_layoutldiv UpperTriangular{T, <:Transpose{T,<:$Typ{T}}} where T + ArrayLayouts.@_layoutldiv UnitUpperTriangular{T, <:Transpose{T,<:$Typ{T}}} where T + ArrayLayouts.@_layoutldiv LowerTriangular{T, <:Transpose{T,<:$Typ{T}}} where T + ArrayLayouts.@_layoutldiv UnitLowerTriangular{T, <:Transpose{T,<:$Typ{T}}} where T end) end