Mercurial > hg > octave-nkf
comparison scripts/general/cell2mat.m @ 12931:cefd568ea073
Replace function handles with function names in cellfun calls for 15% speedup.
* accumarray.m arrayfun.m, blkdiag.m, cell2mat.m, common_size.m, interp3.m,
interpn.m, __isequal__.m, structfun.m, voronoi.m, strread.m, fullfile.m,
getfield.m, __xzip__.m, setfield.m, what.m, pkg.m, axis.m, pareto.m,
__ghostscript__.m, __go_draw_axes__.m, __patch__.m, refreshdata.m, whitebg.m,
lcm.m, index.m, strcat.m, strmatch.m, validatestring.m: Replace function
handles in calls to cellfun with double quoted function names.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sat, 06 Aug 2011 18:03:18 -0700 |
parents | c792872f8942 |
children | 72c96de7a403 |
comparison
equal
deleted
inserted
replaced
12930:7bd29d875af1 | 12931:cefd568ea073 |
---|---|
41 if (nb == 0) | 41 if (nb == 0) |
42 m = []; | 42 m = []; |
43 else | 43 else |
44 | 44 |
45 ## We only want numeric, logical, and char matrices. | 45 ## We only want numeric, logical, and char matrices. |
46 valid = cellfun (@isnumeric, c); | 46 valid = cellfun ("isnumeric", c); |
47 valid |= cellfun (@islogical, c); | 47 valid |= cellfun ("islogical", c); |
48 valid |= cellfun (@ischar, c); | 48 valid |= cellfun ("isclass", c, "char"); |
49 validc = cellfun (@iscell, c); | 49 validc = cellfun ("isclass", c, "cell"); |
50 valids = cellfun (@isstruct, c); | 50 valids = cellfun ("isclass", c, "struct"); |
51 | 51 |
52 if (! all (valid(:)) && ! all (validc(:)) && ! all (valids(:))) | 52 if (! all (valid(:)) && ! all (validc(:)) && ! all (valids(:))) |
53 error ("cell2mat: wrong type elements or mixed cells, structs and matrices"); | 53 error ("cell2mat: wrong type elements or mixed cells, structs and matrices"); |
54 endif | 54 endif |
55 | 55 |
69 if (sc(idim) == 1) | 69 if (sc(idim) == 1) |
70 continue; | 70 continue; |
71 endif | 71 endif |
72 xdim = [1:idim-1, idim+1:nd]; | 72 xdim = [1:idim-1, idim+1:nd]; |
73 cc = num2cell (c, xdim); | 73 cc = num2cell (c, xdim); |
74 c = cellfun (@cat, {idim}, cc{:}, "uniformoutput", false); | 74 c = cellfun ("cat", {idim}, cc{:}, "uniformoutput", false); |
75 endfor | 75 endfor |
76 m = c{1}; | 76 m = c{1}; |
77 endif | 77 endif |
78 | 78 |
79 endfunction | 79 endfunction |