Filter löschen
Filter löschen

How to speed up spline calculation (using cscvn)

7 Ansichten (letzte 30 Tage)
David
David am 13 Okt. 2014
Bearbeitet: Stephen23 am 13 Okt. 2014
Hello dear MATLAB community,
I have a problem by using the 'cscvn' function to calculate spline coefficients. I have an optimization problem and during this optimization problem the spline interpolation with cscvn is done to evaluate the function. Actually the calculation of the spline coefficients takes around 30% of the total calculation time.
Do you have an idea why this takes so long and is there a possibility to speed up this calculation? I read something about 'JIT acceleration' and that this acceleration does not work in 'loops that call non builtin functions'. Actually I don´t really understand what this exactly tells me and if there probably IS a way to speed up the spline calculation.
Thank you for your help.
David

Akzeptierte Antwort

Stephen23
Stephen23 am 13 Okt. 2014
Bearbeitet: Stephen23 am 13 Okt. 2014
There will always be some part of your scripts that requires some amount of running time (ie the most computation), and maybe even a significant proportion of the total running time. The other lines of code in your screenshot are array allocations and calls to zeros, both of which are many times simpler than spline fitting. Do you expect spline fitting to also take <0.01 seconds? Fitting a spline 976 times in 1.61 seconds, complete with error checking and other input handling... is that so slow?
How big are your data arrays?
Possibilities to speed up the script:
  • If WayPoints does not change between some iterations, then you can calculate it once and use the same values for several/all iterations.
  • Open the cscvn Mfile (if it has one), remove all the error-checking and array-wrangling at the start, use profile to check which parts you actually use, and save a local copy with only the parts that you need (use a different function name, and do not save over the original Mfile).
  1 Kommentar
David
David am 13 Okt. 2014
I know that some part takes longer and some part is faster in the calculation. I was just wondering that the calculation of the spline coefficients takes the most time in the optimization problem (more than calculating derivatives for the optimization e.g.). At the moment I have a pretty small data set with 7 data points. I will check your possibilites to speed up my code.
Thanks a lot.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by