changeset 5033:3dcc3824b732

[project @ 2004-09-24 04:26:07 by jwe]
author jwe
date Fri, 24 Sep 2004 04:26:07 +0000
parents 3361e0846469
children 49827f6892f4
files src/ChangeLog src/ov-str-mat.cc
diffstat 2 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Sep 24 03:57:04 2004 +0000
+++ b/src/ChangeLog	Fri Sep 24 04:26:07 2004 +0000
@@ -1,3 +1,8 @@
+2004-09-24  John W. Eaton  <jwe@octave.org>
+
+	* ov-str-mat.cc (default_numeric_conversion_function): Return
+	scalar object if numel == 1.
+
 2004-09-23  John W. Eaton  <jwe@octave.org>
 
 	* ops.h	(DEFSTRDBLCONVFN): New macro.
--- a/src/ov-str-mat.cc	Fri Sep 24 03:57:04 2004 +0000
+++ b/src/ov-str-mat.cc	Fri Sep 24 04:26:07 2004 +0000
@@ -39,6 +39,7 @@
 #include "oct-obj.h"
 #include "oct-stream.h"
 #include "ops.h"
+#include "ov-scalar.h"
 #include "ov-re-mat.h"
 #include "ov-str-mat.h"
 #include "gripes.h"
@@ -57,11 +58,21 @@
 static octave_value *
 default_numeric_conversion_function (const octave_value& a)
 {
+  octave_value *retval = 0;
+
   CAST_CONV_ARG (const octave_char_matrix_str&);
 
   NDArray nda = v.array_value (true);
 
-  return error_state ? 0 : new octave_matrix (nda);
+  if (! error_state)
+    {
+      if (nda.numel () == 1)
+	retval = new octave_scalar (nda(0));
+      else
+	retval = new octave_matrix (nda);
+    }
+
+  return retval;
 }
 
 type_conv_fcn