octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #29921] spline() should ignore NaNs


From: Rik
Subject: [Octave-bug-tracker] [bug #29921] spline() should ignore NaNs
Date: Tue, 25 May 2010 04:52:57 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100402 Ubuntu/9.10 (karmic) Firefox/3.5.9

Follow-up Comment #1, bug #29921 (project octave):

>From your Changeset:
+  if (any (isnan (a)))
+    for k = 1:size(a,2)
+      ok = (! isnan (a(:,k)));
+      a(!ok,k) = spline (x(ok), a(ok,k), x(!ok));
+    endfor
+  endif

This will iterate over all of the columns (1:size(a,2)), including the ones
which don't have NaNs in them.  It would be more efficient to operate only on
the columns with NaNs in them.
For example:
  for k = (1:columns (a))(any (isnan (a)))
    ok = ! isnan (a(:,k));
    a(!ok,k) = spline (x(ok), a(ok,k), x(!ok));
  endfor

It is a little opaque but the key is that it creates a range from 1 to the
number of columns and then uses the isnan function to index into it so that
only columns with NaNs will get processed.

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?29921>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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