annotate examples/code/@polynomial/subsref.m @ 19225:c8240a60dd01

Add penny.mat to build system. * examples/data/penny.mat: New example data file. * examples/data/Makefile.am: Automake file for new directory of example data files. * examples/Makefile.am: Change to be just a pass-through to the subdirectories code/ and data/. * examples/@FIRfilter/FIRfilter.m, examples/@FIRfilter/FIRfilter_aggregation.m, examples/@FIRfilter/display.m, examples/@FIRfilter/module.mk, examples/@FIRfilter/subsasgn.m, examples/@FIRfilter/subsref.m, examples/@polynomial/display.m, examples/@polynomial/double.m, examples/@polynomial/end.m, examples/@polynomial/get.m, examples/@polynomial/module.mk, examples/@polynomial/mtimes.m, examples/@polynomial/numel.m, examples/@polynomial/plot.m, examples/@polynomial/polynomial.m, examples/@polynomial/polynomial_superiorto.m, examples/@polynomial/polyval.m, examples/@polynomial/roots.m, examples/@polynomial/set.m, examples/@polynomial/subsasgn.m, examples/@polynomial/subsref.m, examples/COPYING, examples/addtwomatrices.cc, examples/celldemo.cc, examples/embedded.cc, examples/fortrandemo.cc, examples/fortransub.f, examples/funcdemo.cc, examples/globaldemo.cc, examples/helloworld.cc, examples/make_int.cc, examples/mex_demo.c, examples/mycell.c, examples/myfeval.c, examples/myfevalf.f, examples/myfunc.c, examples/myhello.c, examples/mypow2.c, examples/myprop.c, examples/myset.c, examples/mysparse.c, examples/mystring.c, examples/mystruct.c, examples/oct_demo.cc, examples/oregonator.cc, examples/oregonator.m, examples/paramdemo.cc, examples/standalone.cc, examples/standalonebuiltin.cc, examples/stringdemo.cc, examples/structdemo.cc, examples/unwinddemo.cc: Move current example files to examples/code/ directory. * configure.ac: Add Makefiles in examples/code and examples/data directories. * build-aux/common.mk: Define octdatadir variable. * doc/interpreter/Makefile.am: Change location of External Code Interface examples to examples/code directory. * doc/interpreter/munge-texi.pl: Expand EXAMPLEFILE macro to examples/code directory.
author Rik <rik@octave.org>
date Tue, 19 Aug 2014 14:32:44 -0700
parents examples/@polynomial/subsref.m@bf6da2fbfa4e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8223
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
1 function b = subsref (a, s)
9285
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
2 if (isempty (s))
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
3 error ("polynomial: missing index");
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
4 endif
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
5 switch (s(1).type)
8223
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 case "()"
9285
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
7 ind = s(1).subs;
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
8 if (numel (ind) != 1)
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
9 error ("polynomial: need exactly one index");
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
10 else
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
11 b = polyval (fliplr (a.poly), ind{1});
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
12 endif
8223
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 case "{}"
9285
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
14 ind = s(1).subs;
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
15 if (numel (ind) != 1)
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
16 error ("polynomial: need exactly one index");
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
17 else
9332
bf6da2fbfa4e examples/polynomial: properly handle magic colon
Jaroslav Hajek <highegg@gmail.com>
parents: 9285
diff changeset
18 if (isnumeric (ind{1}))
bf6da2fbfa4e examples/polynomial: properly handle magic colon
Jaroslav Hajek <highegg@gmail.com>
parents: 9285
diff changeset
19 b = a.poly(ind{1}+1);
bf6da2fbfa4e examples/polynomial: properly handle magic colon
Jaroslav Hajek <highegg@gmail.com>
parents: 9285
diff changeset
20 else
bf6da2fbfa4e examples/polynomial: properly handle magic colon
Jaroslav Hajek <highegg@gmail.com>
parents: 9285
diff changeset
21 b = a.poly(ind{1});
bf6da2fbfa4e examples/polynomial: properly handle magic colon
Jaroslav Hajek <highegg@gmail.com>
parents: 9285
diff changeset
22 endif
9285
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
23 endif
8223
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
24 case "."
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
25 fld = s.subs;
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
26 if (strcmp (fld, "poly"))
9284
567e3e4ab74d fix up examples/@polynomial
Robert T. Short <octave@phaselockedsystems.com>
parents: 8516
diff changeset
27 b = a.poly;
8223
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
28 else
9284
567e3e4ab74d fix up examples/@polynomial
Robert T. Short <octave@phaselockedsystems.com>
parents: 8516
diff changeset
29 error ("@polynomial/subsref: invalid property \"%s\"", fld);
8223
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
30 endif
9285
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
31 otherwise
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
32 error ("invalid subscript type");
8223
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
33 endswitch
9285
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
34 if (numel (s) > 1)
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
35 b = subsref (b, s(2:end));
226f6d001ee2 further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 9284
diff changeset
36 endif
8223
0c91b9a17dcf Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff changeset
37 endfunction