[Pkg-octave-commit] [SCM] octave-symbolic branch, master, updated. a718b53403d9f164f8c2a3df521385a01d28a11b
bensapp
bensapp at 416fae20-06d0-4450-9b69-c6c34d4b5f03
Mon Jan 3 03:40:25 UTC 2011
The following commit has been merged in the master branch:
commit 055fbaf36bdf9081f24f1710e09bf5069ecc8b87
Author: bensapp <bensapp at 416fae20-06d0-4450-9b69-c6c34d4b5f03>
Date: Wed Mar 27 01:15:11 2002 +0000
*** empty log message ***
git-svn-id: https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/main/symbolic@236 416fae20-06d0-4450-9b69-c6c34d4b5f03
diff --git a/ov-sym.cc b/ov-sym.cc
index a814ad4..ceb2605 100644
--- a/ov-sym.cc
+++ b/ov-sym.cc
@@ -1,202 +1,51 @@
/*
-Copyright (C) 2000 Benjamin Sapp
-This is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
+Copyright (C) 2002 Ben Sapp
-This is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
-You can have receive a copy of the GNU General Public License. Write
-to the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-*/
-
-#include <octave/config.h>
-
-#include <cstdlib>
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
-#include <string>
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-class ostream;
-
-#include <octave/lo-mappers.h>
-#include <octave/lo-utils.h>
-#include <octave/mx-base.h>
-#include <octave/str-vec.h>
+*/
-#include <octave/error.h>
-#include <octave/gripes.h>
-#include <octave/oct-obj.h>
-#include <octave/ops.h>
-#include <octave/ov-base.h>
-#include <octave/ov-typeinfo.h>
-#include <octave/ov.h>
-#include <octave/ov-scalar.h>
-#include <octave/pager.h>
-#include <octave/pr-output.h>
-#include <octave/symtab.h>
-#include <octave/variables.h>
+#include <octave/config.h>
#include "ov-ex.h"
#include "ov-sym.h"
-#include "ov-vpa.h"
-
-#ifdef DEFUNOP_OP
-#undef DEFUNOP_OP
-#endif
-
-#define DEFUNOP_OP(name, t, op) \
- UNOPDECL (name, a) \
- { \
- try \
- { \
- CAST_UNOP_ARG (const octave_ ## t&); \
- return octave_value (new octave_ex (op v.t ## _value ())); \
- } \
- catch (exception &e) \
- { \
- error(e.what()); \
- return octave_value (); \
- } \
- }
-
-DEFUNOP_OP (uminus, sym, -)
-
-#ifdef DEFBINOP_OP
-#undef DEFBINOP_OP
-#endif
-
-
-#define DEFBINOP_OP(name, t1, t2, op) \
- BINOPDECL (name, a1, a2) \
- { \
- try \
- { \
- CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
- return octave_value \
- (new octave_ex (v1.t1 ## _value () op v2.t2 ## _value ())); \
- } \
- catch (exception &e) \
- { \
- error(e.what()); \
- return octave_value (); \
- } \
- }
-
-#ifdef DEFBINOP_POW
-#undef DEFBINOP_POW
-#endif
-#define DEFBINOP_POW(name, t1, t2) \
- BINOPDECL(name, a1, a2) \
- { \
- try \
- { \
- CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
- return octave_value \
- (new octave_ex (pow(v1.t1 ## _value (), v2.t2 ## _value ()))); \
- } \
- catch (exception &e) \
- { \
- error(e.what()); \
- return octave_value (); \
- } \
- }
-
-// Addition operations
-DEFBINOP_OP(sym_scalar_add,sym,scalar,+)
-DEFBINOP_OP(scalar_sym_add,scalar,sym,+)
-DEFBINOP_OP(sym_vpa_add,sym,vpa,+)
-DEFBINOP_OP (sym_sym_add, sym, sym, +)
-DEFBINOP_OP(sym_ex_add,sym,ex,+)
-
-// Subtraction operations
-DEFBINOP_OP(sym_scalar_sub,sym,scalar,-)
-DEFBINOP_OP(scalar_sym_sub,scalar,sym,-)
-DEFBINOP_OP(sym_vpa_sub,sym,vpa,-)
-DEFBINOP_OP (sym_sym_sub, sym, sym, -)
-DEFBINOP_OP(sym_ex_sub,sym,ex,-)
-
-// Multiplication operations
-DEFBINOP_OP(sym_scalar_mul,sym,scalar,*)
-DEFBINOP_OP(scalar_sym_mul,scalar,sym,*)
-DEFBINOP_OP(sym_vpa_mul,sym,vpa,*)
-DEFBINOP_OP (sym_sym_mul, sym, sym, *)
-DEFBINOP_OP(sym_ex_mul,sym,ex,*)
-
-// Division operations
-DEFBINOP_OP(sym_scalar_div,sym,scalar,/)
-DEFBINOP_OP(scalar_sym_div,scalar,sym,/)
-DEFBINOP_OP(sym_vpa_div,sym,vpa,/)
-DEFBINOP_OP (sym_sym_div, sym, sym, /)
-DEFBINOP_OP(sym_ex_div,sym,ex,/)
-
-// Power operations
-DEFBINOP_POW(sym_sym_pow,sym,sym)
-DEFBINOP_POW(sym_scalar_pow,sym,scalar)
-DEFBINOP_POW(scalar_sym_pow,scalar,sym)
-DEFBINOP_POW(sym_vpa_pow,sym,vpa)
-DEFBINOP_POW(sym_ex_pow,sym,ex)
+class ostream;
-GiNaC::symbol octave_sym::sym_value() const
+octave_sym::octave_sym(char *str)
{
- // This is ugly
- return GiNaC::ex_to<GiNaC::symbol>(GiNaC::ex(*(x.duplicate ())));
+ x = GiNaC::symbol(str);
}
-void
-install_sym_type()
+GiNaC::symbol
+octave_sym::sym_value() const
{
- octave_sym::register_type();
-
- cerr << "installing sym type at type-id = "
- << octave_sym::static_type_id() << "\n";
+ return x;
}
-void
-install_sym_ops()
+octave_value
+octave_sym::uminus (void)
{
- INSTALL_UNOP(op_uminus, octave_sym, uminus); // -x
+ return (new octave_ex(-x));
+}
- // Addition operations
- INSTALL_BINOP(op_add, octave_scalar, octave_sym, scalar_sym_add);
- INSTALL_BINOP(op_add, octave_sym, octave_scalar, sym_scalar_add);
- INSTALL_BINOP(op_add, octave_sym, octave_vpa, sym_vpa_add);
- INSTALL_BINOP(op_add, octave_sym, octave_sym, sym_sym_add);
- INSTALL_BINOP(op_add, octave_sym, octave_ex, sym_ex_add);
-
- // Subtraction operations
- INSTALL_BINOP(op_sub, octave_scalar, octave_sym, scalar_sym_sub);
- INSTALL_BINOP(op_sub, octave_sym, octave_scalar, sym_scalar_sub);
- INSTALL_BINOP(op_sub, octave_sym, octave_vpa, sym_vpa_sub);
- INSTALL_BINOP(op_sub, octave_sym, octave_sym, sym_sym_sub);
- INSTALL_BINOP(op_sub, octave_sym, octave_ex, sym_ex_sub);
-
- // Multiplication operations
- INSTALL_BINOP(op_mul, octave_scalar, octave_sym, scalar_sym_mul);
- INSTALL_BINOP(op_mul, octave_sym, octave_scalar, sym_scalar_mul);
- INSTALL_BINOP(op_mul, octave_sym, octave_vpa, sym_vpa_mul);
- INSTALL_BINOP(op_mul, octave_sym, octave_sym, sym_sym_mul);
- INSTALL_BINOP(op_mul, octave_sym, octave_ex, sym_ex_mul);
-
- // Division operations
- INSTALL_BINOP(op_div, octave_scalar, octave_sym, scalar_sym_div);
- INSTALL_BINOP(op_div, octave_sym, octave_scalar, sym_scalar_div);
- INSTALL_BINOP(op_div, octave_sym, octave_vpa, sym_vpa_div);
- INSTALL_BINOP(op_div, octave_sym, octave_sym, sym_sym_div);
- INSTALL_BINOP(op_div, octave_sym, octave_ex, sym_ex_div);
-
- // Power operations
- INSTALL_BINOP(op_pow, octave_scalar, octave_sym, scalar_sym_pow);
- INSTALL_BINOP(op_pow, octave_sym, octave_scalar, sym_scalar_pow);
- INSTALL_BINOP(op_pow, octave_sym, octave_vpa, sym_vpa_pow);
- INSTALL_BINOP(op_pow, octave_sym, octave_sym, sym_sym_pow);
- INSTALL_BINOP(op_pow, octave_sym, octave_ex, sym_ex_pow);
-}
+void
+octave_sym::print(ostream& os,bool pr_as_read_syntax) const
+{
+ os << x;
+}
DEFINE_OCTAVE_ALLOCATOR (octave_sym);
--
octave-symbolic
More information about the Pkg-octave-commit
mailing list