From 87edc9100cfb4441b07bebe87c574e44c9b8432c Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Sat, 20 Apr 2024 15:24:33 +0100 Subject: [PATCH] Array inbounds_getindex (#174) --- Project.toml | 2 +- src/maps.jl | 1 + test/test_maps.jl | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index d7dde3e..273dc73 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ContinuumArrays" uuid = "7ae1f121-cc2c-504b-ac30-9b923412ae5c" -version = "0.17.1" +version = "0.17.2" [deps] AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c" diff --git a/src/maps.jl b/src/maps.jl index e1111c7..3aefde9 100644 --- a/src/maps.jl +++ b/src/maps.jl @@ -74,6 +74,7 @@ getindex(A::AbstractAffineQuasiVector, ::Colon) = copy(A) copy(A::AbstractAffineQuasiVector) = A inbounds_getindex(A::AbstractAffineQuasiVector{<:Any,<:Any,<:Inclusion}, k::Number) = A.A*k .+ A.b +inbounds_getindex(A::AbstractAffineQuasiVector{<:Number,<:Any,<:Inclusion}, k::AbstractArray{<:Number}) = A.A .* k .+ A.b isempty(A::AbstractAffineQuasiVector) = isempty(A.x) ==(a::AbstractAffineQuasiVector, b::AbstractAffineQuasiVector) = a.A == b.A && a.x == b.x && a.b == b.b ==(a::AbstractAffineQuasiVector, b::Inclusion) = a == affine(b,b) diff --git a/test/test_maps.jl b/test/test_maps.jl index 0f24755..0b58a07 100644 --- a/test/test_maps.jl +++ b/test/test_maps.jl @@ -49,6 +49,7 @@ import ContinuumArrays: AffineQuasiVector @test union(y) == Inclusion(-1..1) @test ContinuumArrays.inbounds_getindex(y,0.1) == y[0.1] @test ContinuumArrays.inbounds_getindex(y,2.1) == 2*2.1 - 1 + @test ContinuumArrays.inbounds_getindex(y, [2.1,2.2]) == 2*[2.1,2.2] .- 1 z = 1 .- x @test minimum(z) == 0.0