[Pkg-octave-commit] [SCM] octave-symbolic branch, master, updated. a718b53403d9f164f8c2a3df521385a01d28a11b

bensapp bensapp at 416fae20-06d0-4450-9b69-c6c34d4b5f03
Mon Jan 3 03:40:32 UTC 2011


The following commit has been merged in the master branch:
commit e0d528177574a21af21766b1bbfb6afacc7274ef
Author: bensapp <bensapp at 416fae20-06d0-4450-9b69-c6c34d4b5f03>
Date:   Fri May 17 15:44:29 2002 +0000

    I have removed the octave_sym class. Now, the octave_ex class feels in
    for sym variables.   All the same routines exist and it looks and operates
    the same.  This should also fix a problem with subs that would cause
    octave to crash.
    
    
    git-svn-id: https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/main/symbolic@439 416fae20-06d0-4450-9b69-c6c34d4b5f03

diff --git a/Makefile b/Makefile
index 737b8ad..dbe9472 100644
--- a/Makefile
+++ b/Makefile
@@ -7,10 +7,14 @@ ifndef OCTAVE_FORGE
 	HAVE_GINAC=1
 endif
 
+#SRC=symbols.cc probably_prime.cc differentiate.cc \
+#	sym-bool.cc sym-create.cc \
+#	ov-ex.cc ov-sym.cc ov-vpa.cc ov-ex-mat.cc ov-relational.cc \
+#	op-ex-mat.cc op-ex.cc op-sym.cc op-vpa.cc 
 SRC=symbols.cc probably_prime.cc differentiate.cc \
 	sym-bool.cc sym-create.cc \
-	ov-ex.cc ov-sym.cc ov-vpa.cc ov-ex-mat.cc ov-relational.cc \
-	op-ex-mat.cc op-ex.cc op-sym.cc op-vpa.cc 
+	ov-ex.cc ov-vpa.cc ov-ex-mat.cc ov-relational.cc \
+	op-ex-mat.cc op-ex.cc op-vpa.cc 
 OBJ=$(SRC:.cc=.o)
 
 %.o: %.cc ; $(MKOCTFILE) -v $(GINAC_CPP_FLAGS) -c $<
diff --git a/differentiate.cc b/differentiate.cc
index d092d7a..1a2da2e 100644
--- a/differentiate.cc
+++ b/differentiate.cc
@@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <octave/oct-obj.h>
 #include <ginac/ginac.h>
 #include "ov-vpa.h"
-#include "ov-sym.h" 
 #include "ov-ex.h"
 #include "symbols.h" 
 
