Mercurial > octave
annotate examples/code/@polynomial/subsasgn.m @ 21072:a9ed4104ecfd
doc: Rewrite documentation for Object Oriented Programming.
* octave.texi: Rename "Manipulating Classes" node to "Class Methods"
* oop.txi: Rewrite signicant parts of Object Oriented Programming chapter.
* examples/code/@FIRfilter/subsasgn.m, examples/code/@FIRfilter/subsref.m,
examples/code/@polynomial/get.m, examples/code/@polynomial/subsasgn.m:
Enclose property in error messages in double quotes ("%s").
* examples/code/@polynomial/subsref.m: Rename input object to 'p'.
Rename variable "ind" to "idx". Enclose property in error messages in double
quotes ("%s").
* ov-class.cc (Fsuperiorto, Finferiorto): Improve docstrings.
* ov-usr-fcn.cc (Foptimize_subsasgn_calls): Improve docstring.
* ov.cc (Fsubsref, Fsubsasgn): Improve docstrings.
* display.m: Rewrite docstring. Rename input variable to "obj". Remove unused
output variable from function declaration.
* subsindex.m: Rename input variable to "obj". Rewrite examples in docstring.
Add input validation and BIST tests to m-file.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 14 Jan 2016 13:30:22 -0800 |
parents | fd97ed44f2da |
children |
rev | line source |
---|---|
9285
226f6d001ee2
further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9284
diff
changeset
|
1 function p = subsasgn (p, s, val) |
21059
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
2 |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
3 if (isempty (s)) |
20726
25d676f9619c
Preface error() messages with name of function when possible.
Rik <rik@octave.org>
parents:
19596
diff
changeset
|
4 error ("@polynomial/subsasgn: needs index"); |
9285
226f6d001ee2
further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9284
diff
changeset
|
5 endif |
21059
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
6 |
9285
226f6d001ee2
further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9284
diff
changeset
|
7 switch (s(1).type) |
21059
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
8 |
9285
226f6d001ee2
further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9284
diff
changeset
|
9 case "{}" |
226f6d001ee2
further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9284
diff
changeset
|
10 ind = s(1).subs; |
226f6d001ee2
further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9284
diff
changeset
|
11 if (numel (ind) != 1) |
20726
25d676f9619c
Preface error() messages with name of function when possible.
Rik <rik@octave.org>
parents:
19596
diff
changeset
|
12 error ("@polynomial/subsasgn: need exactly one index"); |
21059
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
13 elseif (numel (s) != 1) |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
14 error ("@polynomial/subsasgn: chained subscripts not allowed for {}"); |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
15 endif |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
16 |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
17 if (isnumeric (ind{1})) |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
18 p.poly(ind{1}+1) = val; |
9285
226f6d001ee2
further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9284
diff
changeset
|
19 else |
21059
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
20 p.poly(ind{1}) = val; |
8223
0c91b9a17dcf
Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
21 endif |
21059
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
22 |
8223
0c91b9a17dcf
Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
23 case "." |
9285
226f6d001ee2
further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9284
diff
changeset
|
24 fld = s(1).subs; |
21059
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
25 if (! strcmp (fld, "poly")) |
21072
a9ed4104ecfd
doc: Rewrite documentation for Object Oriented Programming.
Rik <rik@octave.org>
parents:
21070
diff
changeset
|
26 error ('@polynomial/subsasgn: invalid property "%s"', fld); |
9284
567e3e4ab74d
fix up examples/@polynomial
Robert T. Short <octave@phaselockedsystems.com>
parents:
8256
diff
changeset
|
27 endif |
21059
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
28 if (numel (s) == 1) |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
29 p.poly = val; |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
30 else |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
31 p.poly = subsasgn (p.poly, s(2:end), val); |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
32 endif |
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
33 |
9285
226f6d001ee2
further improve the polynomial example, fix indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
9284
diff
changeset
|
34 otherwise |
20726
25d676f9619c
Preface error() messages with name of function when possible.
Rik <rik@octave.org>
parents:
19596
diff
changeset
|
35 error ("@polynomial/subsasgn: invalid subscript type"); |
21070
fd97ed44f2da
doc: Use more coding conventions in Object Oriented reference example code.
Rik <rik@octave.org>
parents:
21059
diff
changeset
|
36 |
8223
0c91b9a17dcf
Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
37 endswitch |
21059
73ab962bc52d
doc: Use newer coding conventions in examples/code directory.
Rik <rik@octave.org>
parents:
20726
diff
changeset
|
38 |
8223
0c91b9a17dcf
Commit missing files from previous change
David Bateman <dbateman@free.fr>
parents:
diff
changeset
|
39 endfunction |