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

rlaboiss rlaboiss at 416fae20-06d0-4450-9b69-c6c34d4b5f03
Mon Jan 3 03:41:12 UTC 2011


The following commit has been merged in the master branch:
commit 58cbcb3027a2d6907acd177e91da828aabad4432
Author: rlaboiss <rlaboiss at 416fae20-06d0-4450-9b69-c6c34d4b5f03>
Date:   Sat May 23 13:32:29 2009 +0000

    Use cell() instead of the deprecated list()
    
    The list() function has been deprecated in Octave.  The patch below
    replaces all calls to list() in the scripts poly2sym.m, sym2poly.m,
    and symfsolve.m by calls to cell().
    
    Also, add a new test using cell in function sym2poly.
    
    
    git-svn-id: https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/main/symbolic@5864 416fae20-06d0-4450-9b69-c6c34d4b5f03

diff --git a/inst/poly2sym.m b/inst/poly2sym.m
index 1a252b0..50d9afa 100644
--- a/inst/poly2sym.m
+++ b/inst/poly2sym.m
@@ -19,7 +19,7 @@
 ## @deftypefn {Function File} {} @var{p} = poly2sym (@var{c}, @var{x})
 ## Creates a symbolic polynomial expression @var{p} with coefficients @var{c}.
 ## If @var{p} is not specified, the free variable is set to sym("x"). @var{c}
-## may be a vector or a list/cell-array of symbols. @var{x} may be a symbolic
+## may be a vector or a cell-array of symbols. @var{x} may be a symbolic
 ## expression or a string.
 ## The coefficients correspond to decreasing exponent of the free variable.
 ##
@@ -28,7 +28,7 @@
 ## symbols
 ## x=sym("x"); y=sym("y");
 ## p = poly2sym ([2,5,-3]);         # p = 2*x^2+5*x-3
-## c = poly2sym (list(2*y,5,-3),x); # p = 2*y*x^2+5*x-3
+## c = poly2sym ({2*y,5,-3},x); # p = 2*y*x^2+5*x-3
 ## @end example
 ##
 ## @end deftypefn
@@ -45,9 +45,9 @@ endif
 
 N = length(c);
 
-if !iscell(c) & !islist(c)
+if !iscell(c)
 	tmp = c;
-	c = list;
+	c = cell;
 	for i=1:N
 		c(i) = tmp(i);
 	endfor
diff --git a/inst/sym2poly.m b/inst/sym2poly.m
index 840baf3..fa9afc4 100644
--- a/inst/sym2poly.m
+++ b/inst/sym2poly.m
@@ -21,7 +21,7 @@
 ## as a vector. If there is only one free variable in @var{p} the
 ## coefficient vector @var{c} is a plain numeric vector. If there is more
 ## than one free variable in @var{p}, a second argument @var{x} specifies the
-## free variable and the function returns a list of symbolic expressions.
+## free variable and the function returns a cell vector of symbolic expressions.
 ## The coefficients correspond to decreasing exponent of the free variable.
 ##
 ## Example:
@@ -29,7 +29,7 @@
 ## symbols
 ## x=sym("x"); y=sym("y");
 ## c = sym2poly (x^2+3*x-4);    # c = [1,3,-4]
-## c = sym2poly (x^2+y*x,x);    # c = list(2,y,0)
+## c = sym2poly (x^2+y*x,x);    # c = {2,y,0}
 ## @end example
 ##
 ## If @var{p} is not a polynomial the result has no warranty.
@@ -94,7 +94,7 @@ endfor
 p = expand(p);
 p_terms = sumterms(p);
 # if this is well behaved, I can find the coefficients by dividing with x
-c_ex = list;
+c_ex = cell;
 for i=1:length(p_terms)
 	tmp = p_terms{i};
 	for j=1:BADPOLY_COEFF_LIMIT
@@ -146,10 +146,10 @@ else
 	c = c_ex;
 endif
 
-% test examples
+%!shared
+% symbols
+% x=sym("x"); y=sym("y");
 %!test
-%! symbols
-%! x=sym("x"); y=sym("y");
-%! c = sym2poly (x^2+3*x-4);
-%! assert(c, [1,3,-4]);
-
+% assert(sym2poly (x^2+3*x-4), [1,3,-4]);
+%!test
+% assert (sym2poly (x^2+y*x,x), {2,y,0})
diff --git a/inst/symfsolve.m b/inst/symfsolve.m
index c7dd28d..564589d 100644
--- a/inst/symfsolve.m
+++ b/inst/symfsolve.m
@@ -44,7 +44,7 @@
 ## @end example
 ##
 ## The system of equations to solve for can be given as separate arguments or
-## as a single list/cell-array:
+## as a single cell-array:
 ##
 ## @example
 ## a = symfsolve(@{f,g@},@{y==1,x==2@});  # here y=a(1), x=a(2)
@@ -52,7 +52,7 @@
 ##
 ## If the variables are not specified explicitly with the initial conditions,
 ## they are placed in alphabetic order. The system of equations can be comma-
-## separated or given in a list or cell-array. The return-values are those of
+## separated or given in a cell-array. The return-values are those of
 ## fsolve; @var{x} holds the found roots.
 ## @end deftypefn
 ## @seealso{fsolve}
@@ -65,12 +65,12 @@
 function [ x,inf,msg ] = symfsolve (varargin)
 
 	#separate variables and equations
-	eqns = list;
-	vars = list;
+	eqns = cell();
+	vars = cell();
 
-	if iscell(varargin{1}) | islist(varargin{1})
+	if iscell(varargin{1})
 		if !strcmp(typeinfo(varargin{1}{1}),"ex")
-			error("First argument must be (a cell-array/list of) symbolic expressions.")
+			error("First argument must be (a cell-array of) symbolic expressions.")
 		endif
 		eqns = varargin{1};
 		arg_count = 1;
@@ -78,7 +78,7 @@ function [ x,inf,msg ] = symfsolve (varargin)
 		arg_count = 0;
 		for i=1:nargin
 			tmp = disp(varargin{i});
-			if( iscell(varargin{i}) | islist(varargin{i}) | ...
+			if( iscell(varargin{i}) | ...
 					all(isalnum(tmp) | tmp=="_" | tmp==",") | ...
 					!strcmp(typeinfo(varargin{i}),"ex") )
 				break;
@@ -129,8 +129,8 @@ function [ x,inf,msg ] = symfsolve (varargin)
 		if nvars!=nevars
 			error("The number of initial conditions does not match the number of free variables.")
 		endif
-		if iscell(varargin{arg_count+1}) | islist(varargin{arg_count+1})
-			# List/cell-array of relations - this should work for a list of strings ("x==3") too.
+		if iscell(varargin{arg_count+1})
+			# cell-array of relations - this should work for a list of strings ("x==3") too.
 			for i=1:nvars
 				tmp = disp(varargin{arg_count+1}{i});
 				vars = append(vars,sym(strtok(tmp,"==")));

-- 
octave-symbolic



More information about the Pkg-octave-commit mailing list