LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

slow spline interpolation

   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

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 1 of 6
(3,890 Views)
I've tried in several ways to reproduce a slow cubic spline with your array sizes, but it always finishes in a few milliseconds. We need to see some code, I guess.
0 Kudos
Message 2 of 6
(3,876 Views)

   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

-------------------------------------------------------------
David Thomson Original Code Consulting
www.originalcode.com
National Instruments Alliance Program Member
Certified LabVIEW Architect
Certified Embedded Systems Developer
-------------------------------------------------------------
There are 10 kinds of people: those who understand binary, and those who don't.
0 Kudos
Message 3 of 6
(3,859 Views)

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.

0 Kudos
Message 4 of 6
(2,708 Views)

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.

0 Kudos
Message 5 of 6
(2,679 Views)

Found this (see attached):

 

(see also this thread. Note that some of these functions have been optimized significantly over the last 10 years))

0 Kudos
Message 6 of 6
(2,672 Views)