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

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


The following commit has been merged in the master branch:
commit 88d3edc6f4b22f8b4166ed89de6cae3635626e16
Author: bensapp <bensapp at 416fae20-06d0-4450-9b69-c6c34d4b5f03>
Date:   Wed Mar 27 00:54:38 2002 +0000

    I changed many things.  Moved the operators into seperate files. Added a
    new "relational" type for comparing symbolic types.  Defined binary
    operators for +,-,* and / operators for vpa,scalar,complex,sym,matrix,
    complex_matrix and ex_matrix types. The unary operators have been
    temporarily removed. Removed many unused include files.  Moved some
    functions from symbols.cc into seperate files.
    
    
    git-svn-id: https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/main/symbolic@233 416fae20-06d0-4450-9b69-c6c34d4b5f03

diff --git a/differentiate.cc b/differentiate.cc
new file mode 100644
index 0000000..85ff10d
--- /dev/null
+++ b/differentiate.cc
@@ -0,0 +1,89 @@
+/*
+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/defun-dld.h>
+#include <octave/oct-obj.h>
+#include <ginac/ginac.h>
+#include "ov-vpa.h"
+#include "ov-sym.h" 
+#include "ov-ex.h"
+#include "symbols.h" 
+
+
+DEFUN_DLD(differentiate,args,,
+"-*- texinfo -*-\n\
+ at deftypefn Loadable Function {da_dx =} differentiate(@var{a}, at var{x} [, @var{n}])\n\
+\n\
+Return the @var{n}th derivative of @var{a} with respect to @var{x}. If @var{n} is not\n\
+supplied then a default value of 1 is used.\n\
+ at end deftypefn")
+{
+  GiNaC::ex expression;
+  GiNaC::symbol variable;
+  GiNaC::numeric num;
+  int order;
+  octave_value retval;
+  int nargin = args.length();
+
+  if ((nargin < 2) || (nargin > 3))
+    {
+      print_usage ("differentiate");
+      return retval;
+    }
+  try 
+    { 
+      if (!get_expression (args(0), expression))
+	{
+	  print_usage ("differentiate");
+	  return retval;
+	}
+      
+      if (!get_symbol (args(1), variable))
+	{
+	  print_usage ("differentiate");
+	  return retval;
+	}
+      
+      if (nargin == 3)
+	{
+	  if (!get_numeric (args(2), num))
+	    {
+	      print_usage ("differentiate");
+	      return retval;
+	    }
+	  order = int(num.to_double ());
+	  if (order < 0)
+	    {
+	      error("must supply an integer greater than zero\n");
+	      return retval;
+	    }
+	}
+      else
+	order = 1;
+
+      retval = octave_value(new octave_ex(expression.diff(variable,order)));
+    }
+  catch(exception &e)
+    {
+      error(e.what ());
+      retval = octave_value ();
+    }
+
+  return retval;
+}
diff --git a/op-ex-mat.cc b/op-ex-mat.cc
new file mode 100644
index 0000000..4a21107
--- /dev/null
+++ b/op-ex-mat.cc
@@ -0,0 +1,75 @@
+/*
+
+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 ex_matrix is first */
+DEFINE_MATRIX_MATRIX_OPS(ex_matrix, ex_matrix)
+DEFINE_MATRIX_MATRIX_OPS(ex_matrix, matrix)
+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 */ 
+DEFINE_MATRIX_MATRIX_OPS(complex_matrix, ex_matrix)
+DEFINE_MATRIX_MATRIX_OPS(matrix, ex_matrix)
+DEFINE_EX_MATRIX_OPS(complex, ex_matrix)
+DEFINE_EX_MATRIX_OPS(scalar, ex_matrix)
+
+
+void 
+install_ex_matrix_ops()
+{
+  INSTALL_MATRIX_MATRIX_OPS(ex_matrix, ex_matrix);
+  INSTALL_MATRIX_MATRIX_OPS(ex_matrix, matrix);
+  INSTALL_MATRIX_MATRIX_OPS(ex_matrix, complex_matrix);
+  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 */ 
+  INSTALL_MATRIX_MATRIX_OPS(complex_matrix, ex_matrix);
+  INSTALL_MATRIX_MATRIX_OPS(matrix, ex_matrix);
+  INSTALL_EX_MATRIX_OPS(complex, ex_matrix);
+  INSTALL_EX_MATRIX_OPS(scalar, ex_matrix);
+
+#if 0
+
+  INSTALL_UNOP(op_uminus, octave_ex, uminus);             // -x
+  
+  INSTALL_NCUNOP(op_incr, octave_ex, incr);               // x++
+  INSTALL_NCUNOP(op_decr, octave_ex, decr);               // x--
+
+#endif
+}
diff --git a/op-ex.cc b/op-ex.cc
new file mode 100644
index 0000000..fb6aceb
--- /dev/null
+++ b/op-ex.cc
@@ -0,0 +1,72 @@
+/*
+
+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 ex is first */
+DEFINE_EX_MATRIX_OPS(ex, ex_matrix)
+DEFINE_EX_MATRIX_OPS(ex, matrix)
+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 */ 
+DEFINE_MATRIX_EX_OPS(complex_matrix, ex)
+DEFINE_MATRIX_EX_OPS(matrix, ex)
+DEFINE_EX_EX_OPS(scalar, ex)
+DEFINE_EX_EX_OPS(complex, ex)
+
+void 
+install_ex_ops()
+{
+  INSTALL_EX_MATRIX_OPS(ex, ex_matrix);
+  INSTALL_EX_MATRIX_OPS(ex, matrix);
+  INSTALL_EX_MATRIX_OPS(ex, complex_matrix);
+  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 */ 
+  INSTALL_MATRIX_EX_OPS(complex_matrix, ex);
+  INSTALL_MATRIX_EX_OPS(matrix, ex);
+  INSTALL_EX_EX_OPS(scalar, ex);
+  INSTALL_EX_EX_OPS(complex, ex);
+
+#if 0
+  INSTALL_UNOP(op_uminus, octave_ex, uminus);             // -x
+  
+  INSTALL_NCUNOP(op_incr, octave_ex, incr);               // x++
+  INSTALL_NCUNOP(op_decr, octave_ex, decr);               // x--
+#endif
+}
diff --git a/op-sym.cc b/op-sym.cc
new file mode 100644
index 0000000..652cb5e
--- /dev/null
+++ b/op-sym.cc
@@ -0,0 +1,70 @@
+/*
+
+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
new file mode 100644
index 0000000..cceaf71
--- /dev/null
+++ b/op-vpa.cc
@@ -0,0 +1,85 @@
+/*
+
+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 vpa is first */
+DEFINE_EX_MATRIX_OPS(vpa, ex_matrix)
+DEFINE_EX_MATRIX_OPS(vpa, matrix)
+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 */ 
+DEFINE_MATRIX_EX_OPS(complex_matrix, vpa)
+DEFINE_MATRIX_EX_OPS(matrix, vpa)
+DEFINE_EX_EX_OPS(scalar, vpa)
+DEFINE_EX_EX_OPS(complex, vpa)
+
+void install_vpa_ops()
+{
+  // INSTALL_UNOP (op_not, octave_vpa, not);
+  /*
+  INSTALL_UNOP (op_uminus, octave_vpa, uminus);
+  INSTALL_UNOP (op_transpose, octave_vpa, transpose);
+  INSTALL_UNOP (op_hermitian, octave_vpa, hermitian);
+  
+  INSTALL_NCUNOP (op_incr, octave_vpa, incr);
+  INSTALL_NCUNOP (op_decr, octave_vpa, decr);
+  */
+
+  /* for when the vpa is first */
+  INSTALL_EX_MATRIX_OPS(vpa, ex_matrix);
+  INSTALL_EX_MATRIX_OPS(vpa, matrix);
+  INSTALL_EX_MATRIX_OPS(vpa, complex_matrix);
+  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 */ 
+  INSTALL_MATRIX_EX_OPS(complex_matrix, vpa);
+  INSTALL_MATRIX_EX_OPS(matrix, vpa);
+  INSTALL_EX_EX_OPS(scalar, vpa);
+  INSTALL_EX_EX_OPS(complex, vpa);
+
+
+  /* 
+  INSTALL_BINOP (op_lt, octave_vpa, octave_vpa, lt);
+  INSTALL_BINOP (op_le, octave_vpa, octave_vpa, le);
+  INSTALL_BINOP (op_eq, octave_vpa, octave_vpa, eq);
+  INSTALL_BINOP (op_ge, octave_vpa, octave_vpa, ge);
+  INSTALL_BINOP (op_gt, octave_vpa, octave_vpa, gt);
+  INSTALL_BINOP (op_ne, octave_vpa, octave_vpa, ne);
+  */
+}
diff --git a/ov-ex-mat.cc b/ov-ex-mat.cc
index d6df240..25ac0e8 100644
--- a/ov-ex-mat.cc
+++ b/ov-ex-mat.cc
@@ -1,224 +1,104 @@
 /*
-Copyright (C) 2002 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>
-
-#include <string>
+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.
 
-class ostream;
-class octave_sym;
+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/lo-mappers.h>
-#include <octave/lo-utils.h>
-#include <octave/mx-base.h>
-#include <octave/str-vec.h>
+*/
 
-#include <octave/defun-dld.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/config.h>
 #include <octave/ov-scalar.h>
-#include <octave/ov-re-mat.h>
 #include <octave/ov-complex.h>
-#include <octave/pager.h>
-#include <octave/pr-output.h>
-#include <octave/symtab.h>
-#include <octave/variables.h>
-#include <iostream>
-#include <fstream>
+#include <octave/ov-re-mat.h>
+#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)
+{
+  x = ox.x;
+}
 
-#if 0
-DEFUNOP_OP (uminus, ex, -)
-
-DEFNCUNOP_METHOD (incr, ex, increment)
-DEFNCUNOP_METHOD (decr, ex, decrement)
+octave_ex_matrix::octave_ex_matrix(octave_ex &ox)
+{
+  x = GiNaC::matrix(1,1);
+  x(0,0) = ox.ex_value (); 
+}
 
