Caching a large 3D interpolation using griddata()
3 views (last 30 days)
Show older comments
I'm using griddata() to go from a spherical grid of sizes on the order (128x256x1500) to a Cartesian cube centered on the sphere, containing N^3 regularly-spaced points (where N is between 128 and 512). I need to do this for dozens or hundreds of checkpoints in my simulation, and several variables per checkpoint. I'm going to need to interpolate from the same spherical grid to the same cubic grid several hundred or several thousand times over, using new data on the spherical grid each time!
Since the most computationally expensive part of this routine is the triangulation and interpolation, I would like to cache some information the first time the routine is run and use that information for subsequent runs.
As far as I can tell, this is not possible using the current implementation of griddata(). Is there any way I could do something like this -- perhaps re-writing the griddata() routine?
0 Comments
Answers (1)
Matt J
on 5 Jul 2014
Edited: Matt J
on 5 Jul 2014
In recent versions of MATLAB, you have scatteredInterpolant which pre-composes an interpolation object, so probably does some of the caching you're talking about. Beyond that, there is parfor in the Parallel Computing Toolbox, if you have it. You would probably have to be strategic about how you slice the input and output data, if you go that route.
2 Comments
Matt J
on 5 Jul 2014
Edited: Matt J
on 5 Jul 2014
It might be worthwhile having a look at FUNC2MAT. It will let you express the interpolation as a multiplication of Y(:) with a reusable sparse matrix that is (X,X1)-dependent. The computation of this matrix will be time-consuming, but if you'll be reusing it enough, it might be worth it. FUNC2MAT also lets you mitigate the matrix computation using the Parallel Computing Toolbox, if you have it.
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!