diff -r 6892c5562950 scripts/audio/wavread.m
--- a/scripts/audio/wavread.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/audio/wavread.m Fri Jul 09 12:12:45 2010 +0200
@@ -193,7 +193,8 @@
if (bits_per_sample == 24)
yi = reshape (yi, 3, rows(yi)/3)';
- yi(yi(:,3) >= 128, 3) -= 256;
+ ix = yi(:,3) >= 128;
+ yi(ix, 3) = yi(ix, 3) - 256;
yi = yi * [1; 256; 65536];
endif
diff -r 6892c5562950 scripts/general/bicubic.m
--- a/scripts/general/bicubic.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/general/bicubic.m Fri Jul 09 12:12:45 2010 +0200
@@ -101,7 +101,7 @@
X = reshape (X, 1, cz);
- X(cz) *= 1 + sign (X(cz))*myeps;
+ X(cz) = X(cz) * (1 + sign (X(cz))*myeps);
if (X(cz) == 0)
X(cz) = myeps;
endif;
@@ -111,7 +111,7 @@
xidx = o(find (i > cz));
Y = reshape (Y, rz, 1);
- Y(rz) *= 1 + sign (Y(rz))*myeps;
+ Y(rz) = Y(rz) * (1 + sign (Y(rz))*myeps);
if (Y(rz) == 0)
Y(rz) = myeps;
endif;
diff -r 6892c5562950 scripts/general/del2.m
--- a/scripts/general/del2.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/general/del2.m Fri Jul 09 12:12:45 2010 +0200
@@ -83,7 +83,7 @@
dx{i} = h * ones (sz (i), 1);
else
if (length (h) == sz (i))
- dx{i} = diff (h)(:);
+ dx{i} = vec(diff (h));
else
error ("del2: dimensionality mismatch in %d-th spacing vector", i);
endif
@@ -100,7 +100,7 @@
dx{i} = varargin{i} * ones (sz (i), 1);
else
if (length (varargin{i}) == sz (i))
- dx{i} = diff (varargin{i})(:);
+ dx{i} = vec(diff (varargin{i}));
else
error ("del2: dimensionality mismatch in %d-th spacing vector", i);
endif
diff -r 6892c5562950 scripts/general/idivide.m
--- a/scripts/general/idivide.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/general/idivide.m Fri Jul 09 12:12:45 2010 +0200
@@ -68,7 +68,7 @@
elseif (nargin == 2)
op = "fix";
else
- op = tolower (op);
+ op = lower (op);
endif
if (strcmp (op, "round"))
diff -r 6892c5562950 scripts/general/interp1.m
--- a/scripts/general/interp1.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/general/interp1.m Fri Jul 09 12:12:45 2010 +0200
@@ -113,7 +113,7 @@
for i = 1:length (varargin)
arg = varargin{i};
if (ischar (arg))
- arg = tolower (arg);
+ arg = lower (arg);
if (strcmp ("extrap", arg))
extrap = "extrap";
elseif (strcmp ("pp", arg))
@@ -296,7 +296,7 @@
xs = [x(1);x(3:nx-2)];
yi = mkpp ([x(1);x(3:nx-2);x(nx)],
[a(:), (b(:) + 3.*xs(:,J).*a(:)), ...
- (c(:) + 2.*xs(:,J).*b(:) + 3.*xs(:,J)(:).^2.*a(:)), ...
+ (c(:) + 2.*xs(:,J).*b(:) + 3.*reshape(xs(:,J),[],1).^2.*a(:)), ...
(d(:) + xs(:,J).*c(:) + xs(:,J).^2.*b(:) + ...
xs(:,J).^3.*a(:))], szy(2:end));
else
diff -r 6892c5562950 scripts/general/interpn.m
--- a/scripts/general/interpn.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/general/interpn.m Fri Jul 09 12:12:45 2010 +0200
@@ -64,7 +64,7 @@
function vi = interpn (varargin)
method = "linear";
- extrapval = NA;
+ extrapval = NaN;
nargs = nargin;
if (nargin < 1)
@@ -135,16 +135,16 @@
x{1} = x{1}(idx{:})(:);
endif
- method = tolower (method);
+ method = lower (method);
if (strcmp (method, "linear"))
vi = __lin_interpn__ (x{:}, v, y{:});
- vi (isna (vi)) = extrapval;
+ vi (isnan (vi)) = extrapval;
elseif (strcmp (method, "nearest"))
yshape = size (y{1});
yidx = cell (1, nd);
for i = 1 : nd
- y{i} = y{i}(:);
+ y{i} = vec(y{i});
yidx{i} = lookup (x{i}, y{i}, "lr");
endfor
idx = cell (1,nd);
diff -r 6892c5562950 scripts/general/private/__isequal__.m
--- a/scripts/general/private/__isequal__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/general/private/__isequal__.m Fri Jul 09 12:12:45 2010 +0200
@@ -106,7 +106,7 @@
idx++;
args = {nans_compare_equal, {x.(fn_x{idx})}};
for argn = 1:l_v
- args{argn+2} = {varargin{argn}.(fn_x{idx})};
+ args{argn+2} = {getfield(varargin{argn},fn_x{idx})};
endfor
## Minimize function calls by calling for all the arguments at
## once.
diff -r 6892c5562950 scripts/general/quadgk.m
--- a/scripts/general/quadgk.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/general/quadgk.m Fri Jul 09 12:12:45 2010 +0200
@@ -152,7 +152,8 @@
elseif (strcmpi (str, "abstol"))
abstol = varargin{idx++};
elseif (strcmpi (str, "waypoints"))
- waypoints = varargin{idx++} (:);
+ waypoints = vec(varargin{idx});
+ idx++;
if (isreal(waypoints))
waypoints (waypoints < a | waypoints > b) = [];
endif
@@ -284,7 +285,8 @@
## Split interval into at least 10 sub-interval with a 15 point
## Gauss-Kronrod rule giving a minimum of 150 function evaluations
while (length (subs) < 11)
- subs = [subs' ; subs(1:end-1)' + diff(subs') ./ 2, NaN](:)(1 : end - 1);
+ subs = reshape([subs' ; subs(1:end-1)' + diff(subs') ./ 2, NaN],[],1);
+ subs = subs (1 : end - 1);
endwhile
subs = [subs(1:end-1), subs(2:end)];
diff -r 6892c5562950 scripts/general/rat.m
--- a/scripts/general/rat.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/general/rat.m Fri Jul 09 12:12:45 2010 +0200
@@ -122,7 +122,8 @@
j = 1;
while (true)
- step = steps(i, j++);
+ step = steps(i, j);
+ j++;
if (isnan (step))
break;
endif
diff -r 6892c5562950 scripts/geometry/griddata.m
--- a/scripts/geometry/griddata.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/geometry/griddata.m Fri Jul 09 12:12:45 2010 +0200
@@ -45,7 +45,7 @@
endif
if (ischar (method))
- method = tolower (method);
+ method = lower (method);
endif
if (! all (size (x) == size (y) & size (x) == size (z)))
error ("griddata: x, y, and z must be vectors of same length");
diff -r 6892c5562950 scripts/geometry/griddatan.m
--- a/scripts/geometry/griddatan.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/geometry/griddatan.m Fri Jul 09 12:12:45 2010 +0200
@@ -40,7 +40,7 @@
endif
if (ischar (method))
- method = tolower (method);
+ method = lower (method);
endif
[m, n] = size (x);
diff -r 6892c5562950 scripts/geometry/rectint.m
--- a/scripts/geometry/rectint.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/geometry/rectint.m Fri Jul 09 12:12:45 2010 +0200
@@ -92,16 +92,16 @@
## determine the height of the rectangle
## r1 completely encloses r2
- area(r1y1small & r1y2large,i) .*= r2(i,4) - r2(i,2);
+ area(r1y1small & r1y2large,i) = area(r1y1small & r1y2large,i) .* (r2(i,4) - r2(i,2));
## the range goes from r2y min to r1y max
mask = r1y1small & r1y2mid;
- area(mask,i) .*= r1(mask,4) - r2(i,2);
+ area(mask,i) = area(mask,i) .* (r1(mask,4) - r2(i,2));
## the range goes from r1y min to r2y max
mask = r1y1mid & r1y2large;
- area(mask,i) .*= r2(i,4) - r1(mask,2);
+ area(mask,i) = area(mask,i) .* (r2(i,4) - r1(mask,2));
## the range goes from r1x min to r1x max
mask = r1y1mid & r1y2mid;
- area(mask,i) .*= r1(mask,4) - r1(mask,2);
+ area(mask,i) = area(mask,i) .* (r1(mask,4) - r1(mask,2));
endfor
diff -r 6892c5562950 scripts/geometry/triplot.m
--- a/scripts/geometry/triplot.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/geometry/triplot.m Fri Jul 09 12:12:45 2010 +0200
@@ -37,11 +37,11 @@
idx = tri(:, [1, 2, 3, 1]).';
nt = size (tri, 1);
if (nargout > 0)
- h = plot ([x(idx); NaN(1, nt)](:),
- [y(idx); NaN(1, nt)](:), varargin{:});
+ h = plot (reshape([x(idx); NaN(1, nt)],[],1),
+ reshape([y(idx); NaN(1, nt)],[],1), varargin{:});
else
- plot ([x(idx); NaN(1, nt)](:),
- [y(idx); NaN(1, nt)](:), varargin{:});
+ plot (reshape([x(idx); NaN(1, nt)],[],1),
+ reshape([y(idx); NaN(1, nt)],[],1), varargin{:});
endif
endfunction
diff -r 6892c5562950 scripts/help/__strip_html_tags__.m
--- a/scripts/help/__strip_html_tags__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/help/__strip_html_tags__.m Fri Jul 09 12:12:45 2010 +0200
@@ -48,7 +48,7 @@
groups = [els(1), 1]; # list containing [start, length] of each group
for k = 1:length (dels)
if (dels (k) == 1)
- groups (end, 2) ++;
+ groups (end, 2) = groups (end, 2) + 1;
else
groups (end+1, 1:2) = [els(k+1), 1];
endif
diff -r 6892c5562950 scripts/image/gmap40.m
--- a/scripts/image/gmap40.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/image/gmap40.m Fri Jul 09 12:12:45 2010 +0200
@@ -40,8 +40,7 @@
endif
if (number >= 1)
- map = repmat ([1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1],
- ceil (number / 6), 1) (1:number, :);
+ map = repmat ([1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1], ceil (number / 6), 1) (1:number, :);
else
map = [];
endif
diff -r 6892c5562950 scripts/image/hsv2rgb.m
--- a/scripts/image/hsv2rgb.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/image/hsv2rgb.m Fri Jul 09 12:12:45 2010 +0200
@@ -41,7 +41,7 @@
if (ismatrix (hsv_map) && ndims (hsv_map) == 3)
is_image = true;
Sz = size (hsv_map);
- hsv_map = [hsv_map(:,:,1)(:), hsv_map(:,:,2)(:), hsv_map(:,:,3)(:)];
+ hsv_map = [reshape(hsv_map(:,:,1),[],1), reshape(hsv_map(:,:,2),[],1), reshape(hsv_map(:,:,3),[],1)];
## Convert to a double image.
if (isinteger (hsv_map))
C = class (hsv_map);
diff -r 6892c5562950 scripts/image/imshow.m
--- a/scripts/image/imshow.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/image/imshow.m Fri Jul 09 12:12:45 2010 +0200
@@ -119,7 +119,7 @@
## Set default display range if display_range not set yet.
if (isempty (display_range))
display_range = [min(im(:)), max(im(:))];
- elseif (isna (display_range))
+ elseif (isnan (display_range))
t = class (im);
switch (t)
case {"double", "single", "logical"}
diff -r 6892c5562950 scripts/image/ntsc2rgb.m
--- a/scripts/image/ntsc2rgb.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/image/ntsc2rgb.m Fri Jul 09 12:12:45 2010 +0200
@@ -37,7 +37,7 @@
if (ismatrix (yiq) && ndims (yiq) == 3)
is_image = true;
Sz = size (yiq);
- yiq = [yiq(:,:,1)(:), yiq(:,:,2)(:), yiq(:,:,3)(:)];
+ yiq = [vec(yiq(:,:,1)), vec(yiq(:,:,2)), vec(yiq(:,:,3))];
## Convert to a double image.
if (isinteger (yiq))
C = class (yiq);
diff -r 6892c5562950 scripts/image/rgb2hsv.m
--- a/scripts/image/rgb2hsv.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/image/rgb2hsv.m Fri Jul 09 12:12:45 2010 +0200
@@ -43,7 +43,7 @@
if (ismatrix (rgb) && ndims (rgb) == 3)
is_image = true;
Sz = size (rgb);
- rgb = [rgb(:,:,1)(:), rgb(:,:,2)(:), rgb(:,:,3)(:)];
+ rgb = [reshape(rgb(:,:,1),[],1), reshape(rgb(:,:,2),[],1), reshape(rgb(:,:,3),[],1)];
## Convert to a double image.
if (isinteger (rgb))
C = class (rgb);
diff -r 6892c5562950 scripts/image/rgb2ntsc.m
--- a/scripts/image/rgb2ntsc.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/image/rgb2ntsc.m Fri Jul 09 12:12:45 2010 +0200
@@ -37,7 +37,7 @@
if (ismatrix (rgb) && ndims (rgb) == 3)
is_image = true;
Sz = size (rgb);
- rgb = [rgb(:,:,1)(:), rgb(:,:,2)(:), rgb(:,:,3)(:)];
+ rgb = [reshape(rgb(:,:,1),[],1), reshape(rgb(:,:,2),[],1), reshape(rgb(:,:,3),[],1)];
## Convert to a double image.
if (isinteger (rgb))
C = class (rgb);
diff -r 6892c5562950 scripts/io/textread.m
--- a/scripts/io/textread.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/io/textread.m Fri Jul 09 12:12:45 2010 +0200
@@ -1,4 +1,5 @@
## Copyright (C) 2009 Eric Chassande-Mottin, CNRS (France)
+## Copyright (C) 2010 Alois Schloegl
##
## 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
@@ -28,6 +29,9 @@
## supports one more:
## @itemize
## @item "headerlines":
+## @item "delimiter":
+## @item "endofline":
+## @item "emptyvalue":
## @end itemize
## The first @var{value} number of lines of @var{str} are skipped.
## @seealso{strread, load, dlmread, fscanf}
@@ -49,16 +53,64 @@
error ("textread: could not open '%s' for reading", filename);
endif
- ## Maybe skip header lines
- headerlines = find (strcmpi (varargin, "headerlines"), 1);
- if (! isempty (headerlines))
- fskipl (fid, headerlines);
- varargin(headerlines:headerlines+1) = [];
+ ## Maybe skip header lineswhitespace=char([9,32]);
+ cdelim = ',';
+ rdelim = char([10,13]);
+ headerlines = 0;
+ emptyval = NaN;
+ commentstyle = [];
+ whitespace = char([8,9,32]); % " \b\t"
+
+ ix = find (strcmpi (varargin, "headerlines"), 1);
+ if (! isempty (ix))
+ headerlines = varargin{ix+1};
+ while (headerlines > 0),
+ fgetl(fid); % skip header lines
+ headerlines--;
+ end;
+ varargin(ix:ix+1) = [];
endif
-
- str = fread (fid, "char=>char").';
+
+ str = fread (fid, [1,inf], 'uint8=>char');
fclose (fid);
## Call strread to make it do the real work
- [varargout{1:max (nargout, 1)}] = strread (str, formatstr, varargin {:});
+ if ~isempty(formatstr)
+ [varargout{1:max (nargout, 1)}] = strread (str, formatstr, varargin {:});
+ else
+ k = 0;
+ while (k < length(varargin))
+ k = k+1;
+ if strcmp(varargin{k},'delimiter')
+ cdelim = varargin{k+1};
+ k = k+1;
+ elseif strcmp(varargin{k},'endofline')
+ rdelim = varargin{k+1};
+ if strcmp(rdelim,'\n') rdelim = char(10); end;
+ k = k+1;
+ elseif strcmp(varargin{k},'headerlines')
+ headerlines = varargin{k+1};
+ k = k+1;
+ elseif strcmp(varargin{k},'emptyvalue')
+ emptyval = varargin{k+1};
+ k = k+1;
+ elseif strcmp(varargin{k},'commentstyle')
+ commentstyle = varargin{k+1};
+ k = k+1;
+ warning('textread: argument ''commentstyle'' is ignored');
+ elseif strcmp(varargin{k},'whitespace')
+ whitespace = varargin{k+1};
+ k = k+1;
+ warning('textread: argument ''whitespace'' is ignored');
+ else
+ warning(sprintf('textread: argument ''%s'' unknown/unsupported',varargin{k}))
+ end
+ end;
+
+ [d,v,s] = str2array(str,cdelim,rdelim);
+ d(v~=0) = emptyval;
+ varargout{1} = d;
+
+ end;
+
endfunction
diff -r 6892c5562950 scripts/linear-algebra/rref.m
--- a/scripts/linear-algebra/rref.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/linear-algebra/rref.m Fri Jul 09 12:12:45 2010 +0200
@@ -77,9 +77,10 @@
A (ridx, c:cols) = A (ridx, c:cols) - A (ridx, c) * A(r, c:cols);
## Check if done
- if (r++ == rows)
+ if (r == rows)
break;
endif
+ r += 1;
endif
endfor
k = find (used);
diff -r 6892c5562950 scripts/miscellaneous/edit.m
--- a/scripts/miscellaneous/edit.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/miscellaneous/edit.m Fri Jul 09 12:12:45 2010 +0200
@@ -154,7 +154,7 @@
mlock;
if (nargin == 2)
- switch (toupper (file))
+ switch (upper (file))
case "EDITOR"
FUNCTION.EDITOR = state;
case "HOME"
@@ -186,8 +186,8 @@
endif
FUNCTION.EDITINPLACE = state;
case "GET"
- if (isfield (FUNCTION, toupper(state)))
- ret = FUNCTION.(toupper (state));
+ if (isfield (FUNCTION, upper(state)))
+ ret = getfield(FUNCTION,upper (state));
else
ret = FUNCTION;
endif
@@ -346,7 +346,7 @@
author = cstrcat ("Author: ", FUNCTION.AUTHOR, " ", FUNCTION.EMAIL);
## Fill in the header.
- uclicense = toupper (FUNCTION.LICENSE);
+ uclicense = upper (FUNCTION.LICENSE);
switch (uclicense)
case "GPL"
head = cstrcat (copyright, "\n\n", "\
diff -r 6892c5562950 scripts/miscellaneous/orderfields.m
--- a/scripts/miscellaneous/orderfields.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/miscellaneous/orderfields.m Fri Jul 09 12:12:45 2010 +0200
@@ -151,7 +151,9 @@
n = numel (s1);
for i = 1:numel (names)
el = names(i);
- [t(1:n).(el)] = s1(:).(el);
+ for j = 1:n,
+ setfield(t(j), el, getfields(s1(j),el));
+ endfor
endfor
## inherit dimensions
t = reshape (t, size (s1));
diff -r 6892c5562950 scripts/optimization/__all_opts__.m
--- a/scripts/optimization/__all_opts__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/optimization/__all_opts__.m Fri Jul 09 12:12:45 2010 +0200
@@ -54,7 +54,7 @@
end_try_catch
endfor
names = unique (names);
- lnames = unique (tolower (names));
+ lnames = unique (lower (names));
if (length (lnames) < length (names))
## This is bad.
error ("__all_opts__: duplicate options with inconsistent case");
diff -r 6892c5562950 scripts/optimization/fminunc.m
--- a/scripts/optimization/fminunc.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/optimization/fminunc.m Fri Jul 09 12:12:45 2010 +0200
@@ -171,7 +171,7 @@
grad = grad(:);
nfev ++;
else
- grad = __fdjac__ (fcn, reshape (x, xsiz), fval, typicalx, cdif)(:);
+ grad = reshape (__fdjac__ (fcn, reshape (x, xsiz), fval, typicalx, cdif),[],1);
nfev += (1 + cdif) * length (x);
endif
@@ -231,7 +231,7 @@
delta = min (delta, sn);
endif
- fval1 = fcn (reshape (x + s, xsiz)) (:);
+ fval1 = reshape (fcn (reshape (x + s, xsiz)),[],1);
nfev ++;
if (fval1 < fval)
diff -r 6892c5562950 scripts/optimization/fsolve.m
--- a/scripts/optimization/fsolve.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/optimization/fsolve.m Fri Jul 09 12:12:45 2010 +0200
@@ -301,7 +301,7 @@
delta = min (delta, sn);
endif
- fvec1 = fcn (reshape (x + s, xsiz)) (:);
+ fvec1 = reshape (fcn (reshape (x + s, xsiz)),[],1);
fn1 = norm (fvec1);
nfev ++;
diff -r 6892c5562950 scripts/optimization/fzero.m
--- a/scripts/optimization/fzero.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/optimization/fzero.m Fri Jul 09 12:12:45 2010 +0200
@@ -141,7 +141,8 @@
aa = a;
endif
for b = [0.9*aa, 1.1*aa, aa-1, aa+1, 0.5*aa 1.5*aa, -aa, 2*aa, -10*aa, 10*aa]
- fb = fun (b); nfev += 1;
+ fb = fun (b);
+ nfev += 1;
if (sign (fa) * sign (fb) <= 0)
break;
endif
@@ -262,7 +263,8 @@
## Calculate new point.
x = c;
fval = fc = fun (c);
- niter ++; nfev ++;
+ niter ++;
+ nfev ++;
## Modification 2: skip inverse cubic interpolation if
## nonmonotonicity is detected.
diff -r 6892c5562950 scripts/optimization/private/__fdjac__.m
--- a/scripts/optimization/private/__fdjac__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/optimization/private/__fdjac__.m Fri Jul 09 12:12:45 2010 +0200
@@ -28,9 +28,9 @@
fjac = zeros (length (fvec), numel (x));
for i = 1:numel (x)
x1 = x2 = x;
- x1(i) += h(i);
- x2(i) -= h(i);
- fjac(:,i) = (fcn (x1)(:) - fcn (x2)(:)) / (x1(i) - x2(i));
+ x1(i) = x1(i) + h(i);
+ x2(i) = x2(i) - h(i);
+ fjac(:,i) = (reshape(fcn (x1),[],1) - reshape(fcn (x2),[],1)) / (x1(i) - x2(i));
endfor
else
err = sqrt (max (eps, err));
@@ -38,8 +38,8 @@
fjac = zeros (length (fvec), numel (x));
for i = 1:numel (x)
x1 = x;
- x1(i) += h(i);
- fjac(:,i) = (fcn (x1)(:) - fvec) / (x1(i) - x(i));
+ x1(i) = x1(i) + h(i);
+ fjac(:,i) = (reshape(fcn (x1)) - fvec,[],1) / (x1(i) - x(i));
endfor
endif
endfunction
diff -r 6892c5562950 scripts/pkg/get_forge_pkg.m
--- a/scripts/pkg/get_forge_pkg.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/pkg/get_forge_pkg.m Fri Jul 09 12:12:45 2010 +0200
@@ -32,7 +32,7 @@
error ("get_forge_pkg: invalid package name: %s", name);
endif
- name = tolower (name);
+ name = lower (name);
## Try to download package's index page.
[html, succ] = urlread (sprintf ("http://octave.sourceforge.net/%s/index.html", name));
diff -r 6892c5562950 scripts/pkg/pkg.m
--- a/scripts/pkg/pkg.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/pkg/pkg.m Fri Jul 09 12:12:45 2010 +0200
@@ -1094,7 +1094,8 @@
elseif (! isspace (line(1)))
## Category.
if (! isempty (pkg_idx_struct{cat_num}.functions))
- pkg_idx_struct{++cat_num}.functions = {};
+ ++cat_num;
+ pkg_idx_struct{cat_num}.functions = {};
endif
pkg_idx_struct{cat_num}.category = deblank (line);
else
@@ -1666,7 +1667,7 @@
disp ("skipping line");
else
colon = colon(1);
- keyword = tolower (strip (line(1:colon-1)));
+ keyword = lower (strip (line(1:colon-1)));
value = strip (line (colon+1:end));
if (length (value) == 0)
fclose (fid);
@@ -1693,7 +1694,7 @@
else
desc.depends = "";
endif
- desc.name = tolower (desc.name);
+ desc.name = lower (desc.name);
endfunction
## Make sure the version string v is a valid x.y.z version string
@@ -1723,7 +1724,7 @@
## This function returns a cell of structures with the following fields:
## package, version, operator
function deps_cell = fix_depends (depends)
- deps = split_by (tolower (depends), ",");
+ deps = split_by (lower (depends), ",");
deps_cell = cell (1, length (deps));
## For each dependency.
@@ -1734,7 +1735,7 @@
## Does the dependency specify a version
## Example: package(>= version).
if (length (lpar) == 1 && length (rpar) == 1)
- package = tolower (strip (dep(1:lpar-1)));
+ package = lower (strip (dep(1:lpar-1)));
sub = dep(lpar(1)+1:rpar(1)-1);
parts = strsplit (sub, " ", true);
if (length (parts) != 2)
@@ -1751,7 +1752,7 @@
## we say that the version should be greater than
## or equal to "0.0.0".
else
- package = tolower (strip (dep));
+ package = lower (strip (dep));
operator = ">=";
version = "0.0.0";
endif
diff -r 6892c5562950 scripts/plot/__gnuplot_print__.m
--- a/scripts/plot/__gnuplot_print__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/__gnuplot_print__.m Fri Jul 09 12:12:45 2010 +0200
@@ -478,7 +478,7 @@
if (restore_properties)
props = fieldnames (p);
for n = 1:numel(props)
- set (gcf, props{n}, p.(props{n}))
+ set (gcf, props{n}, getfield(p,props{n}))
endfor
endif
if (opts.use_color < 0)
@@ -625,8 +625,8 @@
end_unwind_protect
f = fieldnames (h);
for nf = 1:numel(f)
- if (! isempty (h.(f{nf})))
- v = get (h.(f{nf}), f{nf});
+ if (! isempty (getfield(h,f{nf})))
+ v = get (getfield(h,f{nf}), f{nf});
if (! iscell (v))
v = {v};
endif
diff -r 6892c5562950 scripts/plot/__go_draw_axes__.m
--- a/scripts/plot/__go_draw_axes__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/__go_draw_axes__.m Fri Jul 09 12:12:45 2010 +0200
@@ -1964,7 +1964,8 @@
labels = regexprep(labels, "%", "%%");
for i = 1:ntics
- fprintf (plot_stream, " \"%s\" %.15g", labels{k++}, tics(i));
+ fprintf (plot_stream, " \"%s\" %.15g", labels{k}, tics(i));
+ k++;
if (i < ntics)
fputs (plot_stream, ", ");
endif
diff -r 6892c5562950 scripts/plot/__next_line_color__.m
--- a/scripts/plot/__next_line_color__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/__next_line_color__.m Fri Jul 09 12:12:45 2010 +0200
@@ -40,7 +40,8 @@
endif
elseif (! isempty (color_rotation))
rgb = color_rotation(color_index,:);
- if (++color_index > num_colors)
+ ++color_index;
+ if (color_index > num_colors)
color_index = 1;
__next_line_style__ ("incr");
endif
diff -r 6892c5562950 scripts/plot/__next_line_style__.m
--- a/scripts/plot/__next_line_style__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/__next_line_style__.m Fri Jul 09 12:12:45 2010 +0200
@@ -33,9 +33,10 @@
if (nargin < 2)
if (nargin == 1)
if (ischar (reset) && strncmp (reset, "incr", 4))
+ ++style_index;
if (isempty (style_rotation))
error ("__next_line_style__: style_rotation not initialized");
- elseif (++style_index > num_styles)
+ elseif (style_index > num_styles)
style_index = 1;
endif
elseif (reset || isempty (style_rotation))
diff -r 6892c5562950 scripts/plot/colorbar.m
--- a/scripts/plot/colorbar.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/colorbar.m Fri Jul 09 12:12:45 2010 +0200
@@ -100,7 +100,7 @@
if (! deleting)
obj = get (ax);
position = obj.position;
- clen = rows (get (get (ax, "parent"), "colormap"));
+ clen = size (get (get (ax, "parent"), "colormap"),1);
cext = get (ax, "clim");
cdiff = (cext(2) - cext(1)) / clen / 2;
cmin = cext(1) + cdiff;
@@ -190,7 +190,7 @@
function update_colorbar_clim (h, d, hi, vert)
if (ishandle (h) && strcmp (get (h, "type"), "image") &&
(isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off")))
- clen = rows (get (get (h, "parent"), "colormap"));
+ clen = size (get (get (h, "parent"), "colormap"),1);
cext = get (h, "clim");
cdiff = (cext(2) - cext(1)) / clen / 2;
cmin = cext(1) + cdiff;
diff -r 6892c5562950 scripts/plot/findobj.m
--- a/scripts/plot/findobj.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/findobj.m Fri Jul 09 12:12:45 2010 +0200
@@ -216,11 +216,11 @@
if isempty (match)
match = 0;
endif
- elseif (numel (p.(pname{np})) == numel (pvalue{np}))
+ elseif (numel (getfield(p,pname{np})) == numel (pvalue{np}))
if (ischar (pvalue{np}))
match = strcmpi (pvalue{np}, p.(pname{np}));
else
- match = (pvalue{np} == p.(pname{np}));
+ match = (pvalue{np} == getfield(p, pname{np}));
endif
else
match = 0;
diff -r 6892c5562950 scripts/plot/legend.m
--- a/scripts/plot/legend.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/legend.m Fri Jul 09 12:12:45 2010 +0200
@@ -187,7 +187,8 @@
while (k > 1
&& ! (strcmp (typ, "line") || strcmp (typ, "surface")
|| strcmp (typ, "patch") || strcmp (typ, "hggroup")))
- typ = get (kids(--k), "type");
+ --k;
+ typ = get (kids(k), "type");
endwhile
if (k > 0)
if (strcmp (get (kids(k), "type"), "hggroup"))
@@ -203,7 +204,8 @@
set (kids(k), "keylabel", arg);
endif
turn_on_legend = true;
- if (--k == 0)
+ --k;
+ if (k == 0)
break;
endif
elseif (! warned)
diff -r 6892c5562950 scripts/plot/plot3.m
--- a/scripts/plot/plot3.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/plot3.m Fri Jul 09 12:12:45 2010 +0200
@@ -100,7 +100,8 @@
## Gather arguments, decode format, and plot lines.
arg = 0;
- while (arg++ < nargin)
+ while (arg < nargin)
+ arg++;
new = varargin{arg};
new_cell = varargin(arg);
@@ -187,7 +188,8 @@
color = __next_line_color__ ();
endif
- tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
+ idx++;
+ tmp(idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
"color", color, "linestyle", linestyle,
"marker", marker, properties{:});
endfor
@@ -240,7 +242,8 @@
color = __next_line_color__ ();
endif
- tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
+ ++idx;
+ tmp(idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
"color", color, "linestyle", linestyle,
"marker", marker, properties{:});
endfor
@@ -312,7 +315,8 @@
color = __next_line_color__ ();
endif
- tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
+ ++idx;
+ tmp(idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key,
"color", color, "linestyle", linestyle,
"marker", marker, properties{:});
endfor
diff -r 6892c5562950 scripts/plot/private/__bar__.m
--- a/scripts/plot/private/__bar__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/private/__bar__.m Fri Jul 09 12:12:45 2010 +0200
@@ -90,7 +90,8 @@
if (isscalar(varargin{idx}))
width = varargin{idx++};
elseif (idx == nargin - 2)
- newargs = [newargs,varargin(idx++)];
+ newargs = [newargs,varargin(idx)];
+ idx++;
elseif (ischar (varargin{idx})
&& strcmpi (varargin{idx}, "basevalue")
&& isscalar (varargin{idx+1}))
@@ -126,10 +127,10 @@
if (group)
offset = ((delta_p + delta_m) * [-(ycols - 1) / 2 : (ycols - 1) / 2]);
- xb(1:4:4*ylen,:) += offset;
- xb(2:4:4*ylen,:) += offset;
- xb(3:4:4*ylen,:) += offset;
- xb(4:4:4*ylen,:) += offset;
+ xb(1:4:4*ylen,:) = xb(1:4:4*ylen,:) + offset;
+ xb(2:4:4*ylen,:) = xb(2:4:4*ylen,:) + offset;
+ xb(3:4:4*ylen,:) = xb(3:4:4*ylen,:) + offset;
+ xb(4:4:4*ylen,:) = xb(4:4:4*ylen,:) + offset;
y0 = zeros (size (y)) + bv;
y1 = y;
else
diff -r 6892c5562950 scripts/plot/private/__contour__.m
--- a/scripts/plot/private/__contour__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/private/__contour__.m Fri Jul 09 12:12:45 2010 +0200
@@ -100,8 +100,7 @@
endif
if (isscalar (vn))
- lvl = linspace (min (z1(!isinf(z1))), max (z1(!isinf(z1))),
- vn + 2)(1:end-1);
+ lvl = linspace (min (z1(!isinf(z1))), max (z1(!isinf(z1))), vn + 2)(1:end-1);
else
lvl = vn;
endif
diff -r 6892c5562950 scripts/plot/private/__plt__.m
--- a/scripts/plot/private/__plt__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/private/__plt__.m Fri Jul 09 12:12:45 2010 +0200
@@ -61,7 +61,8 @@
if (nargs == 0)
error ("%s: properties must appear followed by a value", caller);
endif
- properties = [properties, [next_cell, varargin(k++)]];
+ properties = [properties, [next_cell, varargin(k)]];
+ k++;
nargs--;
continue;
else
diff -r 6892c5562950 scripts/plot/private/__quiver__.m
--- a/scripts/plot/private/__quiver__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/private/__quiver__.m Fri Jul 09 12:12:45 2010 +0200
@@ -42,8 +42,9 @@
u = varargin{ioff++};
v = varargin{ioff++};
if (is3d)
- w = varargin{ioff++}
+ w = varargin{ioff};
[x, y, z] = meshgrid (1:size(u,2), 1:size(u,1), 1:max(size(w)));
+ ioff++;
else
[x, y] = meshgrid (1:size(u,2), 1:size(u,1));
endif
@@ -94,13 +95,15 @@
else
args {end + 1} = arg;
if (ioff <= nargin)
- args {end + 1} = varargin{ioff++};
+ args {end + 1} = varargin{ioff};
+ ioff++;
endif
endif
else
args {end + 1} = arg;
if (ioff <= nargin)
- args {end + 1} = varargin{ioff++};
+ args {end + 1} = varargin{ioff};
+ ioff++;
endif
endif
endwhile
diff -r 6892c5562950 scripts/plot/private/__scatter__.m
--- a/scripts/plot/private/__scatter__.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/private/__scatter__.m Fri Jul 09 12:12:45 2010 +0200
@@ -104,7 +104,8 @@
else
newargs{end+1} = arg;
if (iarg <= nargin)
- newargs{end+1} = varargin{iarg++};
+ newargs{end+1} = varargin{iarg};
+ iarg++;
endif
endif
endwhile
diff -r 6892c5562950 scripts/plot/slice.m
--- a/scripts/plot/slice.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/slice.m Fri Jul 09 12:12:45 2010 +0200
@@ -145,9 +145,10 @@
for i = length(sy):-1:1
[xi, yi, zi] = meshgrid (squeeze (x(1,:,1)), sy(i), squeeze (z(1,1,:)));
vy = squeeze (interp3 (x, y, z, v, xi, yi, zi, method));
- tmp(sidx++) = surface (squeeze (xi),
+ tmp(sidx) = surface (squeeze (xi),
squeeze (sy(i) * ones (size (zi))),
squeeze (zi), vy);
+ sidx++;
endfor
endif
@@ -155,8 +156,9 @@
for i = length(sx):-1:1
[xi, yi, zi] = meshgrid (sx(i), squeeze (y(:,1,1)), squeeze (z(1,1,:)));
vx = squeeze (interp3 (x, y, z, v, xi, yi, zi, method));
- tmp(sidx++) = surface (squeeze (sx(i) * ones (size (zi))),
+ tmp(sidx) = surface (squeeze (sx(i) * ones (size (zi))),
squeeze (yi), squeeze(zi), vx);
+ sidx++;
endfor
endif
else
diff -r 6892c5562950 scripts/plot/surfl.m
--- a/scripts/plot/surfl.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/plot/surfl.m Fri Jul 09 12:12:45 2010 +0200
@@ -139,9 +139,9 @@
vn = get (tmp, "vertexnormals");
dar = get (h, "plotboxaspectratio");
- vn(:,:,1) *= dar(1);
- vn(:,:,2) *= dar(2);
- vn(:,:,3) *= dar(3);
+ vn(:,:,1) = vn(:,:,1) * dar(1);
+ vn(:,:,2) = vn(:,:,2) * dar(2);
+ vn(:,:,3) = vn(:,:,3) * dar(3);
## Normalize vn.
vn = vn ./ repmat (sqrt (sumsq (vn, 3)), [1, 1, 3]);
diff -r 6892c5562950 scripts/polynomial/deconv.m
--- a/scripts/polynomial/deconv.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/polynomial/deconv.m Fri Jul 09 12:12:45 2010 +0200
@@ -50,8 +50,10 @@
lb = ly - la + 1;
## Ensure A is oriented as Y.
- if (diff (size (y)(1:2)) * diff (size (a)(1:2)) < 0)
- a = permute (a, [2, 1]);
+ szy=size(y);
+ sza=size(a);
+ if (diff (szy(1:2)) * diff (sza(1:2)) < 0)
+ a = a.';
endif
if (ly > la)
diff -r 6892c5562950 scripts/polynomial/mkpp.m
--- a/scripts/polynomial/mkpp.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/polynomial/mkpp.m Fri Jul 09 12:12:45 2010 +0200
@@ -50,7 +50,8 @@
if (nd == 2)
d = 1;
else
- d = prod (size (P)(1:nd-1));
+ sz = size(P);
+ d = prod (sz(1:end-1));
endif
endif
pp.d = d;
diff -r 6892c5562950 scripts/polynomial/ppint.m
--- a/scripts/polynomial/ppint.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/polynomial/ppint.m Fri Jul 09 12:12:45 2010 +0200
@@ -48,7 +48,7 @@
## Adjust constants so the the result is continuous.
jumps = reshape (ppjumps (ppi), prod (d), n-1);
- ppi.P(:,2:n,k) -= cumsum (jumps, 2);
+ ppi.P(:,2:n,k) = ppi.P(:,2:n,k) - cumsum (jumps, 2);
endfunction
diff -r 6892c5562950 scripts/signal/freqz.m
--- a/scripts/signal/freqz.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/signal/freqz.m Fri Jul 09 12:12:45 2010 +0200
@@ -151,8 +151,10 @@
ha = zeros (n, 1);
for i = 1:N:pad_sz
- hb = hb + fft (postpad (b(i:i+N-1), N))(1:n);
- ha = ha + fft (postpad (a(i:i+N-1), N))(1:n);
+ tmp = fft (postpad (b(i:i+N-1), N));
+ hb = hb + tmp(1:n);
+ tmp = fft (postpad (a(i:i+N-1), N));
+ ha = ha + tmp(1:n);
endfor
endif
diff -r 6892c5562950 scripts/signal/periodogram.m
--- a/scripts/signal/periodogram.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/signal/periodogram.m Fri Jul 09 12:12:45 2010 +0200
@@ -1,5 +1,6 @@
## Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2005, 2007
## Friedrich Leisch
+## Copyright (C) 2010 Alois Schloegl
##
## This file is part of Octave.
##
@@ -18,33 +19,167 @@
## .
## -*- texinfo -*-
-## @deftypefn {Function File} {} periodogram (@var{x})
+## @deftypefn {Function File} {[Pxx,w]} = periodogram (@var{x})
## For a data matrix @var{x} from a sample of size @var{n}, return the
-## periodogram.
+## periodogram. w returns the angular frequency.
+##
+## [Pxx,w] = periodogram(@var{x}).
+##
+## [Pxx,w] = periodogram(@var{x},win).
+##
+## [Pxx,w] = periodogram(@var{x},win,nfft).
+##
+## [Pxx,f] = periodogram(@var{x},win,nfft,Fs).
+##
+## [Pxx,f] = periodogram(@var{x},win,nfft,Fs,'range').
+##
+## x data; if real-valued a one-sided spectrum is estimated, if complex-valued or range indicates 'twosided', the full spectrum is estimated.
+##
+## win weight data with window, x.*win is used for further computation, if window is empty, a rectangular window is used.
+##
+## nfft number of frequency bins, default max(256, 2.^ceil(log2(length(x)))).
+##
+## Fs sampleing rate, default 1.
+##
+## range: 'onesided' computes spectrum from [0..nfft/2+1].
+## 'twosided' computes spectrum from [0..nfft-1].
+## these strings can appear at any position in the list input arguments after window.
+##
+## Pxx one-, or two-sided power spectrum.
+##
+## w angular frequency [0..2*pi) (two-sided) or [0..pi] one-sided.
+##
+## f frequency [0..Fs) (two-sided) or [0..Fs/2] one-sided.
+##
+##
## @end deftypefn
-
+
## Author: FL
## Description: Compute the periodogram
-function retval = periodogram (x)
+function [pxx,f] = periodogram (x,varargin)
- if (nargin != 1)
+ %#### check input arguments ######
+
+ if nargin < 1 || nargin > 5,
print_usage ();
- endif
+ end % if
+ nfft = []; fs = []; range = []; window = [];
+ j = 1;
+ for k = 1:length(varargin)
+ if ischar(varargin{k})
+ range = varargin{k};
+ else
+ switch j
+ case 1
+ window = varargin{k};
+ case 2
+ nfft = varargin{k};
+ case 3
+ fs = varargin{k};
+ case 4
+ range = varargin{k};
+ end % switch
+ j = j+1;
+ end % if
+ end % for
+
[r, c] = size(x);
-
if (r == 1)
r = c;
- endif
+ end % if
- retval = (abs (fft (x - mean (x)))) .^ 2 / r;
+ if ischar(window)
+ range = window;
+ window = [];
+ end % if;
+ if ischar(nfft)
+ range = nfft;
+ nfft = [];
+ end % if;
+ if ischar(fs)
+ range = fs;
+ fs = [];
+ end % if;
-endfunction
+ if ~isempty(window)
+ if all(size(x)==size(window))
+ x = x .* window;
+ elseif size(x,1)==size(window,1) && size(window,2)==1,
+ x = x .* window(:,ones(1,c));
+ end % if;
+ end % if
+ if numel(nfft)>1,
+ error('nfft must be scalar');
+ end % if
+ if isempty(nfft)
+ nfft = max(256, 2.^ceil(log2(r)));
+ end % if
+ if strcmp(range,'onesided')
+ range = 1;
+ elseif strcmp(range,'twosided')
+ range = 2;
+ else
+ range = [];
+ end % if
+ if isempty(range)
+ range = 2-isreal(x);
+ end % if
+ %#### compute periodogram ######
+
+ if r>nfft,
+ Pxx = 0;
+ rr = rem(length(x),nfft);
+ if rr,
+ x = [x(:);zeros(nfft-rr,1)];
+ end;
+ x = sum(reshape(x,nfft,[]),2);
+ end % if
+ Pxx = (abs (fft (x, nfft))) .^ 2 / r;
+
+ if nargin<4,
+ Pxx = Pxx/(2*pi);
+ elseif ~isempty(fs)
+ Pxx = Pxx/fs;
+ end % if
+
+ %#### generate output arguments ######
+ if range==1, # onesided
+ Pxx = Pxx(1:nfft/2+1) + [0;Pxx(end:-1:(nfft/2+2));0];
+ end % if
-
-
+ if nargout~=1,
+ if range==1,
+ f = (0:nfft/2)'/nfft;
+ elseif range==2,
+ f = (0:nfft-1)'/nfft;
+ end % if
+ if nargin<4,
+ f = 2*pi*f; % generate w=2*pi*f
+ elseif ~isempty(fs)
+ f = f*fs;
+ end % if
+ end % if
+
+ if nargout==0,
+ if nargin<4,
+ plot(f/(2*pi), 10*log10(Pxx));
+ xlabel('normalized frequency [x pi rad]');
+ ylabel('Power density [dB/rad/sample]');
+ else
+ plot(f, 10*log10(Pxx));
+ xlabel('frequency [Hz]');
+ ylabel('Power density [dB/Hz]');
+ end
+ grid on;
+ title('Periodogram Power Spectral Density Estimate');
+ else
+ pxx = Pxx;
+ end % if
+
+end % function
diff -r 6892c5562950 scripts/special-matrix/hadamard.m
--- a/scripts/special-matrix/hadamard.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/special-matrix/hadamard.m Fri Jul 09 12:12:45 2010 +0200
@@ -125,8 +125,10 @@
function h = hnormalize (h)
## Make sure each row and column starts with +1.
- h(h(:,1)==-1,:) *= -1;
- h(:,h(1,:)==-1) *= -1;
+ ix = h(:,1)==-1;
+ h(ix,:) = -h(ix,:);
+ ix = h(1,:)==-1;
+ h(:,ix) = -h(:,ix);
endfunction
function h = h28 ()
diff -r 6892c5562950 scripts/special-matrix/toeplitz.m
--- a/scripts/special-matrix/toeplitz.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/special-matrix/toeplitz.m Fri Jul 09 12:12:45 2010 +0200
@@ -103,7 +103,7 @@
spdiags(repmat(r(ridx),nr,1),ridx-1,nr,nc);
else
## Concatenate data into a single column vector.
- data = [r(end:-1:2)(:); c(:)];
+ data = [reshape(r(end:-1:2),[],1); c(:)];
## Get slices.
slices = cellslices (data, nc:-1:1, nc+nr-1:-1:nr);
diff -r 6892c5562950 scripts/statistics/base/center.m
--- a/scripts/statistics/base/center.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/statistics/base/center.m Fri Jul 09 12:12:45 2010 +0200
@@ -37,7 +37,10 @@
endif
if (nargin < 2)
- dim = [find(size (x) != 1, 1), 1](1); # First non-singleton dim.
+ ### this is really a remarkable construct, does jwe make the code more complicated than necessary ???
+ ### whats the purpose of this, only to obfuscate the code ???
+ # dim = [find(size (a) != 1, 1), 1](1); # First non-singleton dim.
+ dim = find(size (a) != 1, 1); # First non-singleton dim.
endif
n = size (x, dim);
diff -r 6892c5562950 scripts/statistics/base/median.m
--- a/scripts/statistics/base/median.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/statistics/base/median.m Fri Jul 09 12:12:45 2010 +0200
@@ -55,7 +55,7 @@
print_usage ();
endif
if (nargin < 2)
- [~, dim] = max (size (a) != 1); # First non-singleton dim.
+ [tmp, dim] = max (size (a) != 1); # First non-singleton dim.
endif
if (numel (a) > 0)
diff -r 6892c5562950 scripts/statistics/base/mode.m
--- a/scripts/statistics/base/mode.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/statistics/base/mode.m Fri Jul 09 12:12:45 2010 +0200
@@ -79,11 +79,11 @@
t = cat (dim, true (sz2), diff (xs, 1, dim) != 0);
if (dim != 1)
- t2 (permute (t != 0, perm)) = diff ([find(permute (t, perm))(:); prod(sz)+1]);
+ t2 (permute (t != 0, perm)) = diff ([reshape(find(permute (t, perm)),[],1); prod(sz)+1]);
f = max (ipermute (t2, perm), [], dim);
xs = permute (xs, perm);
else
- t2 (t) = diff ([find(t)(:); prod(sz)+1]);
+ t2 (t) = diff ([reshape(find(t),[],1); prod(sz)+1]);
f = max (t2, [], dim);
endif
diff -r 6892c5562950 scripts/statistics/distributions/binornd.m
--- a/scripts/statistics/distributions/binornd.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/statistics/distributions/binornd.m Fri Jul 09 12:12:45 2010 +0200
@@ -101,8 +101,8 @@
L = length (k);
tmp = rand (N, L);
ind = (1 : N)' * ones (1, L);
- rnd(k) = sum ((tmp < ones (N, 1) * p(k)(:)') &
- (ind <= ones (N, 1) * n(k)(:)'),1);
+ rnd(k) = sum ((tmp < ones (N, 1) * reshape(p(k),[],1)') &
+ (ind <= ones (N, 1) * reshape(n(k),[],1)'),1);
endif
endif
diff -r 6892c5562950 scripts/statistics/distributions/cauchy_rnd.m
--- a/scripts/statistics/distributions/cauchy_rnd.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/statistics/distributions/cauchy_rnd.m Fri Jul 09 12:12:45 2010 +0200
@@ -84,7 +84,7 @@
rnd = NaN (sz);
k = find ((l > -Inf) & (l < Inf) & (scale > 0) & (scale < Inf));
if (any (k))
- rnd(k) = l(k)(:) - cot (pi * rand (size (k))) .* scale(k)(:);
+ rnd(k) = reshape(l(k),[],1) - cot (pi * rand (size (k))) .* reshape (scale(k),[],1);
endif
endif
diff -r 6892c5562950 scripts/statistics/distributions/discrete_cdf.m
--- a/scripts/statistics/distributions/discrete_cdf.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/statistics/distributions/discrete_cdf.m Fri Jul 09 12:12:45 2010 +0200
@@ -50,7 +50,8 @@
if (any (k))
n = length (k);
[vs, vi] = sort (v);
- cdf(k) = [0 ; cumsum(p(vi))](lookup (vs, x(k)) + 1);
+ tmp = [0 ; cumsum(p(vi))];
+ cdf(k) = tmp(lookup (vs, x(k)) + 1);
endif
endfunction
diff -r 6892c5562950 scripts/strings/base2dec.m
--- a/scripts/strings/base2dec.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/strings/base2dec.m Fri Jul 09 12:12:45 2010 +0200
@@ -67,7 +67,7 @@
elseif (base < 2 || base > length (symbols))
error ("base2dec: base must be between 2 and 36 or a string of symbols");
else
- d = toupper (d);
+ d = upper (d);
endif
## Right justify the values before anything else.
diff -r 6892c5562950 scripts/strings/dec2hex.m
--- a/scripts/strings/dec2hex.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/strings/dec2hex.m Fri Jul 09 12:12:45 2010 +0200
@@ -52,11 +52,11 @@
endfunction
-%!assert(strcmp (tolower (dec2hex (2748)), "abc"));
+%!assert(strcmp (lower (dec2hex (2748)), "abc"));
%!error dec2hex ();
-%!assert(strcmp (tolower (dec2hex (2748, 5)), "00abc"));
+%!assert(strcmp (lower (dec2hex (2748, 5)), "00abc"));
%!error dec2hex (1, 2, 3);
diff -r 6892c5562950 scripts/strings/index.m
--- a/scripts/strings/index.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/strings/index.m Fri Jul 09 12:12:45 2010 +0200
@@ -74,7 +74,7 @@
n = f(1);
endif
else
- error ("index: direction must be either \"first\" or \"last\"");
+ error ("index: direction must be either \'first\' or \'last\'");
endif
endfunction
diff -r 6892c5562950 scripts/strings/regexptranslate.m
--- a/scripts/strings/regexptranslate.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/strings/regexptranslate.m Fri Jul 09 12:12:45 2010 +0200
@@ -55,7 +55,7 @@
endif
if (ischar (op))
- op = tolower (op);
+ op = lower (op);
if (strcmp ("wildcard", op))
y = regexprep (regexprep (regexprep (x, "\\.", "\\."), "\\*",
".*"), "\\?", ".");
diff -r 6892c5562950 scripts/strings/strjust.m
--- a/scripts/strings/strjust.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/strings/strjust.m Fri Jul 09 12:12:45 2010 +0200
@@ -45,7 +45,7 @@
if (nargin == 1)
just = "right";
else
- just = tolower (just);
+ just = lower (just);
endif
if (ndims (x) != 2)
diff -r 6892c5562950 scripts/testfun/assert.m
--- a/scripts/testfun/assert.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/testfun/assert.m Fri Jul 09 12:12:45 2010 +0200
@@ -111,7 +111,7 @@
elseif (isstruct (expected))
if (! isstruct (cond) || any (size (cond) != size (expected))
- || rows (fieldnames (cond)) != rows (fieldnames (expected)))
+ || size (fieldnames (cond), 2) != size (fieldnames (expected), 2))
iserror = 1;
else
try
@@ -129,7 +129,7 @@
else
v = v(:)';
endif
- assert (v, {expected.(k)}, tol);
+ assert (v, {getfield(expected,k)}, tol);
endfor
catch
iserror = 1;
@@ -173,10 +173,7 @@
A = cond(:);
B = expected(:);
## Check exceptional values.
- if (any (isna (A) != isna (B)))
- iserror = 1;
- coda = "NAs don't match";
- elseif (any (isnan (A) != isnan (B)))
+ if (any (isnan (A) != isnan (B)))
iserror = 1;
coda = "NaNs don't match";
## Try to avoid problems comparing strange values like Inf+NaNi.
diff -r 6892c5562950 scripts/testfun/test.m
--- a/scripts/testfun/test.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/testfun/test.m Fri Jul 09 12:12:45 2010 +0200
@@ -563,7 +563,7 @@
## Create structure with fieldnames the name of the input variables.
function s = varstruct (varargin)
for i = 1:nargin
- s.(deblank (argn(i,:))) = varargin{i};
+ setfield(s, deblank (argn(i,:)), varargin{i});
endfor
endfunction
@@ -630,7 +630,7 @@
## (based on Etienne Grossmann's tar function).
function s = bundle (varargin)
for i = 1:nargin
- s.(deblank (argn(i,:))) = varargin{i};
+ setfield(s, deblank (argn(i,:)), varargin{i});
endfor
endfunction
diff -r 6892c5562950 scripts/time/addtodate.m
--- a/scripts/time/addtodate.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/time/addtodate.m Fri Jul 09 12:12:45 2010 +0200
@@ -51,11 +51,11 @@
if (any (strcmpi ({"year" "month"}, f)))
dtmp = datevec (d);
if (strcmpi ("year", f))
- dtmp(:,1) += q(:);
+ dtmp(:,1) = dtmp(:,1) + q(:);
elseif (strcmpi ("month", f))
- dtmp(:,2) += q(:);
+ dtmp(:,2) = dtmp(:,2) + q(:);
## adjust the years and months if the date rolls over a year
- dtmp(:,1) += floor ((dtmp(:,2)-1)/12);
+ dtmp(:,1) = dtmp(:,1) + floor ((dtmp(:,2)-1)/12);
dtmp(:,2) = mod (dtmp(:,2)-1, 12) + 1;
endif
dnew = datenum (dtmp);
diff -r 6892c5562950 scripts/time/datetick.m
--- a/scripts/time/datetick.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/time/datetick.m Fri Jul 09 12:12:45 2010 +0200
@@ -135,7 +135,7 @@
for i = 1 : length (objs)
fld = get (objs (i));
if (isfield (fld, strcat (ax, "data")))
- xdata = getfield (fld, strcat (ax, "data"))(:);
+ xdata = reshape (getfield (fld, strcat (ax, "data")), [], 1);
xmin = min (xmin, min (xdata));
xmax = max (xmax, max (xdata));
endif
diff -r 6892c5562950 scripts/time/datevec.m
--- a/scripts/time/datevec.m Thu Jul 08 13:51:37 2010 +0200
+++ b/scripts/time/datevec.m Fri Jul 09 12:12:45 2010 +0200
@@ -160,8 +160,9 @@
m = fix ((5 * c + 456) / 153);
d = c - fix ((153 * m - 457) / 5);
## Move to Jan 1 as start of year.
- ++y(m > 12);
- m(m > 12) -= 12;
+ ix = (m > 12);
+ y(ix) = y(ix) + 1;
+ m(ix) = m(ix) - 12;
## Convert hour-minute-seconds. Attempt to account for precision of
## datenum format.