changeset 5679:2b962ee1530a octave-forge

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.
author rlaboiss
date Sat, 23 May 2009 13:32:29 +0000
parents 51728d4bcdd4
children a01b1d68712a
files main/symbolic/inst/poly2sym.m main/symbolic/inst/sym2poly.m main/symbolic/inst/symfsolve.m
diffstat 3 files changed, 22 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/main/symbolic/inst/poly2sym.m	Sat May 23 13:31:03 2009 +0000
+++ b/main/symbolic/inst/poly2sym.m	Sat May 23 13:32:29 2009 +0000
@@ -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 @@
 
 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
--- a/main/symbolic/inst/sym2poly.m	Sat May 23 13:31:03 2009 +0000
+++ b/main/symbolic/inst/sym2poly.m	Sat May 23 13:32:29 2009 +0000
@@ -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 @@
 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 @@
 	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})
--- a/main/symbolic/inst/symfsolve.m	Sat May 23 13:31:03 2009 +0000
+++ b/main/symbolic/inst/symfsolve.m	Sat May 23 13:32:29 2009 +0000
@@ -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 @@
 		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 @@
 		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,"==")));