changeset 4897:89eee52fd4c7

[project @ 2004-06-03 23:07:55 by jwe]
author jwe
date Thu, 03 Jun 2004 23:11:14 +0000
parents b8a5e0bc63fe
children 8fd9495f5054
files scripts/ChangeLog scripts/plot/__errcomm__.m scripts/plot/__errplot__.m src/ChangeLog src/DLD-FUNCTIONS/filter.cc
diffstat 5 files changed, 52 insertions(+), 96 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Thu Jun 03 19:37:59 2004 +0000
+++ b/scripts/ChangeLog	Thu Jun 03 23:11:14 2004 +0000
@@ -1,3 +1,8 @@
+2004-06-03  Paul Kienzle  <pkienzle@users.sf.net>
+
+	* plot/__errcomm__.m, plot/__errplot__.m: Simplify code and fix
+	the bug which causes __errplot__ to ignore the last argument.
+
 2004-06-03  David Bateman  <dbateman@free.fr>
 
 	* general/shiftdim.m: New function based on JWE code snippet.
--- a/scripts/plot/__errcomm__.m	Thu Jun 03 19:37:59 2004 +0000
+++ b/scripts/plot/__errcomm__.m	Thu Jun 03 23:11:14 2004 +0000
@@ -31,13 +31,11 @@
 
 function __errcomm__ (caller, varargin)
 
-  nargs = nargin ();
-
-  if (nargs < 3)
-    usage ("%s (...)", caller);
+  if (nargin < 3)
+    usage ("%s (x,y,dy,'fmt',...)", caller);
   endif
 
-  nargs--;
+  nargs = length (varargin);
   save_hold = ishold;
   unwind_protect
     if (! ishold)
@@ -45,9 +43,9 @@
     endif
     hold on;
     k = 1;
-    while (nargs-- > 0)
+    data = cell(6,1);
+    while (k <= nargs)
       a = varargin{k++};
-      nargs--;
       if (isvector (a))
         a = a(:);
       elseif (ismatrix (a))
@@ -57,16 +55,11 @@
       endif
       sz = size (a);
       ndata = 1;
-      arg1 = a;
-      while (nargs-- > 0)
+      data{ndata} = a;
+      while (k <= nargs)
 	a = varargin{k++};
 	if (isstr (a))
-	  fmt = a;
-	  cmd = "__errplot__ (arg1";
-	  for i = 2:ndata,
-	    cmd = sprintf ("%s, arg%d", cmd, i);
-	  endfor
-	  eval (sprintf ("%s, fmt);", cmd));
+	  __errplot__ (a, data{1:ndata});
 	  break;
 	elseif (isvector (a))
 	  a = a(:);
@@ -78,8 +71,7 @@
 	if (size (a) != sz)
 	  error ("argument sizes do not match");
 	endif
-	ndata++;
-	eval (sprintf ("arg%d = a;", ndata));
+	data{++ndata} = a;
 	if (ndata > 6)
 	  error ("too many arguments to a plot");
 	endif
@@ -87,12 +79,7 @@
     endwhile
 
     if (! isstr (a))
-      fmt = "~";
-      cmd = "__errplot__ (arg1";
-      for i = 2:ndata,
-	cmd = sprintf ("%s, arg%d", cmd, i);
-      endfor
-      eval (sprintf ("%s, fmt);", cmd));
+      __errplot__ ("~", data{1:ndata});
     endif
   unwind_protect_cleanup
     if (! save_hold)
--- a/scripts/plot/__errplot__.m	Thu Jun 03 19:37:59 2004 +0000
+++ b/scripts/plot/__errplot__.m	Thu Jun 03 23:11:14 2004 +0000
@@ -33,81 +33,41 @@
 ## Author: Teemu Ikonen <tpikonen@pcu.helsinki.fi>
 ## Keywords: errorbar, plotting
 
-function __errplot__ (varargin)
-
-  nargs = nargin ();
-
-  if (nargs < 3) # atleast two data arguments needed
-    usage ("__errplot__ (arg1, ..., fmt)");
-  endif
+function __errplot__ (fstr,a1,a2,a3,a4,a5,a6)
 
-  fstr = " ";
-  ndata = 0;
-  k = 1;
-
-  while (nargs--)
-    a = varargin{k++};
-    if (! isstr (a))
-      ndata++;
-      eval (sprintf ("arg%d = a;", ndata));
-    else
-      fstr = a;
-    endif
-  endwhile
+  if (nargin < 3 || nargin > 7) # at least three data arguments needed
+    usage ("__errplot__ (fmt, arg1, ...)");
+  endif
 
   fmt = __pltopt__ ("__errplot__", fstr);
 
