annotate examples/@polynomial/subsref.m @ 15163:886d1fc9d575 gui

GUI branch merged in, closing the GUI branch
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Mon, 13 Aug 2012 11:01:26 -0400
parents 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