@@ -35,7 +34,7 @@ supplied then a default value of 1 is used.\n\
 @end deftypefn")
 {
   GiNaC::ex expression;
-  GiNaC::symbol variable;
+  GiNaC::ex variable;
   GiNaC::numeric num;
   int order;
   octave_value retval;
@@ -77,7 +76,9 @@ supplied then a default value of 1 is used.\n\
       else
 	order = 1;
 
-      retval = octave_value(new octave_ex(expression.diff(variable,order)));
+      retval = octave_value(new octave_ex
+			    (expression.diff
+			     (GiNaC::ex_to<GiNaC::symbol>(variable),order)));
     }
   catch (std::exception &e)
     {
diff --git a/op-ex-mat.cc b/op-ex-mat.cc
index 4a21107..840f0c8 100644
--- a/op-ex-mat.cc
+++ b/op-ex-mat.cc
@@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <octave/ov-cx-mat.h>
 #include "sym-ops.h"
 #include "ov-vpa.h"
-#include "ov-sym.h"
 #include "ov-ex.h"
 #include "ov-ex-mat.h"
 
@@ -36,7 +35,6 @@ DEFINE_MATRIX_MATRIX_OPS(ex_matrix, complex_matrix)
 DEFINE_MATRIX_EX_OPS(ex_matrix, scalar)
 DEFINE_MATRIX_EX_OPS(ex_matrix, complex)
 DEFINE_MATRIX_EX_OPS(ex_matrix, vpa)
-DEFINE_MATRIX_EX_OPS(ex_matrix, sym)
 DEFINE_MATRIX_EX_OPS(ex_matrix, ex)
 
 /* extra operators need for octave builtin types */ 
@@ -55,7 +53,6 @@ install_ex_matrix_ops()
   INSTALL_MATRIX_EX_OPS(ex_matrix, scalar);
   INSTALL_MATRIX_EX_OPS(ex_matrix, complex);
   INSTALL_MATRIX_EX_OPS(ex_matrix, vpa);
-  INSTALL_MATRIX_EX_OPS(ex_matrix, sym);
   INSTALL_MATRIX_EX_OPS(ex_matrix, ex);
  
   /* extra operators need for octave builtin types */ 
diff --git a/op-ex.cc b/op-ex.cc
index fb6aceb..73d811b 100644
--- a/op-ex.cc
+++ b/op-ex.cc
@@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <octave/ov-cx-mat.h>
 #include "sym-ops.h"
 #include "ov-vpa.h"
-#include "ov-sym.h"
 #include "ov-ex.h"
 #include "ov-ex-mat.h"
 
@@ -36,7 +35,6 @@ DEFINE_EX_MATRIX_OPS(ex, complex_matrix)
 DEFINE_EX_EX_OPS(ex, scalar)
 DEFINE_EX_EX_OPS(ex, complex)
 DEFINE_EX_EX_OPS(ex, vpa)
-DEFINE_EX_EX_OPS(ex, sym)
 DEFINE_EX_EX_OPS(ex, ex)
 
 /* extra operators need for octave builtin types */ 
@@ -54,7 +52,6 @@ install_ex_ops()
   INSTALL_EX_EX_OPS(ex, scalar);
   INSTALL_EX_EX_OPS(ex, complex);
   INSTALL_EX_EX_OPS(ex, vpa);
-  INSTALL_EX_EX_OPS(ex, sym);
   INSTALL_EX_EX_OPS(ex, ex);
 
   /* extra operators need for octave builtin types */ 
diff --git a/op-sym.cc b/op-sym.cc
deleted file mode 100644
index 652cb5e..0000000
--- a/op-sym.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-
-Copyright (C) 2002 Ben Sapp
-
-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.
-
-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.
-
-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
-
-*/
-
-#include <octave/config.h>
-#include <octave/ov-scalar.h>
-#include <octave/ov-complex.h>
-#include <octave/ov-re-mat.h>
-#include <octave/ov-cx-mat.h>
-#include "sym-ops.h"
-#include "ov-vpa.h"
-#include "ov-sym.h"
-#include "ov-ex.h"
-#include "ov-ex-mat.h"
-
-/* definitions for when the sym is first */
-DEFINE_EX_MATRIX_OPS(sym, ex_matrix)
-DEFINE_EX_MATRIX_OPS(sym, matrix)
-DEFINE_EX_MATRIX_OPS(sym, complex_matrix)
-DEFINE_EX_EX_OPS(sym, scalar)
-DEFINE_EX_EX_OPS(sym, complex)
-DEFINE_EX_EX_OPS(sym, vpa)
-DEFINE_EX_EX_OPS(sym, sym)
-DEFINE_EX_EX_OPS(sym, ex)
-
-/* extra operators need for octave builtin types */ 
-DEFINE_MATRIX_EX_OPS(complex_matrix, sym)
-DEFINE_MATRIX_EX_OPS(matrix, sym)
-DEFINE_EX_EX_OPS(scalar, sym)
-DEFINE_EX_EX_OPS(complex, sym)
-
-void
-install_sym_ops()
-{
-#if 0
-  INSTALL_UNOP(op_uminus, octave_sym, uminus);             // -x 
-#endif
-
-  /* for when the sym is first */
-  INSTALL_EX_MATRIX_OPS(sym, ex_matrix);
-  INSTALL_EX_MATRIX_OPS(sym, matrix);
-  INSTALL_EX_MATRIX_OPS(sym, complex_matrix);
-  INSTALL_EX_EX_OPS(sym, scalar);
-  INSTALL_EX_EX_OPS(sym, complex);
-  INSTALL_EX_EX_OPS(sym, vpa);
-  INSTALL_EX_EX_OPS(sym, sym);
-  INSTALL_EX_EX_OPS(sym, ex);
-  
-  /* extra operators need for octave builtin types */ 
-  INSTALL_MATRIX_EX_OPS(complex_matrix, sym);
-  INSTALL_MATRIX_EX_OPS(matrix, sym);
-  INSTALL_EX_EX_OPS(scalar, sym);
-  INSTALL_EX_EX_OPS(complex, sym);
-}
diff --git a/op-vpa.cc b/op-vpa.cc
index cceaf71..d3e43ef 100644
--- a/op-vpa.cc
+++ b/op-vpa.cc
@@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <octave/ov-cx-mat.h>
 #include "sym-ops.h"
 #include "ov-vpa.h"
-#include "ov-sym.h"
 #include "ov-ex.h"
 #include "ov-ex-mat.h"
 
@@ -36,7 +35,6 @@ DEFINE_EX_MATRIX_OPS(vpa, complex_matrix)
 DEFINE_EX_EX_OPS(vpa, scalar)
 DEFINE_EX_EX_OPS(vpa, complex)
 DEFINE_EX_EX_OPS(vpa, vpa)
-DEFINE_EX_EX_OPS(vpa, sym)
 DEFINE_EX_EX_OPS(vpa, ex)
 
 /* extra operators need for octave builtin types */ 
@@ -64,7 +62,6 @@ void install_vpa_ops()
   INSTALL_EX_EX_OPS(vpa, scalar);
   INSTALL_EX_EX_OPS(vpa, complex);
   INSTALL_EX_EX_OPS(vpa, vpa);
-  INSTALL_EX_EX_OPS(vpa, sym);
   INSTALL_EX_EX_OPS(vpa, ex);
 
   /* extra operators need for octave builtin types */ 
diff --git a/ov-ex-mat.cc b/ov-ex-mat.cc
index 308a84b..8d83872 100644
--- a/ov-ex-mat.cc
+++ b/ov-ex-mat.cc
@@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <octave/ov-cx-mat.h>
 #include "ov-ex.h"
 #include "ov-ex-mat.h"
-#include "ov-sym.h"
 #include "ov-vpa.h"
 
 octave_ex_matrix::octave_ex_matrix(octave_ex_matrix &ox)
diff --git a/ov-ex.cc b/ov-ex.cc
index 0644d63..c348231 100644
--- a/ov-ex.cc
+++ b/ov-ex.cc
@@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <octave/config.h>
 #include <ginac/ginac.h>
 #include "ov-ex.h"
-#include "ov-sym.h"
 #include "ov-vpa.h"
 
 octave_ex::octave_ex(octave_ex &ox)
@@ -34,11 +33,6 @@ octave_ex::octave_ex(GiNaC::ex expression)
   x = expression;
 }
 
