DataInterpolations.jl icon indicating copy to clipboard operation
DataInterpolations.jl copied to clipboard

Integral on matrix interpolations throws method error

Open afod22 opened this issue 3 years ago • 1 comments

Integral on matrix interpolations throws error

Integral is defined for any AbstractInterpolation but then calls samples on that interpolation which only has methods for ::LinearInterpolation{<:AbstractVector} types.

It would be useful to be able to get the integral of multi-dimensional interpolations. Derivetives returns a vector with element for each data dimension. Integral could do the same though this may not be a useful output for every use case.

I'd like to be able to use this to calculate means and standard deviations for each signal in an interpolation.

Example code:

u = rand(3,20)
t = sort(rand(20))

X1 = LinearInterpolation(u[1,:],t)
DataInterpolations.integral(X1, 0, 0.5) # Works

X = LinearInterpolation(u,t)
# MethodError: no method matching samples(::LinearInterpolation{Matrix{Float64}, Vector{Float64}, true, Float64})
DataInterpolations.integral(X, 0, 0.5)

Thanks,

Aaron.

afod22 avatar Sep 16 '22 11:09 afod22

I just ran into this today and agree that it would be useful.

jbiffl avatar Jan 28 '25 21:01 jbiffl