Mercurial > hg > octave-nkf
annotate examples/code/celldemo.cc @ 20794:e5986cba4ca8
new octave_value::cell_value method with optional error message
* ov.h, ov.cc (octave_value::cell_value): New method.
* ov-base.h, ov-base.cc (octave_base_value::cell_value):
New default method.
* ov-cell.h, ov-cell.cc (octave_cell::cell_value): New method.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 09 Oct 2015 14:41:49 -0400 |
parents | 2f8500ca91d3 |
children |
rev | line source |
---|---|
6572 | 1 #include <octave/oct.h> |
2 #include <octave/Cell.h> | |
3 | |
12174 | 4 DEFUN_DLD (celldemo, args, , "Cell Demo") |
6572 | 5 { |
6 octave_value_list retval; | |
20753
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
7 |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
8 if (args.length () != 1) |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
9 print_usage (); |
6572 | 10 |
20753
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
11 Cell c = args(0).cell_value (); |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
12 |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
13 for (octave_idx_type i = 0; i < c.numel (); i++) |
6572 | 14 { |
20753
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
15 retval(i) = c(i); // using operator syntax |
2f8500ca91d3
eliminate error_state from example files
John W. Eaton <jwe@octave.org>
parents:
19225
diff
changeset
|
16 //retval(i) = c.elem (i); // using method syntax |
6572 | 17 } |
9053
4295d634797d
remove copyright notices from example files
John W. Eaton <jwe@octave.org>
parents:
7081
diff
changeset
|
18 |
6572 | 19 return retval; |
20 } |