From 13184d68cfd7d32abcdbf535fc86182a27837aae Mon Sep 17 00:00:00 2001 From: Daniel VandenHeuvel <95613936+DanielVandH@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:12:14 +0000 Subject: [PATCH] =?UTF-8?q?Support=20`maximum(Block(OneTo(+=E2=88=9E))`=20?= =?UTF-8?q?(#211)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * maximum * mention pr --- Project.toml | 2 +- ext/InfiniteArraysBlockArraysExt.jl | 6 ++++-- test/test_infblock.jl | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 79594ab..39f9007 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "InfiniteArrays" uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c" -version = "0.15.1" +version = "0.15.2" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/ext/InfiniteArraysBlockArraysExt.jl b/ext/InfiniteArraysBlockArraysExt.jl index 5733823..ac7cd0a 100644 --- a/ext/InfiniteArraysBlockArraysExt.jl +++ b/ext/InfiniteArraysBlockArraysExt.jl @@ -2,10 +2,10 @@ module InfiniteArraysBlockArraysExt using InfiniteArrays, BlockArrays using InfiniteArrays.ArrayLayouts, InfiniteArrays.LazyArrays, InfiniteArrays.LinearAlgebra -import Base: length, size, axes, BroadcastStyle, copy, +, - +import Base: length, size, axes, BroadcastStyle, copy, +, -, maximum, OneTo import Base.Broadcast: Broadcasted import ArrayLayouts: sub_materialize, axes_print_matrix_row -import InfiniteArrays: OneToInf, PosInfinity, InfRanges, RealInfinity, Infinity, InfStepRange, TridiagonalToeplitzLayout +import InfiniteArrays: OneToInf, PosInfinity, InfRanges, RealInfinity, Infinity, InfStepRange, TridiagonalToeplitzLayout, InfiniteCardinal import BlockArrays: AbstractBlockLayout, sizes_from_blocks, BlockTridiagonal, OneToCumsum, BlockSlice, AbstractBlockedUnitRange, BlockLayout import LazyArrays: PaddedColumns, LazyArrayStyle @@ -28,6 +28,8 @@ BlockArrays.blocklasts(a::InfRanges) = Fill(length(a),1) BlockArrays.findblock(::BlockedOneTo, ::RealInfinity) = Block(ℵ₀) +maximum(::BlockRange{1, Tuple{OneTo{InfiniteCardinal{0}}}}) = Block(ℵ₀) + function BlockArrays.sortedunion(a::Vcat{Int,1,<:Tuple{Union{Int,AbstractVector{Int}},<:AbstractRange}}, b::Vcat{Int,1,<:Tuple{Union{Int,AbstractVector{Int}},<:AbstractRange}}) @assert a == b # TODO: generailse? Not sure how to do so in a type stable fashion diff --git a/test/test_infblock.jl b/test/test_infblock.jl index ce36cff..2130715 100644 --- a/test/test_infblock.jl +++ b/test/test_infblock.jl @@ -139,6 +139,11 @@ const BlockTriPertToeplitz = InfiniteArraysBlockArraysExt.BlockTriPertToeplitz @test findblock(blockedrange(1:2:∞), RealInfinity()) == Block(ℵ₀) end + @testset "maximum of Inf Block Range" begin + # See https://github.com/JuliaApproximation/HarmonicOrthogonalPolynomials.jl/pull/89 + @test maximum(Block.(Base.OneTo(Integer(+∞)))) == Block(ℵ₀) + end + @testset "BlockTridiagonal Pert Toeplitz" begin A = BlockTridiagonal(Vcat([fill(1.0, 2, 1), Matrix(1.0I, 2, 2), Matrix(1.0I, 2, 2), Matrix(1.0I, 2, 2)], Fill(Matrix(1.0I, 2, 2), ∞)), Vcat([zeros(1, 1)], Fill(zeros(2, 2), ∞)),