Are You saying that the function de_min() is broken and nobody cares
about fixing it? I checked and found that nth() is used 44 times in 22
functions (in main/optim, main/vrml and extra/tk_octave) using the
function nth().
Several functions in the 'optim' package will no longer work with Octave
3.4. There was a thread on fixing this, but it haven't seen much
activity lately. Personally, I'm quite tied up at the moment, so I can't
be of much help. The basic issue is that to fix this problem there will
have to be API changes in the 'optim' package. The question is then how
these changes should look.
Shall I check in the fixes for using nth()?
What fixes?
Attached is a patch that replaces the obsolete functions nth() and
struct_contains(). This is perhaps a first step to address the issues in
optim, vrml and tk_octave.
The problem of using lists in optim does not seem too difficult to
solve. If there is nobody else, I'll look into this problem.
Alois
Index: extra/tk_octave/inst/tk_scale.m
===================================================================
--- extra/tk_octave/inst/tk_scale.m (revision 7322)
+++ extra/tk_octave/inst/tk_scale.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 1998, 1999, 2000 Joao Cardoso.
##
## This program is free software; you can redistribute it and/or modify it
@@ -52,11 +53,11 @@
va_arg_cnt = 1;
for i=1:nopt
- desc = nth (varargin, va_arg_cnt++);
- val = nth (varargin, va_arg_cnt++);
- min_val = nth (varargin, va_arg_cnt++);
- max_val = nth (varargin, va_arg_cnt++);
- inc_val = nth (varargin, va_arg_cnt++);
+ desc = varargin{va_arg_cnt++};
+ val = varargin{va_arg_cnt++};
+ min_val = varargin{va_arg_cnt++};
+ max_val = varargin{va_arg_cnt++};
+ inc_val = varargin{va_arg_cnt++};
tk_cmd( sprintf("set val_%d %f", i, val) );
tk_cmd( sprintf("scale .master.s%d -from %f -to %f \
@@ -75,3 +76,4 @@
endfor
endfunction
+
Index: extra/graceplot/inst/alternatives/print.m
===================================================================
--- extra/graceplot/inst/alternatives/print.m (revision 7322)
+++ extra/graceplot/inst/alternatives/print.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2001 Laurent Mazet
##
## This program is free software; it is distributed in the hope that it
@@ -124,7 +125,7 @@
va_arg_cnt = 1;
for i=1:nargin
- arg = nth (varargin, va_arg_cnt++);
+ arg = varargin{va_arg_cnt++};
if ischar(arg)
if strcmp(arg, "-color")
use_color = 1;
@@ -412,3 +413,4 @@
endif
endfunction
+
Index: extra/pdb/inst/write_pdb.m
===================================================================
--- extra/pdb/inst/write_pdb.m (revision 7322)
+++ extra/pdb/inst/write_pdb.m (working copy)
@@ -24,7 +24,7 @@
function write_pdb(p, fname, varargin)
-if(!isstruct(p)) # || !struct_contains(p, "acoord"))
+if(!isstruct(p)) # || !isfield(p, "acoord"))
error("p must be a pdb struct");
endif
@@ -44,13 +44,13 @@
# Print the Title Section
-if( struct_contains(p, "classification") || struct_contains(p, "idcode") )
- if struct_contains(p, "classification")
+if( isfield(p, "classification") || isfield(p, "idcode") )
+ if isfield(p, "classification")
classification = p.classification;
else
classification = "Unknown";
endif
- if(struct_contains(p, "idcode"))
+ if(isfield(p, "idcode"))
idcode = p.idcode;
else
idcode = "N/A ";
@@ -65,7 +65,7 @@
# Print the Primary Structure Section
numres = 0;
-if(struct_contains(p, "seqres"))
+if(isfield(p, "seqres"))
numres = size(p.seqres, 1);
j = 1;
i = 1;
@@ -104,24 +104,24 @@
# Print the Crystallographic and Coordinate Transformation Section
-if( struct_contains(p, "cellsize") || struct_contains(p, "cellangl") \
- || struct_contains(p, "sgroup") || struct_contains(p, "z") )
- if(struct_contains(p, "cellsize"))
+if( isfield(p, "cellsize") || isfield(p, "cellangl") \
+ || isfield(p, "sgroup") || isfield(p, "z") )
+ if(isfield(p, "cellsize"))
cellsize = p.cellsize;
else
cellsize = zeros(3,1);
endif
- if(struct_contains(p, "cellangl"))
+ if(isfield(p, "cellangl"))
cellangl = p.cellangl;
else
cellangl = zeros(3,1);
endif
- if(struct_contains(p, "sgroup"))
+ if(isfield(p, "sgroup"))
sgroup = p.sgroup;
else
sgroup = "N/A";
endif
- if(struct_contains(p, "z"))
+ if(isfield(p, "z"))
z = p.z;
else
z = 0;
@@ -149,13 +149,13 @@
#buf(80) = "\n";
#fprintf(f, "%s", buf);
-if( struct_contains(p, "scalem") || struct_contains(p, "scalev") )
- if(struct_contains(p, "scalem"))
+if( isfield(p, "scalem") || isfield(p, "scalev") )
+ if(isfield(p, "scalem"))
scalem = p.scalem;
else
scalem = eye(3);
endif
- if(struct_contains(p, "scalev"))
+ if(isfield(p, "scalev"))
scalev = p.scalev;
else
scalev = zeros(3,1);
@@ -183,33 +183,33 @@
endif # if(!quick)
serialn = 0;
-if(struct_contains(p, "acoord"))
+if(isfield(p, "acoord"))
natoms = size(p.acoord, 1);
- if(struct_contains(p, "atomname"))
+ if(isfield(p, "atomname"))
atomname = toupper(p.atomname);
else
for i = 1:natoms,
atomname(i, :) = " ";
endfor
endif
- if(struct_contains(p, "aresname"))
+ if(isfield(p, "aresname"))
aresname = toupper(p.aresname);
else
for i = 1:natoms,
aresname(i, :) = " ";
endfor
endif
- if(struct_contains(p, "aresseq"))
+ if(isfield(p, "aresseq"))
aresseq = p.aresseq;
else
aresseq = ones(natoms, 1);
endif
- if(struct_contains(p, "aoccupancy"))
+ if(isfield(p, "aoccupancy"))
aoccupancy = p.aoccupancy;
else
aoccupancy = ones(natoms, 1);
endif
- if(struct_contains(p, "atempfactor"))
+ if(isfield(p, "atempfactor"))
atempfactor = p.atempfactor;
else
atempfactor = zeros(natoms, 1);
@@ -265,33 +265,33 @@
fprintf(f, "%s", buf);
endif
-if(struct_contains(p,"hetcoord"))
+if(isfield(p,"hetcoord"))
nhet = size(p.hetcoord, 1);
- if(struct_contains(p, "hetname"))
+ if(isfield(p, "hetname"))
hetname = toupper(p.hetname);
else
for i = 1:nhet
hetname(i, :) = " ";
endfor
endif
- if(struct_contains(p, "hetresname"))
+ if(isfield(p, "hetresname"))
hetresname = toupper(p.hetresname);
else
for i = 1:nhet,
hetresname(i, :) = " ";
endfor
endif
- if(struct_contains(p, "hetresseq"))
+ if(isfield(p, "hetresseq"))
hetresseq = p.hetresseq;
else
hetresseq = ones(nhet, 1);
endif
- if(struct_contains(p, "hetoccupancy"))
+ if(isfield(p, "hetoccupancy"))
hetoccupancy = p.hetoccupancy;
else
hetoccupancy = ones(nhet, 1);
endif
- if(struct_contains(p, "hettempfactor"))
+ if(isfield(p, "hettempfactor"))
hettempfactor = p.hettempfactor;
else
hettempfactor = zeros(nhet, 1);
Index: extra/pdb/inst/read_pdb.m
===================================================================
--- extra/pdb/inst/read_pdb.m (revision 7322)
+++ extra/pdb/inst/read_pdb.m (working copy)
@@ -54,11 +54,11 @@
global elements_struct;
load("-force", file_in_loadpath("elements_struct.mat"));
-if(struct_contains(p, "atomname"))
+if(isfield(p, "atomname"))
p.az = atomnames_to_z(p.atomname);
endif
-if(struct_contains(p, "hetname"))
+if(isfield(p, "hetname"))
p.hetz = atomnames_to_z(p.hetname);
endif
Index: main/optim/inst/__semi_bracket.m
===================================================================
--- main/optim/inst/__semi_bracket.m (revision 7322)
+++ main/optim/inst/__semi_bracket.m (working copy)
@@ -1,7 +1,9 @@
+
+
## [a, b, ga, gb, nev] = semi_bracket (f, dx, a, narg, args)
##
## Find an interval containing a local minimum of the function
-## g : h in [a, inf[ ---> f (x+h*dx) where x = nth (args, narg)
+## g : h in [a, inf[ ---> f (x+h*dx) where x = args{narg}
##
## The local minimum may be in a.
## a < b.
@@ -15,7 +17,7 @@
step = 1;
-x = nth (args, narg);
+x = args{narg};
args{narg} = x+a*dx; ga = feval (f, args );
b = a + step;
args{narg} = x+b*dx; gb = feval (f, args );
@@ -36,3 +38,5 @@
step *= 2;
a = b; b = c; ga = gb; gb = gc;
end
+
+
Index: main/optim/inst/de_min.m
===================================================================
--- main/optim/inst/de_min.m (revision 7322)
+++ main/optim/inst/de_min.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2009 Christian Fischer <cfisc...@itm.uni-stuttgart.de>
## Copyright (C) 1996, 1997 R. Storn
##
@@ -147,7 +148,7 @@
if nargin > 2,
ctl = struct (varargin{:});
else
- ctl = nth (varargin, va_arg_cnt++);
+ ctl = varargin{va_arg_cnt++};
end
if isnumeric (ctl)
if length (ctl)>=1 && !isnan (ctl(1)), XVmin = ctl(1); end
@@ -455,3 +456,4 @@
%! ## and solve it with de_min
%! [x, obj_value, nfeval, convergence] = de_min (f, ctl)
+
Index: main/optim/inst/nelder_mead_min.m
===================================================================
--- main/optim/inst/nelder_mead_min.m (revision 7322)
+++ main/optim/inst/nelder_mead_min.m (working copy)
@@ -1,3 +1,6 @@
+
+
+
## Copyright (C) 2002-2008 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -65,7 +68,7 @@
##
## { x + e_i | i in 0..N }
##
-## Where x == nth (args, narg) is the initial value
+## Where x == args{narg} is the initial value
## e_0 == zeros (size (x)),
## e_i(j) == 0 if j != i and e_i(i) == ctl(5)
## e_i has same size as x
@@ -100,7 +103,7 @@
if nargin >= 3, # Read control arguments
va_arg_cnt = 1;
- if nargin > 3, ctl = struct (varargin{:}); else ctl = nth (varargin, va_arg_cnt++); end
+ if nargin > 3, ctl = struct (varargin{:}); else ctl = varargin{va_arg_cnt++}; end
if isnumeric (ctl)
if length (ctl)>=1 && !isnan (ctl(1)), crit = ctl(1); end
if length (ctl)>=2 && !isnan (ctl(2)), tol = ctl(2); end
@@ -109,16 +112,16 @@
if length (ctl)>=5 && !isnan (ctl(5)), isz = ctl(5); end
if length (ctl)>=6 && !isnan (ctl(6)), rst = ctl(6); end
else
- if struct_contains (ctl, "crit") && ! isnan (ctl.crit ), crit = ctl.crit ; end
- if struct_contains (ctl, "tol") && ! isnan (ctl.tol ), tol = ctl.tol ; end
- if struct_contains (ctl, "ftol") && ! isnan (ctl.ftol ), ftol = ctl.ftol ; end
- if struct_contains (ctl, "rtol") && ! isnan (ctl.rtol ), rtol = ctl.rtol ; end
- if struct_contains (ctl, "vtol") && ! isnan (ctl.vtol ), vtol = ctl.vtol ; end
- if struct_contains (ctl, "narg") && ! isnan (ctl.narg ), narg = ctl.narg ; end
- if struct_contains (ctl,"maxev") && ! isnan (ctl.maxev), maxev = ctl.maxev; end
- if struct_contains (ctl, "isz") && ! isnan (ctl.isz ), isz = ctl.isz ; end
- if struct_contains (ctl, "rst") && ! isnan (ctl.rst ), rst = ctl.rst ; end
- if struct_contains(ctl,"verbose")&& !isnan(ctl.verbose),verbose=ctl.verbose;end
+ if isfield (ctl, "crit") && ! isnan (ctl.crit ), crit = ctl.crit ; end
+ if isfield (ctl, "tol") && ! isnan (ctl.tol ), tol = ctl.tol ; end
+ if isfield (ctl, "ftol") && ! isnan (ctl.ftol ), ftol = ctl.ftol ; end
+ if isfield (ctl, "rtol") && ! isnan (ctl.rtol ), rtol = ctl.rtol ; end
+ if isfield (ctl, "vtol") && ! isnan (ctl.vtol ), vtol = ctl.vtol ; end
+ if isfield (ctl, "narg") && ! isnan (ctl.narg ), narg = ctl.narg ; end
+ if isfield (ctl,"maxev") && ! isnan (ctl.maxev), maxev = ctl.maxev; end
+ if isfield (ctl, "isz") && ! isnan (ctl.isz ), isz = ctl.isz ; end
+ if isfield (ctl, "rst") && ! isnan (ctl.rst ), rst = ctl.rst ; end
+ if isfield(ctl,"verbose")&& !isnan(ctl.verbose),verbose=ctl.verbose;end
end
end
@@ -355,3 +358,6 @@
x = reshape (u(imin,:), R, C) ;
v = ymin ;
end
+
+
+
Index: main/optim/inst/optimset_compat.m
===================================================================
--- main/optim/inst/optimset_compat.m (revision 7322)
+++ main/optim/inst/optimset_compat.m (working copy)
@@ -1,3 +1,5 @@
+
+
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -45,7 +47,7 @@
# Integrate all leading structs
-while length (args) && isstruct (o = nth (args, 1))
+while length (args) && isstruct (o = args{1})
args = args(2:length(args)); # Remove 1st element of args
# Add key/value pairs
@@ -62,3 +64,5 @@
" MinEquiv Backend "];
opt = read_options (args, "op1",op1, "default",opt,"prefix",1,"nocase",1);
+
+
Index: main/optim/inst/d2_min.m
===================================================================
--- main/optim/inst/d2_min.m (revision 7322)
+++ main/optim/inst/d2_min.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -113,14 +114,14 @@
if length (ctl)>=4 && !isnan (ctl(4)), maxev = ctl(4); end
if length (ctl)>=5 && !isnan (ctl(5)), id2f = ctl(5); end
elseif isstruct (ctl)
- if struct_contains (ctl, "crit") , crit = ctl.crit ; end
- if struct_contains (ctl, "tol") , tol = ctl.tol ; end
- if struct_contains (ctl, "narg") , narg = ctl.narg ; end
- if struct_contains (ctl, "maxev") , maxev = ctl.maxev ; end
- if struct_contains (ctl, "maxout") , maxout = ctl.maxout ; end
- if struct_contains (ctl, "id2f") , id2f = ctl.id2f ; end
- if struct_contains (ctl, "verbose"), verbose = ctl.verbose; end
- if struct_contains (ctl, "code") , code = ctl.code ; end
+ if isfield (ctl, "crit") , crit = ctl.crit ; end
+ if isfield (ctl, "tol") , tol = ctl.tol ; end
+ if isfield (ctl, "narg") , narg = ctl.narg ; end
+ if isfield (ctl, "maxev") , maxev = ctl.maxev ; end
+ if isfield (ctl, "maxout") , maxout = ctl.maxout ; end
+ if isfield (ctl, "id2f") , id2f = ctl.id2f ; end
+ if isfield (ctl, "verbose"), verbose = ctl.verbose; end
+ if isfield (ctl, "code") , code = ctl.code ; end
else
error ("The 'ctl' argument should be either a vector or a struct");
end
@@ -136,7 +137,7 @@
if nargin < 5, code = "" ; end
if is_list (args) # List of arguments
- x = nth (args, narg);
+ x = args{narg};
else # Single argument
x = args;
args = list (args);
@@ -390,3 +391,4 @@
printf (" : %8.3e - %8.3e = %8.3e != 0\n",err,vbest,err-vbest);
end
end
+
Index: main/optim/inst/test_nelder_mead_min_1.m
===================================================================
--- main/optim/inst/test_nelder_mead_min_1.m (revision 7322)
+++ main/optim/inst/test_nelder_mead_min_1.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -68,7 +69,7 @@
z = randn (R*C); z = z*z';
for i = 1:length (fnames)
- fname = nth (fnames, i);
+ fname = fnames{i};
if verbose,
printf ("trying to minimize '%s'\n", fname);
end
@@ -188,3 +189,4 @@
printf ("All tests ok\n");
end
+
Index: main/optim/inst/line_min.m
===================================================================
--- main/optim/inst/line_min.m (revision 7322)
+++ main/optim/inst/line_min.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2000 Ben Sapp. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -47,7 +48,7 @@
nev = 0;
h = 0.001; # Was 0.01 here
- x = nth (args,narg);
+ x = args{narg};
a = 0;
# was 1e-4
while (abs (velocity) > 0.000001)
@@ -66,4 +67,5 @@
endfunction
## Rem : Although not clear from the code, the returned a always seems to
-## correspond to (nearly) optimal fx.
\ No newline at end of file
+## correspond to (nearly) optimal fx.
+
Index: main/optim/inst/fminunc_compat.m
===================================================================
--- main/optim/inst/fminunc_compat.m (revision 7322)
+++ main/optim/inst/fminunc_compat.m (working copy)
@@ -97,7 +97,7 @@
"Backend" , "backend");
for [v,k] = equiv
- if struct_contains (opt,k)
+ if isfield (opt,k)
opm = setfield (opm, getfield(equiv,k), getfield(opt,k));
end
end
@@ -124,14 +124,14 @@
end
end
# Return only options to minimize() ##
-if struct_contains (opt, "MinEquiv")
+if isfield (opt, "MinEquiv")
x = opml;
if nargout > 1
warning ("Only 1 return value is defined with the 'MinEquiv' option");
end
return
# Use the backend option #############
-elseif struct_contains (opm, "backend")
+elseif isfield (opm, "backend")
[x,fval] = minimize (fun, args, opml);
if nargout > 2
warning ("Only 2 return values are defined with the 'Backend' option");
@@ -140,7 +140,7 @@
else # Do the minimization ################
[x,fval,out] = minimize (fun, args, opml);
- if struct_contains (opm, "maxev")
+ if isfield (opm, "maxev")
flag = out(1) < getfield(opm,"maxev");
else
flag = 1;
Index: main/optim/inst/deriv.m
===================================================================
--- main/optim/inst/deriv.m (revision 7322)
+++ main/optim/inst/deriv.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2000 Ben Sapp. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -28,17 +29,17 @@
endif
if(nargin >= 3)
va_arg_cnt = 1;
- h = nth (varargin, va_arg_cnt++);
+ h = varargin{va_arg_cnt++};
if(!is_scalar(h))
error("h must be a scalar.");
endif
if(nargin >= 4)
- O = nth (varargin, va_arg_cnt++);
+ O = varargin{va_arg_cnt++};
if((O != 2) && (O != 4))
error("Only order 2 or 4 is supported.\n");
endif
if(nargin >= 5)
- N = nth (varargin, va_arg_cnt++);
+ N = varargin{va_arg_cnt++};
if((N > 4)||(N < 1))
error("Only 1st,2nd,3rd or 4th order derivatives are acceptable.\n");
endif
@@ -83,3 +84,4 @@
error("Only order 4 or 2 supported\n");
endswitch
endfunction
+
Index: main/optim/inst/minimize.m
===================================================================
--- main/optim/inst/minimize.m (revision 7322)
+++ main/optim/inst/minimize.m (working copy)
@@ -1,3 +1,6 @@
+
+
+
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -135,7 +138,7 @@
if nargin == 3 # Accomodation to struct and list optional
va_arg_cnt = 1; # args
- tmp = nth (varargin, va_arg_cnt++);
+ tmp = varargin{va_arg_cnt++};
if isstruct (tmp)
opls = list ();
@@ -279,7 +282,7 @@
if nargout > 3, vr_val_cnt = 1; varargout{vr_val_cnt++} = h; end
elseif strcmp (method, "bfgsmin")
nev = nan;
- if is_list (args),tmp={};for i=1:length(args),tmp{i}=nth(args,i);end;args=tmp;end
+ if is_list (args),tmp={};for i=1:length(args),tmp{i}=args{i};end;args=tmp;end
if !iscell(args), args = {args}; end
if isnan (ftol), ftol = 1e-12; end # Use bfgsmin's defaults
if isnan (utol), utol = 1e-6; end
@@ -298,3 +301,6 @@
end
+
+
+
Index: main/miscellaneous/inst/read_options.m
===================================================================
--- main/miscellaneous/inst/read_options.m (revision 7322)
+++ main/miscellaneous/inst/read_options.m (working copy)
@@ -184,7 +184,7 @@
tmp = args{++nread};
if verbose, printf ("read_options : size is %i x %i\n",size(tmp)); end
if !isnumeric (tmp) || !all (isnan (tmp(:))) || \
- !struct_contains (op, fullname)
+ !isfield (op, fullname)
op.(fullname) = tmp;
else
if verbose, printf ("read_options : ignoring nan\n"); end
Index: main/miscellaneous/inst/temp_name.m
===================================================================
--- main/miscellaneous/inst/temp_name.m (revision 7322)
+++ main/miscellaneous/inst/temp_name.m (working copy)
@@ -38,7 +38,7 @@
if nargin<2, quick = 1; end
if quick
- if ! struct_contains (cnt, rootname)
+ if ! isfield (cnt, rootname)
cnt.(rootname) = 0;
c = 0 ;
else
@@ -57,4 +57,4 @@
if quick
cnt.(rootname) = c ;
-end
\ No newline at end of file
+end
Index: main/vrml/inst/vrml_DirectionalLight.m
===================================================================
--- main/vrml/inst/vrml_DirectionalLight.m (revision 7322)
+++ main/vrml/inst/vrml_DirectionalLight.m (working copy)
@@ -37,7 +37,7 @@
if !(isnumeric(val) && isnan (val)),
# Check validity of field
- if ! struct_contains (tpl, key)
+ if ! isfield (tpl, key)
error (sprintf ("vrml_PointLight : unknown field '%s'",key));
end
Index: main/vrml/inst/vrml_group.m
===================================================================
--- main/vrml/inst/vrml_group.m (revision 7322)
+++ main/vrml/inst/vrml_group.m (working copy)
@@ -1,3 +1,5 @@
+
+
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -29,9 +31,9 @@
# varargin = list(varargin, all_va_args);
# end
# endpre 2.1.38
-if nargin > 0, s = nth (varargin, 1); end
+if nargin > 0, s = varargin{1}; end
if nargin > 1
- for i = 2:nargin, s = [s,",\n", nth(varargin, i)]; end
+ for i = 2:nargin, s = [s,",\n", varargin{i}]; end
end
## indent s
ni = 4;
@@ -45,3 +47,5 @@
s);
endfunction
+
+
Index: main/vrml/inst/save_vrml.m
===================================================================
--- main/vrml/inst/save_vrml.m (revision 7322)
+++ main/vrml/inst/save_vrml.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -76,7 +77,7 @@
args = nargin; # nargin is now a function
while --args,
- tmp = nth (varargin, i++);
+ tmp = varargin{i++};
if strcmp (tmp, "nobg"),
bg_node = "";
elseif strcmp (tmp, "nolight"),
@@ -120,3 +121,4 @@
fclose(fid);
endfunction
+
Index: main/vrml/inst/vrml_lines.m
===================================================================
--- main/vrml/inst/vrml_lines.m (revision 7322)
+++ main/vrml/inst/vrml_lines.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -46,7 +47,7 @@
while args>=i ,
- tmp = nth (varargin, i++) ; # pos 2.1.39
+ tmp = varargin{i++} ; # pos 2.1.39
if ! ischar(tmp) ,
error ("vrml_lines : Non-string option : \n") ;
## keyboard
@@ -55,7 +56,7 @@
if index(opt1,[" ",tmp," "]) ,
- tmp2 = nth (varargin, i++); # pos 2.1.39
+ tmp2 = varargin{i++}; # pos 2.1.39
## args-- ;
eval([tmp,"=tmp2;"]) ;
@@ -97,3 +98,4 @@
endfunction
+
Index: main/vrml/inst/vrml_Background.m
===================================================================
--- main/vrml/inst/vrml_Background.m (revision 7322)
+++ main/vrml/inst/vrml_Background.m (working copy)
@@ -56,7 +56,7 @@
body = "";
for [val,key] = hash,
- if struct_contains (opts, key)
+ if isfield (opts, key)
n = opts.(key);
if (n == 0)
if (ischar(val))
Index: main/vrml/inst/vrml_TimeSensor.m
===================================================================
--- main/vrml/inst/vrml_TimeSensor.m (revision 7322)
+++ main/vrml/inst/vrml_TimeSensor.m (working copy)
@@ -1,3 +1,6 @@
+
+
+
## s = vrml_TimeSensor (...) - Low-level vrml TimeSensor node
##
## s is a vrml node with possible fields :
@@ -43,12 +46,12 @@
i = j = k = 1; # i:pos in new varargin, j:pos in headpar,
# k:pos is old varargin.
while i <= length (varargin) && \
- ! (ischar (nth (varargin,i)) && struct_contains (tpl, nth (varargin,i)))
+ ! (ischar (varargin{i}) && isfield (tpl, varargin{i}))
if j <= length (headpar)
if verbose
- printf ("vrml_TimeSensor : Assume arg %i is '%s'\n",k,nth(headpar,j));
+ printf ("vrml_TimeSensor : Assume arg %i is '%s'\n",k,headpar{j});
end
varargin = splice (varargin, i, 0, headpar(j++));
@@ -56,7 +59,7 @@
k++;
else
error ("vrml_TimeSensor : Argument %i should be string, not '%s'",\
- k,typeinfo (nth (varargin, i)));
+ k,typeinfo (varargin{i}));
end
end
@@ -69,18 +72,18 @@
i = 1;
while i < length (varargin)
- k = nth (varargin, i++); # Read key
+ k = varargin{i++}; # Read key
if ! ischar (k)
error ("vrml_TimeSensor : Arg n. %i should be a string, not a %s.",\
i-1, typeinfo (k));
end
- if ! struct_contains (tpl, k) && ! strcmp (k,"DEF")
+ if ! isfield (tpl, k) && ! strcmp (k,"DEF")
error ("vrml_TimeSensor : Unknown field '%s'. Should be one of :\n%s",\
k, sprintf (" '%s'\n",fieldnames (tpl)'{:}));
end
- v = nth (varargin, i++); # Read value
+ v = varargin{i++}; # Read value
# Add DEF
if strcmp (k,"DEF")
@@ -103,11 +106,11 @@
if is_list (v) # v is list of arguments
# Check whether 1st arg is node type's name.
- tn = nth (v,1);
+ tn = v{1};
if all (exist (["vrml_",tn]) != [2,3,5])
# If it isn't type's name, use default type.
- if struct_contains (dnode, k)
+ if isfield (dnode, k)
if verbose
printf ("vrml_TimeSensor : Using default type : %s\n",dnode.(k));
end
@@ -123,7 +126,7 @@
# If v is not a list, maybe it has a default
# node type type (otherwise, it's be sent
# plain.
- elseif struct_contains (dnode, k)
+ elseif isfield (dnode, k)
if verbose
printf ("vrml_TimeSensor : Using default type : %s\n",dnode.(k));
end
@@ -138,3 +141,6 @@
s = leval ("strcat", l);
endfunction
+
+
+
Index: main/vrml/inst/vrml_frame.m
===================================================================
--- main/vrml/inst/vrml_frame.m (revision 7322)
+++ main/vrml/inst/vrml_frame.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -140,3 +141,4 @@
endfunction
+
Index: main/vrml/inst/vrml_newname.m
===================================================================
--- main/vrml/inst/vrml_newname.m (revision 7322)
+++ main/vrml/inst/vrml_newname.m (working copy)
@@ -14,7 +14,7 @@
if isempty (root), root = "N"; end
n = sprintf ([root,"%0d"],100000*rand());
-while struct_contains (vrml_namespace, n)
+while isfield (vrml_namespace, n)
n = sprintf ([root,"%0d"],100000*rand());
end
endfunction
Index: main/vrml/inst/vrml_interp.m
===================================================================
--- main/vrml/inst/vrml_interp.m (revision 7322)
+++ main/vrml/inst/vrml_interp.m (working copy)
@@ -27,7 +27,7 @@
"Position" , "Position",
"scal" , "Scalar",
"Scalar" , "Scalar");
-if struct_contains (nname, typ)
+if isfield (nname, typ)
typs = nname.(typ);
elseif ischar(typ)
e2 = leval ("sprintf",\
Index: main/vrml/inst/vrml_points.m
===================================================================
--- main/vrml/inst/vrml_points.m (revision 7322)
+++ main/vrml/inst/vrml_points.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2002 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -65,7 +66,7 @@
while i <= nargin-1
- tmp = nth (varargin,i++);
+ tmp = varargin{i++};
if strcmp(tmp,"hide") ,
hide = 1;
elseif strcmp(tmp,"balls") ,
@@ -74,20 +75,20 @@
cubes = 1;
elseif strcmp(tmp,"rad") ,
- rad = nth (varargin,i++);
+ rad = varargin{i++};
elseif strcmp(tmp,"nums") ,
nums = 1;
elseif strcmp(tmp,"emit") ,
- emit = nth (varargin,i++);
+ emit = varargin{i++};
elseif strcmp(tmp,"col") ,
- col = nth (varargin,i++);
+ col = varargin{i++};
elseif strcmp(tmp,"name") ,
- name = nth (varargin,i++);
+ name = varargin{i++};
elseif strcmp(tmp,"tran") ,
- tran = nth (varargin,i++);
+ tran = varargin{i++};
end
end
@@ -218,3 +219,4 @@
end
endfunction
+
Index: main/vrml/inst/vrml_faces.m
===================================================================
--- main/vrml/inst/vrml_faces.m (revision 7322)
+++ main/vrml/inst/vrml_faces.m (working copy)
@@ -95,7 +95,7 @@
i = 1;
while nargin>=i
- tmp = nth (varargin, i++);
+ tmp = varargin{i++};
if ! ischar(tmp) ,
error ("vrml_faces : Non-string option : \n") ;
## keyboard
@@ -103,7 +103,7 @@
if index(opt1,[" ",tmp," "]) ,
- tmp2 = nth (varargin, i++) ;
+ tmp2 = varargin{i++};
eval([tmp,"=tmp2;"]) ;
@@ -270,10 +270,10 @@
if is_list (f)
npts = 0;
- for i = 1:length (f), npts += ptsface(i) = 1+length (nth (f,i)); end
+ for i = 1:length (f), npts += ptsface(i) = 1+length (f{i}); end
ii = [0, cumsum(ptsface)]';
all_indexes = -ones (1,npts);
- for i = 1:length (f), all_indexes(ii(i)+1:ii(i+1)-1) = nth (f,i) - 1; end
+ for i = 1:length (f), all_indexes(ii(i)+1:ii(i+1)-1) = f{i} - 1; end
else
f = [f;-ones(1,columns(f))];
npts = sum (ptsface = (sum (!! f)));
Index: main/vrml/inst/vrml_PointLight.m
===================================================================
--- main/vrml/inst/vrml_PointLight.m (revision 7322)
+++ main/vrml/inst/vrml_PointLight.m (working copy)
@@ -56,7 +56,7 @@
elseif !(isnumeric(val) && isnan (val))
# Check validity of field
- if ! struct_contains (tpl, key)
+ if ! isfield (tpl, key)
error (sprintf ("vrml_PointLight : unknown field '%s'",key));
end
@@ -67,7 +67,7 @@
end
end
s = sprintf ("PointLight {\n%s}\n", body);
-if struct_contains (h,"DEF") && !isempty (h.DEF)
+if isfield (h,"DEF") && !isempty (h.DEF)
s = ["DEF ",h.DEF," ",s];
end
endfunction
Index: main/vrml/inst/vmesh.m
===================================================================
--- main/vrml/inst/vmesh.m (revision 7322)
+++ main/vrml/inst/vmesh.m (working copy)
@@ -1,3 +1,4 @@
+
## Copyright (C) 2002-2009 Etienne Grossmann. All rights reserved.
##
## This program is free software; you can redistribute it and/or modify it
@@ -125,9 +126,8 @@
"zgray","zrb","zcol"};
for i = 1:length(all_surf_opts)
- ## optname = nth (all_surf_opts, i);
optname = all_surf_opts{i};
- if struct_contains (opts, optname)
+ if isfield (opts, optname)
## surf_args = append (surf_args, list (optname));
surf_args{length(surf_args)+1} = optname;
if index (op1,[" ",optname," "])
@@ -274,3 +274,4 @@
endfunction
+
------------------------------------------------------------------------------
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev