GithubHelp home page GithubHelp logo

Comments (6)

sglyon avatar sglyon commented on May 17, 2024

@btengels great to see you here!

The only reason is that it hasn't been implemented.

For gridded interpolation there is a significant efficiency gain if we can cache the indices. The gain isn't as large with with cardinal ("vanilla") B-splines.

I have plans to implement vector evaluation for cardinal B-splines because you can actually get decent speedups if you make certain assumptions. One assumption is that you assume the points you want to evaluate at are sorted or otherwise close to one another. Then you can avoid a whole binary search across the vector by starting with a guess for the index at point i being near the index at point i-1.

from interpolations.jl.

timholy avatar timholy commented on May 17, 2024

With a Gridded object, there's a big performance savings to vectorization, because you have to do a grid-lookup for each evaluation and you can effectively cache the results. With a plain BSpline, there's no performance advantage in vectorization, and it seems that we were hoping to use julia's fallbacks: for most AbstractArray types, you only have to write routines for scalar indexes, and julia takes care of the rest. However, that seems to require that the indexes are integers, which obviously doesn't work with Interpolations.

So, someone presumably needs to implement the vectorization within Interpolations. It should be pretty simple, e.g., the one-liner

getindex(itp, index1, index2) = [itp[i1,i2] for i1 in index1, i2 in index2]

work for 2d. But obviously it has to be done for arbitrary dimensionality (using generated functions, presumably).

from interpolations.jl.

tomasaschan avatar tomasaschan commented on May 17, 2024

If it can be done, I'd really like to "force" the vectorized fallbacks in Julia to become compatible with this* instead of implementing it here. For one thing, the code here is going to be very similar to the one in base Julia, and for another I think this package is a good use case for testing that the fallbacks become flexible enough to actually be useful.

There might be some perfomance optimizations for B-splines that are still possible after that, but I doubt that any of them are worth the added complexity, and I definitely think we should wait with implementing until we can measure that it's needed.

In the meantime, @btengels, I just do [J_itp[x,1] for x in linspace(1,2,10)] manually whenever I need something like that.

*) although it's a little over my head to implement it, so I'm just hoping @timholy and @ mbauman (who doesn't need to be pinged here...) will sort it out 😄

For reference, see also #24, #54, #55, #96 for other discussions related to vector-valued evaluation.

from interpolations.jl.

timholy avatar timholy commented on May 17, 2024

*) although it's a little over my head to implement it, so I'm just hoping @timholy and @ mbauman (who doesn't need to be pinged here...) will sort it out 

We will. But it will only arrive in julia 0.5.

from interpolations.jl.

tomasaschan avatar tomasaschan commented on May 17, 2024

Not supporting itp[linspace(1,10,100), 3.5] until Julia 0.5 arrives is fine by me - after all, it's really only nicer syntax for functionality that already exists in more verbose forms (list comprehensions). If others disagree strongly there might be merit in doing something about it, but MHO is that the added value isn't worth the added complexity. Interpolations.jl's source is already pretty complex as it is.

from interpolations.jl.

tomasaschan avatar tomasaschan commented on May 17, 2024

Closing this for housekeeping - feel free to re-open if there is more to discuss here.

from interpolations.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.