help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

interp1 OCT file


From: Luke M
Subject: interp1 OCT file
Date: Fri, 2 Jul 2010 08:29:18 -0700 (PDT)

Hello all,

As an exercise to help me learn to write oct files, I partially implemented
interp1 in C++.  Please have a look at the code here (130 lines, didn't want
to breach length etiquette):

http://pastebin.com/CTkSBfVc http://pastebin.com/CTkSBfVc 

I learned the following in the course of developing:

- Minimizing the use of charMatrix (using enum for interpolation type) sped
the code up a lot.  It's only still there for compatibility with interp1.
- Reading in the arguments as ColumnVectors instead of NDArrays sped up the
code considerably (~3-4x).
- Removing the check for monotonic input gave an extra 20% boost.
- Some linear interpolation benchmarks against interp1 and interp1q:

x = [0:1:1000]'; y = sort(rand(length(x),1)); xi = [12.5:6.7:900]';
10000 interp1's: 6.32674 seconds.
10000 interp1q's: 3.26641 seconds.
10000 ointerp1's: 0.831889 seconds.
10000 ointerp1q's: 0.632212 seconds.
x = [0:1:10000]'; y = sort(rand(length(x),1)); xi = [12.5:6.7:9000]';
1000 interp1's: 1.23987 seconds.
1000 interp1q's: 0.865512 seconds.
1000 ointerp1's: 0.734048 seconds.
1000 ointerp1q's: 0.640468 seconds.
x = [0:1:100000]'; y = sort(rand(length(x),1)); xi = [12.5:6.7:90000]';
1000 interp1's: 6.05447 seconds.
1000 interp1q's: 4.54011 seconds.
1000 ointerp1's: 9.2129 seconds.
1000 ointerp1q's: 7.56058 seconds.

Does anybody have any tips on squeezing extra speed out of it, especially
for longer input vectors?

Thanks,
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/interp1-OCT-file-tp2276588p2276588.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]