Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZeroSpline... add option for constant abscissa step? #34

Open
BerntLie opened this issue Jul 6, 2019 · 2 comments
Open

ZeroSpline... add option for constant abscissa step? #34

BerntLie opened this issue Jul 6, 2019 · 2 comments

Comments

@BerntLie
Copy link

BerntLie commented Jul 6, 2019

For the case that the step size in the abscissa is constant, the following zero_hold interpolant is some 150 times faster than ZeroSpline -- on a test case. However, I'm no super coder, so my code uses some 7 times more memory on my test case.

function zero_hold(x,dx,y)
    if x < 0
        return y[1]
    elseif x >= length(y)*dx
        return y[end]
    else
        return y[trunc(Int,x/dx)+1]
    end
end

The added speed is important (my test case is not that important -- I used a simple sinus function). But because of added memory use, in practice my code is slower when used in an ODE solver (due to garbage collection).

Would it be possible to extend the ZeroSpline interpolant to allow for constant abscissa step? With your coding expertise -- can you make it memory efficient, too? That would be super!

@ChrisRackauckas
Copy link
Member

It would just need to specialize on range types so that way its find function is faster. That should be pretty straightforward to do just through dispatch, without actually changing most of the package.

@ChrisRackauckas
Copy link
Member

This is the same thing as #43. We probably should do such a specialization when we see that t is a range object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants