Mercurial > hg > octave-nkf
annotate scripts/general/structfun.m @ 14363:f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
* wavread.m, acosd.m, acot.m, acotd.m, acoth.m, acsc.m, acscd.m, acsch.m,
asec.m, asecd.m, asech.m, asind.m, atand.m, cosd.m, cot.m, cotd.m, coth.m,
csc.m, cscd.m, csch.m, sec.m, secd.m, sech.m, sind.m, tand.m, accumarray.m,
accumdim.m, bitcmp.m, bitget.m, bitset.m, blkdiag.m, cart2pol.m, cart2sph.m,
celldisp.m, chop.m, circshift.m, colon.m, common_size.m, cplxpair.m,
cumtrapz.m, curl.m, dblquad.m, deal.m, divergence.m, flipdim.m, fliplr.m,
flipud.m, genvarname.m, gradient.m, idivide.m, int2str.m, interp1.m,
interp1q.m, interp2.m, interp3.m, interpft.m, interpn.m, isa.m, isdir.m,
isequal.m, isequalwithequalnans.m, issquare.m, logspace.m, nargchk.m,
narginchk.m, nargoutchk.m, nextpow2.m, nthargout.m, num2str.m, pol2cart.m,
polyarea.m, postpad.m, prepad.m, profile.m, profshow.m, quadgk.m, quadv.m,
randi.m, rat.m, repmat.m, rot90.m, rotdim.m, shift.m, shiftdim.m, sph2cart.m,
structfun.m, trapz.m, triplequad.m, convhull.m, dsearch.m, dsearchn.m,
griddata3.m, griddatan.m, rectint.m, tsearchn.m, __makeinfo__.m, doc.m,
get_first_help_sentence.m, help.m, type.m, unimplemented.m, which.m, imread.m,
imwrite.m, dlmwrite.m, fileread.m, is_valid_file_id.m, strread.m, textread.m,
textscan.m, commutation_matrix.m, cond.m, condest.m, cross.m,
duplication_matrix.m, expm.m, housh.m, isdefinite.m, ishermitian.m,
issymmetric.m, logm.m, normest.m, null.m, onenormest.m, orth.m, planerot.m,
qzhess.m, rank.m, rref.m, trace.m, vech.m, ans.m, bincoeff.m, bug_report.m,
bzip2.m, comma.m, compare_versions.m, computer.m, edit.m, fileparts.m,
fullfile.m, getfield.m, gzip.m, info.m, inputname.m, isappdata.m, isdeployed.m,
ismac.m, ispc.m, isunix.m, list_primes.m, ls.m, mexext.m, namelengthmax.m,
news.m, orderfields.m, paren.m, recycle.m, rmappdata.m, semicolon.m,
setappdata.m, setfield.m, substruct.m, symvar.m, ver.m, version.m,
warning_ids.m, xor.m, fminbnd.m, fsolve.m, fzero.m, lsqnonneg.m, optimset.m,
pqpnonneg.m, sqp.m, matlabroot.m, __gnuplot_drawnow__.m,
__plt_get_axis_arg__.m, ancestor.m, cla.m, clf.m, close.m, colorbar.m,
colstyle.m, comet3.m, contourc.m, figure.m, gca.m, gcbf.m, gcbo.m, gcf.m,
ginput.m, graphics_toolkit.m, gtext.m, hggroup.m, hist.m, hold.m, isfigure.m,
ishghandle.m, ishold.m, isocolors.m, isonormals.m, isosurface.m, isprop.m,
legend.m, line.m, loglog.m, loglogerr.m, meshgrid.m, ndgrid.m, newplot.m,
orient.m, patch.m, plot3.m, plotyy.m, __print_parse_opts__.m, quiver3.m,
refreshdata.m, ribbon.m, semilogx.m, semilogxerr.m, semilogy.m, stem.m,
stem3.m, subplot.m, title.m, uigetfile.m, view.m, whitebg.m, compan.m, conv.m,
deconv.m, mkpp.m, mpoles.m, pchip.m, poly.m, polyaffine.m, polyder.m,
polyfit.m, polygcd.m, polyint.m, polyout.m, polyval.m, polyvalm.m, ppder.m,
ppint.m, ppjumps.m, ppval.m, residue.m, roots.m, spline.m, intersect.m,
ismember.m, powerset.m, setdiff.m, setxor.m, union.m, unique.m,
autoreg_matrix.m, bartlett.m, blackman.m, detrend.m, fftconv.m, fftfilt.m,
fftshift.m, freqz.m, hamming.m, hanning.m, ifftshift.m, sinc.m, sinetone.m,
sinewave.m, unwrap.m, bicg.m, bicgstab.m, gmres.m, gplot.m, nonzeros.m, pcg.m,
pcr.m, spaugment.m, spconvert.m, spdiags.m, speye.m, spfun.m, spones.m,
sprand.m, sprandsym.m, spstats.m, spy.m, svds.m, treelayout.m, bessel.m,
beta.m, betaln.m, factor.m, factorial.m, isprime.m, lcm.m, legendre.m,
nchoosek.m, nthroot.m, perms.m, pow2.m, primes.m, reallog.m, realpow.m,
realsqrt.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, rosser.m,
vander.m, __finish__.m, center.m, cloglog.m, corr.m, cov.m, gls.m, histc.m,
iqr.m, kendall.m, kurtosis.m, logit.m, mahalanobis.m, mean.m, meansq.m,
median.m, mode.m, moment.m, ols.m, ppplot.m, prctile.m, probit.m, quantile.m,
range.m, ranks.m, run_count.m, runlength.m, skewness.m, spearman.m,
statistics.m, std.m, table.m, var.m, zscore.m, betacdf.m, betainv.m, betapdf.m,
betarnd.m, binocdf.m, binoinv.m, binopdf.m, binornd.m, cauchy_cdf.m,
cauchy_inv.m, cauchy_pdf.m, cauchy_rnd.m, chi2cdf.m, chi2inv.m, chi2pdf.m,
chi2rnd.m, discrete_cdf.m, discrete_inv.m, discrete_pdf.m, discrete_rnd.m,
empirical_cdf.m, empirical_inv.m, empirical_pdf.m, empirical_rnd.m, expcdf.m,
expinv.m, exppdf.m, exprnd.m, fcdf.m, finv.m, fpdf.m, frnd.m, gamcdf.m,
gaminv.m, gampdf.m, gamrnd.m, geocdf.m, geoinv.m, geopdf.m, geornd.m,
hygecdf.m, hygeinv.m, hygepdf.m, hygernd.m, kolmogorov_smirnov_cdf.m,
laplace_cdf.m, laplace_inv.m, laplace_pdf.m, laplace_rnd.m, logistic_cdf.m,
logistic_inv.m, logistic_pdf.m, logistic_rnd.m, logncdf.m, logninv.m,
lognpdf.m, lognrnd.m, nbincdf.m, nbininv.m, nbinpdf.m, nbinrnd.m, normcdf.m,
norminv.m, normpdf.m, normrnd.m, poisscdf.m, poissinv.m, poisspdf.m,
poissrnd.m, stdnormal_cdf.m, stdnormal_inv.m, stdnormal_pdf.m, stdnormal_rnd.m,
tcdf.m, tinv.m, tpdf.m, trnd.m, unidcdf.m, unidinv.m, unidpdf.m, unidrnd.m,
unifcdf.m, unifinv.m, unifpdf.m, unifrnd.m, wblcdf.m, wblinv.m, wblpdf.m,
wblrnd.m, kolmogorov_smirnov_test.m, kruskal_wallis_test.m, base2dec.m,
bin2dec.m, blanks.m, cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m,
findstr.m, hex2dec.m, index.m, isletter.m, mat2str.m, rindex.m, str2num.m,
strcat.m, strjust.m, strmatch.m, strsplit.m, strtok.m, strtrim.m, strtrunc.m,
substr.m, validatestring.m, demo.m, example.m, fail.m, speed.m, addtodate.m,
asctime.m, clock.m, ctime.m, date.m, datenum.m, datetick.m, datevec.m,
eomday.m, etime.m, is_leap_year.m, now.m:
Use Octave coding conventions in all m-file %!test blocks
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 13 Feb 2012 07:29:44 -0800 |
parents | 4d917a6a858b |
children | 7eff3032d144 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13305
diff
changeset
|
1 ## Copyright (C) 2007-2012 David Bateman |
10132
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
2 ## Copyright (C) 2010 VZLU Prague |
6863 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
6863 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
6863 | 19 |
20 ## -*- texinfo -*- | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11190
diff
changeset
|
21 ## @deftypefn {Function File} {} structfun (@var{func}, @var{S}) |
11471
994e2a93a8e2
Use uppercase 'A' to refer to matrix inputs in m-files.
Rik <octave@nomad.inbox5.com>
parents:
11469
diff
changeset
|
22 ## @deftypefnx {Function File} {[@var{A}, @dots{}] =} structfun (@dots{}) |
8507 | 23 ## @deftypefnx {Function File} {} structfun (@dots{}, "ErrorHandler", @var{errfunc}) |
24 ## @deftypefnx {Function File} {} structfun (@dots{}, "UniformOutput", @var{val}) | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
25 ## |
6863 | 26 ## Evaluate the function named @var{name} on the fields of the structure |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11190
diff
changeset
|
27 ## @var{S}. The fields of @var{S} are passed to the function @var{func} |
6863 | 28 ## individually. |
29 ## | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
30 ## @code{structfun} accepts an arbitrary function @var{func} in the form of |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
31 ## an inline function, function handle, or the name of a function (in a |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
32 ## character string). In the case of a character string argument, the |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
33 ## function must accept a single argument named @var{x}, and it must return |
9036
58604c45ca74
Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
34 ## a string value. If the function returns more than one argument, they are |
6863 | 35 ## returned as separate output variables. |
36 ## | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
37 ## If the parameter "UniformOutput" is set to true (the default), then the |
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
38 ## function |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
7208
diff
changeset
|
39 ## must return a single element which will be concatenated into the |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
40 ## return value. If "UniformOutput" is false, the outputs are placed into a |
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
10687
diff
changeset
|
41 ## structure |
6863 | 42 ## with the same fieldnames as the input structure. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
43 ## |
6863 | 44 ## @example |
45 ## @group | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
46 ## s.name1 = "John Smith"; |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
47 ## s.name2 = "Jill Jones"; |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
48 ## structfun (@@(x) regexp (x, '(\w+)$', "matches")@{1@}, s, |
8507 | 49 ## "UniformOutput", false) |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
50 ## @result{} |
10122
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9036
diff
changeset
|
51 ## @{ |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9036
diff
changeset
|
52 ## name1 = Smith |
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9036
diff
changeset
|
53 ## name2 = Jones |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
54 ## @} |
6863 | 55 ## @end group |
56 ## @end example | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
57 ## |
10122
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9036
diff
changeset
|
58 ## Given the parameter "ErrorHandler", @var{errfunc} defines a function to |
9036
58604c45ca74
Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
59 ## call in case @var{func} generates an error. The form of the function is |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
60 ## |
6863 | 61 ## @example |
62 ## function [@dots{}] = errfunc (@var{se}, @dots{}) | |
63 ## @end example | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
64 ## |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
65 ## @noindent |
6863 | 66 ## where there is an additional input argument to @var{errfunc} relative to |
9036
58604c45ca74
Cleanup of data types related documentation
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
67 ## @var{func}, given by @var{se}. This is a structure with the elements |
8507 | 68 ## "identifier", "message" and "index", giving respectively the error |
6863 | 69 ## identifier, the error message, and the index into the input arguments |
10122
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9036
diff
changeset
|
70 ## of the element that caused the error. For an example on how to use |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
71 ## an error handler, @pxref{doc-cellfun, @code{cellfun}}. |
10122
9d1a14e12431
Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9036
diff
changeset
|
72 ## |
10687
a8ce6bdecce5
Improve documentation strings.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
73 ## @seealso{cellfun, arrayfun, spfun} |
6863 | 74 ## @end deftypefn |
75 | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11190
diff
changeset
|
76 function varargout = structfun (func, S, varargin); |
10134
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
77 |
6863 | 78 if (nargin < 2) |
79 print_usage (); | |
80 endif | |
81 | |
10134
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
82 nargs = length (varargin); |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
83 |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
84 recognized_opts = {"UniformOutput", "ErrorHandler"}; |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
85 uo_str = recognized_opts{1}; |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
86 |
10132
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
87 uniform_output = true; |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
88 |
10134
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
89 while (nargs >= 2) |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
90 opt_match = strcmpi (varargin{nargs-1}, recognized_opts); |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
91 if (opt_match(1)) |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
92 uniform_output = varargin{nargs}; |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
93 endif |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
94 if (any (opt_match)) |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
95 nargs -= 2; |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
96 else |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
97 break; |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
98 endif |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
99 endwhile |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
100 |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
101 if (nargs > 0) |
be13fa20656a
error on invalid opts in structfun
Jaroslav Hajek <highegg@gmail.com>
parents:
10132
diff
changeset
|
102 error ("structfun: invalid options"); |
10132
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
103 endif |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
104 |
6863 | 105 varargout = cell (max ([nargout, 1]), 1); |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11190
diff
changeset
|
106 [varargout{:}] = cellfun (func, struct2cell (S), varargin{:}); |
6863 | 107 |
10132
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
108 if (! uniform_output) |
12931
cefd568ea073
Replace function handles with function names in cellfun calls for 15% speedup.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
109 varargout = cellfun ("cell2struct", varargout, {fieldnames(S)}, {1}, uo_str, false); |
6863 | 110 endif |
111 endfunction | |
112 | |
113 | |
114 %!test | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
115 %! s.name1 = "John Smith"; |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
116 %! s.name2 = "Jill Jones"; |
6863 | 117 %! l.name1 = "Smith"; |
118 %! l.name2 = "Jones"; | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
119 %! o = structfun (@(x) regexp (x, '(\w+)$', "matches"){1}, s, |
10549 | 120 %! "UniformOutput", false); |
6863 | 121 %! assert (o, l); |
10132
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
122 |
13305
63463570d9fe
Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents:
12931
diff
changeset
|
123 %!function [a, b] = __twoouts (x) |
10132
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
124 %! a = x + x; |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
125 %! b = x * x; |
13305
63463570d9fe
Add %!endfunction block keyword to test.m
Rik <octave@nomad.inbox5.com>
parents:
12931
diff
changeset
|
126 %!endfunction |
10132
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
127 |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
128 %!test |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
129 %! s = struct ("a", {1, 2, 3}, "b", {4, 5, 6}); |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
130 %! c(1:2, 1, 1) = [2; 8]; |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
131 %! c(1:2, 1, 2) = [4; 10]; |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
132 %! c(1:2, 1, 3) = [6; 12]; |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
133 %! d(1:2, 1, 1) = [1; 16]; |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
134 %! d(1:2, 1, 2) = [4; 25]; |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
135 %! d(1:2, 1, 3) = [9; 36]; |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
136 %! [aa, bb] = structfun (@__twoouts, s); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
137 %! assert (aa, c); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
138 %! assert (bb, d); |
10132
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
139 |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
140 %!test |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
141 %! s = struct ("a", {1, 2, 3}, "b", {4, 5, 6}); |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
142 %! c = struct ("a", {2, 4, 6}, "b", {8, 10, 12}); |
aa0f575cf39b
improve structfun's Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents:
10122
diff
changeset
|
143 %! d = struct ("a", {1, 4, 9}, "b", {16, 25, 36}); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
144 %! [aa, bb] = structfun (@__twoouts, s, "UniformOutput", false); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
145 %! assert (aa, c); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
146 %! assert (bb, d); |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
147 |