Skip to content

Commit

Permalink
Merge branch 'master' into revertUpLowTriangular
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Jul 20, 2023
2 parents 34e7f8c + 610da35 commit cdf7b79
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
version:
- '1.6'
- '1'
- '~1.10.0-0'
os:
- ubuntu-latest
- macOS-latest
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ArrayLayouts"
uuid = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
authors = ["Sheehan Olver <solver@mac.com>"]
version = "1.0.12"
version = "1.0.13"

[deps]
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
Expand Down
8 changes: 6 additions & 2 deletions src/ArrayLayouts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -361,7 +361,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,
Expand Down
10 changes: 10 additions & 0 deletions src/ldiv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions src/mul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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, α, β)
Expand Down
4 changes: 2 additions & 2 deletions src/triangular.jl
Original file line number Diff line number Diff line change
@@ -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))



Expand Down
9 changes: 9 additions & 0 deletions test/test_layoutarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit cdf7b79

Please sign in to comment.