changeset 16891:486c3e2731ff

interpn.m: Use Octave coding conventions. * scripts/general/interpn.m: Use Octave coding conventions.
author Rik <rik@octave.org>
date Wed, 03 Jul 2013 13:48:49 -0700
parents 830f27544bb7
children 68fc671a9339
files scripts/general/interpn.m
diffstat 1 files changed, 21 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/general/interpn.m	Tue Jul 02 14:56:31 2013 -0700
+++ b/scripts/general/interpn.m	Wed Jul 03 13:48:49 2013 -0700
@@ -76,14 +76,14 @@
 
   if (ischar (varargin{end}))
     method = varargin{end};
-    nargs = nargs - 1;
+    nargs -= 1;
   elseif (nargs > 1 && ischar (varargin{end - 1}))
     if (! isnumeric (varargin{end}) || ! isscalar (varargin{end}))
       error ("interpn: extrapal is expected to be a numeric scalar");
     endif
     method = varargin{end - 1};
     extrapval = varargin{end};
-    nargs = nargs - 2;
+    nargs -= 2;
   endif
 
   if (nargs < 3)
@@ -102,7 +102,7 @@
     nd = ndims (v);
     x = cell (1, nd);
     y = cell (1, nd);
-    for i = 1 : nd;
+    for i = 1 : nd
       x{i} = 1 : sz(i);
       y{i} = 1 : (1 / (2 ^ m)) : sz(i);
     endfor
@@ -113,18 +113,18 @@
     sz = size (v);
     nd = ndims (v);
     x = cell (1, nd);
-    y = varargin (2 : nargs);
-    for i = 1 : nd;
+    y = varargin(2 : nargs);
+    for i = 1 : nd
       x{i} = 1 : sz(i);
     endfor
-  elseif (rem (nargs, 2) == 1 && nargs ==
-          (2 * ndims (varargin{ceil (nargs / 2)})) + 1)
+  elseif (rem (nargs, 2) == 1
+          && nargs == (2 * ndims (varargin{ceil (nargs / 2)})) + 1)
     nv = ceil (nargs / 2);
     v = varargin{nv};
     sz = size (v);
     nd = ndims (v);
-    x = varargin (1 : (nv - 1));
-    y = varargin ((nv + 1) : nargs);
+    x = varargin(1 : (nv - 1));
+    y = varargin((nv + 1) : nargs);
   else
     error ("interpn: wrong number or incorrectly formatted input arguments");
   endif
@@ -134,12 +134,12 @@
       if (! size_equal (x{1}, x{i}) || ! size_equal (x{i}, v))
         error ("interpn: dimensional mismatch");
       endif
-      idx (1 : nd) = {1};
-      idx (i) = ":";
+      idx(1 : nd) = {1};
+      idx(i) = ":";
       x{i} = x{i}(idx{:})(:);
     endfor
-    idx (1 : nd) = {1};
-    idx (1) = ":";
+    idx(1 : nd) = {1};
+    idx(1) = ":";
     x{1} = x{1}(idx{:})(:);
   endif
 
@@ -154,7 +154,7 @@
 
   if (strcmp (method, "linear"))
     vi = __lin_interpn__ (x{:}, v, y{:});
-    vi (isna (vi)) = extrapval;
+    vi(isna (vi)) = extrapval;
   elseif (strcmp (method, "nearest"))
     yshape = size (y{1});
     yidx = cell (1, nd);
@@ -166,7 +166,7 @@
     for i = 1 : nd
       idx{i} = yidx{i} + (y{i} - x{i}(yidx{i})(:) >= x{i}(yidx{i} + 1)(:) - y{i});
     endfor
-    vi = v (sub2ind (sz, idx{:}));
+    vi = v(sub2ind (sz, idx{:}));
     idx = zeros (prod (yshape), 1);
     for i = 1 : nd
       idx |= y{i} < min (x{i}(:)) | y{i} > max (x{i}(:));
@@ -179,12 +179,12 @@
         if (! size_equal (y{1}, y{i}))
           error ("interpn: dimensional mismatch");
         endif
-        idx (1 : nd) = {1};
-        idx (i) = ":";
+        idx(1 : nd) = {1};
+        idx(i) = ":";
         y{i} = y{i}(idx{:});
       endfor
-      idx (1 : nd) = {1};
-      idx (1) = ":";
+      idx(1 : nd) = {1};
+      idx(1) = ":";
       y{1} = y{1}(idx{:});
     endif
 
@@ -196,9 +196,9 @@
       q = cell (1, nd);
       for i = 1 : ly
         q(:) = i;
-        idx {i} = q;
+        idx{i} = q;
       endfor
-      vi = vi (cellfun (@(x) sub2ind (size (vi), x{:}), idx));
+      vi = vi(cellfun (@(x) sub2ind (size (vi), x{:}), idx));
       vi = reshape (vi, size (y{1}));
     endif
   elseif (strcmp (method, "cubic"))