-octave_ex::octave_ex(octave_sym &osym) 
-{
-  x = osym.sym_value () + 0; 
-}
-
 octave_ex::octave_ex(GiNaC::symbol sym)
 {
   x = sym;
diff --git a/ov-ex.h b/ov-ex.h
index e511d72..0817b01 100644
--- a/ov-ex.h
+++ b/ov-ex.h
@@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <ginac/ginac.h>
 #include <octave/ov-complex.h>
 #include <octave/ov-scalar.h>
-#include "ov-sym.h"
 #include "ov-vpa.h"
 
 
@@ -39,7 +38,6 @@ public:
 
   octave_ex(octave_ex &ox);
   octave_ex(GiNaC::ex expression);
-  octave_ex(octave_sym &osym);
   octave_ex(GiNaC::symbol sym);
   octave_ex(octave_complex &cmplx);
   octave_ex(Complex z);
diff --git a/ov-sym.cc b/ov-sym.cc
deleted file mode 100644
index 36dbf8a..0000000
--- a/ov-sym.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-
-Copyright (C) 2002 Ben Sapp
-
-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.
-
-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.
-
-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
-
-*/
-
-#include <octave/config.h>
-#include "ov-ex.h"
-#include "ov-sym.h"
-
-// class ostream;
-
-octave_sym::octave_sym(char *str)
-{
-  x = GiNaC::symbol(str);
-}
-
-GiNaC::symbol 
-octave_sym::sym_value() const 
-{
-  return x;
-}
-
-octave_value 
-octave_sym::uminus (void)
-{
-  return (new octave_ex(-x));
-} 
-  
-void 
-octave_sym::print(std::ostream& os,bool pr_as_read_syntax) const
-{
-  os << x;
-}
-
-DEFINE_OCTAVE_ALLOCATOR (octave_sym);
-
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_sym, "sym");
-
-/*
-;;; Local Variables: ***
-;;; mode: C++ ***
-;;; End: ***
-*/
diff --git a/ov-sym.h b/ov-sym.h
deleted file mode 100644
index 7f7b762..0000000
--- a/ov-sym.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-
-Copyright (C) 2002 Ben Sapp
-
-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.
-
-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.
-
-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
-
-*/
-
-#if !defined (octave_sym_h)
-#define octave_sym_h 1
-
-#include <ginac/ginac.h>
-#include "ov-base.h"
-
-class octave_ex;
-
-class 
-octave_sym : public octave_base_value
-{
-public:
-  octave_sym(void){}
-  octave_sym(char *str);
-  octave_sym(const octave_sym &xtmp):x(xtmp.x){}
-  octave_sym(GiNaC::symbol xtmp):x(xtmp){}
-
-  ~octave_sym (void) {}
-
-  octave_value *clone (void) {return new octave_sym(*this);}
-
-  GiNaC::symbol sym_value(void) const;
-
-  octave_value uminus (void); 
-
-  void print(std::ostream& os,bool pr_as_read_syntax) const;
-
-  int rows (void) const { return 1; }
-  int columns (void) const { return 1; }
-
-  bool is_constant (void) const { return true; }
-  bool is_defined (void) const { return true; }
-  bool is_real_scalar (void) const { return false; }
-  
-  bool is_real_type(void) const {return false;}
-  bool is_scalar_type(void) const {return true;}
-  bool is_numeric_type(void) const {return false;}
-
-  bool valid_as_scalar_index(void) const {return false;}
-
-  bool is_true(void) const { return true; }
-   
-private:
-  GiNaC::symbol x;
-
-  DECLARE_OCTAVE_ALLOCATOR
-
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA  
-
-};
-
-#endif
-
-/*
-;;; Local Variables: ***
-;;; mode: C++ ***
-;;; End: ***
-*/
diff --git a/sym-bool.cc b/sym-bool.cc
index 9f2a8f2..e0856ae 100644
--- a/sym-bool.cc
+++ b/sym-bool.cc
@@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <octave/defun-dld.h>
 #include <octave/oct-obj.h> 
 #include "ov-vpa.h" 
