changeset 6959:47f4f4e88166

[project @ 2007-10-04 20:43:32 by jwe]
author jwe
date Thu, 04 Oct 2007 20:43:33 +0000
parents a18c784ae599
children d5339f9f5f9c
files configure.in liboctave/ChangeLog liboctave/oct-sort.cc liboctave/randmtzig.c src/ChangeLog src/DLD-FUNCTIONS/bsxfun.cc src/DLD-FUNCTIONS/convhulln.cc src/DLD-FUNCTIONS/symrcm.cc src/OPERATORS/op-streamoff.cc src/data.cc src/error.cc src/load-save.cc src/oct-map.cc src/oct-map.h src/ov-base-int.cc src/pr-output.cc src/pt-const.cc src/zfstream.cc
diffstat 18 files changed, 431 insertions(+), 449 deletions(-) [+]
line wrap: on
line diff
--- a/configure.in	Thu Oct 04 19:21:23 2007 +0000
+++ b/configure.in	Thu Oct 04 20:43:33 2007 +0000
@@ -29,7 +29,7 @@
 EXTERN_CXXFLAGS="$CXXFLAGS"
 
 AC_INIT
-AC_REVISION($Revision: 1.577 $)
+AC_REVISION($Revision: 1.578 $)
 AC_PREREQ(2.57)
 AC_CONFIG_SRCDIR([src/octave.cc])
 AC_CONFIG_HEADER(config.h)
@@ -1790,7 +1790,7 @@
 
 ### We have to insert extra levels of backslash quoting here so that
 ### the right thing ends up in oct-conf.h.
-UGLY_DEFS=`echo $DEFS | $(SED) 's,\\",\\\\\\\\\\\\\\\\\\",g'`
+UGLY_DEFS=`echo $DEFS | $SED 's,\\",\\\\\\\\\\\\\\\\\\",g'`
 AC_MSG_NOTICE([defining UGLY_DEFS to be $UGLY_DEFS])
 AC_SUBST(UGLY_DEFS)
 
--- a/liboctave/ChangeLog	Thu Oct 04 19:21:23 2007 +0000
+++ b/liboctave/ChangeLog	Thu Oct 04 20:43:33 2007 +0000
@@ -1,3 +1,8 @@
+2007-10-04  John W. Eaton  <jwe@octave.org>
+
+	* oct-sort.cc (octave_sort<T>::binarysort): Remove register
+	qualifiers on local variables.
+
 2007-10-04  Marco Caliari  <mcaliari@math.unipd.it>
 
 	* CMatrix.cc (ComplexMatrix::expm): Limit shift to values less
--- a/liboctave/oct-sort.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/liboctave/oct-sort.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -127,8 +127,8 @@
 void
 octave_sort<T>::binarysort (T *lo, T *hi, T *start)
 {
-  register T *l, *p, *r;
-  register T pivot;
+  T *l, *p, *r;
+  T pivot;
 
   if (lo == start)
     ++start;
--- a/liboctave/randmtzig.c	Thu Oct 04 19:21:23 2007 +0000
+++ b/liboctave/randmtzig.c	Thu Oct 04 20:43:33 2007 +0000
@@ -356,6 +356,8 @@
 #endif
 }
 
+#if 0
+// FIXME -- this doesn't seem to be used anywhere; should it be removed?
 static uint64_t 
 randi64 (void)
 {
@@ -371,7 +373,9 @@
   return (((uint64_t)hi<<32)|lo);
 #endif
 }
+#endif
 
+#ifdef ALLBITS
 /* generates a random number on (0,1)-real-interval */
 static double
 randu32 (void)
@@ -379,30 +383,27 @@
   return ((double)randi32() + 0.5) * (1.0/4294967296.0); 
   /* divided by 2^32 */
 }
-
+#else
 /* generates a random number on (0,1) with 53-bit resolution */
 static double
 randu53 (void) 
 { 
   const uint32_t a=randi32()>>5;
   const uint32_t b=randi32()>>6; 
-  return(a*67108864.0+b+0.4) * (1.0/9007199254740992.0);
+  return (a*67108864.0+b+0.4) * (1.0/9007199254740992.0);
 } 
+#endif
 
 /* Determine mantissa for uniform doubles */
-#ifdef ALLBITS
 double
 oct_randu (void)
 {
-  return randu32();
-}
+#ifdef ALLBITS
+  return randu32 ();
 #else
-double
-oct_randu (void)
-{
-  return randu53();
+  return randu53 ();
+#endif
 }
-#endif
 
 /* ===== Ziggurat normal and exponential generators ===== */
 #ifdef ALLBITS
--- a/src/ChangeLog	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/ChangeLog	Thu Oct 04 20:43:33 2007 +0000
@@ -1,5 +1,29 @@
 2007-10-04  John W. Eaton  <jwe@octave.org>
 
+	* DLD-FUNCTIONS/symrcm.cc: Move static functions to top of file to
+	avoid forward decls.
+	(Q_enq): Delete unused arg QH.  Change all uses.
+	(Q_deq): Delete unused arg QT.  Change all uses.
+	(find_starting_node): Delete unused local variable J.
+	(H_heapify_min, H_insert, find_starting_node, Fsymrcm):
+	Move local variable decls to point of first use.
+
+	* OPERATORS/op-streamoff.cc (STREAMOFF_COMP_OP):
+	Avoid control-reaches-end-of-non-void-function warning.
+
+	* pt-const.cc (tree_constant::dup): Avoid unused parameter warning.
+
+	* pr-output.cc (set_real_format, set_real_matrix_format,
+	set_complex_format, set_complex_matrix_format):
+	Delete unused arg, SIGN.  Change uses.
+
+	* oct-map.cc (Octave_map::Octave_map): Avoid shadow warning.
+
+	* load-save.cc (write_header): Use reinterpret_cast to avoid
+	old-style cast warning.
+
+	* data.cc (do_permute): Delete unused arg, FNAME.  Change all uses.
+
 	* sysdep.cc (w32_set_quiet_shutdown, MINGW_signal_cleanup): Now static.
 	(w32_set_octave_home, w32_set_quiet_shutdown, MINGW_signal_cleanup): 
 	Only define if defined (__WIN32__) && ! defined (_POSIX_VERSION).