-  nplots = size (arg1, 2);
-  len = size (arg1, 1);
-
-  if (ndata == 2)
-    for i = 1:nplots,
-      tmp = [(1:len)', arg1(:,i), arg2(:,i)];
-      cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :));
-      eval (cmd);
-    endfor
-  elseif (ndata == 3)
-    for i = 1:nplots,
-      tstr = "tmp =[arg1(:,i)";
-      for j = 2:ndata,
-       tstr = [tstr, sprintf(", arg%d(:,i)", j)];
-      endfor
-      tstr = [tstr, "];"];
-      eval (tstr);
-      cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :));
-      eval (cmd);
-    endfor
-  elseif (ndata == 4)
-    for i = 1:nplots, # this is getting ugly
-      if (index (fmt, "boxxy") || index (fmt, "xyerr"))
-       tstr = "tmp = [arg1(:,i), arg2(:,i), arg3(:,i), arg4(:,i)];";
-      elseif (index (fmt, "xerr"))
-       tstr = "tmp = [arg1(:,i), arg2(:,i), arg1(:,i)-arg3(:,i), arg1(:,i)+arg4(:,i)];";
-      else
-       tstr = "tmp = [arg1(:,i), arg2(:,i), arg2(:,i)-arg3(:,i), arg2(:,i)+arg4(:,i)];";
-      endif
-      eval (tstr);
-      cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :));
-      eval (cmd);
-    endfor
-  elseif (ndata == 6)
-    for i = 1:nplots,
-      tstr = "tmp = [arg1(:,i), arg2(:,i), arg1(:,i)-arg3(:,i), arg1(:,i)+arg4(:,i), arg2(:,i)-arg5(:,i), arg2(:,i)+arg6(:,i)];";
-      eval (tstr);
-      cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :));
-      eval (cmd);
-    endfor
-  else
-    for i = 1:nplots,
-      tstr = "tmp = [arg1(:,i)";
-      for j = 2:ndata,
-       tstr = [tstr, sprintf(", arg%d(:,i)", j)];
-      endfor
-      tstr = [tstr, "];"];
-      eval (tstr);
-      cmd = sprintf ("gplot tmp %s", fmt(min(i, rows(fmt)), :));
-      eval (cmd);
-    endfor
-  endif
+  nplots = size (a1, 2);
+  len = size (a1, 1);
+  for i = 1:nplots
+    ifmt = fmt(1+mod(i,size(fmt,1)), :);
+    switch (nargin - 1)
+      case 2
+	tmp = [(1:len)', a1(:,i), a2(:,i)];
+      case 3
+	tmp = [a1(:,i), a2(:,i), a3(:,i)];
+      case 4
+	if (index (ifmt, "boxxy") || index (ifmt, "xyerr"))
+	  tmp = [a1(:,i), a2(:,i), a3(:,i), a4(:,i)];
+	elseif (index (ifmt, "xerr"))
+	  tmp = [a1(:,i), a2(:,i), a1(:,i)-a3(:,i), a1(:,i)+a4(:,i)];
+	else
+	  tmp = [a1(:,i), a2(:,i), a2(:,i)-a3(:,i), a2(:,i)+a4(:,i)];
+	endif
+      case 5
+	error ("error plot requires 2, 3, 4 or 6 columns");
+	## tmp = [a1(:,i), a2(:,i), a3(:,i), a4(:,i), a5(:,i)];
+      case 6
+	tmp = [a1(:,i), a2(:,i), ...
+	       a1(:,i)-a3(:,i), a1(:,i)+a4(:,i), ...
+	       a2(:,i)-a5(:,i), a2(:,i)+a6(:,i)];
+    endswitch
+    cmd = sprintf ("gplot tmp %s", ifmt);
+    eval (cmd);
+endfor
 
 endfunction
--- a/src/ChangeLog	Thu Jun 03 19:37:59 2004 +0000
+++ b/src/ChangeLog	Thu Jun 03 23:11:14 2004 +0000
@@ -1,3 +1,7 @@
+2004-06-03  David Bateman  <dbateman@free.fr>
+
+	* DLD-FUNCTIONS/filter.cc: Fix for length(a)=1 && length(b)=2 case.
+
 2004-05-07  John W. Eaton  <jwe@octave.org>
 
 	* ov.cc (octave_value::print_with_name): Only print name tag if
--- a/src/DLD-FUNCTIONS/filter.cc	Thu Jun 03 19:37:59 2004 +0000
+++ b/src/DLD-FUNCTIONS/filter.cc	Thu Jun 03 23:11:14 2004 +0000
@@ -113,7 +113,7 @@
       b = b / norm;
     }
 
-  if ((a_len <= 1) && (si_len <= 1))
+  if ((a_len <= 1) && (si_len <= 0))
     return b(0) * x;
 
   y.resize (x_dims, 0.0);