help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sys2tf seems broken in 2.1.38


From: John W. Eaton
Subject: sys2tf seems broken in 2.1.38
Date: Thu, 31 Oct 2002 12:59:58 -0600

On 30-Oct-2002, Nicholas Piper <address@hidden> wrote:

| I'm using Octave 2.1.38 that I compiled myself, with gcc version
| 2.95.3 20010315 (release).
| 
| I first noticed that the DEMOcontrol didn't work correctly, but now I
| also see that sys2tf fails with a traceback.
| 
| If I select [ 1] Double integrator example from the DEMOcontrol I get:
| 
| [...]
|
| error: A(I) = X: X must be a scalar or a vector with same length as I
| error: assignment failed, or no method for `matrix = matrix'
| 
| [...]

Please try the following patch.  It should fix this problem as well as
another that caused other examples in DEMOcontrol to fail.

The functions in DEMOcontrol would make a good set of tests for
Octave, but it is tedious to run through them by hand using the menus.
Would someone please help to convert the demos to tests that can be
run automatically so they can be used by the check target in the
Makefile?

Thanks,

jwe



liboctave/ChangeLog:

2002-10-31  John W. Eaton  <address@hidden>

        * mx-inlines.cc (MX_BASE_REDUCTION_OP): Also return scalar
        MT_RESULT if nr == 1 && nc == 0 && dim == -1 (i.e.,
        sum(zeros(1,0)) returns 0, not [](1x0)).


src/ChangeLog:

2002-10-31  John W. Eaton  <address@hidden>

        * ov-base.cc (octave_base_value::subsasgn): Handle default numeric
        case here.


Index: liboctave/mx-inlines.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/liboctave/mx-inlines.cc,v
retrieving revision 1.21
diff -u -r1.21 mx-inlines.cc
--- liboctave/mx-inlines.cc     2 Aug 2002 07:59:19 -0000       1.21
+++ liboctave/mx-inlines.cc     31 Oct 2002 18:43:41 -0000
@@ -303,17 +303,14 @@
            } \
        } \
     } \
-  else if (nr == 0 && nc == 0) \
-    { \
-      retval.resize (1, 1); \
-      retval.elem (0, 0) = MT_RESULT; \
-    } \
+  else if (nc == 0 && (nr == 0 || (nr == 1 && dim == -1))) \
+    retval.resize (1, 1, MT_RESULT); \
   else if (nr == 0 && (dim == 0 || dim == -1)) \
     retval.resize (1, nc, MT_RESULT); \
   else if (nc == 0 && dim == 1) \
     retval.resize (nr, 1, MT_RESULT); \
   else \
-    retval.resize (nr, nc); \
+    retval.resize (nr > 0, nc > 0); \
  \
   return retval
 
Index: src/ov-base.cc
===================================================================
RCS file: /usr/local/cvsroot/octave/src/ov-base.cc,v
retrieving revision 1.31
diff -u -r1.31 ov-base.cc
--- src/ov-base.cc      14 Oct 2002 20:16:44 -0000      1.31
+++ src/ov-base.cc      31 Oct 2002 18:43:49 -0000
@@ -103,8 +103,40 @@
 
   if (is_defined ())
     {
-      std::string nm = type_name ();
-      error ("can't perform indexed assignment for %s type", nm.c_str ());
+      if (is_numeric_type ())
+       {
+         switch (type[0])
+           {
+           case '(':
+             {
+               if (type.length () == 1)
+                 retval = numeric_assign (type, idx, rhs);
+               else
+                 {
+                   std::string nm = type_name ();
+                   error ("in indexed assignment of %s, last rhs index must be 
()",
+                          nm.c_str ());
+                 }
+             }
+             break;
+
+           case '{':
+           case '.':
+             {
+               std::string nm = type_name ();
+               error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
+             }
+             break;
+
+           default:
+             panic_impossible ();
+           }
+       }
+      else
+       {
+         std::string nm = type_name ();
+         error ("can't perform indexed assignment for %s type", nm.c_str ());
+       }
     }
   else
     {



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]