help-octave
[Top][All Lists]
Advanced

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

Re: Sparse functions for octave


From: John W. Eaton
Subject: Re: Sparse functions for octave
Date: Fri, 29 Oct 1999 22:54:32 -0500 (CDT)

On 29-Oct-1999, A+A Adler <address@hidden> wrote:

| I've downloaded 2.1.19 and have modified my make_sparse to
| work with it. I got binary operators to work ( * .* \ == ),
| but got errors with unitary operators ( x' -x etc.).
| 
| Then I tried this with the make_int.cc from 2.1.19 and
| found the same problem. 
| 
| A:> cp /usr/src/octave-2.1.19/examples/make_int.cc .
| A:> mkoctfile make_int.cc
| A:> octave -q
| octave:1> x=make_int(4);y=make_int(5);
| installing integer type at type-id = 18
| installing integer type at type-id = 18
| octave:2> x+y
| ans = 9
| octave:2> x==y
| ans = 0
| octave:4> x'
| error: unary operator `'' not implemented for `integer' operands
| error: evaluating postfix operator `'' near line 4, column 1
| octave:4> -x
| error: unary operator `-' not implemented for `integer' operands
| error: evaluating prefix operator `-' near line 4, column 1
| 
| 
| I suspect that there is a bug in make_int.cc in 2.1.19

I'd rather say it was just an incomplete example.

You can get the other operators if you add the following code:

--- make_int.cc~        Wed Oct 20 01:48:03 1999
+++ make_int.cc Fri Oct 29 22:51:17 1999
@@ -140,6 +140,25 @@
   octave_print_internal (os, scalar, pr_as_read_syntax);
 }
 
+#ifdef DEFUNOP_OP
+#undef DEFUNOP_OP
+#endif
+
+#define DEFUNOP_OP(name, t, op) \
+  UNOPDECL (name, a) \
+  { \
+    CAST_UNOP_ARG (const octave_ ## t&); \
+    return octave_value (new octave_integer (op v.t ## _value ())); \
+  }
+
+DEFUNOP_OP (not, integer, !)
+DEFUNOP_OP (uminus, integer, -)
+DEFUNOP_OP (transpose, integer, /* no-op */)
+DEFUNOP_OP (hermitian, integer, /* no-op */)
+
+DEFNCUNOP_METHOD (incr, integer, increment)
+DEFNCUNOP_METHOD (decr, integer, decrement)
+
 #ifdef DEFBINOP_OP
 #undef DEFBINOP_OP
 #endif
@@ -244,6 +263,14 @@
 
       cerr << "installing integer type at type-id = "
           << octave_integer::static_type_id () << "\n";
+
+      INSTALL_UNOP (not, octave_integer, not);
+      INSTALL_UNOP (uminus, octave_integer, uminus);
+      INSTALL_UNOP (transpose, octave_integer, transpose);
+      INSTALL_UNOP (hermitian, octave_integer, hermitian);
+
+      INSTALL_NCUNOP (incr, octave_integer, incr);
+      INSTALL_NCUNOP (decr, octave_integer, decr);
 
       INSTALL_BINOP (add, octave_integer, octave_integer, add);
       INSTALL_BINOP (sub, octave_integer, octave_integer, sub);


jwe



---------------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.  To ensure
that development continues, see www.che.wisc.edu/octave/giftform.html
Instructions for unsubscribing: www.che.wisc.edu/octave/archive.html
---------------------------------------------------------------------



reply via email to

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