-#include "ov-sym.h"
 #include "ov-ex.h"
 #include "ov-ex-mat.h" 
 
@@ -38,7 +37,10 @@ DEFUN_DLD(is_vpa, args, ,
 DEFUN_DLD(is_sym,args, ,"Return true if an object is of type sym false otherwise.\n")
 {
   bool retval;
-  retval = (args(0).type_id() == octave_sym::static_type_id());
+  const octave_value& rep = args(0).get_rep();
+
+  retval = args(0).type_id () == octave_ex::static_type_id () &&
+	    GiNaC::is_a<GiNaC::symbol>(((octave_ex& ) rep).ex_value ());
   return octave_value(retval);
 }
 
diff --git a/sym-create.cc b/sym-create.cc
index 42054c5..55b4aed 100644
--- a/sym-create.cc
+++ b/sym-create.cc
@@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <octave/defun-dld.h>
 #include <octave/oct-obj.h> 
 #include "ov-vpa.h" 
-#include "ov-sym.h"
 #include "ov-ex.h"
 #include "ov-ex-mat.h" 
 #include "symbols.h" 
@@ -84,8 +83,8 @@ Create an object of type symbol\n")
   try 
     {
       GiNaC::symbol xtmp(args(0).string_value());
-      octave_sym x(xtmp);
-      retval = octave_value(new octave_sym(x));
+      octave_ex x(xtmp);
+      retval = octave_value(new octave_ex(x));
     }
   catch (std::exception &e)
     {
diff --git a/sym-ops.h b/sym-ops.h
index f458aa0..aff41c0 100644
--- a/sym-ops.h
+++ b/sym-ops.h
@@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 void install_ex_ops(void); 
-void install_sym_ops(void);
 void install_vpa_ops(void);
 void install_ex_matrix_ops(void);
 
diff --git a/symbols.cc b/symbols.cc
index e686c49..b2b5248 100644
--- a/symbols.cc
+++ b/symbols.cc
@@ -27,10 +27,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #include <octave/error.h>
 #include <octave/gripes.h>
 #include <octave/oct-obj.h>
+#include <octave/pager.h>
 #include <ginac/ginac.h>
 #include "ov-vpa.h"
 #include "ov-ex.h"
-#include "ov-sym.h"
 #include "ov-ex-mat.h"
 #include "ov-relational.h"
 #include "sym-ops.h"
@@ -45,11 +45,6 @@ bool get_expression(const octave_value arg, GiNaC::ex& expression)
       GiNaC::numeric x = ((octave_vpa& ) rep).vpa_value();
       expression = x+0;
     }
-  else if (arg.type_id () == octave_sym::static_type_id ())
-    {
-      GiNaC::symbol x = ((octave_sym& ) rep).sym_value();
-      expression = x+0;
-    }
   else if (arg.type_id () == octave_ex::static_type_id ())
     {
       GiNaC::ex x = ((octave_ex& ) rep).ex_value();
@@ -68,20 +63,17 @@ bool get_expression(const octave_value arg, GiNaC::ex& expression)
   return true;
 }
 
-bool get_symbol(const octave_value arg, GiNaC::symbol& sym)
+bool get_symbol(const octave_value arg, GiNaC::ex& sym)
 {
   const octave_value& rep = arg.get_rep ();
-     
-  if (arg.type_id () == octave_sym::static_type_id ())
-    sym = ((octave_sym& ) rep).sym_value();
-  else if (arg.type_id () == octave_ex::static_type_id ())
-    {
-      GiNaC::ex x = ((octave_ex& ) rep).ex_value();
-      if(GiNaC::is_a<GiNaC::symbol>(x))
-	sym = GiNaC::ex_to<GiNaC::symbol>(x);
-      else
-	return false;
-    }
+  GiNaC::ex x; 
+  if (arg.type_id () == octave_ex::static_type_id ())
+    x = ((octave_ex& ) rep).ex_value();
+  else
+    return false;
+
+  if (GiNaC::is_a<GiNaC::symbol>(x))
+    sym = x;
   else
     return false;
 
@@ -116,14 +108,12 @@ DEFUN_DLD(symbols,args,,"Initialize symbolic manipulation")
 {
   octave_value retval;
   octave_vpa::register_type ();
-  octave_sym::register_type ();
   octave_ex::register_type (); 
   octave_ex_matrix::register_type ();
   octave_relational::register_type (); 
 
   install_ex_matrix_ops();
   install_ex_ops();
-  install_sym_ops();
   install_vpa_ops();
   return retval;
 }
@@ -273,7 +263,7 @@ Substitute a number for a variables in an expression\n\
 ")
 {
   GiNaC::ex expression;
-  GiNaC::symbol the_sym;
+  GiNaC::ex the_sym;
   GiNaC::ex ex_sub;
   GiNaC::ex tmp;
   int nargin = args.length ();
@@ -378,7 +368,7 @@ Obtain the @var{n}th coefficient of the variable @var{x} in @var{a}.
 {
   octave_value retval;
   GiNaC::ex expression;
-  GiNaC::symbol sym;
+  GiNaC::ex sym;
   int n;
 
   if(args.length () != 3)
@@ -389,23 +379,13 @@ Obtain the @var{n}th coefficient of the variable @var{x} in @var{a}.
 
   try 
     {
-      if(args(0).type_id() == octave_ex::static_type_id())
-	{
-	  const octave_value& rep0 = args(0).get_rep();
-	  expression = ((const octave_ex& ) rep0).ex_value();
-	}
-      else
+      if(!get_expression(args(0), expression))
 	{
 	  gripe_wrong_type_arg("coeff",args(0));
 	  return retval;
 	}
 
-      if(args(1).type_id() == octave_sym::static_type_id())
-	{
-	  const octave_value& rep1 = args(1).get_rep();
-	  sym = ((const octave_sym& ) rep1).sym_value();
-	}
-      else
+      if(!get_symbol (args(1), sym))
 	{
 	  gripe_wrong_type_arg("coeff",args(1));
 	  return retval;
@@ -449,7 +429,7 @@ collect the terms in @var{a} as a univariate polynomial in @var{x}\n\
 {
   octave_value retval;
   GiNaC::ex expression;
-  GiNaC::symbol the_sym;
+  GiNaC::ex the_sym;
 
   if(args.length() != 2)
     {
@@ -459,22 +439,12 @@ collect the terms in @var{a} as a univariate polynomial in @var{x}\n\
 
   try 
     {
-      if(args(0).type_id() == octave_ex::static_type_id())
-	{
-	  const octave_value& rep1 = args(0).get_rep();
-	  expression = ((const octave_ex& ) rep1).ex_value();
-	}
-      else
+      if(!get_expression(args(0), expression))
 	{
 	  gripe_wrong_type_arg("collect",args(0));
 	}
       
-      if(args(1).type_id() == octave_sym::static_type_id())
-	{
-	  const octave_value& rep2 = args(1).get_rep();
-	  the_sym = ((octave_sym& ) rep2).sym_value();
-	}
-      else
+      if(!get_symbol(args(1), the_sym))
 	{
 	  gripe_wrong_type_arg("collect",args(1));
 	}
@@ -508,7 +478,7 @@ Collect the terms in @var{a} as a univariate polynomial in @var{x}\n\
 {
   octave_value retval;
   GiNaC::ex expression;
-  GiNaC::symbol the_sym;
+  GiNaC::ex the_sym;
 
   if(args.length() != 2)
     {
@@ -516,27 +486,17 @@ Collect the terms in @var{a} as a univariate polynomial in @var{x}\n\
       return retval;
     }
 
-  if(args(0).type_id() == octave_ex::static_type_id())
-    {
-      const octave_value& rep1 = args(0).get_rep();
-      expression = ((const octave_ex& ) rep1).ex_value();
-    }
-  else
+  if(!get_expression(args(0), expression))
     {
       gripe_wrong_type_arg("collect",args(0));
     }
 
-  if(args(1).type_id() == octave_sym::static_type_id())
-    {
-      const octave_value& rep2 = args(1).get_rep();
-      the_sym = ((octave_sym& ) rep2).sym_value();
-    }
-  else
+  if(!get_symbol(args(0), the_sym))
     {
       gripe_wrong_type_arg("collect",args(1));
     }
 
-  retval = new octave_ex(expression.collect(the_sym));
+  retval = new octave_ex(expression.collect(GiNaC::ex_to<GiNaC::symbol>(the_sym)));
 
   return retval;
 }
diff --git a/symbols.h b/symbols.h
index 29a8b79..a0a9d2b 100644
--- a/symbols.h
+++ b/symbols.h
@@ -1,5 +1,5 @@
 bool get_expression(const octave_value arg, GiNaC::ex& expression);
-bool get_symbol(const octave_value arg, GiNaC::symbol& sym);
+bool get_symbol(const octave_value arg, GiNaC::ex& sym);
 bool get_numeric(const octave_value arg, GiNaC::numeric& number);
 
 #define DEFUN_DLD_EX_GINAC_FUNCTION(oct_name,ginac_name,description) \
@@ -53,7 +53,7 @@ Return the " description " of a symbolic expression.\n\
   octave_value retval; \
   octave_ex *r = NULL; \
   GiNaC::ex expression; \
-  GiNaC::symbol sym; \
+  GiNaC::ex sym; \
  \
   if (nargin != 2) \
     { \
@@ -75,7 +75,8 @@ Return the " description " of a symbolic expression.\n\
           return retval; \
         } \
  \
-      r = new octave_ex(expression.ginac_name(sym)); \
+      r = new octave_ex(expression.ginac_name \
+			(GiNaC::ex_to<GiNaC::symbol>(sym))); \
  \
     } \
   catch (std::exception &e) \
@@ -101,7 +102,7 @@ Return the " description " of a symbolic expression.\n\
   octave_ex *r = NULL; \
   GiNaC::ex expression0; \
   GiNaC::ex expression1; \
-  GiNaC::symbol sym; \
+  GiNaC::ex sym; \
  \
   if (nargin != 3) \
     { \
@@ -132,7 +133,9 @@ Return the " description " of a symbolic expression.\n\
           return retval; \
         } \
  \
-      r = new octave_ex(ginac_name (expression0, expression1, sym)); \
+      r = new octave_ex(ginac_name (expression0, \
+				    expression1, \
+				    GiNaC::ex_to<GiNaC::symbol>(sym) )); \
  \
     } \
   catch (std::exception &e) \

-- 
octave-symbolic



More information about the Pkg-octave-commit mailing list