changeset 4764:86c748d5f0af

[project @ 2004-02-16 05:14:59 by jwe]
author jwe
date Mon, 16 Feb 2004 05:15:50 +0000
parents ac927178fce7
children e941e1470d7b
files src/data.cc src/ov-cell.cc
diffstat 2 files changed, 36 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/data.cc	Mon Feb 16 05:11:01 2004 +0000
+++ b/src/data.cc	Mon Feb 16 05:15:50 2004 +0000
@@ -840,7 +840,7 @@
 
       int curr_add_dims = 0;
 
-      // Tells us wether the array we concatenated had less dimensions
+      // Tells us wether the array we concatenated had fewer dimensions
       // than dim, such that we only add one dimension to
       // curr_add_dims.
 
--- a/src/ov-cell.cc	Mon Feb 16 05:11:01 2004 +0000
+++ b/src/ov-cell.cc	Mon Feb 16 05:15:50 2004 +0000
@@ -1015,69 +1015,72 @@
   "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} struct2cell (@var{S})\n\
 Create a new cell array from the objects stored in the struct object.\n\
-If F is the number of fields in the structure, the resulting cell array will\n\
-have a dimension vector corresponding to [F size(S)].\n\
-\n\
+If @var{f} is the number of fields in the structure, the resulting\n\
+cell array will have a dimension vector corresponding to\n\
+@code{[@var{F} size(@var{S})]}.\n\
 @end deftypefn\n\
 @seealso{cell2struct, fieldnames}")
 {
   octave_value retval;
-  
+
   int nargin = args.length ();
-  
+
   if (nargin == 1)
     {
-      Octave_map m = args(0).map_value();
-      
+      Octave_map m = args(0).map_value ();
+
       if (! error_state)
 	{
 	  dim_vector m_dv = m.dims ();
-	  
+
 	  string_vector keys = m.keys ();
-	  
+
 	  int fields_numel = keys.length ();
-	  
+
 	  // The resulting dim_vector should have dimensions:
 	  // [numel(fields) size(struct)]
+
 	  dim_vector result_dv;
-	  result_dv.resize (m_dv.length () + 1); //Add 1 for the fields
-	  
-	  result_dv(0) = fields_numel;	 
+	  result_dv.resize (m_dv.length () + 1); // Add 1 for the fields.
+
+	  result_dv(0) = fields_numel;
 
 	  for (int i = 1; i < result_dv.length (); i++)
 	    result_dv(i) = m_dv(i-1);
-	  
-	  // Squeeze to be sure that a (3,1) vector doesn't
-	  // get turned into a (3,3,1) vector.
-	  result_dv = result_dv.squeeze (); 
-	  
+
+	  // Squeeze to be sure that a (3,1) vector doesn't get turned
+	  // into a (3,3,1) vector.
+
+	  result_dv = result_dv.squeeze ();
+
 	  Cell c (result_dv);
-	  
-	  // Use ra_idx both for counting and for assignments,
-	  // so ra_idx(0) will both contain fields_numel for 
-	  // each call to increment_index and j for each assignment.
+
+	  // Use ra_idx both for counting and for assignments, so
+	  // ra_idx(0) will both contain fields_numel for each call to
+	  // increment_index and j for each assignment.
+
 	  Array<int> ra_idx (result_dv.length (), 0);
-	  ra_idx(0) = fields_numel;	  
+	  ra_idx(0) = fields_numel;
 
 	  for (int i = 0; i < m_dv.numel (); i++)
 	    {
 	      for (int j = 0; j < fields_numel; j++)
 		{
 		  ra_idx(0) = j;
-		  
+
 		  Cell c_tmp = m.contents (keys(j));
-		  
-		  if (c_tmp.length () > 1) // Is a cell
+
+		  if (c_tmp.length () > 1) // Is a cell.
 		    c(ra_idx) = c_tmp;
-		  else if (c_tmp.length () == 1) // Get octave_value
+		  else if (c_tmp.length () == 1) // Get octave_value.
 		    c(ra_idx) = c_tmp(0);
-		  else // c.tmp.length () == 0, Create empty Cell
-		    c(ra_idx) = Cell();
-		  
+		  else
+		    c(ra_idx) = Cell ();
+
 		  ra_idx(0) = fields_numel;
 		}
 
-	      increment_index(ra_idx, result_dv);	      
+	      increment_index (ra_idx, result_dv);
 	    }
 
 	  retval = c;
@@ -1087,7 +1090,7 @@
     }
   else
     print_usage ("struct2cell");
-  
+
   return retval;
 }