06-01-2009 02:09 PM
I'm using LV 8.5. I don't have a lot of experience with implementing cubic splines, but my client gave me data that was interpolated with a cubic spline using another tool, and I've been able to replicate the data using the Spline Interpolation 1D function. That's the good news. It was pretty easy to get the right results. The bad news is that to do the interpolation on an array of 1040 points takes 22 seconds. (This computer isn't very new, but it's decent. Not a complete dog.) Is this expected? I would certainly hope we could do this type of analysis much more quickly. I looked through the forums and found some mentions where Altenbach got a linear interpolation to work much faster by making a minor mod involving setting the starting point for a Threshold Array call. This isn't the problem in this case. I searched down into the library and found that the builk of the time is being spent by the VI Solve General Linear Equation, which is a dll call. I also found one other mention of the built-in spline being too slow, and someone saying that they rewrote it to be faster, but I didn't find any example code posted.
Any ideas?
Thanks, DaveT
06-01-2009 04:05 PM
06-01-2009 09:39 PM
Just a quick follow up: I was using the Spline Interpolation 1D VI, which runs a Solve Linear Equations on the entire array at once. Altenbach pointed out an example that loops through the array and uses the simpler, more efficient Spline Interpolation VI. Following his suggestion, I rewrote it similar to the example (except with the Interpolant OUTSIDE the loop), and it now runs in 1 to 2 ms instead of 20 s!
Hats off to the Knight of NI, Sir Altenbach!
DaveT
09-30-2019 08:17 AM - edited 09-30-2019 08:42 AM
Hi Dave,
here I am, 10 years later, asking if you still have a working example (LV 2019) or a link to the Altenbach suggestion. Using Spline Interpolant VI (outside the for loop) and Spline Interpolation VI inside the for loop to cycle trough my X_new array I managed to halve the time required by the Spline Interpolation 1D VI. I'm wondering what else I should code to obtain the huge gain that you reported (from 20s to 2ms).
Thank you,
Marco.
09-30-2019 04:25 PM
I doubt that code is still around, but if you attach your code with some sample data I would be happy to take a quick look.
09-30-2019 04:53 PM - edited 09-30-2019 05:07 PM
Found this (see attached):
(see also this thread. Note that some of these functions have been optimized significantly over the last 10 years))