-#endif 
- 
-// Addition operations
-DEFBINOP_MATRIX_OP(ex_matrix_complex_matrix_add, ex_matrix, complex_matrix, add)
-DEFBINOP_MATRIX_OP(complex_matrix_ex_matrix_add, complex_matrix, ex_matrix, add)
-DEFBINOP_MATRIX_OP(ex_matrix_matrix_add, ex_matrix, matrix, add)
-DEFBINOP_MATRIX_OP(matrix_ex_matrix_add, matrix, ex_matrix, add)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_complex_add, ex_matrix, complex, +)
-DEFBINOP_SCALAR_EXMAT_OP(complex_ex_matrix_add, complex, ex_matrix, +)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_scalar_add,ex_matrix,scalar,+)
-DEFBINOP_SCALAR_EXMAT_OP(scalar_ex_matrix_add,scalar,ex_matrix,+)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_vpa_add,ex_matrix,vpa,+)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_ex_add, ex_matrix, ex, +)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_sym_add,ex_matrix,sym,+)
-DEFBINOP_MATRIX_OP(add,ex_matrix,ex_matrix,add)
-
-// Subtraction operations
-DEFBINOP_MATRIX_OP(ex_matrix_complex_matrix_sub, ex_matrix, complex_matrix, sub)
-DEFBINOP_MATRIX_OP(complex_matrix_ex_matrix_sub, complex_matrix, ex_matrix, sub)
-DEFBINOP_MATRIX_OP(ex_matrix_matrix_sub, ex_matrix, matrix, sub)
-DEFBINOP_MATRIX_OP(matrix_ex_matrix_sub, matrix, ex_matrix, sub)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_complex_sub, ex_matrix, complex, -)
-DEFBINOP_SCALAR_EXMAT_OP(complex_ex_matrix_sub, complex, ex_matrix, -)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_scalar_sub,ex_matrix,scalar, -)
-DEFBINOP_SCALAR_EXMAT_OP(scalar_ex_matrix_sub,scalar,ex_matrix, -)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_vpa_sub,ex_matrix,vpa, -)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_ex_sub, ex_matrix, ex, -)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_sym_sub,ex_matrix,sym, -)
-DEFBINOP_MATRIX_OP(sub,ex_matrix,ex_matrix,sub)
-
-// multiplication operations
-DEFBINOP_MATRIX_OP(ex_matrix_complex_matrix_mul, ex_matrix, complex_matrix, mul)
-DEFBINOP_MATRIX_OP(complex_matrix_ex_matrix_mul, complex_matrix, ex_matrix, mul)
-DEFBINOP_MATRIX_OP(ex_matrix_matrix_mul, ex_matrix, matrix, mul)
-DEFBINOP_MATRIX_OP(matrix_ex_matrix_mul, matrix, ex_matrix, mul)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_complex_mul, ex_matrix, complex, *)
-DEFBINOP_SCALAR_EXMAT_OP(complex_ex_matrix_mul, complex, ex_matrix, *)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_scalar_mul,ex_matrix,scalar, *)
-DEFBINOP_SCALAR_EXMAT_OP(scalar_ex_matrix_mul,scalar,ex_matrix, *)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_vpa_mul,ex_matrix,vpa, *)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_ex_mul, ex_matrix, ex, *)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_sym_mul,ex_matrix,sym, *)
-DEFBINOP_MATRIX_OP(mul,ex_matrix,ex_matrix,mul)
-
-// "right division" operations
-DEFBINOP_MATRIX_DIV(ex_matrix_complex_matrix_div, ex_matrix, complex_matrix)
-DEFBINOP_MATRIX_DIV(complex_matrix_ex_matrix_div, complex_matrix, ex_matrix)
-DEFBINOP_MATRIX_DIV(ex_matrix_matrix_div, ex_matrix, matrix)
-DEFBINOP_MATRIX_DIV(matrix_ex_matrix_div, matrix, ex_matrix)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_complex_div, ex_matrix, complex, /)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_scalar_div,ex_matrix,scalar, /)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_vpa_div,ex_matrix,vpa, /)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_ex_div, ex_matrix, ex, /)
-DEFBINOP_EXMAT_SCALAR_OP(ex_matrix_sym_div,ex_matrix,sym, /)
-DEFBINOP_MATRIX_DIV(div,ex_matrix,ex_matrix)
-
-// power operators
-DEFBINOP_POW(ex_matrix_complex_pow, ex_matrix, complex)
-DEFBINOP_POW(ex_matrix_scalar_pow,ex_matrix,scalar)
-DEFBINOP_POW(ex_matrix_vpa_pow,ex_matrix,vpa)
-DEFBINOP_POW(ex_matrix_ex_pow, ex_matrix, ex)
-DEFBINOP_POW(ex_matrix_sym_pow,ex_matrix,sym)
+octave_ex_matrix::octave_ex_matrix(GiNaC::symbol sym)
+{
+  x = GiNaC::matrix(1,1);
+  x(0,0) = GiNaC::ex(sym);
+}
+  
+octave_ex_matrix::octave_ex_matrix(GiNaC::matrix ex_mat)
+{
+  x = ex_mat;
+}
 
-void 
-octave_ex_matrix::print(ostream& os,bool pr_as_read_syntax) const
+octave_ex_matrix::octave_ex_matrix(GiNaC::ex expression)
 {
-  os << x;
+  x = GiNaC::matrix(1,1);
+  x(0,0) = expression; 
 }
- 
-octave_ex_matrix& octave_ex_matrix::operator=(const octave_ex_matrix& a)
+
+octave_ex_matrix::octave_ex_matrix(int rows, int columns)
 {
-  // GiNaC::ex *tmp;
-  // tmp = (a.x.bp->duplicate());
-  // return octave_ex(*tmp);
-  return (*(new octave_ex_matrix(a.x)));
+  x = GiNaC::matrix(rows,columns);
 }
 
-void 
-install_ex_matrix_type()
+octave_ex_matrix::octave_ex_matrix(octave_matrix ov)
 {
-  octave_ex_matrix::register_type();
+  Matrix mat = ov.matrix_value (); 
+  
+  int rows = mat.rows ();
+  int cols = mat.cols (); 
+  
+  x = GiNaC::matrix(rows, cols);
   
-  cerr << "installing ex matrix type at type-id = " 
-       << octave_ex_matrix::static_type_id() << "\n";
+  for (int i = 0; i < rows; i++)
+    for (int j = 0; j < cols; j++)
+      x(i,j) = GiNaC::ex(mat(i,j));
+}
+
+octave_ex_matrix::octave_ex_matrix(octave_complex_matrix ov)
+{
+    ComplexMatrix mat = ov.complex_matrix_value ();
+    
+    int rows = mat.rows ();
+    int cols = mat.cols (); 
+    
+    x = GiNaC::matrix(rows, cols);
+    
+    for (int i = 0; i < rows; i++)
+      for (int j = 0; j < cols; j++)
+	x(i,j) = GiNaC::ex(mat(i,j).real ()) + GiNaC::I*GiNaC::ex(mat(i,j).imag ());
 }
 
 
 void 
-install_ex_matrix_ops()
+octave_ex_matrix::print(ostream& os,bool pr_as_read_syntax) const
 {
-  // Install addition operators
-  INSTALL_BINOP(op_add, octave_ex_matrix, octave_complex_matrix, ex_matrix_complex_matrix_add);
-  INSTALL_BINOP(op_add, octave_complex_matrix, octave_ex_matrix, complex_matrix_ex_matrix_add);
-  INSTALL_BINOP(op_add, octave_ex_matrix, octave_matrix, ex_matrix_matrix_add);
-  INSTALL_BINOP(op_add, octave_matrix, octave_ex_matrix, matrix_ex_matrix_add);
-  INSTALL_BINOP(op_add, octave_ex_matrix, octave_complex, ex_matrix_complex_add);
-  INSTALL_BINOP(op_add, octave_complex, octave_ex_matrix, complex_ex_matrix_add);
-  INSTALL_BINOP(op_add, octave_ex_matrix, octave_scalar, ex_matrix_scalar_add);
-  INSTALL_BINOP(op_add, octave_scalar, octave_ex_matrix, scalar_ex_matrix_add);
-  INSTALL_BINOP(op_add, octave_ex_matrix, octave_vpa, ex_matrix_vpa_add);
-  INSTALL_BINOP(op_add, octave_ex_matrix, octave_ex, ex_matrix_ex_add);
-  INSTALL_BINOP(op_add, octave_ex_matrix, octave_sym, ex_matrix_sym_add);
-  INSTALL_BINOP(op_add, octave_ex_matrix, octave_ex_matrix, add);
-
-  // Install subtraction operators
-  INSTALL_BINOP(op_sub, octave_ex_matrix, octave_complex_matrix, ex_matrix_complex_matrix_sub);
-  INSTALL_BINOP(op_sub, octave_complex_matrix, octave_ex_matrix, complex_matrix_ex_matrix_sub);
-  INSTALL_BINOP(op_sub, octave_ex_matrix, octave_matrix, ex_matrix_matrix_sub);
-  INSTALL_BINOP(op_sub, octave_matrix, octave_ex_matrix, matrix_ex_matrix_sub);
-  INSTALL_BINOP(op_sub, octave_ex_matrix, octave_complex, ex_matrix_complex_sub);
-  INSTALL_BINOP(op_sub, octave_complex, octave_ex_matrix, complex_ex_matrix_sub);
-  INSTALL_BINOP(op_sub, octave_ex_matrix, octave_scalar, ex_matrix_scalar_sub);
-  INSTALL_BINOP(op_sub, octave_scalar, octave_ex_matrix, scalar_ex_matrix_sub);
-  INSTALL_BINOP(op_sub, octave_ex_matrix, octave_vpa, ex_matrix_vpa_sub);
-  INSTALL_BINOP(op_sub, octave_ex_matrix, octave_ex, ex_matrix_ex_sub);
-  INSTALL_BINOP(op_sub, octave_ex_matrix, octave_sym, ex_matrix_sym_sub);
-  INSTALL_BINOP(op_sub, octave_ex_matrix, octave_ex_matrix, sub);
-
-  // Install multiplication operators
-  INSTALL_BINOP(op_mul, octave_ex_matrix, octave_complex_matrix, ex_matrix_complex_matrix_mul);
-  INSTALL_BINOP(op_mul, octave_complex_matrix, octave_ex_matrix, complex_matrix_ex_matrix_mul);
-  INSTALL_BINOP(op_mul, octave_ex_matrix, octave_matrix, ex_matrix_matrix_mul);
-  INSTALL_BINOP(op_mul, octave_matrix, octave_ex_matrix, matrix_ex_matrix_mul);
-  INSTALL_BINOP(op_mul, octave_ex_matrix, octave_complex, ex_matrix_complex_mul);
-  INSTALL_BINOP(op_mul, octave_complex, octave_ex_matrix, complex_ex_matrix_mul);
-  INSTALL_BINOP(op_mul, octave_ex_matrix, octave_scalar, ex_matrix_scalar_mul);
-  INSTALL_BINOP(op_mul, octave_scalar, octave_ex_matrix, scalar_ex_matrix_mul);
-  INSTALL_BINOP(op_mul, octave_ex_matrix, octave_vpa, ex_matrix_vpa_mul);
-  INSTALL_BINOP(op_mul, octave_ex_matrix, octave_ex, ex_matrix_ex_mul);
-  INSTALL_BINOP(op_mul, octave_ex_matrix, octave_sym, ex_matrix_sym_mul);
-  INSTALL_BINOP(op_mul, octave_ex_matrix, octave_ex_matrix, mul);
-
-  // Install "right division" operators
-  INSTALL_BINOP(op_div, octave_ex_matrix, octave_complex_matrix, ex_matrix_complex_matrix_div);
-  INSTALL_BINOP(op_div, octave_complex_matrix, octave_ex_matrix, complex_matrix_ex_matrix_div);
-  INSTALL_BINOP(op_div, octave_ex_matrix, octave_matrix, ex_matrix_matrix_div);
-  INSTALL_BINOP(op_div, octave_matrix, octave_ex_matrix, matrix_ex_matrix_div);
-  INSTALL_BINOP(op_div, octave_ex_matrix, octave_complex, ex_matrix_complex_div);
-  INSTALL_BINOP(op_div, octave_ex_matrix, octave_scalar, ex_matrix_scalar_div);
-  INSTALL_BINOP(op_div, octave_ex_matrix, octave_vpa, ex_matrix_vpa_div);
-  INSTALL_BINOP(op_div, octave_ex_matrix, octave_ex, ex_matrix_ex_div);
-  INSTALL_BINOP(op_div, octave_ex_matrix, octave_sym, ex_matrix_sym_div);
-  INSTALL_BINOP(op_div, octave_ex_matrix, octave_ex_matrix, div);
-
-  // Install power operators
-  INSTALL_BINOP(op_pow, octave_ex_matrix, octave_complex, ex_matrix_complex_pow);
-  INSTALL_BINOP(op_pow, octave_ex_matrix, octave_scalar, ex_matrix_scalar_pow);
-  INSTALL_BINOP(op_pow, octave_ex_matrix, octave_vpa, ex_matrix_vpa_pow);
-  INSTALL_BINOP(op_pow, octave_ex_matrix, octave_ex, ex_matrix_ex_pow);
-  INSTALL_BINOP(op_pow, octave_ex_matrix, octave_sym, ex_matrix_sym_pow);
-
-#if 0
-
-  INSTALL_UNOP(op_uminus, octave_ex, uminus);             // -x
-  
-  INSTALL_NCUNOP(op_incr, octave_ex, incr);               // x++
-  INSTALL_NCUNOP(op_decr, octave_ex, decr);               // x--
-
-#endif
+  os << x;
+}
+ 
+octave_ex_matrix& octave_ex_matrix::operator=(const octave_ex_matrix& a)
+{
+  return (*(new octave_ex_matrix(a.x)));
 }
 
 DEFINE_OCTAVE_ALLOCATOR (octave_ex_matrix);
