changeset 4671:7a80bb43ea63

[project @ 2003-11-28 02:50:12 by jwe]
author jwe
date Fri, 28 Nov 2003 02:50:12 +0000
parents 4ad69c3588a9
children 2c5adf308c84
files src/ChangeLog src/pt-arg-list.cc
diffstat 2 files changed, 25 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Nov 26 14:42:52 2003 +0000
+++ b/src/ChangeLog	Fri Nov 28 02:50:12 2003 +0000
@@ -1,3 +1,7 @@
+2003-11-27  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* pt-arg-list.cc (F__end__): Handle N-d objects.
+
 2003-11-25  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* OPERATORS/op-b-bm.cc: New file.
--- a/src/pt-arg-list.cc	Wed Nov 26 14:42:52 2003 +0000
+++ b/src/pt-arg-list.cc	Fri Nov 28 02:50:12 2003 +0000
@@ -123,45 +123,37 @@
 
   if (indexed_object)
     {
+      dim_vector dv = indexed_object->dims ();
+
       switch (index_position)
 	{
 	case -1:
-	  // XXX FIXME XXX -- we really want "numel" here.
 	  {
-	    int nr = indexed_object->rows ();
-	    int nc = indexed_object->columns ();
-
-	    if (nr < 0 || nc < 0)
-	      ::error ("invalid use of end: (nr=%d, nc=%d)", nr, nc);
-	    else
-	      retval = nr * nc;
-	  }
-	  break;
-
-	case 0:
-	  {
-	    int nr = indexed_object->rows ();
+	    int numel = indexed_object->numel ();
 
-	    if (nr < 0)
-	      ::error ("invalid use of end: (nr=%d)", nr);
+	    if (numel < 0)
+	      {
+		std::string dv_str = dv.str ();
+		::error ("invalid use of end: (index 1, dims %s)",
+			 dv_str.c_str ());
+	      }
 	    else
-	      retval = nr;
-	  }
-	  break;
-
-	case 1:
-	  {
-	    int nc = indexed_object->columns ();
-
-	    if (nc < 0)
-	      ::error ("invalid use of end: (nc=%d)", nc);
-	    else
-	      retval = nc;
+	      retval = numel;
 	  }
 	  break;
 
 	default:
-	  ::error ("__end__: internal error");
+	  {
+
+	    if (index_position < dv.length ())
+	      retval = dv(index_position);
+	    else
+	      {
+		std::string dv_str = dv.str ();
+		::error ("invalid use of end: (index %d, dims %s)",
+			 index_position+1, dv_str.c_str ());
+	      }
+	  }
 	  break;
 	}
     }