--- a/src/DLD-FUNCTIONS/bsxfun.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/DLD-FUNCTIONS/bsxfun.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -90,6 +90,8 @@
     }
 }
 
+#if 0
+// FIXME -- this function is not used; is it OK to delete it?
 static void
 update_index (octave_value_list& idx, const dim_vector& dv, octave_idx_type i)
 {
@@ -110,6 +112,7 @@
 	}
     }
 }
+#endif
 
 static void
 update_index (Array<int>& idx, const dim_vector& dv, octave_idx_type i)
@@ -124,7 +127,7 @@
     }
 }
 
-DEFUN_DLD (bsxfun, args, nargout,
+DEFUN_DLD (bsxfun, args, ,
   " -*- texinfo -*-\n\
 @deftypefn {Lodable Function} {} bsxfun (@var{f}, @var{a}, @var{b})\n\
 Applies a binary function @var{f} element-wise to two matrix arguments\n\
--- a/src/DLD-FUNCTIONS/convhulln.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/DLD-FUNCTIONS/convhulln.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -66,10 +66,11 @@
 @end deftypefn")
 {
   octave_value_list retval;
+
 #ifdef HAVE_QHULL
   std::string options;
 
-  int nargin = args.length();
+  int nargin = args.length ();
   if (nargin < 1 || nargin > 2) 
     {
       print_usage ();
@@ -78,19 +79,19 @@
 
   if (nargin == 2) 
     {
-      if (args (1).is_string () ) 
-	options = args (1).string_value();
-      else if (args (1).is_cell ())
+      if (args (1).is_string ()) 
+	options = args(1).string_value ();
+      else if (args(1).is_cell ())
 	{
-	  Cell c = args (1). cell_value ();
+	  Cell c = args(1).cell_value ();
 	  options = "";
-	  for (octave_idx_type i = 0; i < c.numel(); i++)
+	  for (octave_idx_type i = 0; i < c.numel (); i++)
 	    {
-	      if (!c.elem(i).is_string()) 
+	      if (! c.elem(i).is_string ())
 		{
 		  error ("convhulln: second argument must be a string or cell array of strings");
 		  return retval;
-	      }
+		}
 
 	      options = options + c.elem(i).string_value() + " ";
 	    }
@@ -105,82 +106,83 @@
     // turn on some consistency checks
     options = "s Qci Tcv";
 
-  Matrix p(args(0).matrix_value());
+  Matrix p (args(0).matrix_value ());
 
-  const octave_idx_type dim = p.columns();
-  const octave_idx_type n = p.rows();
-  p = p.transpose();
+  const octave_idx_type dim = p.columns ();
+  const octave_idx_type n = p.rows ();
+  p = p.transpose ();
 
-  double *pt_array = p.fortran_vec();
+  double *pt_array = p.fortran_vec ();
 
   boolT ismalloc = False;
 
-  OCTAVE_LOCAL_BUFFER(char, flags, 250);
+  OCTAVE_LOCAL_BUFFER (char, flags, 250);
 
   // hmm, lots of options for qhull here
   // QJ guarantees that the output will be triangles
-  snprintf(flags, 250, "qhull QJ %s", options.c_str());
+  snprintf (flags, 250, "qhull QJ %s", options.c_str ());
 
-  if (!qh_new_qhull (dim, n, pt_array, ismalloc, flags, NULL, stderr)) 
+  if (! qh_new_qhull (dim, n, pt_array, ismalloc, flags, NULL, stderr)) 
     {
       // If you want some debugging information replace the NULL
       // pointer with stdout
 
-      vertexT *vertex,**vertexp;
+      vertexT *vertex, **vertexp;
       facetT *facet;
       setT *vertices;
       unsigned int nf = qh num_facets;
 
-      Matrix idx(nf, dim);
+      Matrix idx (nf, dim);
 
       octave_idx_type j, i = 0;
       FORALLfacets 
 	{
 	  j = 0;
-	  if (!facet->simplicial)
+	  if (! facet->simplicial)
 	    // should never happen with QJ
-	    error("convhulln: non-simplicial facet");
+	    error ("convhulln: non-simplicial facet");
 
 	  if (dim == 3) 
 	    {
 	      vertices = qh_facet3vertex (facet);
-	      FOREACHvertex_(vertices)
+	      FOREACHvertex_ (vertices)
 		idx(i, j++) = 1 + qh_pointid(vertex->point);
-	      qh_settempfree(&vertices);
+	      qh_settempfree (&vertices);
 	    } 
 	  else 
 	    {
 	      if (facet->toporient ^ qh_ORIENTclock) 
 		{
-		  FOREACHvertex_(facet->vertices)
+		  FOREACHvertex_ (facet->vertices)
 		    idx(i, j++) = 1 + qh_pointid(vertex->point);
 		} 
 	      else 
 		{
-		  FOREACHvertexreverse12_(facet->vertices)
+		  FOREACHvertexreverse12_ (facet->vertices)
 		    idx(i, j++) = 1 + qh_pointid(vertex->point);
 		}
 	    }
 	  if (j < dim)
 	    // likewise but less fatal
-	    warning("facet %d only has %d vertices",i,j);
+	    warning ("facet %d only has %d vertices", i, j);
 	  i++;
 	}
-      retval(0) = octave_value(idx);
+      retval(0) = octave_value (idx);
     }
-  qh_freeqhull (!qh_ALL);
-  //free long memory
+
+  // free long memory
+  qh_freeqhull (! qh_ALL);
+
+  // free short memory and memory allocator
   int curlong, totlong;
   qh_memfreeshort (&curlong, &totlong);
-  //free short memory and memory allocator
 
   if (curlong || totlong) 
-    {
-      warning("convhulln: did not free %d bytes of long memory (%d pieces)",
-	      totlong, curlong);
-    }
+    warning ("convhulln: did not free %d bytes of long memory (%d pieces)",
+	    totlong, curlong);
 #else
   error ("convhulln: not available in this version of Octave");
 #endif
+
   return retval;
 }
--- a/src/DLD-FUNCTIONS/symrcm.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/DLD-FUNCTIONS/symrcm.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -82,14 +82,23 @@
 // stored in an array. qh and qt point to queue head and tail.
 
 // Enqueue operation (adds a node "o" at the tail)
+
 inline static void 
-Q_enq (CMK_Node *Q, octave_idx_type N, octave_idx_type& qh,
-       octave_idx_type& qt, const CMK_Node& o);	
+Q_enq (CMK_Node *Q, octave_idx_type N, octave_idx_type& qt, const CMK_Node& o)
+{	
+  Q[qt] = o;
+  qt = (qt + 1) % (N + 1);
+}
 
 // Dequeue operation (removes a node from the head)
+
 inline static CMK_Node 
-Q_deq(CMK_Node * Q, octave_idx_type N, octave_idx_type &qh,
-      octave_idx_type &qt);
+Q_deq (CMK_Node * Q, octave_idx_type N, octave_idx_type& qh)
+{
+  CMK_Node r = Q[qh];
+  qh = (qh + 1) % (N + 1);
+  return r;
+}
 
 // Predicate (queue empty)
 #define Q_empty(Q, N, qh, qt)	((qh) == (qt))
@@ -105,41 +114,305 @@
 
 // Builds a min-heap (the root contains the smallest element). A is an array
 // with the graph's nodes, i is a starting position, size is the length of A.
+
 static void 
-H_heapify_min(CMK_Node *A, octave_idx_type i, octave_idx_type size);
+H_heapify_min (CMK_Node *A, octave_idx_type i, octave_idx_type size)
+{
+  octave_idx_type j = i;
+  for (;;)
+    {
+      octave_idx_type l = LEFT(j);
+      octave_idx_type r = RIGHT(j);
+
+      octave_idx_type smallest;
+      if (l < size && A[l].deg < A[j].deg)
+	smallest = l;
+      else
+	smallest = j;
+
+      if (r < size && A[r].deg < A[smallest].deg)
+	smallest = r;
+
+      if (smallest != j)
+	{
+	  CMK_Node tmp = A[j];
+	  A[j] = A[smallest];
+	  A[smallest] = tmp;
+	  j = smallest;
+	}
+      else 
+	break;
+    }
+}
 
 // Heap operation insert. Running time is O(log(n))
+
 static void 
-H_insert(CMK_Node *H, octave_idx_type &h, const CMK_Node &o);
+H_insert (CMK_Node *H, octave_idx_type& h, const CMK_Node& o)
+{
+  octave_idx_type i = h++;
+
+  H[i] = o;
+
+  if (i == 0) 
+    return;
+  do
+    {
+      octave_idx_type p = PARENT(i);
+      if (H[i].deg < H[p].deg)
+	{
+	  CMK_Node tmp = H[i];
+	  H[i] = H[p];
+	  H[p] = tmp;
+
+	  i = p;
+	}
+      else 
+	break;
+    }
+  while (i > 0);
+}
 
 // Heap operation remove-min. Removes the smalles element in O(1) and
 // reorganizes the heap optionally in O(log(n))
+
 inline static CMK_Node 
-H_remove_min(CMK_Node *H, octave_idx_type &h, int reorg /*=1*/);
+H_remove_min (CMK_Node *H, octave_idx_type& h, int reorg/*=1*/)
+{
+  CMK_Node r = H[0];
+  H[0] = H[--h];
+  if (reorg) 
+    H_heapify_min(H, 0, h);
+  return r;
+}
 
 // Predicate (heap empty)
 #define H_empty(H, h)	((h) == 0)
 
 // Helper function for the Cuthill-McKee algorithm. Tries to determine a
 // pseudo-peripheral node of the graph as starting node.
+
 static octave_idx_type 
-find_starting_node(octave_idx_type N, const octave_idx_type *ridx,
-		   const octave_idx_type *cidx, const octave_idx_type *ridx2,
-		   const octave_idx_type *cidx2, octave_idx_type *D, 
-		   octave_idx_type start);
+find_starting_node (octave_idx_type N, const octave_idx_type *ridx, 
+		    const octave_idx_type *cidx, const octave_idx_type *ridx2, 
+		    const octave_idx_type *cidx2, octave_idx_type *D, 
+		    octave_idx_type start)
+{
+  CMK_Node w;
+
+  OCTAVE_LOCAL_BUFFER (CMK_Node, Q, N+1);
+  boolNDArray btmp (dim_vector (1, N), false);
+  bool *visit = btmp.fortran_vec ();
+
+  octave_idx_type qh = 0;
+  octave_idx_type qt = 0;
+  CMK_Node x;
+  x.id = start;
+  x.deg = D[start];
+  x.dist = 0;
+  Q_enq (Q, N, qt, x);
+  visit[start] = true;
+
+  // distance level
+  octave_idx_type level = 0;
+  // current largest "eccentricity"
+  octave_idx_type max_dist = 0;
+
+  for (;;)
+    {
+      while (! Q_empty (Q, N, qh, qt))
+	{
+	  CMK_Node v = Q_deq (Q, N, qh);
+
+	  if (v.dist > x.dist || (v.id != x.id && v.deg > x.deg))
+	    x = v;
+
+	  octave_idx_type i = v.id;
+
+	  // add all unvisited neighbors to the queue
+	  octave_idx_type j1 = cidx[i];
+	  octave_idx_type j2 = cidx2[i];
+	  while (j1 < cidx[i+1] || j2 < cidx2[i+1])
+	    {
+	      OCTAVE_QUIT;
+
+	      if (j1 == cidx[i+1])
+		{
+		  octave_idx_type r2 = ridx2[j2++];
+		  if (! visit[r2])
+		    {
+		      // the distance of node j is dist(i)+1
+		      w.id = r2;
+		      w.deg = D[r2];
+		      w.dist = v.dist+1;
+		      Q_enq (Q, N, qt, w);
+		      visit[r2] = true;
+
+		      if (w.dist > level)
+			level = w.dist;
+		    }
+		}
+	      else if (j2 == cidx2[i+1])
+		{
+		  octave_idx_type r1 = ridx[j1++];
+		  if (! visit[r1])
+		    {
+		      // the distance of node j is dist(i)+1
+		      w.id = r1;
+		      w.deg = D[r1];
+		      w.dist = v.dist+1;
+		      Q_enq (Q, N, qt, w);
+		      visit[r1] = true;
+
+		      if (w.dist > level)
+			level = w.dist;
+		    }
+		}
+	      else
+		{
+		  octave_idx_type r1 = ridx[j1];
+		  octave_idx_type r2 = ridx2[j2];
+		  if (r1 <= r2)
+		    {
+		      if (! visit[r1])
+			{
+			  w.id = r1;
+			  w.deg = D[r1];
+			  w.dist = v.dist+1;
+			  Q_enq (Q, N, qt, w);
+			  visit[r1] = true;
+
+			  if (w.dist > level)
+			    level = w.dist;
+			}
+		      j1++;
+		      if (r1 == r2)
+			j2++;
+		    }
+		  else
+		    {
+		      if (! visit[r2])
+			{
+			  w.id = r2;
+			  w.deg = D[r2];
+			  w.dist = v.dist+1;
+			  Q_enq (Q, N, qt, w);
+			  visit[r2] = true;
+
+			  if (w.dist > level)
+			    level = w.dist;
+			}
+		      j2++;
+		    }
+		}
+	    }
+	} // finish of BFS
+
+      if (max_dist < x.dist)
+	{
+	  max_dist = x.dist;
+
+	  for (octave_idx_type i = 0; i < N; i++)
+	    visit[i] = false;
+
+	  visit[x.id] = true;
+	  x.dist = 0;
+	  qt = qh = 0;
+	  Q_enq (Q, N, qt, x);
+	}
+      else
+	break;
+    }
+  return x.id;
+}
 
 // Calculates the node's degrees. This means counting the non-zero elements
 // in the symmetric matrix' rows. This works for non-symmetric matrices 
 // as well.
-static octave_idx_type
-calc_degrees(octave_idx_type N, const octave_idx_type *ridx, 
-	     const octave_idx_type *cidx, octave_idx_type *D);
+
+static octave_idx_type 
+calc_degrees (octave_idx_type N, const octave_idx_type *ridx, 
+	      const octave_idx_type *cidx, octave_idx_type *D)
+{
+  octave_idx_type max_deg = 0;
+
+  for (octave_idx_type i = 0; i < N; i++) 
+    D[i] = 0;
+
+  for (octave_idx_type j = 0; j < N; j++)
+    {
+      for (octave_idx_type i = cidx[j]; i < cidx[j+1]; i++)
+	{
+	  OCTAVE_QUIT;
+	  octave_idx_type k = ridx[i];
+	  // there is a non-zero element (k,j)
+	  D[k]++;
+	  if (D[k] > max_deg) 
+	    max_deg = D[k];
+	  // if there is no element (j,k) there is one in
+	  // the symmetric matrix:
+	  if (k != j)
+	    {
+	      bool found = false;
+	      for (octave_idx_type l = cidx[k]; l < cidx[k + 1]; l++)
+		{
+		  OCTAVE_QUIT;
+
+		  if (ridx[l] == j)
+		    {
+		      found = true;
+		      break;
+		    }
+		  else if (ridx[l] > j)
+		    break;
+		}
+
+	      if (! found)
+		{
+		  // A(j,k) == 0
+		  D[j]++;
+		  if (D[j] > max_deg) 
+		    max_deg = D[j];
+		}
+	    }
+	}
+    }
+  return max_deg;
+}
 
 // Transpose of the structure of a square sparse matrix
+
 static void
 transpose (octave_idx_type N, const octave_idx_type *ridx, 
 	   const octave_idx_type *cidx, octave_idx_type *ridx2, 
-	   octave_idx_type *cidx2);
+	   octave_idx_type *cidx2)
+{
+  octave_idx_type nz = cidx[N];
+
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, w, N + 1);
+  for (octave_idx_type i = 0; i < N; i++)
+    w[i] = 0;
+  for (octave_idx_type i = 0; i < nz; i++)
+    w[ridx[i]]++;
+  nz = 0;
+  for (octave_idx_type i = 0; i < N; i++)
+    {
+      OCTAVE_QUIT;
+      cidx2[i] = nz;
+      nz += w[i];
+      w[i] = cidx2[i];
+    }
+  cidx2[N] = nz;
+  w[N] = nz;
+
+  for (octave_idx_type j = 0; j < N; j++)
+    for (octave_idx_type k = cidx[j]; k < cidx[j + 1]; k++)
+      {
+	OCTAVE_QUIT;
+	octave_idx_type q = w [ridx[k]]++;
+	ridx2[q] = j;
+      }
+}
 
 // An implementation of the Cuthill-McKee algorithm.
 DEFUN_DLD (symrcm, args, ,
@@ -168,7 +441,7 @@
 @end deftypefn")
 {
   octave_value retval;
-  int nargin = args.length();
+  int nargin = args.length ();
 
   if (nargin != 1)
     {
@@ -176,7 +449,7 @@
       return retval;
     }
 
-  octave_value arg = args (0);
+  octave_value arg = args(0);
 
   // the parameter of the matrix is converted into a sparse matrix 
   //(if necessary)
@@ -187,14 +460,14 @@
 
   if (arg.is_real_type ())
     {
-      Ar = arg.sparse_matrix_value();
+      Ar = arg.sparse_matrix_value ();
       // Note cidx/ridx are const, so use xridx and xcidx...
       cidx = Ar.xcidx ();
       ridx = Ar.xridx ();
     }
   else
     {
-      Ac = arg.sparse_complex_matrix_value();
+      Ac = arg.sparse_complex_matrix_value ();
       cidx = Ac.xcidx ();
       ridx = Ac.xridx ();
     }
@@ -207,32 +480,22 @@
 
   if (nr != nc)
     {
-      gripe_square_matrix_required("symrcm");
+      gripe_square_matrix_required ("symrcm");
       return retval;
     }
 
   if (nr == 0 && nc == 0)
-    {
-      retval = NDArray (dim_vector (1, 0));
-      return retval;
-    }
-  
+    return octave_value (NDArray (dim_vector (1, 0)));
+
   // sizes of the heaps
   octave_idx_type s = 0;
+
   // head- and tail-indices for the queue
-  octave_idx_type qt=0, qh=0;
+  octave_idx_type qt = 0, qh = 0;
   CMK_Node v, w;
-  octave_idx_type c;
-  octave_idx_type i, j, max_deg;
-  // upper bound for the bandwidth (=quality of solution)
-  octave_idx_type B;
-  // lower bound for the bandwidth of a subgraph
-  octave_idx_type Bsub;
-  octave_idx_type level, level_N;
   // dimension of the matrix
-  octave_idx_type N;
-  
-  N = nr;
+  octave_idx_type N = nr;
+
   OCTAVE_LOCAL_BUFFER (octave_idx_type, cidx2, N + 1);
   OCTAVE_LOCAL_BUFFER (octave_idx_type, ridx2, cidx[N]);
   transpose (N, ridx, cidx, ridx2, cidx2);
@@ -241,34 +504,34 @@
   NDArray P (dim_vector (1, N));
 
   // compute the node degrees
-  OCTAVE_LOCAL_BUFFER(octave_idx_type, D, N);
-  max_deg = calc_degrees(N, ridx, cidx, D);
+  OCTAVE_LOCAL_BUFFER (octave_idx_type, D, N);
+  octave_idx_type max_deg = calc_degrees (N, ridx, cidx, D);
 
   // if none of the nodes has a degree > 0 (a matrix of zeros)
   // the return value corresponds to the identity permutation
   if (max_deg == 0)
     {
-      for (i = 0; i < N; i++) 
-	P (i) = i;
-      retval = P;
-      return retval;
+      for (octave_idx_type i = 0; i < N; i++) 
+	P(i) = i;
+      return octave_value (P);
     }
 
   // a heap for the a node's neighbors. The number of neighbors is
   // limited by the maximum degree max_deg:
-  OCTAVE_LOCAL_BUFFER(CMK_Node, S, max_deg);
+  OCTAVE_LOCAL_BUFFER (CMK_Node, S, max_deg);
 
   // a queue for the BFS. The array is always one element larger than
   // the number of entries that are stored.
-  OCTAVE_LOCAL_BUFFER(CMK_Node, Q, N+1);
+  OCTAVE_LOCAL_BUFFER (CMK_Node, Q, N+1);
 
   // a counter (for building the permutation)
-  c = -1;
+  octave_idx_type c = -1;
 
+  // upper bound for the bandwidth (=quality of solution)
   // initialize the bandwidth of the graph with 0. B contains the
   // the maximum of the theoretical lower limits of the subgraphs
   // bandwidths.
-  B = 0;
+  octave_idx_type B = 0;
 
   // mark all nodes as unvisited; with the exception of the nodes
   // that have degree==0 and build a CC of the graph.
@@ -279,6 +542,7 @@
   do
     {
       // locate an unvisited starting node of the graph
+      octave_idx_type i;
       for (i = 0; i < N; i++)
 	if (! visit[i]) 
 	  break;
@@ -292,20 +556,21 @@
       v.deg = D[v.id];
       v.dist = 0;
       visit[v.id] = true;
-      Q_enq (Q, N, qh, qt, v);
+      Q_enq (Q, N, qt, v);
 
+      // lower bound for the bandwidth of a subgraph
       // keep a "level" in the spanning tree (= min. distance to the
       // root) for determining the bandwidth of the computed
       // permutation P
-      Bsub = 0;
+      octave_idx_type Bsub = 0;
       // min. dist. to the root is 0
-      level = 0;
+      octave_idx_type level = 0;
       // the root is the first/only node on level 0
-      level_N = 1;
+      octave_idx_type level_N = 1;
 	
       while (! Q_empty (Q, N, qh, qt))
 	{
-	  v = Q_deq (Q, N, qh, qt);
+	  v = Q_deq (Q, N, qh);
 	  i = v.id;
 
 	  c++;
@@ -386,7 +651,7 @@
 	    }
 
 	  // add the neighbors to the queue (sorted by node degree)
-	  while (! H_empty(S, s))
+	  while (! H_empty (S, s))
 	    {
 	      OCTAVE_QUIT;
 
@@ -415,7 +680,7 @@
 		}
 	
 	      // enqueue v in O(1)
-	      Q_enq (Q, N, qh, qt, v);
+	      Q_enq (Q, N, qt, v);
 	    }
 	
 	  // synchronize the bandwidth with level_N once again:
@@ -433,7 +698,7 @@
 
   // compute the reverse-ordering
   s = N / 2 - 1;
-  for (i = 0, j = N - 1; i <= s; i++, j--)
+  for (octave_idx_type i = 0, j = N - 1; i <= s; i++, j--)
     {
       double tmp = P.elem(i);
       P.elem(i) = P.elem(j);
@@ -441,313 +706,5 @@
     }
 
   // increment all indices, since Octave is not C
-  retval = P+1;
-  return retval;
-}
-
-//
-// implementatation of static functions
-//
-
-inline static void 
-Q_enq (CMK_Node *Q, octave_idx_type N, octave_idx_type& qh,
-       octave_idx_type& qt, const CMK_Node& o)
-{	
-  Q[qt] = o;
-  qt = (qt + 1) % (N + 1);
-}
-
-inline static CMK_Node 
-Q_deq(CMK_Node * Q, octave_idx_type N, octave_idx_type &qh,
-      octave_idx_type &qt)
-{
-  CMK_Node r = Q[qh];
-  qh = (qh + 1) % (N + 1);
-  return r;
-}
-
-static void 
-H_heapify_min(CMK_Node *A, octave_idx_type i, octave_idx_type size)
-{
-  octave_idx_type j, l, r;
-  octave_idx_type smallest;
-  CMK_Node tmp;
-
-  j = i;
-  for (;;)
-    {
-      l = LEFT(j);
-      r = RIGHT(j);
-
-      if (l<size && A[l].deg<A[j].deg)
-	smallest = l;
-      else
-	smallest = j;
-
-      if (r < size && A[r].deg < A[smallest].deg)
-	smallest = r;
-
-      if (smallest != j)
-	{
-	  tmp = A[j];
-	  A[j] = A[smallest];
-	  A[smallest] = tmp;
-	  j = smallest;
-	}
-      else 
-	break;
-    }
-}
-
-static void 
-H_insert(CMK_Node *H, octave_idx_type &h, const CMK_Node &o)
-{
-  octave_idx_type i = h++;
-  octave_idx_type p;
-  CMK_Node tmp;
-
-  H[i] = o;
-
-  if (i == 0) 
-    return;
-  do
-    {
-      p = PARENT(i);
-      if (H[i].deg < H[p].deg)
-	{
-	  tmp = H[i];
-	  H[i] = H[p];
-	  H[p] = tmp;
-
-	  i = p;
-	}
-      else 
-	break;
-    }
-  while (i > 0);
-}
-
-inline static CMK_Node 
-H_remove_min(CMK_Node *H, octave_idx_type &h, int reorg/*=1*/)
-{
-  CMK_Node r = H[0];
-  H[0] = H[--h];
-  if (reorg) 
-    H_heapify_min(H, 0, h);
-  return r;
+  return octave_value (P+1);
 }
-
-static octave_idx_type 
-find_starting_node(octave_idx_type N, const octave_idx_type *ridx, 
-		   const octave_idx_type *cidx,  const octave_idx_type *ridx2, 
-		   const octave_idx_type *cidx2, octave_idx_type *D, 
-		   octave_idx_type start)
-{
-  octave_idx_type i, j, qt, qh, level, max_dist;
-  CMK_Node v, w, x;
-
-  OCTAVE_LOCAL_BUFFER(CMK_Node, Q, N+1);
-  boolNDArray btmp (dim_vector (1, N), false);
-  bool * visit = btmp.fortran_vec ();
-
-  qh = qt = 0;
-  x.id = start;
-  x.deg = D[start];
-  x.dist = 0;
-  Q_enq (Q, N, qh, qt, x);
-  visit[start] = true;
-
-  // distance level
-  level = 0;
-  // current largest "eccentricity"
-  max_dist = 0;
-
-  for (;;)
-    {
-      while (! Q_empty(Q, N, qh, qt))
-	{
-	  v = Q_deq(Q, N, qh, qt);
-
-	  if (v.dist > x.dist || (v.id != x.id && v.deg > x.deg))
-	    x = v;
-
-	  i = v.id;
-
-	  // add all unvisited neighbors to the queue
-	  octave_idx_type j1 = cidx[i];
-	  octave_idx_type j2 = cidx2[i];
-	  while (j1 < cidx[i+1] || j2 < cidx2[i+1])
-	    {
-	      OCTAVE_QUIT;
-
-	      if (j1 == cidx[i+1])
-		{
-		  octave_idx_type r2 = ridx2[j2++];
-		  if (! visit[r2])
-		    {
-		      // the distance of node j is dist(i)+1
-		      w.id = r2;
-		      w.deg = D[r2];
-		      w.dist = v.dist+1;
-		      Q_enq(Q, N, qh, qt, w);
-		      visit[r2] = true;
-
-		      if (w.dist > level)
-			level = w.dist;
-		    }
-		}
-	      else if (j2 == cidx2[i+1])
-		{
-		  octave_idx_type r1 = ridx[j1++];
-		  if (! visit[r1])
-		    {
-		      // the distance of node j is dist(i)+1
-		      w.id = r1;
-		      w.deg = D[r1];
-		      w.dist = v.dist+1;
-		      Q_enq(Q, N, qh, qt, w);
-		      visit[r1] = true;
-
-		      if (w.dist > level)
-			level = w.dist;
-		    }
-		}
-	      else
-		{
-		  octave_idx_type r1 = ridx[j1];
-		  octave_idx_type r2 = ridx2[j2];
-		  if (r1 <= r2)
-		    {
-		      if (! visit[r1])
-			{
-			  w.id = r1;
-			  w.deg = D[r1];
-			  w.dist = v.dist+1;
-			  Q_enq(Q, N, qh, qt, w);
-			  visit[r1] = true;
-
-			  if (w.dist > level)
-			    level = w.dist;
-			}
-		      j1++;
-		      if (r1 == r2)
-			j2++;
-		    }
-		  else
-		    {
-		      if (! visit[r2])
-			{
-			  w.id = r2;
-			  w.deg = D[r2];
-			  w.dist = v.dist+1;
-			  Q_enq(Q, N, qh, qt, w);
-			  visit[r2] = true;
-
-			  if (w.dist > level)
-			    level = w.dist;
-			}
-		      j2++;
-		    }
-		}
-	    }
-	} // finish of BFS
-
-      if (max_dist < x.dist)
-	{
-	  max_dist = x.dist;
-
-	  for (i = 0; i < N; i++)
-	    visit[i] = false;
-
-	  visit[x.id] = true;
-	  x.dist = 0;
-	  qt = qh = 0;
-	  Q_enq (Q, N, qh, qt, x);
-	}
-      else
-	break;
-    }
-  return x.id;
-}
-
-static octave_idx_type 
-calc_degrees(octave_idx_type N, const octave_idx_type *ridx, 
-	     const octave_idx_type *cidx, octave_idx_type *D)
-{
-  octave_idx_type max_deg = 0;
-
-  for (octave_idx_type i = 0; i < N; i++) 
-    D[i] = 0;
-
-  for (octave_idx_type j = 0; j < N; j++)
-    {
-      for (octave_idx_type i = cidx[j]; i < cidx[j+1]; i++)
-	{
-	  OCTAVE_QUIT;
-	  octave_idx_type k = ridx[i];
-	  // there is a non-zero element (k,j)
-	  D[k]++;
-	  if (D[k] > max_deg) 
-	    max_deg = D[k];
-	  // if there is no element (j,k) there is one in
-	  // the symmetric matrix:
-	  if (k != j)
-	    {
-	      bool found = false;
-	      for (octave_idx_type l = cidx[k]; l < cidx[k + 1]; l++)
-		{
-		  OCTAVE_QUIT;
-
-		  if (ridx[l] == j)
-		    {
-		      found = true;
-		      break;
-		    }
-		  else if (ridx[l] > j)
-		    break;
-		}
-
-	      if (! found)
-		{
-		  // A(j,k) == 0
-		  D[j]++;
-		  if (D[j] > max_deg) 
-		    max_deg = D[j];
-		}
-	    }
-	}
-    }
-  return max_deg;
-}
-
-static void
-transpose (octave_idx_type N, const octave_idx_type *ridx, 
-	   const octave_idx_type *cidx, octave_idx_type *ridx2, 
-	   octave_idx_type *cidx2)
-{
-  octave_idx_type nz = cidx[N];
-
-  OCTAVE_LOCAL_BUFFER (octave_idx_type, w, N + 1);
-  for (octave_idx_type i = 0; i < N; i++)
-    w[i] = 0;
-  for (octave_idx_type i = 0; i < nz; i++)
-    w[ridx[i]]++;
-  nz = 0;
-  for (octave_idx_type i = 0; i < N; i++)
-    {
-      OCTAVE_QUIT;
-      cidx2[i] = nz;
-      nz += w[i];
-      w[i] = cidx2[i];
-    }
-  cidx2[N] = nz;
-  w[N] = nz;
-
-  for (octave_idx_type j = 0; j < N; j++)
-    for (octave_idx_type k = cidx[j]; k < cidx[j + 1]; k++)
-      {
-	OCTAVE_QUIT;
-	octave_idx_type q = w [ridx[k]]++;
-	ridx2[q] = j;
-      }
-}
--- a/src/OPERATORS/op-streamoff.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/OPERATORS/op-streamoff.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -95,8 +95,8 @@
 			     m2, cm2, m1(i,j) OP m2(i,j), #OP, 0.0, 1.0); \
 	  } \
       } \
-    else \
-      return octave_value (); \
+ \
+    return boolMatrix (); \
   }
 
 STREAMOFF_COMP_OP (eq, ==, streamoff, streamoff);
