Why is it so fast to calculate one-dimensional cubic Spline interpolation through matlab?
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I learned that the Time complexity of one-dimensional cubic Spline interpolation is at least n ^ 2. I implemented the algorithm through C++and solved System of linear equations through LU decomposition, but obviously the computation is too much!
But why does MATLAB quickly solve for data interpolation of 10 million?
Did you use any acceleration methods?
Akzeptierte Antwort
Bruno Luong
am 12 Jul. 2023
Bearbeitet: Bruno Luong
am 12 Jul. 2023
"I learned that the Time complexity of one-dimensional cubic Spline interpolation is at least n ^ 2"
What is n?
There is two distinc steps in spline interpolation, (1) estimate the cubic coefficients from each subinterval of the pp form. (2) Find where the query points are in which intervals then evaluate the 3rd cubic polynomial.
The first step is O(N) with N is number of X-Y, as it requires mainy solving a tridiagonal matrix where the complexity is linear to the size.
The second step is O(M*log(N)) if searching using dichotomy method, where M is number of query points. MATLAB can detect also if the knot points are equidistance and use simply a division to find the interval (I don't know if such optimization is implemented in INTERP1), but that brings the complexity to O(M).
In any case O(n^2) you read is NOT optimal for spline.
6 Kommentare
Bruno Luong
am 13 Jul. 2023
"If LU decomposition is used to solve x, then the Time complexity is about O (n ^ 3) (not the n ^ 2 I mentioned earlier"
BTW this figure of complexity must be your (wrong) conclusion, not the book-ref whatever you read. The LU on tridiagonal matrix is O(N), since the Thomas algorithm is actually based on LU.
The key difference is that if ones knows the shape of the input matrix to be decomposed one can stops the loop of LU during the decomposition much earlier. Essentially with this small but important observation the LU becomesThomas algorithm.
Lesson: don't draw a hasty conclusion.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spline Postprocessing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!