Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ LinearAlgebra = "1.10"
MCIntegration = "0.4.2"
MonteCarloIntegration = "0.2, 0.3"
Mooncake = "0.5.6"
OffsetArrays = "1"
QuadGK = "2.11"
Random = "1.10"
Reexport = "1.2"
Expand All @@ -91,11 +92,12 @@ FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
FastTanhSinhQuadrature = "b650e0df-f744-4436-b963-b44034668c57"
HAdaptiveIntegration = "eaa5ad34-b243-48e9-b09c-54bc0655cecf"
MCIntegration = "ea1e2de9-7db7-4b42-91ee-0cd1bf6df167"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[targets]
test = ["ADTypes", "Arblib", "StaticArrays", "SafeTestsets", "SciMLTesting", "Test", "Distributions", "ChainRulesCore", "FastGaussQuadrature", "FastTanhSinhQuadrature", "Cuba", "Cubature", "MCIntegration", "DifferentiationInterface", "HAdaptiveIntegration", "Unitful"]
test = ["ADTypes", "Arblib", "StaticArrays", "SafeTestsets", "SciMLTesting", "Test", "Distributions", "ChainRulesCore", "FastGaussQuadrature", "FastTanhSinhQuadrature", "Cuba", "Cubature", "MCIntegration", "DifferentiationInterface", "HAdaptiveIntegration", "Unitful", "OffsetArrays"]
4 changes: 2 additions & 2 deletions src/sampled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dimension(D::Int) = D
# Specialized evalrule for 1D arrays (Vector) - returns scalar
function evalrule(data::AbstractVector, weights, dim)
# Only use fast indexing path when scalar indexing is efficient (e.g., not on GPU arrays)
if ArrayInterface.fast_scalar_indexing(data)
if ArrayInterface.fast_scalar_indexing(data) && !Base.has_offset_axes(data)
n = length(data)
n == 0 && throw(ArgumentError("No points to integrate"))
out = data[1] * weights[1]
Expand All @@ -67,7 +67,7 @@ end
# This is the most common case for vector-valued integrands
function evalrule(data::AbstractMatrix{T}, weights, dim) where {T}
# Only use fast indexing path when scalar indexing is efficient (e.g., not on GPU arrays)
if ArrayInterface.fast_scalar_indexing(data)
if ArrayInterface.fast_scalar_indexing(data) && !Base.has_offset_axes(data)
m, n = size(data)
n == 0 && throw(ArgumentError("No points to integrate"))
if dim == 2 || dim == ndims(data)
Expand Down
14 changes: 13 additions & 1 deletion test/sampled_tests.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Integrals, Test, Unitful
using Integrals, OffsetArrays, Test, Unitful
@testset "Sampled Integration" begin
lb = 0.4
ub = 1.1
Expand Down Expand Up @@ -42,6 +42,18 @@ end
@test sol.u == [2.0, 2.0]u"m"
end

@testset "Sampled integration with OffsetArrays" begin
x = range(0, 1, length = 5)
y = OffsetArray(ones(2, 5), 0:1, 1:5)
sol = solve(SampledIntegralProblem(y, x; dim = 2), TrapezoidalRule())
@test collect(sol.u) == [1.0, 1.0]

yv = OffsetArray(ones(5), 0:4)
xv = OffsetArray(collect(x), 0:4)
solv = solve(SampledIntegralProblem(yv, xv), TrapezoidalRule())
@test solv.u == 1.0
end

@testset "Caching interface" begin
x = 0.0:0.1:1.0
y = sin.(x)
Expand Down
Loading