Skip to content

Commit 4734173

Browse files
authored
Fix infinite indexing with Eye (#73)
* Fix infinite indexing with Eye * simplify overloads * Update infbanded.jl
1 parent 126b6a1 commit 4734173

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "InfiniteLinearAlgebra"
22
uuid = "cde9dba0-b1de-11e9-2c62-0bab9446c55c"
3-
version = "0.5.3"
3+
version = "0.5.4"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/banded/infbanded.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ sub_materialize(_, V::SubArray{<:Any,1,<:AbstractMatrix,Tuple{InfBandCartesianIn
3636
# Diagonal
3737
###
3838

39-
getindex(D::Diagonal, k::InfAxes, j::InfAxes) = layout_getindex(D, k, j)
39+
Base._unsafe_getindex(::IndexCartesian, D::Diagonal, k::InfAxes, j::InfAxes) = layout_getindex(D, k, j)
40+
Base._unsafe_getindex(::IndexCartesian, D::Diagonal, k::InfAxes, j::Union{Real,AbstractArray}) = layout_getindex(D, k, j)
41+
Base._unsafe_getindex(::IndexCartesian, D::Diagonal, k::Union{Real,AbstractArray}, j::InfAxes) = layout_getindex(D, k, j)
4042

4143
const TriToeplitz{T} = Tridiagonal{T,Fill{T,1,Tuple{OneToInf{Int}}}}
4244
const ConstRowMatrix{T} = ApplyMatrix{T,typeof(*),<:Tuple{<:AbstractVector,<:AbstractFill{<:Any,2,Tuple{OneTo{Int},OneToInf{Int}}}}}
@@ -364,10 +366,12 @@ _BandedMatrix(::PertToeplitzLayout, A::AbstractMatrix) =
364366
# end
365367
# end
366368

369+
sub_materialize(::AbstractBandedLayout, V, ::Tuple{InfAxes,InfAxes}) = V
370+
sub_materialize(::AbstractBandedLayout, V, ::Tuple{OneTo{Int},InfAxes}) = V
371+
sub_materialize(::AbstractBandedLayout, V, ::Tuple{InfAxes,OneTo{Int}}) = V
367372

368373
@inline sub_materialize(::ApplyBandedLayout{typeof(*)}, V, ::Tuple{InfAxes,InfAxes}) = V
369374
@inline sub_materialize(::BroadcastBandedLayout, V, ::Tuple{InfAxes,InfAxes}) = V
370-
@inline sub_materialize(::AbstractBandedLayout, V, ::Tuple{InfAxes,InfAxes}) = V
371375
@inline sub_materialize(::BandedColumns, V, ::Tuple{InfAxes,InfAxes}) = BandedMatrix(V)
372376

373377

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ import LazyBandedMatrices: BroadcastBandedBlockBandedLayout, BroadcastBandedLayo
120120
@test copy(A')[1:10,1:10] == (A')[1:10,1:10]
121121
@test copy(transpose(A))[1:10,1:10] == transpose(A)[1:10,1:10]
122122
end
123+
124+
@testset "Eye subindex" begin
125+
@test Eye(∞)[:,1:3][1:5,:] == Eye(∞)[Base.Slice(oneto(∞)),1:3][1:5,:] == Eye(5,3)
126+
@test Eye(∞)[1:3,:][:,1:5] == Eye(∞)[1:3,Base.Slice(oneto(∞))][:,1:5] == Eye(3,5)
127+
@test Eye(∞)[:,:][1:5,1:3] == Eye(∞)[Base.Slice(oneto(∞)),Base.Slice(oneto(∞))][1:5,1:3] == Eye(5,3)
128+
end
123129
end
124130

125131
@testset "∞-block arrays" begin

0 commit comments

Comments
 (0)