diff --git a/ov-ex-mat.h b/ov-ex-mat.h
index 038bf29..a2dd549 100644
--- a/ov-ex-mat.h
+++ b/ov-ex-mat.h
@@ -1,148 +1,30 @@
 /*
-Copyright (C) 2002 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.
+
+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
 
-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.
 */
 
 #if !defined (octave_ex_matrix_h)
 #define octave_ex_matrix_h 1
 
 #include <ginac/ginac.h>
-#include <octave/ov-re-mat.h>
-#include <octave/ov-cx-mat.h>
-
-void install_ex_matrix_type();
-void install_ex_matrix_ops();
-
-#define DEFBINOP_MATRIX_OP(name, t1, t2, op) \
-  BINOPDECL (name, a1, a2) \
-  { \
-    try \
-      { \
-        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
-        GiNaC::matrix r1 = octave_ex_matrix(v1.t1 ## _value ()).ex_matrix_value (); \
-	GiNaC::matrix r2 = octave_ex_matrix(v2.t2 ## _value ()).ex_matrix_value (); \
-        if ( (r1.rows () != r2.rows ()) || (r1.cols () != r2.cols ()) ) \
-          { \
-	    error("nonconformant arguments\n"); \
-	    return octave_value (); \
-	  } \
-        return octave_value \
-          (new octave_ex_matrix (r1.op (r2))); \
-      } \
-    catch (exception &e) \
-      { \
-        error(e.what()); \
-        return octave_value (); \
-      } \
-  }
 
-#define DEFBINOP_MATRIX_DIV(name, t1, t2) \
-  BINOPDECL (name, a1, a2) \
-  { \
-    try \
-      { \
-        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
-        GiNaC::matrix r1 = octave_ex_matrix(v1.t1 ## _value ()).ex_matrix_value (); \
-	GiNaC::matrix r2 = octave_ex_matrix(v2.t2 ## _value ()).ex_matrix_value (); \
-        if ( (r1.rows () != r2.rows ()) || (r1.cols () != r2.cols ()) ) \
-          { \
-	    error("nonconformant arguments\n"); \
-	    return octave_value (); \
-	  } \
-        return octave_value \
-          (new octave_ex_matrix (r2.transpose ().inverse ().mul (r1).transpose ())); \
-      } \
-    catch (exception &e) \
-      { \
-        error(e.what()); \
-        return octave_value (); \
-      } \
-  }
-
-#define DEFBINOP_SCALAR_EXMAT_OP(name, t1, t2, op) \
-  BINOPDECL (name, a1, a2) \
-  { \
-    try \
-      { \
-        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
-	GiNaC::matrix r1 = octave_ex_matrix(v2.t2 ## _value ()).ex_matrix_value (); \
-	GiNaC::ex r2 = octave_ex(v1.t1 ## _value ()).ex_value (); \
-        int rows = int(r1.rows ()); \
-        int cols = int(r1.cols ()); \
-	GiNaC::matrix result(rows, cols); \
-        for (int i = 0; i < rows; i++) \
-	  for (int j = 0; j < cols; j++) \
-	    result(i,j) = r1(i,j) op r2; \
-      return octave_value \
-          (new octave_ex_matrix (result)); \
-      } \
-    catch (exception &e) \
-      { \
-        error(e.what()); \
-        return octave_value (); \
-      } \
-  }
-
-#define DEFBINOP_EXMAT_SCALAR_OP(name, t1, t2, op) \
-  BINOPDECL (name, a1, a2) \
-  { \
-    try \
-      { \
-        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
-	GiNaC::matrix r1 = octave_ex_matrix(v1.t1 ## _value ()).ex_matrix_value (); \
-	GiNaC::ex r2 = octave_ex(v2.t2 ## _value ()).ex_value (); \
-        int rows = int(r1.rows ()); \
-        int cols = int(r1.cols ()); \
-	GiNaC::matrix result(rows, cols); \
-        for (int i = 0; i < rows; i++) \
-	  for (int j = 0; j < cols; j++) \
-	    result(i,j) = r1(i,j) op r2; \
-        return octave_value \
-          (new octave_ex_matrix (result)); \
-      } \
-    catch (exception &e) \
-      { \
-        error(e.what()); \
-        return octave_value (); \
-      } \
-  }
-
-#define DEFBINOP_POW(name, t1, t2) \
-  BINOPDECL (name, a1, a2) \
-  { \
-    try \
-      { \
-        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
-	GiNaC::matrix r1 = octave_ex_matrix(v1.t1 ## _value ()).ex_matrix_value (); \
-	GiNaC::ex r2 = octave_ex(v2.t2 ## _value ()).ex_value (); \
-        int rows = int(r1.rows ()); \
-        int cols = int(r1.cols ()); \
-	GiNaC::matrix result(rows, cols); \
-        for (int i = 0; i < rows; i++) \
-	  for (int j = 0; j < cols; j++) \
-	    result(i,j) = GiNaC::pow(r1(i,j), r2); \
-      return octave_value \
-          (new octave_ex_matrix (result)); \
-      } \
-    catch (exception &e) \
-      { \
-        error(e.what()); \
-        return octave_value (); \
-      } \
-  }
+class octave_matrix;
+class octave_complex_matrix;
 
 class 
 octave_ex_matrix : public octave_base_value
@@ -150,66 +32,14 @@ octave_ex_matrix : public octave_base_value
 public:
   octave_ex_matrix(void):octave_base_value() {}
 
-  octave_ex_matrix(octave_ex_matrix &ox)
-    {
-      x = ox.x;
-    }
-
-  octave_ex_matrix(octave_ex &ox)
-    {
-      x = GiNaC::matrix(1,1);
-      x(0,0) = ox.ex_value (); 
-    }
-
-  octave_ex_matrix(GiNaC::symbol sym)
-    {
-      x = GiNaC::matrix(1,1);
-      x(0,0) = GiNaC::ex(sym);
-    }
-  
-  octave_ex_matrix(GiNaC::matrix ex_mat)
-    {
-      x = ex_mat;
-    }
-
-  octave_ex_matrix(GiNaC::ex expression)
-    {
-      x = GiNaC::matrix(1,1);
-      x(0,0) = expression; 
-    }
-
-  octave_ex_matrix(int rows, int columns)
-    {
-      x = GiNaC::matrix(rows,columns);
-    }
-
-  octave_ex_matrix(octave_matrix ov)
-    {
-      Matrix mat = ov.matrix_value (); 
-
-      int rows = mat.rows ();
-      int cols = mat.cols (); 
-
-      x = GiNaC::matrix(rows, cols);
-
-      for (int i = 0; i < rows; i++)
-	for (int j = 0; j < cols; j++)
-	  x(i,j) = GiNaC::ex(mat(i,j));
-    }
-
-  octave_ex_matrix(octave_complex_matrix ov)
-  {
-    ComplexMatrix mat = ov.complex_matrix_value ();
-
-    int rows = mat.rows ();
-    int cols = mat.cols (); 
-    
-    x = GiNaC::matrix(rows, cols);
-    
-    for (int i = 0; i < rows; i++)
-      for (int j = 0; j < cols; j++)
-	x(i,j) = GiNaC::ex(mat(i,j).real ()) + GiNaC::I*GiNaC::ex(mat(i,j).imag ());
-  }
+  octave_ex_matrix(octave_ex_matrix &ox);
+  octave_ex_matrix(octave_ex &ox);
+  octave_ex_matrix(GiNaC::symbol sym);  
+  octave_ex_matrix(GiNaC::matrix ex_mat);
+  octave_ex_matrix(GiNaC::ex expression);
+  octave_ex_matrix(int rows, int columns);
+  octave_ex_matrix(octave_matrix ov);
+  octave_ex_matrix(octave_complex_matrix ov);
 
   ~octave_ex_matrix() {}
   
@@ -217,15 +47,11 @@ public:
 
   GiNaC::matrix ex_matrix_value(bool = false) const
     {
-      // GiNaC::ex tmp = *(x.bp->duplicate());
-      // return tmp;
       return x;
     }
   
   GiNaC::ex ex_value(bool = false) const
     {
-      // GiNaC::ex tmp = *(x.bp->duplicate());
-      // return tmp;
       return GiNaC::ex(x);
     }
   
@@ -245,11 +71,7 @@ public:
   bool is_true(void) const { return true; }
    
   octave_value uminus (void) const { return new octave_ex_matrix(-x); } 
-  /*
-  void increment (void) { x = x+1;}
 
-  void decrement (void) { x = x-1;}
-  */ 
   void print(ostream& os,bool pr_as_read_syntax) const;
   
 private:
diff --git a/ov-ex.cc b/ov-ex.cc
index bae6176..69319dd 100644
--- a/ov-ex.cc
+++ b/ov-ex.cc
@@ -1,218 +1,81 @@
 /*
-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.
+
+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
 
-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>
-
-#include <string>
-
-class ostream;
-class octave_sym;
-
-#include <octave/lo-mappers.h>
-#include <octave/lo-utils.h>
-#include <octave/mx-base.h>
-#include <octave/str-vec.h>
-
-#include <octave/defun-dld.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 <iostream>
-#include <fstream>
+#include <ginac/ginac.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, ex, -)
-
-DEFNCUNOP_METHOD (incr, ex, increment)
-DEFNCUNOP_METHOD (decr, ex, decrement)
-
-#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(ex_scalar_add,ex,scalar,+)
-DEFBINOP_OP(scalar_ex_add,scalar,ex,+)
-DEFBINOP_OP(ex_vpa_add,ex,vpa,+)
-DEFBINOP_OP (add, ex, ex, +)
-DEFBINOP_OP(ex_sym_add,ex,sym,+)
-
-// Subtraction operations
-DEFBINOP_OP(ex_scalar_sub,ex,scalar,-)
-DEFBINOP_OP(scalar_ex_sub,scalar,ex,-)
-DEFBINOP_OP(ex_vpa_sub,ex,vpa,-)
-DEFBINOP_OP (sub, ex, ex, -)
-DEFBINOP_OP(ex_sym_sub,ex,sym,-)
-
-// Multiplication operations
-DEFBINOP_OP(ex_scalar_mul,ex,scalar,*)
-DEFBINOP_OP(scalar_ex_mul,scalar,ex,*)
-DEFBINOP_OP(ex_vpa_mul,ex,vpa,*)
-DEFBINOP_OP (mul, ex, ex, *)
-DEFBINOP_OP(ex_sym_mul,ex,sym,*)
-
-// Division operations
-DEFBINOP_OP(ex_scalar_div,ex,scalar,/)
-DEFBINOP_OP(scalar_ex_div,scalar,ex,/)
-DEFBINOP_OP(ex_vpa_div,ex,vpa,/)
-DEFBINOP_OP (div, ex, ex, /)
-DEFBINOP_OP(ex_sym_div,ex,sym,/)
-
-// Power operations 
-DEFBINOP_POW(pow,ex,ex)
-DEFBINOP_POW(ex_scalar_pow,ex,scalar)
-DEFBINOP_POW(scalar_ex_pow,scalar,ex)
-DEFBINOP_POW(ex_vpa_pow,ex,vpa)
-DEFBINOP_POW(ex_sym_pow,ex,sym)
- 
-void 
-octave_ex::print(ostream& os,bool pr_as_read_syntax) const
+octave_ex::octave_ex(octave_ex &ox)
 {
-  os << x;
+  x = ox.x;
 }
- 
-octave_ex& octave_ex::operator=(const octave_ex& a)
+
+octave_ex::octave_ex(GiNaC::ex expression)
 {
-  // GiNaC::ex *tmp;
-  // tmp = (a.x.bp->duplicate());
-  // return octave_ex(*tmp);
-  return (*(new octave_ex(a.x)));
+  x = expression;
 }
 
-void 
-install_ex_type()
+octave_ex::octave_ex(octave_sym &osym) 
+{
+  x = osym.sym_value () + 0; 
+}
+
+octave_ex::octave_ex(GiNaC::symbol sym)
+{
+  x = sym;
+}
+
+octave_ex::octave_ex(octave_complex &cmplx)
 {
-  octave_ex::register_type();
-  
-  cerr << "installing ex type at type-id = " 
-       << octave_ex::static_type_id() << "\n";
+  Complex z = cmplx.complex_value (); 
+  x = z.real () + GiNaC::I*z.imag ();
+}
+
+octave_ex::octave_ex(Complex z)
+{
+  x = z.real () + GiNaC::I*z.imag ();
+}
+
+octave_ex::octave_ex(octave_scalar &s)
+{
+  double d = s.double_value (); 
+  x = d;
+}
+
+octave_ex::octave_ex(double d)
+{
+  x = d;
 }
 
 void 
-install_ex_ops()
+octave_ex::print(ostream& os,bool pr_as_read_syntax) const
+{
+  os << x;
+}
+
+ 
+octave_ex& octave_ex::operator=(const octave_ex& a)
 {
-  INSTALL_UNOP(op_uminus, octave_ex, uminus);             // -x
-  
-  INSTALL_NCUNOP(op_incr, octave_ex, incr);               // x++
-  INSTALL_NCUNOP(op_decr, octave_ex, decr);               // x--
-  
-  // Addition operations
-  INSTALL_BINOP(op_add, octave_scalar, octave_ex, scalar_ex_add);
-  INSTALL_BINOP(op_add, octave_ex, octave_scalar, ex_scalar_add);
-  INSTALL_BINOP(op_add, octave_ex, octave_vpa, ex_vpa_add);
-  INSTALL_BINOP(op_add, octave_ex, octave_ex, add);
-  INSTALL_BINOP(op_add, octave_ex, octave_sym, ex_sym_add);
-  
-  // Subtraction operations
-  INSTALL_BINOP(op_sub, octave_scalar, octave_ex, scalar_ex_sub);
-  INSTALL_BINOP(op_sub, octave_ex, octave_scalar, ex_scalar_sub);
-  INSTALL_BINOP(op_sub, octave_ex, octave_vpa, ex_vpa_sub);
-  INSTALL_BINOP(op_sub, octave_ex, octave_ex, sub);
-  INSTALL_BINOP(op_sub, octave_ex, octave_sym, ex_sym_sub);
-  
-  // Multiplication operations
-  INSTALL_BINOP(op_mul, octave_scalar, octave_ex, scalar_ex_mul);
-  INSTALL_BINOP(op_mul, octave_ex, octave_scalar, ex_scalar_mul);
-  INSTALL_BINOP(op_mul, octave_ex, octave_vpa, ex_vpa_mul);
-  INSTALL_BINOP(op_mul, octave_ex, octave_ex, mul);
-  INSTALL_BINOP(op_mul, octave_ex, octave_sym, ex_sym_mul);
-  
-  // Division operations
-  INSTALL_BINOP(op_div, octave_scalar, octave_ex, scalar_ex_div);
-  INSTALL_BINOP(op_div, octave_ex, octave_scalar, ex_scalar_div);
-  INSTALL_BINOP(op_div, octave_ex, octave_vpa, ex_vpa_div);
-  INSTALL_BINOP(op_div, octave_ex, octave_ex, div);
-  INSTALL_BINOP(op_div, octave_ex, octave_sym, ex_sym_div);
-  
-  // Power operations
-  INSTALL_BINOP(op_pow, octave_scalar, octave_ex, scalar_ex_pow);
-  INSTALL_BINOP(op_pow, octave_ex, octave_scalar, ex_scalar_pow);  
-  INSTALL_BINOP(op_pow, octave_ex, octave_vpa, ex_vpa_pow);        
-  INSTALL_BINOP(op_pow, octave_ex, octave_sym, ex_sym_pow);
-  INSTALL_BINOP(op_pow, octave_ex, octave_ex, pow); 
+  return (*(new octave_ex(a.x)));
 }
 
 DEFINE_OCTAVE_ALLOCATOR (octave_ex);
diff --git a/ov-ex.h b/ov-ex.h
index c5875be..e366017 100644
--- a/ov-ex.h
+++ b/ov-ex.h
@@ -1,28 +1,35 @@
 /*
-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.
+
+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
 
-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.
 */
 
 #if !defined (octave_ex_h)
 #define octave_ex_h 1
 
 #include <ginac/ginac.h>
+#include <octave/ov-complex.h>
+#include <octave/ov-scalar.h>
+#include "ov-sym.h"
+#include "ov-vpa.h"
+
 
-void install_ex_type();
-void install_ex_ops();
+class octave_complex;
+class octave_scalar;
 
 class 
 octave_ex : public octave_base_value
@@ -30,33 +37,14 @@ octave_ex : public octave_base_value
 public:
   octave_ex(void):octave_base_value() {}
 
-  octave_ex(octave_ex &ox)
-    {
-      // x = *(ox.x.bp->duplicate());
-      x = ox.x;
-    }
-
-  octave_ex(GiNaC::symbol sym)
-    {
-      // x = *(sym.duplicate());
-      x = sym;
-    }
-  
-  octave_ex(GiNaC::ex expression)
-    {
-      // x = *(expression.bp->duplicate());
-      x = expression;
-    }
-  
-  octave_ex(Complex z)
-    {
-      x = z.real () + GiNaC::I*z.imag ();
-    }
-
-  octave_ex(double d)
-    {
-      x = d;
-    }
+  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);
+  octave_ex(octave_scalar &s);
+  octave_ex(double d);
 
   ~octave_ex() {}
   
@@ -64,8 +52,6 @@ public:
 
   GiNaC::ex ex_value(bool = false) const
     {
-      // GiNaC::ex tmp = *(x.bp->duplicate());
-      // return tmp;
       return x;
     }
   
diff --git a/ov-relational.h b/ov-relational.h
new file mode 100644
index 0000000..5b4201a
--- /dev/null
+++ b/ov-relational.h
@@ -0,0 +1,91 @@
+/*
+
+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_relational_h)
+#define octave_relational_h 1
+
+// GiNaC
+#include <ginac/ginac.h>
+#include <octave/ov-base.h>
+#include "ov-ex.h"
+
+// relational values.
+
+class
+octave_relational : public octave_base_value
+{
+public:
+
+  octave_relational (void):octave_base_value() {}
+  
+  octave_relational (GiNaC::relational & orel) : octave_base_value () { rel = orel;}
+
+  octave_relational (const GiNaC::ex & lhs, 
+		   const GiNaC::ex & rhs, 
+		   GiNaC::relational::operators op=GiNaC::relational::equal);
+
+  octave_relational (const octave_ex & lhs, 
+		   const octave_ex & rhs, 
+		   GiNaC::relational::operators op=GiNaC::relational::equal);
+
+  octave_relational (const octave_ex & lhs, 
+		   const GiNaC::ex & rhs, 
+		   GiNaC::relational::operators op=GiNaC::relational::equal);
+
+  octave_relational (const GiNaC::ex & lhs, 
+		   const octave_ex & rhs, 
+		   GiNaC::relational::operators op=GiNaC::relational::equal);
+
+  ~octave_relational (void) { }
+
+  octave_value *clone (void) { return new octave_relational (*this); }
+
+  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; }
+
+  octave_value all (void) const { return (double) bool(rel); }
+  octave_value any (void) const { return (double) bool(rel); }
+
+  bool is_true (void) const { return bool(rel); }
+
+  GiNaC::relational relational_value (bool = false) const { return rel; }
+
+  void print (ostream& os, bool pr_as_read_syntax = false) const;
+
+private:
+  
+  GiNaC::relational rel;
+
+  DECLARE_OCTAVE_ALLOCATOR
+
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+};
+
+#endif
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
diff --git a/ov-sym.h b/ov-sym.h
index 866729a..f264716 100644
--- a/ov-sym.h
+++ b/ov-sym.h
@@ -1,49 +1,38 @@
 /*
-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.
+
+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
 
-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.
 */
 
 #if !defined (octave_sym_h)
 #define octave_sym_h 1
 
 #include <ginac/ginac.h>
-#include "ov.h"
 #include "ov-base.h"
-#include "ov-ex.h"
-
-class Octave_map;
-class octave_value_list;
-class tree_walker;
 
-void install_sym_type();
-void install_sym_ops();
+class octave_ex;
 
 class 
 octave_sym : public octave_base_value
 {
 public:
   octave_sym(void){}
-
-  octave_sym(char *str)
-  {
-    x = GiNaC::symbol(str);
-  }
-
+  octave_sym(char *str);
   octave_sym(const octave_sym &xtmp):x(xtmp.x){}
-
   octave_sym(GiNaC::symbol xtmp):x(xtmp){}
 
   ~octave_sym (void) {}
@@ -52,12 +41,9 @@ public:
 
   GiNaC::symbol sym_value(void) const;
 
-  octave_value uminus (void){ return (new octave_ex(-x));}
+  octave_value uminus (void); 
 
-  void print(ostream& os,bool pr_as_read_syntax) const
-  {
-    os << x;
-  }
+  void print(ostream& os,bool pr_as_read_syntax) const;
 
   int rows (void) const { return 1; }
   int columns (void) const { return 1; }
diff --git a/ov-vpa.cc b/ov-vpa.cc
index ea046eb..a76eec2 100644
--- a/ov-vpa.cc
+++ b/ov-vpa.cc
@@ -1,269 +1,57 @@
 /*
-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.
-
-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.
-*/
+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.
 
-#include <octave/config.h>
+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 <cstdlib>
+*/
 
-#include <string>
+#include <octave/config.h>
+#include "ov-vpa.h"
 
 class ostream;
 
-#include <octave/lo-mappers.h>
-#include <octave/lo-utils.h>
-#include <octave/mx-base.h>
-#include <octave/str-vec.h>
-
-#include <octave/defun-dld.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 "ov-vpa.h"
-#include "ov-ex.h"
-#include "ov-sym.h"
-
-void
-octave_vpa::print (ostream& os, bool pr_as_read_syntax) const
+octave_vpa::octave_vpa(void):octave_base_value()
 {
-  os << scalar;
+  scalar = GiNaC::numeric(0);
 }
 
+octave_vpa::octave_vpa (int i):octave_base_value()
+{ 
+  scalar = GiNaC::numeric(0);
+}
 
-#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_vpa (op v.t ## _value ())); \
-      } \
-    catch(exception &e) \
-      { \
-        error(e.what()); \
-        return octave_value (); \
-      } \
-  }  
-
+octave_vpa::octave_vpa (const octave_vpa& s):octave_base_value()
+{ 
+  scalar = s.scalar;
+}
   
-
-// DEFUNOP_OP (not, vpa, !)
-DEFUNOP_OP (uminus, vpa, -)
-DEFUNOP_OP (transpose, vpa, /* no-op */)
-DEFUNOP_OP (hermitian, vpa, /* no-op */)
-
-DEFNCUNOP_METHOD (incr, vpa, increment)
-DEFNCUNOP_METHOD (decr, vpa, decrement)
-
-#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_vpa (v1.t1 ## _value () op v2.t2 ## _value ())); \
-      } \
-    catch(exception &e) \
-      { \
-        error(e.what()); \
-        return octave_value (); \
-      } \
-  }
-
-#define DEFBINOP_OP_NUM(name, t1, t2, op) \
-  BINOPDECL (name, a1, a2) \
-  { \
-    try \
-      { \
-        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
-        return octave_value \
-          (new octave_vpa (v1.t1 ## _value () op v2.t2 ## _value ())); \
-      } \
-    catch (exception &e) \
-      { \
-        error(e.what()); \
-        return octave_value (); \
-      } \
-  }
-
-#define DEFBINOP_OP_EX(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) \
-      { \
-        octave_value_list empty; \
-        error(e.what()); \
-        return empty; \
-      } \
-  }
-
-// relational ops.
-DEFBINOP_OP (lt, vpa, vpa, <)
-DEFBINOP_OP (le, vpa, vpa, <=)
-DEFBINOP_OP (eq, vpa, vpa, ==)
-DEFBINOP_OP (ge, vpa, vpa, >=)
-DEFBINOP_OP (gt, vpa, vpa, >)
-DEFBINOP_OP (ne, vpa, vpa, !=)
-  //DEFBINOP_OP (el_mul, vpa, vpa, !=)
-
-  //#error The type of return arguements in sym_vpa class are not always correct
-
-// Addition operations
-DEFBINOP_OP_NUM(vpa_scalar_add,vpa,scalar,+)
-DEFBINOP_OP_NUM(scalar_vpa_add,scalar,vpa,+)
-DEFBINOP_OP_NUM (add, vpa, vpa, +)
-DEFBINOP_OP_EX(vpa_sym_add,vpa,sym,+)
-DEFBINOP_OP_EX(vpa_ex_add,vpa,ex,+)
-
-// Subtraction operations
-DEFBINOP_OP_NUM(vpa_scalar_sub,vpa,scalar,-)
-DEFBINOP_OP_NUM(scalar_vpa_sub,scalar,vpa,-)
-DEFBINOP_OP_NUM(sub, vpa, vpa, -)
-DEFBINOP_OP_EX(vpa_sym_sub,vpa,sym,-)
-DEFBINOP_OP_EX(vpa_ex_sub,vpa,ex,-)
-
-// Multiplication operations
-DEFBINOP_OP_NUM(vpa_scalar_mul,vpa,scalar,*)
-DEFBINOP_OP_NUM(scalar_vpa_mul,scalar,vpa,*)
-DEFBINOP_OP_NUM(mul, vpa, vpa, *)
-DEFBINOP_OP_EX(vpa_sym_mul,vpa,sym,*)
-DEFBINOP_OP_EX(vpa_ex_mul,vpa,ex,*)
-
-// Division operations
-DEFBINOP_OP_NUM(vpa_scalar_div,vpa,scalar,/)
-DEFBINOP_OP_NUM(scalar_vpa_div,scalar,vpa,/)
-DEFBINOP_OP_NUM(div, vpa, vpa, /)
-DEFBINOP_OP_EX(vpa_sym_div,vpa,sym,/)
-DEFBINOP_OP_EX(vpa_ex_div,vpa,ex,/)
-
-// Power operations 
-DEFBINOP_POW(pow,vpa,vpa)
-DEFBINOP_POW(vpa_scalar_pow,vpa,scalar)
-DEFBINOP_POW(scalar_vpa_pow,scalar,vpa)
-DEFBINOP_POW(vpa_sym_pow,vpa,sym) 
-DEFBINOP_POW(vpa_ex_pow,vpa,ex)
-
-void 
-install_vpa_type()
+octave_vpa::octave_vpa (const GiNaC::numeric& s):octave_base_value()
 {
-  octave_vpa::register_type ();
+  scalar = s;
+}
   
-  cerr << "installing vpa type at type-id = "
-       << octave_vpa::static_type_id () << "\n";
+octave_vpa::octave_vpa( const GiNaC::ex& x):octave_base_value()
+{
+  scalar = GiNaC::ex_to<GiNaC::numeric>(x);
 }
 
-void install_vpa_ops()
+void
+octave_vpa::print (ostream& os, bool pr_as_read_syntax) const
 {
-  // INSTALL_UNOP (op_not, octave_vpa, not);
-  INSTALL_UNOP (op_uminus, octave_vpa, uminus);
-  INSTALL_UNOP (op_transpose, octave_vpa, transpose);
-  INSTALL_UNOP (op_hermitian, octave_vpa, hermitian);
-  
-  INSTALL_NCUNOP (op_incr, octave_vpa, incr);
-  INSTALL_NCUNOP (op_decr, octave_vpa, decr);
-  
-  // Addition operations
-  INSTALL_BINOP(op_add, octave_scalar, octave_vpa, scalar_vpa_add);
-  INSTALL_BINOP(op_add, octave_vpa, octave_scalar, vpa_scalar_add);
-  INSTALL_BINOP(op_add, octave_vpa, octave_vpa, add);
-  INSTALL_BINOP(op_add, octave_vpa, octave_sym, vpa_sym_add);
-  INSTALL_BINOP(op_add, octave_vpa, octave_ex, vpa_ex_add);
-  
-  // Subtraction operations
-  INSTALL_BINOP(op_sub, octave_scalar, octave_vpa, scalar_vpa_sub);
-  INSTALL_BINOP(op_sub, octave_vpa, octave_scalar, vpa_scalar_sub);
-  INSTALL_BINOP(op_sub, octave_vpa, octave_vpa, sub);
-  INSTALL_BINOP(op_sub, octave_vpa, octave_sym, vpa_sym_sub);
-  INSTALL_BINOP(op_sub, octave_vpa, octave_ex, vpa_ex_sub);
-  
-  // Multiplication operations
-  INSTALL_BINOP(op_mul, octave_scalar, octave_vpa, scalar_vpa_mul);
-  INSTALL_BINOP(op_mul, octave_vpa, octave_scalar, vpa_scalar_mul);
-  INSTALL_BINOP(op_mul, octave_vpa, octave_vpa, mul);
-  INSTALL_BINOP(op_mul, octave_vpa, octave_sym, vpa_sym_mul);
-  INSTALL_BINOP(op_mul, octave_vpa, octave_ex, vpa_ex_mul);
-  
-  // Division operations
-  INSTALL_BINOP(op_div, octave_scalar, octave_vpa, scalar_vpa_div);
-  INSTALL_BINOP(op_div, octave_vpa, octave_scalar, vpa_scalar_div);
-  INSTALL_BINOP(op_div, octave_vpa, octave_vpa, div);
-  INSTALL_BINOP(op_div, octave_vpa, octave_sym, vpa_sym_div);
-  INSTALL_BINOP(op_div, octave_vpa, octave_ex, vpa_ex_div);
-  
-  // Power operations
-  INSTALL_BINOP(op_pow, octave_scalar, octave_vpa, scalar_vpa_pow);
-  INSTALL_BINOP(op_pow, octave_vpa, octave_scalar, vpa_scalar_pow);  
-  INSTALL_BINOP(op_pow, octave_vpa, octave_vpa, pow);        
-  INSTALL_BINOP(op_pow, octave_vpa, octave_sym, vpa_sym_pow);
-  INSTALL_BINOP(op_pow, octave_vpa, octave_ex, vpa_ex_pow);
-  
-  INSTALL_BINOP (op_lt, octave_vpa, octave_vpa, lt);
-  INSTALL_BINOP (op_le, octave_vpa, octave_vpa, le);
-  INSTALL_BINOP (op_eq, octave_vpa, octave_vpa, eq);
-  INSTALL_BINOP (op_ge, octave_vpa, octave_vpa, ge);
-  INSTALL_BINOP (op_gt, octave_vpa, octave_vpa, gt);
-  INSTALL_BINOP (op_ne, octave_vpa, octave_vpa, ne);
-  
+  os << scalar;
 }
 
 DEFINE_OCTAVE_ALLOCATOR (octave_vpa);
diff --git a/ov-vpa.h b/ov-vpa.h
index 4072694..4414983 100644
--- a/ov-vpa.h
+++ b/ov-vpa.h
@@ -1,19 +1,21 @@
 /*
-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.
+
+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
 
-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.
 */
 
 #if !defined (octave_vpa_h)
@@ -21,14 +23,7 @@ Boston, MA  02111-1307, USA.
 
 // GiNaC
 #include <ginac/ginac.h>
-
-class Octave_map;
-class octave_value_list;
-
-class tree_walker;
-
-void install_vpa_type();
-void install_vpa_ops();
+#include <octave/ov-base.h>
 
 // vpa values.
 
@@ -37,30 +32,11 @@ octave_vpa : public octave_base_value
 {
 public:
 
-  octave_vpa (void):octave_base_value()
-    {
-      scalar = GiNaC::numeric(0);
-    }
-  
-  octave_vpa (int i):octave_base_value()
-    { 
-      scalar = GiNaC::numeric(0);
-    }
-  
-  octave_vpa (const octave_vpa& s):octave_base_value()
-    { 
-      scalar = s.scalar;
-    }
-  
-  octave_vpa (const GiNaC::numeric& s):octave_base_value()
-    {
-      scalar = s;
-    }
-  
-  octave_vpa( const GiNaC::ex& x):octave_base_value()
-    {
-      scalar = GiNaC::ex_to<GiNaC::numeric>(x);
-    }
+  octave_vpa (void);  
+  octave_vpa (int i);
+  octave_vpa (const octave_vpa& s);
+  octave_vpa (const GiNaC::numeric& s);
+  octave_vpa( const GiNaC::ex& x);
 
   ~octave_vpa (void) { }
 
diff --git a/sym-bool.cc b/sym-bool.cc
new file mode 100644
index 0000000..9f2a8f2
--- /dev/null
+++ b/sym-bool.cc
@@ -0,0 +1,71 @@
+/*
+
+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/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" 
+
+DEFUN_DLD(is_vpa, args, ,
+"Return true if an object is of type vpa, false otherwise.\n")
+{
+  bool retval;
+  retval = (args(0).type_id() == octave_vpa::static_type_id());
+  return octave_value(retval);
+}
+
+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());
+  return octave_value(retval);
+}
+
+
+DEFUN_DLD(is_ex,args,,
+"-*- texinfo -*-\n\
+ at deftypefn Loadable Function {bool =} is_ex(@var{a})\n\
+\n\
+Return true if an object is a symbolic expression.\n\
+ at seealso{is_vpa, is_sym, is_ex_matrix}\n\
+ at end deftypefn")
+{
+  bool retval;
+  retval = (args(0).type_id() == octave_ex::static_type_id());
+  return octave_value(retval);
+}
+
+
+DEFUN_DLD(is_ex_matrix,args,,
+"-*- texinfo -*-\n\
+ at deftypefn Loadable Function {bool =} is_ex_matrix(@var{a})\n\
+\n\
+Return true if an object is a symbolic matrix.\n\
+ at seealso{is_vpa, is_sym, is_ex}\n\
+ at end deftypefn")
+{
+  bool retval;
+  retval = (args(0).type_id() == octave_ex_matrix::static_type_id());
+  return octave_value(retval);
+}
diff --git a/sym-create.cc b/sym-create.cc
new file mode 100644
index 0000000..91aec97
--- /dev/null
+++ b/sym-create.cc
@@ -0,0 +1,172 @@
+/*
+
+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/gripes.h>
+#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" 
+
+DEFUN_DLD (vpa, args, ,
+"-*- texinfo -*-\n\
+ at deftypefn {Loadable Function} {n =} vpa(@var{s})\n\
+\n\
+Creates a variable precision arithmetic variable from @var{s}.\n\
+ at var{s} can be a scalar, vpa value, string or a ex value that \n\
+is a number.\n\
+ at end deftypefn\n\
+")
+{
+  octave_value retval;
+  GiNaC::numeric d;
+  int nargin = args.length();
+  
+  try 
+    {
+      if (nargin == 1)
+	{
+	  if (!get_numeric (args(0), d))
+	    {
+	      gripe_wrong_type_arg ("vpa", args(0));
+	      return retval;
+	    } 
+	}
+      else
+	{
+	  print_usage("vpa");
+	  return retval;
+	}
+
+      retval = octave_value(new octave_vpa(d));
+    }
+  catch (exception &e)
+    { 
+      error(e.what());
+      retval = octave_value (); 
+    } 
+    
+  return retval;
+}
+
+DEFUN_DLD (sym,args, , 
+"-*- texinfo -*-\n\
+Create an object of type symbol\n")
+{
+  octave_value retval;
+  int nargin = args.length ();
+
+  if (nargin != 1)
+    {
+      error("one argument expected\n");
+      return octave_value ();
+    }
+  try 
+    {
+      GiNaC::symbol xtmp(args(0).string_value());
+      octave_sym x(xtmp);
+      retval = octave_value(new octave_sym(x));
+    }
+  catch (exception &e)
+    {
+      error(e.what());
+      retval = octave_value ();
+    }
+
+  return retval;
+}
+
+// an ex DLD function might be nice 
+
+DEFUN_DLD (ex_matrix, args, ,
+"-*- texinfo -*-\n\
+ at deftypefn {Loadable Function} {n =} ex_matrix(@var{rows}, @var{cols}, ... )\n\
+\n\
+Creates a variable precision arithmetic variable from @var{s}.\n\
+ at var{s} can be a scalar, vpa value, string or a ex value that \n\
+is a number.\n\
+ at end deftypefn\n\
+")
+{
+  octave_value retval;
+  GiNaC::ex expression;
+  int nargin = args.length();
+  int rows, cols,k; 
+
+  if (nargin < 2)
+    {
+      print_usage("ex_matrix");
+      return retval; 
+    }
+
+  if(args(0).is_real_scalar())
+    {
+      rows = int(args(0).double_value());
+    }
+  else
+    {
+      error("You must supply a scalar for the first argument.");
+      return retval;
+    }
+
+  if(args(1).is_real_scalar())
+    {
+      cols = int(args(1).double_value());
+    }
+  else
+    {
+      error("You must supply a scalar for the first argument.");
+      return retval;
+    }
+
+  try 
+    {
+      GiNaC::matrix a = GiNaC::matrix(rows,cols);
+      k = 2;
+      for (int i = 0; i < rows; i++)
+      {
+	for (int j = 0; j < cols; j++, k++)
+	  {
+	    if (k < nargin)
+	      {
+		if (!get_expression(args(k),expression))
+		  {
+		    error("unable to turn an argument into a symbolic expression");
+		    return retval;
+		  }
+		a(i,j) = expression;
+	      }
+	    else
+	      break;
+	  }
+      }
+      retval = octave_value(new octave_ex_matrix(a));
+    }
+  catch (exception &e)
+    {
+      error(e.what());
+      retval = octave_value (); 
+    } 
+    
+  return retval;
+}
diff --git a/sym-ops.h b/sym-ops.h
new file mode 100644
index 0000000..1dbbe20
--- /dev/null
+++ b/sym-ops.h
@@ -0,0 +1,250 @@
+/*
+
+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 (sym_ops_h)
+#define sym_ops_h 1
+
+#include <octave/ops.h>
+
+/* This file defines macros used in the op-X.cc files to define functions
+ */
+
+void install_ex_ops(void); 
+void install_sym_ops(void);
+void install_vpa_ops(void);
+void install_ex_matrix_ops(void);
+
+#define DEFBINOP_MATRIX_MATRIX_OP(name, t1, t2, op) \
+  BINOPDECL (name, a1, a2) \
+  { \
+    try \
+      { \
+        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
+        GiNaC::matrix r1 = octave_ex_matrix(v1.t1 ## _value ()).ex_matrix_value (); \
+	GiNaC::matrix r2 = octave_ex_matrix(v2.t2 ## _value ()).ex_matrix_value (); \
+        if ( (r1.rows () != r2.rows ()) || (r1.cols () != r2.cols ()) ) \
+          { \
+	    error("nonconformant arguments\n"); \
+	    return octave_value (); \
+	  } \
+        return octave_value \
+          (new octave_ex_matrix (r1.op (r2))); \
+      } \
+    catch (exception &e) \
+      { \
+        error(e.what()); \
+        return octave_value (); \
+      } \
+  }
+
+#define DEFBINOP_MATRIX_MATRIX_DIV(name, t1, t2) \
+  BINOPDECL (name, a1, a2) \
+  { \
+    try \
+      { \
+        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
+        GiNaC::matrix r1 = octave_ex_matrix(v1.t1 ## _value ()).ex_matrix_value (); \
+	GiNaC::matrix r2 = octave_ex_matrix(v2.t2 ## _value ()).ex_matrix_value (); \
+        if ( (r1.rows () != r2.rows ()) || (r1.cols () != r2.cols ()) ) \
+          { \
+	    error("nonconformant arguments\n"); \
+	    return octave_value (); \
+	  } \
+        return octave_value \
+          (new octave_ex_matrix (r2.transpose ().inverse ().mul (r1).transpose ())); \
+      } \
+    catch (exception &e) \
+      { \
+        error(e.what()); \
+        return octave_value (); \
+      } \
+  }
+
+#define DEFBINOP_EX_MATRIX_OP(name, t1, t2, op) \
+  BINOPDECL (name, a1, a2) \
+  { \
+    try \
+      { \
+        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
+	GiNaC::matrix r1 = octave_ex_matrix(v2.t2 ## _value ()).ex_matrix_value (); \
+	GiNaC::ex r2 = octave_ex(v1.t1 ## _value ()).ex_value (); \
+        int rows = int(r1.rows ()); \
+        int cols = int(r1.cols ()); \
+	GiNaC::matrix result(rows, cols); \
+        for (int i = 0; i < rows; i++) \
+	  for (int j = 0; j < cols; j++) \
+	    result(i,j) = r1(i,j) op r2; \
+      return octave_value \
+          (new octave_ex_matrix (result)); \
+      } \
+    catch (exception &e) \
+      { \
+        error(e.what()); \
+        return octave_value (); \
+      } \
+  }
+
+#define DEFBINOP_MATRIX_EX_OP(name, t1, t2, op) \
+  BINOPDECL (name, a1, a2) \
+  { \
+    try \
+      { \
+        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
+	GiNaC::matrix r1 = octave_ex_matrix(v1.t1 ## _value ()).ex_matrix_value (); \
+	GiNaC::ex r2 = octave_ex(v2.t2 ## _value ()).ex_value (); \
+        int rows = int(r1.rows ()); \
+        int cols = int(r1.cols ()); \
+	GiNaC::matrix result(rows, cols); \
+        for (int i = 0; i < rows; i++) \
+	  for (int j = 0; j < cols; j++) \
+	    result(i,j) = r1(i,j) op r2; \
+        return octave_value \
+          (new octave_ex_matrix (result)); \
+      } \
+    catch (exception &e) \
+      { \
+        error(e.what()); \
+        return octave_value (); \
+      } \
+  }
+
+#define DEFBINOP_MATRIX_EX_POW(name, t1, t2) \
+  BINOPDECL (name, a1, a2) \
+  { \
+    try \
+      { \
+        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
+	GiNaC::matrix r1 = octave_ex_matrix(v1.t1 ## _value ()).ex_matrix_value (); \
+	GiNaC::ex r2 = octave_ex(v2.t2 ## _value ()).ex_value (); \
+        int rows = int(r1.rows ()); \
+        int cols = int(r1.cols ()); \
+	GiNaC::matrix result(rows, cols); \
+        for (int i = 0; i < rows; i++) \
+	  for (int j = 0; j < cols; j++) \
+	    result(i,j) = GiNaC::pow(r1(i,j), r2); \
+      return octave_value \
+          (new octave_ex_matrix (result)); \
+      } \
+    catch (exception &e) \
+      { \
+        error(e.what()); \
+        return octave_value (); \
+      } \
+  }
+
+#define DEFBINOP_EX_EX_OP(name, t1, t2, op) \
+  BINOPDECL (name, a1, a2) \
+  { \
+    try \
+      { \
+        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
+	GiNaC::ex r1 = octave_ex(v1.t1 ## _value ()).ex_value (); \
+	GiNaC::ex r2 = octave_ex(v2.t2 ## _value ()).ex_value (); \
+	GiNaC::ex result = r1 op r2; \
+        return octave_value \
+          (new octave_ex (result)); \
+      } \
+    catch (exception &e) \
+      { \
+        error(e.what()); \
+        return octave_value (); \
+      } \
+  }
+
+#define DEFBINOP_EX_EX_POW(name, t1, t2) \
+  BINOPDECL (name, a1, a2) \
+  { \
+    try \
+      { \
+        CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
+	GiNaC::ex r1 = octave_ex(v1.t1 ## _value ()).ex_value (); \
+	GiNaC::ex r2 = octave_ex(v2.t2 ## _value ()).ex_value (); \
+	GiNaC::ex result = pow(r1,r2); \
+        return octave_value \
+          (new octave_ex (result)); \
+      } \
+    catch (exception &e) \
+      { \
+        error(e.what()); \
+        return octave_value (); \
+      } \
+  }
+
+#define DEFINE_MATRIX_EX_OPS(TYPE1, TYPE2) \
+DEFBINOP_MATRIX_EX_OP  (TYPE1 ## _ ## TYPE2 ## _add, TYPE1, TYPE2, +) \
+DEFBINOP_MATRIX_EX_OP  (TYPE1 ## _ ## TYPE2 ## _sub, TYPE1, TYPE2, -) \
+DEFBINOP_MATRIX_EX_OP  (TYPE1 ## _ ## TYPE2 ## _mul, TYPE1, TYPE2, *) \
+DEFBINOP_MATRIX_EX_OP  (TYPE1 ## _ ## TYPE2 ## _div, TYPE1, TYPE2, /) \
+DEFBINOP_MATRIX_EX_POW (TYPE1 ## _ ## TYPE2 ## _pow, TYPE1, TYPE2) 
+
+#define INSTALL_MATRIX_EX_OPS(TYPE1, TYPE2) \
+INSTALL_BINOP(op_add, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _add) \
+INSTALL_BINOP(op_sub, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _sub) \
+INSTALL_BINOP(op_mul, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _mul) \
+INSTALL_BINOP(op_div, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _div) \
+INSTALL_BINOP(op_pow, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _pow) 
+
+#define DEFINE_EX_MATRIX_OPS(TYPE1, TYPE2) \
+DEFBINOP_EX_MATRIX_OP  (TYPE1 ## _ ## TYPE2 ## _add, TYPE1, TYPE2, +) \
+DEFBINOP_EX_MATRIX_OP  (TYPE1 ## _ ## TYPE2 ## _sub, TYPE1, TYPE2, -) \
+DEFBINOP_EX_MATRIX_OP  (TYPE1 ## _ ## TYPE2 ## _mul, TYPE1, TYPE2, *) \
+DEFBINOP_EX_MATRIX_OP  (TYPE1 ## _ ## TYPE2 ## _div, TYPE1, TYPE2, /) 
+// DEFBINOP_EX_MATRIX_POW (TYPE1 ## _ ## TYPE2 ## _pow, TYPE1, TYPE2)
+
+#define INSTALL_EX_MATRIX_OPS(TYPE1, TYPE2) \
+INSTALL_BINOP(op_add, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _add) \
+INSTALL_BINOP(op_sub, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _sub) \
+INSTALL_BINOP(op_mul, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _mul) \
+INSTALL_BINOP(op_div, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _div)
+// INSTALL_BINOP(op_pow, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _pow)
+
+#define DEFINE_EX_EX_OPS(TYPE1, TYPE2) \
+DEFBINOP_EX_EX_OP  (TYPE1 ## _ ## TYPE2 ## _add, TYPE1, TYPE2, +) \
+DEFBINOP_EX_EX_OP  (TYPE1 ## _ ## TYPE2 ## _sub, TYPE1, TYPE2, -) \
+DEFBINOP_EX_EX_OP  (TYPE1 ## _ ## TYPE2 ## _mul, TYPE1, TYPE2, *) \
+DEFBINOP_EX_EX_OP  (TYPE1 ## _ ## TYPE2 ## _div, TYPE1, TYPE2, /) \
+DEFBINOP_EX_EX_POW (TYPE1 ## _ ## TYPE2 ## _pow, TYPE1, TYPE2)
+
+#define INSTALL_EX_EX_OPS(TYPE1, TYPE2) \
+INSTALL_BINOP(op_add, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _add) \
+INSTALL_BINOP(op_sub, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _sub) \
+INSTALL_BINOP(op_mul, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _mul) \
+INSTALL_BINOP(op_div, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _div) \
+INSTALL_BINOP(op_pow, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _pow)
+
+#define DEFINE_MATRIX_MATRIX_OPS(TYPE1, TYPE2) \
+DEFBINOP_MATRIX_MATRIX_OP  (TYPE1 ## _ ## TYPE2 ## _add, TYPE1, TYPE2, add) \
+DEFBINOP_MATRIX_MATRIX_OP  (TYPE1 ## _ ## TYPE2 ## _sub, TYPE1, TYPE2, sub) \
+DEFBINOP_MATRIX_MATRIX_OP  (TYPE1 ## _ ## TYPE2 ## _mul, TYPE1, TYPE2, mul) \
+DEFBINOP_MATRIX_MATRIX_DIV (TYPE1 ## _ ## TYPE2 ## _div, TYPE1, TYPE2)
+
+#define INSTALL_MATRIX_MATRIX_OPS(TYPE1, TYPE2) \
+INSTALL_BINOP(op_add, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _add) \
+INSTALL_BINOP(op_sub, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _sub) \
+INSTALL_BINOP(op_mul, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _mul) \
+INSTALL_BINOP(op_div, octave_ ## TYPE1, octave_ ## TYPE2, TYPE1 ## _ ## TYPE2 ## _div) 
+
+#endif 
+
+/*
+;;; Local Variables: ***
+;;; mode: C++ ***
+;;; End: ***
+*/
diff --git a/symbols.cc b/symbols.cc
index 5eebabd..e65bef1 100644
--- a/symbols.cc
+++ b/symbols.cc
@@ -1,43 +1,39 @@
+/*
 
-// 2001-09-18 Paul Kienzle <pkienzle at users.sf.net>
-// * use GiNaC::is_a<GiNaC::blah>(x) rather than is_ex_of_type(x, blah)
-// * use GiNaC::ex_to<GiNaC::blah>(x) rather than ex_to_blah(x)
+Copyright (C) 2002 Ben Sapp
 
-#include <octave/config.h>
-#include <cstdlib>
+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.
 
-#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;
-class octave_sym;
+*/
 
-#include <octave/lo-mappers.h>
-#include <octave/lo-utils.h>
-#include <octave/mx-base.h>
-#include <octave/str-vec.h>
+// 2001-09-18 Paul Kienzle <pkienzle at users.sf.net>
+// * use GiNaC::is_a<GiNaC::blah>(x) rather than is_ex_of_type(x, blah)
+// * use GiNaC::ex_to<GiNaC::blah>(x) rather than ex_to_blah(x)
 
+#include <octave/config.h>
 #include <octave/defun-dld.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 <iostream>
-#include <fstream>
-
 #include <ginac/ginac.h>
-
 #include "ov-vpa.h"
 #include "ov-ex.h"
 #include "ov-sym.h"
-#include "ov-ex-mat.h" 
+#include "ov-ex-mat.h"
+#include "ov-relational.h"
+#include "sym-ops.h"
 #include "symbols.h"
 
 bool get_expression(const octave_value arg, GiNaC::ex& expression)
@@ -119,10 +115,12 @@ bool get_numeric(const octave_value arg, GiNaC::numeric& number)
 DEFUN_DLD(symbols,args,,"Initialize symbolic manipulation")
 {
   octave_value retval;
-  install_ex_matrix_type();
-  install_ex_type();
-  install_sym_type();
-  install_vpa_type();
+  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();
@@ -130,120 +128,6 @@ DEFUN_DLD(symbols,args,,"Initialize symbolic manipulation")
   return retval;
 }
 
-DEFUN_DLD (vpa, args, ,
-"-*- texinfo -*-\n\
- at deftypefn {Loadable Function} {n =} vpa(@var{s})\n\
-\n\
-Creates a variable precision arithmetic variable from @var{s}.\n\
- at var{s} can be a scalar, vpa value, string or a ex value that \n\
-is a number.\n\
- at end deftypefn\n\
-")
-{
-  octave_value retval;
-  GiNaC::numeric d;
-  int nargin = args.length();
-  
-  try 
-    {
-      if (nargin == 1)
-	{
-	  if (!get_numeric (args(0), d))
-	    {
-	      gripe_wrong_type_arg ("vpa", args(0));
-	      return retval;
-	    } 
-	}
-      else
-	{
-	  print_usage("vpa");
-	  return retval;
-	}
-
-      retval = octave_value(new octave_vpa(d));
-    }
-  catch (exception &e)
-    { 
-      error(e.what());
-      retval = octave_value (); 
-    } 
-    
-  return retval;
-}
-
-DEFUN_DLD (ex_matrix, args, ,
-"-*- texinfo -*-\n\
- at deftypefn {Loadable Function} {n =} ex_matrix(@var{rows}, @var{cols}, ... )\n\
-\n\
-Creates a variable precision arithmetic variable from @var{s}.\n\
- at var{s} can be a scalar, vpa value, string or a ex value that \n\
-is a number.\n\
- at end deftypefn\n\
-")
-{
-  octave_value retval;
-  GiNaC::ex expression;
-  int nargin = args.length();
-  int rows, cols,k; 
-
-  if (nargin < 2)
-    {
-      print_usage("ex_matrix");
-      return retval; 
-    }
-
-  if(args(0).is_real_scalar())
-    {
-      rows = int(args(0).double_value());
-    }
-  else
-    {
-      error("You must supply a scalar for the first argument.");
-      return retval;
-    }
-
-  if(args(1).is_real_scalar())
-    {
-      cols = int(args(1).double_value());
-    }
-  else
-    {
-      error("You must supply a scalar for the first argument.");
-      return retval;
-    }
-
-  try 
-    {
-      GiNaC::matrix a = GiNaC::matrix(rows,cols);
-      k = 2;
-      for (int i = 0; i < rows; i++)
-      {
-	for (int j = 0; j < cols; j++, k++)
-	  {
-	    if (k < nargin)
-	      {
-		if (!get_expression(args(k),expression))
-		  {
-		    error("unable to turn an argument into a symbolic expression");
-		    return retval;
-		  }
-		a(i,j) = expression;
-	      }
-	    else
-	      break;
-	  }
-      }
-      retval = octave_value(new octave_ex_matrix(a));
-    }
-  catch (exception &e)
-    {
-      error(e.what());
-      retval = octave_value (); 
-    } 
-    
-  return retval;
-}
-
 DEFUN_DLD(to_double,args, , 
 "-*- texinfo -*-\n\
 @deftypefn {Loadable Function} {d =} to_double(@var{n})\n\
@@ -345,109 +229,6 @@ Pi evaluated to the current value of Digits\n\
   return retval;
 }
 
-DEFUN_DLD(is_vpa, args, ,
-"Return true if an object is of type vpa, false otherwise.\n")
-{
-  bool retval;
-  retval = (args(0).type_id() == octave_vpa::static_type_id());
-  return octave_value(retval);
-}
-
-DEFUN_DLD (sym,args, , 
-"-*- texinfo -*-\n\
-Create an object of type symbol\n")
-{
-  octave_value retval;
-  int nargin = args.length ();
-
-  if (nargin != 1)
-    {
-      error("one argument expected\n");
-      return octave_value ();
-    }
-  try 
-    {
-      GiNaC::symbol xtmp(args(0).string_value());
-      octave_sym x(xtmp);
-      retval = octave_value(new octave_sym(x));
-    }
-  catch (exception &e)
-    {
-      error(e.what());
-      retval = octave_value ();
-    }
-
-  return retval;
-}
-
-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());
-  return octave_value(retval);
-}
-
-DEFUN_DLD(differentiate,args,,
-"-*- texinfo -*-\n\
- at deftypefn Loadable Function {da_dx =} differentiate(@var{a}, at var{x} [, @var{n}])\n\
-\n\
-Return the @var{n}th derivative of @var{a} with respect to @var{x}. If @var{n} is not\n\
-supplied then a default value of 1 is used.\n\
- at end deftypefn")
-{
-  GiNaC::ex expression;
-  GiNaC::symbol variable;
-  GiNaC::numeric num;
-  int order;
-  octave_value retval;
-  int nargin = args.length();
-
-  if ((nargin < 2) || (nargin > 3))
-    {
-      print_usage ("differentiate");
-      return retval;
-    }
-  try 
-    { 
-      if (!get_expression (args(0), expression))
-	{
-	  print_usage ("differentiate");
-	  return retval;
-	}
-      
-      if (!get_symbol (args(1), variable))
-	{
-	  print_usage ("differentiate");
-	  return retval;
-	}
-      
-      if (nargin == 3)
-	{
-	  if (!get_numeric (args(2), num))
-	    {
-	      print_usage ("differentiate");
-	      return retval;
-	    }
-	  order = int(num.to_double ());
-	  if (order < 0)
-	    {
-	      error("must supply an integer greater than zero\n");
-	      return retval;
-	    }
-	}
-      else
-	order = 1;
-
-      retval = octave_value(new octave_ex(expression.diff(variable,order)));
-    }
-  catch(exception &e)
-    {
-      error(e.what ());
-      retval = octave_value ();
-    }
-
-  return retval;
-}
 
 DEFUN_DLD_EX_GINAC_FUNCTION(Cos,cos,"cosine");
 DEFUN_DLD_EX_GINAC_FUNCTION(Sin,sin,"sine");
@@ -474,19 +255,6 @@ DEFUN_DLD_EX_EX_SYM_GINAC_FUNCTION(quotient,quo,"quotient");
 DEFUN_DLD_EX_EX_SYM_GINAC_FUNCTION(remainder,rem,"remainder");
 DEFUN_DLD_EX_EX_SYM_GINAC_FUNCTION(premainder,prem,"pseudo-remainder");
 
-DEFUN_DLD(is_ex,args,,
-"-*- texinfo -*-\n\
- at deftypefn Loadable Function {bool =} is_ex(@var{a})\n\
-\n\
-Return true if an object is of type ex.\n\
- at seealso{is_sym, is_vpa}\n\
- at end deftypefn")
-{
-  bool retval;
-  retval = (args(0).type_id() == octave_ex::static_type_id());
-  return octave_value(retval);
-}
-
 DEFUN_DLD(subs,args,,
 "-*- texinfo -*-\n\
 @deftypefn Loadable Function {b =} subs(@var{a}, at var{x}, at var{n})\n\
@@ -727,7 +495,7 @@ DEFUN_DLD(Gcd,args,,
 "-*- texinfo -*-\n\
 @deftypefn Loadable Function {b =} collect(@var{a}, at var{x})\n\
 \n\
-collect the terms in @var{a} as a univariate polynomial in @var{x}\n\
+Collect the terms in @var{a} as a univariate polynomial in @var{x}\n\
 @table @var\n\
 @item a\n\
  The expresion in which the collection will occur.\n\

-- 
octave-symbolic



More information about the Pkg-octave-commit mailing list