--- a/src/data.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/data.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -888,7 +888,7 @@
 }
 
 static octave_value
-do_permute (const octave_value_list& args, bool inv, const std::string& fname)
+do_permute (const octave_value_list& args, bool inv)
 {
   octave_value retval;
 
@@ -924,7 +924,7 @@
 @seealso{ipermute}\n\
 @end deftypefn")
 {
-  return do_permute (args, false, "permute");
+  return do_permute (args, false);
 }
 
 DEFUN (ipermute, args, ,
@@ -939,7 +939,7 @@
 @seealso{permute}\n\
 @end deftypefn")
 {
-  return do_permute (args, true, "ipermute");
+  return do_permute (args, true);
 }
 
 DEFUN (length, args, ,
--- a/src/error.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/error.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -837,7 +837,7 @@
   int nargin = args.length();
 
   if (nargin != 1)
-    print_usage();
+    print_usage ();
   else
     {
       Octave_map err = args(0).map_value ();
--- a/src/load-save.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/load-save.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -1247,7 +1247,7 @@
     case LS_MAT7_BINARY:
       {
 	char const * versionmagic;
-	int16_t number = *(int16_t *)"\x00\x01";
+	int16_t number = *(reinterpret_cast<const int16_t *>("\x00\x01"));
 	struct tm bdt;
 	time_t now;
 	char headertext[128];
--- a/src/oct-map.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/oct-map.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -31,16 +31,16 @@
 #include "oct-map.h"
 #include "utils.h"
 
-Octave_map::Octave_map (const dim_vector& dv, const Cell& keys)
+Octave_map::Octave_map (const dim_vector& dv, const Cell& key_vals)
   : map (), key_list (), dimensions (dv)
 {
   Cell c (dv);
 
-  if (keys.is_cellstr ())
+  if (key_vals.is_cellstr ())
     {
-      for (octave_idx_type i = 0; i < keys.numel (); i++)
+      for (octave_idx_type i = 0; i < key_vals.numel (); i++)
 	{
-	  std::string k = keys(i).string_value ();
+	  std::string k = key_vals(i).string_value ();
 	  map[k] = c;
 	  key_list.push_back (k);
 	}
--- a/src/oct-map.h	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/oct-map.h	Thu Oct 04 20:43:33 2007 +0000
@@ -47,7 +47,7 @@
   // Warning!  You should always use at least two dimensions.
 
   Octave_map (const dim_vector& dv = dim_vector (0, 0),
-	      const Cell& keys = Cell ());
+	      const Cell& key_vals = Cell ());
 
   Octave_map (const std::string& k, const octave_value& value)
     : map (), key_list (), dimensions (1, 1)
--- a/src/ov-base-int.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/ov-base-int.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -88,6 +88,7 @@
 
       typename T::elt_type::val_type ival = tmp.value ();
 
+      
       if (ival < 0 || ival > UCHAR_MAX)
 	{
 	  // FIXME -- is there something better we could do?
@@ -96,7 +97,6 @@
 
 	  if (! warned)
 	    {
-
 	      ::warning ("range error for conversion to character value");
 	      warned = true;
 	    }
--- a/src/pr-output.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/pr-output.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -426,8 +426,7 @@
 // functions,..
 
 static void
-set_real_format (bool sign, int digits, bool inf_or_nan, bool int_only,
-		 int &fw)
+set_real_format (int digits, bool inf_or_nan, bool int_only, int &fw)
 {
   static float_format fmt;
 
@@ -522,8 +521,6 @@
   if (free_format)
     return;
 
-  bool sign = (d < 0.0);
-
   bool inf_or_nan = (xisinf (d) || xisnan (d));
 
   bool int_only = (! inf_or_nan && D_NINT (d) == d);
@@ -533,7 +530,7 @@
   int digits = (inf_or_nan || d_abs == 0.0)
     ? 0 : static_cast<int> (floor (log10 (d_abs) + 1.0));
 
-  set_real_format (sign, digits, inf_or_nan, int_only, fw);
+  set_real_format (digits, inf_or_nan, int_only, fw);
 }
 
 static inline void
@@ -544,8 +541,8 @@
 }
 
 static void
-set_real_matrix_format (bool sign, int x_max, int x_min,
-			bool inf_or_nan, int int_or_inf_or_nan, int& fw)
+set_real_matrix_format (int x_max, int x_min, bool inf_or_nan,
+			int int_or_inf_or_nan, int& fw)
 {
   static float_format fmt;
 
@@ -669,8 +666,6 @@
   if (free_format)
     return;
 
-  bool sign = m.any_element_is_negative (true);
-
   bool inf_or_nan = m.any_element_is_inf_or_nan ();
 
   bool int_or_inf_or_nan = m.all_elements_are_int_or_inf_or_nan ();
@@ -687,8 +682,7 @@
 
   scale = (x_max == 0 || int_or_inf_or_nan) ? 1.0 : std::pow (10.0, x_max - 1);
 
-  set_real_matrix_format (sign, x_max, x_min, inf_or_nan,
-			  int_or_inf_or_nan, fw);
+  set_real_matrix_format (x_max, x_min, inf_or_nan, int_or_inf_or_nan, fw);
 }
 
 static inline void
@@ -700,8 +694,8 @@
 }
 
 static void
-set_complex_format (bool sign, int x_max, int x_min, int r_x,
-		    bool inf_or_nan, int int_only, int& r_fw, int& i_fw)
+set_complex_format (int x_max, int x_min, int r_x, bool inf_or_nan,
+		    int int_only, int& r_fw, int& i_fw)
 {
   static float_format r_fmt;
   static float_format i_fmt;
@@ -850,8 +844,6 @@
   double rp = c.real ();
   double ip = c.imag ();
 
-  bool sign = (rp < 0.0);
-
   bool inf_or_nan = (xisinf (c) || xisnan (c));
 
   bool int_only = (D_NINT (rp) == rp && D_NINT (ip) == ip);
@@ -878,8 +870,7 @@
       x_min = r_x;
     }
 
-  set_complex_format (sign, x_max, x_min, r_x, inf_or_nan, int_only,
-		      r_fw, i_fw);
+  set_complex_format (x_max, x_min, r_x, inf_or_nan, int_only, r_fw, i_fw);
 }
 
 static inline void
@@ -890,8 +881,8 @@
 }
 
 static void
-set_complex_matrix_format (bool sign, int x_max, int x_min,
-			   int r_x_max, int r_x_min, bool inf_or_nan,
+set_complex_matrix_format (int x_max, int x_min, int r_x_max,
+			   int r_x_min, bool inf_or_nan,
 			   int int_or_inf_or_nan, int& r_fw, int& i_fw)
 {
   static float_format r_fmt;
@@ -1054,8 +1045,6 @@
   Matrix rp = real (cm);
   Matrix ip = imag (cm);
 
-  bool sign = rp.any_element_is_negative (true);
-
   bool inf_or_nan = cm.any_element_is_inf_or_nan ();
 
   bool int_or_inf_or_nan = (rp.all_elements_are_int_or_inf_or_nan ()
@@ -1086,8 +1075,8 @@
 
   scale = (x_max == 0 || int_or_inf_or_nan) ? 1.0 : std::pow (10.0, x_max - 1);
 
-  set_complex_matrix_format (sign, x_max, x_min, r_x_max, r_x_min,
-			     inf_or_nan, int_or_inf_or_nan, r_fw, i_fw);
+  set_complex_matrix_format (x_max, x_min, r_x_max, r_x_min, inf_or_nan,
+			     int_or_inf_or_nan, r_fw, i_fw);
 }
 
 static inline void
--- a/src/pt-const.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/pt-const.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -71,7 +71,7 @@
 }
 
 tree_expression *
-tree_constant::dup (symbol_table *sym_tab)
+tree_constant::dup (symbol_table *)
 {
   tree_constant *new_tc
     = new tree_constant (val, orig_text, line (), column ());
--- a/src/zfstream.cc	Thu Oct 04 19:21:23 2007 +0000
+++ b/src/zfstream.cc	Thu Oct 04 20:43:33 2007 +0000
@@ -160,7 +160,8 @@
 gzfilebuf::open_mode(std::ios_base::openmode mode,
                      char* c_mode) const
 {
-  bool testb = mode & std::ios_base::binary;
+  // FIXME -- do we need testb?
+  // bool testb = mode & std::ios_base::binary;
   bool testi = mode & std::ios_base::in;
   bool testo = mode & std::ios_base::out;
   bool testt = mode & std::ios_base::trunc;