diff --git a/Project.toml b/Project.toml index 065e82f..7b681af 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "InfiniteArrays" uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c" -version = "0.14" +version = "0.14.1" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/InfiniteArrays.jl b/src/InfiniteArrays.jl index 17a0434..5854d31 100644 --- a/src/InfiniteArrays.jl +++ b/src/InfiniteArrays.jl @@ -8,7 +8,7 @@ import Base: *, +, -, /, <, ==, >, \, ≤, ≥, (:), @propagate_inbounds, angle, axes, broadcast, cat_indices, cat_similar, cat_size, checkindex, collect, convert, copy, cumsum, dataids, diff, div, eltype, fill, findfirst, first, floatrange, getindex, hcat, - in, ind2sub_rs, intersect, isempty, isinf, issorted, last, length, lt, max, + in, ind2sub_rs, intersect, inv, isempty, isinf, issorted, last, length, lt, max, maximum, minimum, mod, one, ones, parent, parentindices, permutedims, print_matrix, print_matrix_row, print_matrix_vdots, promote_rule, reinterpret, reshape, reverse, searchsorted, searchsortedfirst, searchsortedlast, setindex!, show, show_circular, show_delim_array, sign, diff --git a/src/infrange.jl b/src/infrange.jl index 4edd6eb..0bb10d7 100644 --- a/src/infrange.jl +++ b/src/infrange.jl @@ -617,3 +617,10 @@ function LinearAlgebra.diag(D::Diagonal{<:Any,<:InfRanges}, k::Integer = 0) return Zeros{eltype(D)}(size(D,1)) # infinite vector of zeros end end + +function inv(D::Diagonal{T, <:InfRanges}) where {T} + d = D.diag + idx = findfirst(==(zero(T)), d) + isnothing(idx) || throw(SingularException(idx)) + return Diagonal(inv.(d)) +end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 1b7b86d..db71d99 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1206,6 +1206,8 @@ end @test @inferred((D -> diag(D,1))(D)) === Zeros{Int}(ℵ₀) # test for compile-time evaluation of off-diagonals @inferred Val((D -> diag(D,1))(D)) + # Issue #176 + @test inv(D)[1:100,1:100] == Diagonal(inv.(1:∞))[1:100,1:100] end @testset "inf padded" begin