yuki-koyama / mathtoolbox

Mathematical tools (interpolation, dimensionality reduction, optimization, etc.) written in C++11 with Eigen

Home Page:https://yuki-koyama.github.io/mathtoolbox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RBF interpolation speed

f-p-b opened this issue · comments

commented

I have been considering the use of the RBF interpolation implementation but while it works correctly its extremely slow. Is this a known issue or do I perhaps need to take some special considerations when compiling or setting up things? I am using it for a 3D interpolation with about 16000 points which I would say is not an extremely large problem and I am using the linear kernel which should be the fastest mode.

The RBF implementation in this library relies on a "direct" linear system solving, which is done by LU decomposition and takes more than O(n^2). Having 16,000 points means the size of the linear system is 16,000, which is infeasible for the direct approach.

https://yuki-koyama.github.io/mathtoolbox/rbf-interpolation/

This issue is well known, and [Carr et al. 2001] also pointed it out at the end of Section 3. Such large problems need an approximation approach; e.g., [Carr et al. 2001] uses the Fast Multipole Method (FMM), which takes only O(N log N) to solve the system.

[Carr et al. 2001]: Reconstruction and representation of 3D objects with radial basis functions. https://dl.acm.org/doi/abs/10.1145/383259.383266

Thanks for the fast reply! I probably should have been a bit more specific. The use of the LU decomposition approach would naturally affect the speed of the construction of the interpolation model but not of a query on it. While the construction may take a bit that's fine for me as it only needs to be done once. The slow part that is actually becoming a bottleneck for me is when I make a query for an output, i.e. use CalcValue(x) which I think is essentially involves vector matrix multiplications.

Thanks for the clarification. CalcValue(x) takes O(N), so the more data points you have, the longer it takes.

I just updated CalcValue(x) in #74, which makes it roughly 5x times faster than before (I measured the performance with 2000 data points with 1000 evaluations).

If further performance is necessary, a possible solution would be to use the technique described in Section 5 of [Carr et al. 2001]. It is about a data point reduction; the reduction itself takes much extra time, but once the reduction is done, the interpolated value calculation will be drastically faster. Hope this helps you.

Thank you so much! I will try it out and see how it performs for my case.