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

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


The following commit has been merged in the master branch:
commit d5937136644203db9544c300369791eec22f44b6
Author: bensapp <bensapp at 416fae20-06d0-4450-9b69-c6c34d4b5f03>
Date:   Mon Mar 4 18:39:51 2002 +0000

    *** empty log message ***
    
    
    git-svn-id: https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/main/symbolic@147 416fae20-06d0-4450-9b69-c6c34d4b5f03

diff --git a/symbols.cc b/symbols.cc
index 06c7d12..0fc791c 100644
--- a/symbols.cc
+++ b/symbols.cc
@@ -37,6 +37,7 @@ class octave_sym;
 #include "ov-vpa.h"
 #include "ov-ex.h"
 #include "ov-sym.h"
+#include "ov-ex-mat.h" 
 #include "symbols.h"
 
 bool get_expression(const octave_value arg, GiNaC::ex& expression)
@@ -118,9 +119,11 @@ 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();
+  install_ex_matrix_ops();
   install_ex_ops();
   install_sym_ops();
   install_vpa_ops();
@@ -168,6 +171,79 @@ is a number.\n\
   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\

-- 
octave-symbolic



More information about the Pkg-octave-commit mailing list