Caching a large 3D interpolation using griddata()
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Matt J
2014-7-5
编辑:Matt J
2014-7-5
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 个评论
Matt J
2014-7-5
编辑:Matt J
2014-7-5
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.
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!