annotate libinterp/octave-value/ov-cell.cc @ 20163:075a5e2e1ba5 stable

doc: Update more docstrings to have one sentence summary as first line. Reviewed build-aux, libinterp/dldfcn, libinterp/octave-value, libinterp/parse-tree directories. * build-aux/mk-opts.pl, libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/amd.cc, libinterp/dldfcn/audiodevinfo.cc, libinterp/dldfcn/audioread.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc, libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-bool-mat.cc, libinterp/octave-value/ov-cell.cc, libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov.cc, libinterp/parse-tree/lex.ll, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-mat.cc: doc: Update more docstrings to have one sentence summary as first line.
author Rik <rik@octave.org>
date Sun, 03 May 2015 21:52:42 -0700
parents 09ed6f7538dd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
1 /*
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19598
diff changeset
3 Copyright (C) 1999-2015 John W. Eaton
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11474
diff changeset
4 Copyright (C) 2009-2010 VZLU Prague
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
5
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
7
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
11 option) any later version.
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
12
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
16 for more details.
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
17
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
20 <http://www.gnu.org/licenses/>.
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
21
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
22 */
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
23
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
25 #include <config.h>
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
26 #endif
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
27
5850
426b94346d70 [project @ 2006-06-09 15:44:35 by jwe]
jwe
parents: 5846
diff changeset
28 #include <iomanip>
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3448
diff changeset
29 #include <iostream>
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
30 #include <sstream>
5164
57077d0ddc8e [project @ 2005-02-25 19:55:24 by jwe]
jwe
parents: 5157
diff changeset
31 #include <vector>
9370
4ff6f8efdda2 fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 9338
diff changeset
32 #include <queue>
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
33
5360
33adb987c033 [project @ 2005-05-23 16:19:56 by jwe]
jwe
parents: 5351
diff changeset
34 #include "Array-util.h"
33adb987c033 [project @ 2005-05-23 16:19:56 by jwe]
jwe
parents: 5351
diff changeset
35 #include "byte-swap.h"
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
36 #include "lo-utils.h"
4153
6b96ce9f5743 [project @ 2002-11-06 20:38:49 by jwe]
jwe
parents: 4066
diff changeset
37 #include "quit.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 8290
diff changeset
38 #include "oct-locbuf.h"
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
39
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
40 #include "defun.h"
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
41 #include "error.h"
15149
62a35ae7d6a2 use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents: 15057
diff changeset
42 #include "mxarray.h"
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
43 #include "ov-cell.h"
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
44 #include "oct-obj.h"
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
45 #include "oct-hdf5.h"
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
46 #include "unwind-prot.h"
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
47 #include "utils.h"
3928
e8627dc4bdf2 [project @ 2002-05-03 19:56:01 by jwe]
jwe
parents: 3538
diff changeset
48 #include "ov-base-mat.h"
e8627dc4bdf2 [project @ 2002-05-03 19:56:01 by jwe]
jwe
parents: 3538
diff changeset
49 #include "ov-base-mat.cc"
e8627dc4bdf2 [project @ 2002-05-03 19:56:01 by jwe]
jwe
parents: 3538
diff changeset
50 #include "ov-re-mat.h"
e8627dc4bdf2 [project @ 2002-05-03 19:56:01 by jwe]
jwe
parents: 3538
diff changeset
51 #include "ov-scalar.h"
5360
33adb987c033 [project @ 2005-05-23 16:19:56 by jwe]
jwe
parents: 5351
diff changeset
52 #include "pr-output.h"
33adb987c033 [project @ 2005-05-23 16:19:56 by jwe]
jwe
parents: 5351
diff changeset
53 #include "ov-scalar.h"
8579
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8551
diff changeset
54 #include "gripes.h"
3928
e8627dc4bdf2 [project @ 2002-05-03 19:56:01 by jwe]
jwe
parents: 3538
diff changeset
55
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
56 #include "ls-oct-ascii.h"
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
57 #include "ls-oct-binary.h"
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
58 #include "ls-hdf5.h"
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
59 #include "ls-utils.h"
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
60
8679
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
61 // Cell is able to handle octave_value indexing by itself, so just forward
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
62 // everything.
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
63
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
64 template <>
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
65 octave_value
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
66 octave_base_matrix<Cell>::do_index_op (const octave_value_list& idx,
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
67 bool resize_ok)
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
68 {
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
69 return matrix.index (idx, resize_ok);
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
70 }
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
71
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
72 template <>
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
73 void
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
74 octave_base_matrix<Cell>::assign (const octave_value_list& idx, const Cell& rhs)
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
75 {
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
76 matrix.assign (idx, rhs);
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
77 }
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
78
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
79 template <>
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
80 void
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
81 octave_base_matrix<Cell>::assign (const octave_value_list& idx,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
82 octave_value rhs)
8679
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
83 {
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
84 // FIXME: Really?
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
85 if (rhs.is_cell ())
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
86 matrix.assign (idx, rhs.cell_value ());
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
87 else
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
88 matrix.assign (idx, Cell (rhs));
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
89 }
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
90
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
91 template <>
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
92 void
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
93 octave_base_matrix<Cell>::delete_elements (const octave_value_list& idx)
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
94 {
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
95 matrix.delete_elements (idx);
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
96 }
280fae940bb0 optimize scalar indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8626
diff changeset
97
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
98 // FIXME: this list of specializations is becoming so long that we should
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
99 // really ask whether octave_cell should inherit from octave_base_matrix at all.
10670
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
100
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
101 template <>
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
102 octave_value
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
103 octave_base_matrix<Cell>::fast_elem_extract (octave_idx_type n) const
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
104 {
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
105 if (n < matrix.numel ())
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
106 return Cell (matrix(n));
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
107 else
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
108 return octave_value ();
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
109 }
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
110
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
111 template <>
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
112 bool
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
113 octave_base_matrix<Cell>::fast_elem_insert (octave_idx_type n,
10670
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
114 const octave_value& x)
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
115 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
116 const octave_cell *xrep =
10670
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
117 dynamic_cast<const octave_cell *> (&x.get_rep ());
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
118
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
119 bool retval = xrep && xrep->matrix.numel () == 1 && n < matrix.numel ();
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
120 if (retval)
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
121 matrix(n) = xrep->matrix(0);
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
122
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
123 return retval;
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
124 }
654fbde5dceb make cellfun's fast scalar collection mechanism public
Jaroslav Hajek <highegg@gmail.com>
parents: 10600
diff changeset
125
3928
e8627dc4bdf2 [project @ 2002-05-03 19:56:01 by jwe]
jwe
parents: 3538
diff changeset
126 template class octave_base_matrix<Cell>;
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
127
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
128
4612
d44675070f1a [project @ 2003-11-14 19:49:56 by jwe]
jwe
parents: 4610
diff changeset
129 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell", "cell");
3353
6b36317855ff [project @ 1999-11-16 16:13:49 by jwe]
jwe
parents:
diff changeset
130
6833
e8a18d380097 [project @ 2007-08-27 17:22:50 by jwe]
jwe
parents: 6767
diff changeset
131 static void
e8a18d380097 [project @ 2007-08-27 17:22:50 by jwe]
jwe
parents: 6767
diff changeset
132 gripe_failed_assignment (void)
e8a18d380097 [project @ 2007-08-27 17:22:50 by jwe]
jwe
parents: 6767
diff changeset
133 {
e8a18d380097 [project @ 2007-08-27 17:22:50 by jwe]
jwe
parents: 6767
diff changeset
134 error ("assignment to cell array failed");
e8a18d380097 [project @ 2007-08-27 17:22:50 by jwe]
jwe
parents: 6767
diff changeset
135 }
e8a18d380097 [project @ 2007-08-27 17:22:50 by jwe]
jwe
parents: 6767
diff changeset
136
7651
443a8f5a50fd require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents: 7622
diff changeset
137 octave_value_list
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4243
diff changeset
138 octave_cell::subsref (const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
139 const std::list<octave_value_list>& idx,
16091
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15877
diff changeset
140 int nargout,
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15877
diff changeset
141 const std::list<octave_lvalue> *lvalue_list)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
142 {
7651
443a8f5a50fd require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents: 7622
diff changeset
143 octave_value_list retval;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
144
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
145 switch (type[0])
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
146 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
147 case '(':
7651
443a8f5a50fd require both subsref variants to be defined in octave_value subclasses
John W. Eaton <jwe@octave.org>
parents: 7622
diff changeset
148 retval(0) = do_index_op (idx.front ());
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
149 break;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
150
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
151 case '{':
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
152 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
153 octave_value tmp = do_index_op (idx.front ());
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
154
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
155 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
156 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
157 Cell tcell = tmp.cell_value ();
4582
db5a24d54915 [project @ 2003-10-31 15:11:45 by jwe]
jwe
parents: 4563
diff changeset
158
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
159 if (tcell.length () == 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
160 retval(0) = tcell(0,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
161 else
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
162 retval = octave_value (octave_value_list (tcell), true);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
163 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
164 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
165 break;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
166
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
167 case '.':
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
168 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
169 std::string nm = type_name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
170 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
171 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
172 break;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
173
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
174 default:
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
175 panic_impossible ();
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
176 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
177
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
178 // FIXME: perhaps there should be an
4994
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4944
diff changeset
179 // octave_value_list::next_subsref member function? See also
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4944
diff changeset
180 // octave_user_function::subsref.
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4944
diff changeset
181
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4944
diff changeset
182 if (idx.size () > 1)
16091
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15877
diff changeset
183 retval = (lvalue_list
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15877
diff changeset
184 ? retval(0).next_subsref (nargout, type, idx, lvalue_list)
1785493171ac pass lvalue_list to more subsref calls (bug #38374)
John W. Eaton <jwe@octave.org>
parents: 15877
diff changeset
185 : retval(0).next_subsref (nargout, type, idx));
4994
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4944
diff changeset
186
48d0defe9445 [project @ 2004-09-15 20:31:31 by jwe]
jwe
parents: 4944
diff changeset
187 return retval;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
188 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
189
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
190 octave_value
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
191 octave_cell::subsref (const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
192 const std::list<octave_value_list>& idx,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
193 bool auto_add)
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
194 {
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
195 octave_value retval;
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
196
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
197 switch (type[0])
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
198 {
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
199 case '(':
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
200 retval = do_index_op (idx.front (), auto_add);
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
201 break;
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
202
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
203 case '{':
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
204 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
205 octave_value tmp = do_index_op (idx.front (), auto_add);
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
206
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
207 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
208 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
209 const Cell tcell = tmp.cell_value ();
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
210
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
211 if (tcell.length () == 1)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
212 retval = tcell(0,0);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
213 else
8579
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8551
diff changeset
214 retval = octave_value (octave_value_list (tcell), true);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
215 }
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
216 }
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
217 break;
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
218
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
219 case '.':
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
220 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
221 std::string nm = type_name ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
222 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
223 }
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
224 break;
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
225
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
226 default:
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
227 panic_impossible ();
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
228 }
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
229
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
230 // FIXME: perhaps there should be an
8551
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
231 // octave_value_list::next_subsref member function? See also
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
232 // octave_user_function::subsref.
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
233
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
234 if (idx.size () > 1)
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
235 retval = retval.next_subsref (auto_add, type, idx);
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
236
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
237 return retval;
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
238 }
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
239
906f976d35a8 further improve struct&cell indexing & indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8546
diff changeset
240 octave_value
4247
fc9a075d10fb [project @ 2002-12-30 23:05:27 by jwe]
jwe
parents: 4243
diff changeset
241 octave_cell::subsasgn (const std::string& type,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
242 const std::list<octave_value_list>& idx,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
243 const octave_value& rhs)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
244 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
245 octave_value retval;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
246
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
247 int n = type.length ();
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
248
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
249 octave_value t_rhs = rhs;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
250
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
251 clear_cellstr_cache ();
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
252
9286
c2248cc4821a don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents: 9109
diff changeset
253 if (idx.front ().empty ())
c2248cc4821a don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents: 9109
diff changeset
254 {
c2248cc4821a don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents: 9109
diff changeset
255 error ("missing index in indexed assignment");
c2248cc4821a don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents: 9109
diff changeset
256 return retval;
c2248cc4821a don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents: 9109
diff changeset
257 }
c2248cc4821a don't crash on assignments like a() = 1
Jaroslav Hajek <highegg@gmail.com>
parents: 9109
diff changeset
258
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
259 if (n > 1)
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
260 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
261 switch (type[0])
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
262 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
263 case '(':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
264 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
265 if (is_empty () && type[1] == '.')
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
266 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
267 // Allow conversion of empty cell array to some other
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
268 // type in cases like
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
269 //
10871
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
270 // x = {}; x(i).f = rhs
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
271
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
272 octave_value tmp = octave_value::empty_conv (type, rhs);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
273
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
274 return tmp.subsasgn (type, idx, rhs);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
275 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
276 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
277 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
278 octave_value tmp = do_index_op (idx.front (), true);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
279
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
280 if (! tmp.is_defined ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
281 tmp = octave_value::empty_conv (type.substr (1), rhs);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
282
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
283 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
284 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
285 std::list<octave_value_list> next_idx (idx);
4362
0c69a845ef1a [project @ 2003-03-03 20:11:08 by jwe]
jwe
parents: 4358
diff changeset
286
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
287 next_idx.erase (next_idx.begin ());
6767
a6c8000f113e [project @ 2007-06-28 19:42:42 by jwe]
jwe
parents: 6686
diff changeset
288
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
289 tmp.make_unique ();
6767
a6c8000f113e [project @ 2007-06-28 19:42:42 by jwe]
jwe
parents: 6686
diff changeset
290
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
291 t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
292 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
293 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
294 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
295 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
296
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
297 case '{':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
298 {
9106
1eb5b24186b6 fix nested cell assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
299 matrix.make_unique ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
300 Cell tmpc = matrix.index (idx.front (), true);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
301
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
302 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
303 {
8546
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
304 std::list<octave_value_list> next_idx (idx);
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
305
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
306 next_idx.erase (next_idx.begin ());
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
307
3d8a914c580e improve parser indexed assigment code
Jaroslav Hajek <highegg@gmail.com>
parents: 8523
diff changeset
308 std::string next_type = type.substr (1);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
309
8579
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8551
diff changeset
310 if (tmpc.numel () == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
311 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
312 octave_value tmp = tmpc(0);
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
313 tmpc = Cell ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
314
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
315 if (! tmp.is_defined () || tmp.is_zero_by_zero ())
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
316 {
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
317 tmp = octave_value::empty_conv (type.substr (1), rhs);
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
318 tmp.make_unique (); // probably a no-op.
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
319 }
8452
d6a349c7bd39 fix {} assigment if error occurs on subsequent assignment component
Jaroslav Hajek <highegg@gmail.com>
parents: 8446
diff changeset
320 else
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
321 // optimization: ignore copy still stored inside array.
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
322 tmp.make_unique (1);
4519
8e1c04e506ce [project @ 2003-09-24 17:11:46 by jwe]
jwe
parents: 4513
diff changeset
323
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
324 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
325 t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
326 }
8446
7b25349b32e6 avoid redundant copying in {} assignment
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
327 else
8579
7e0f36dfefbe implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents: 8551
diff changeset
328 gripe_indexed_cs_list ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
329 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
330 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
331 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
332
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
333 case '.':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
334 {
10871
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
335 if (is_empty ())
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
336 {
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
337 // Do nothing; the next branch will handle it.
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
338 }
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
339 else
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
340 {
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
341 std::string nm = type_name ();
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
342 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
343 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
344 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
345 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
346
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
347 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
348 panic_impossible ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
349 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
350 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
351
3940
1b58576bdaa6 [project @ 2002-05-16 18:11:50 by jwe]
jwe
parents: 3933
diff changeset
352 if (! error_state)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
353 {
3940
1b58576bdaa6 [project @ 2002-05-16 18:11:50 by jwe]
jwe
parents: 3933
diff changeset
354 switch (type[0])
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
355 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
356 case '(':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
357 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
358 octave_value_list i = idx.front ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
359
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
360 if (t_rhs.is_cell ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
361 octave_base_matrix<Cell>::assign (i, t_rhs.cell_value ());
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
362 else if (t_rhs.is_null_value ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
363 octave_base_matrix<Cell>::delete_elements (i);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
364 else
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
365 octave_base_matrix<Cell>::assign (i, Cell (t_rhs));
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
366
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
367 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
368 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
369 count++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
370 retval = octave_value (this);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
371 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
372 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
373 gripe_failed_assignment ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
374 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
375 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
376
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
377 case '{':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
378 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
379 octave_value_list idxf = idx.front ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
380
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
381 if (t_rhs.is_cs_list ())
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
382 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
383 Cell tmp_cell = Cell (t_rhs.list_value ());
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5828
diff changeset
384
8587
35656d6ad061 properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8580
diff changeset
385 // Inquire the proper shape of the RHS.
35656d6ad061 properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8580
diff changeset
386
35656d6ad061 properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8580
diff changeset
387 dim_vector didx = dims ().redim (idxf.length ());
35656d6ad061 properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8580
diff changeset
388 for (octave_idx_type k = 0; k < idxf.length (); k++)
35656d6ad061 properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8580
diff changeset
389 if (! idxf(k).is_magic_colon ()) didx(k) = idxf(k).numel ();
7040
1f16da18d85d [project @ 2007-10-19 18:24:19 by jwe]
jwe
parents: 7017
diff changeset
390
8587
35656d6ad061 properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8580
diff changeset
391 if (didx.numel () == tmp_cell.numel ())
35656d6ad061 properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8580
diff changeset
392 tmp_cell = tmp_cell.reshape (didx);
35656d6ad061 properly reshape cs-lists assigned to struct & cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8580
diff changeset
393
5846
db0598f94c0f [project @ 2006-06-07 18:16:16 by jwe]
jwe
parents: 5828
diff changeset
394
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
395 octave_base_matrix<Cell>::assign (idxf, tmp_cell);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
396 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
397 else if (idxf.all_scalars ()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
398 || do_index_op (idxf, true).numel () == 1)
8455
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8452
diff changeset
399 // Regularize a null matrix if stored into a cell.
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
400 octave_base_matrix<Cell>::assign (idxf,
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
401 Cell (t_rhs.storable_value ()));
8455
fd11a08a9b31 disallow invalid {}-indexed assigments
Jaroslav Hajek <highegg@gmail.com>
parents: 8452
diff changeset
402 else if (! error_state)
10030
83bb2a78c07d improve simple assignments error checks and messages
Jaroslav Hajek <highegg@gmail.com>
parents: 9892
diff changeset
403 gripe_nonbraced_cs_list_assignment ();
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
404
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
405 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
406 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
407 count++;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
408 retval = octave_value (this);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
409 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
410 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
411 gripe_failed_assignment ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
412 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
413 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
414
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
415 case '.':
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
416 {
10871
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
417 if (is_empty ())
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
418 {
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
419 // Allow conversion of empty cell array to some other
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
420 // type in cases like
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
421 //
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
422 // x = {}; x.f = rhs
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
423
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
424 octave_value tmp = octave_value::empty_conv (type, rhs);
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
425
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
426 return tmp.subsasgn (type, idx, rhs);
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
427 }
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
428 else
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
429 {
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
430 std::string nm = type_name ();
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
431 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
333bf09e3b6e only allow struct assignments to non-struct values for empty arrays
Jaroslav Hajek <highegg@gmail.com>
parents: 10840
diff changeset
432 }
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
433 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
434 break;
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
435
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
436 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
437 panic_impossible ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
438 }
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
439 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
440
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
441 return retval;
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
442 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
443
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
444 bool
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
445 octave_cell::is_cellstr (void) const
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
446 {
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
447 bool retval;
10065
64a06079cae4 improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents: 10030
diff changeset
448 if (cellstr_cache.get ())
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
449 retval = true;
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
450 else
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
451 {
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
452 retval = matrix.is_cellstr ();
10065
64a06079cae4 improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents: 10030
diff changeset
453 // Allocate empty cache to mark that this is indeed a cellstr.
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
454 if (retval)
10065
64a06079cae4 improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents: 10030
diff changeset
455 cellstr_cache.reset (new Array<std::string> ());
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
456 }
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
457
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
458 return retval;
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
459 }
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
460
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
461 void
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
462 octave_cell::assign (const octave_value_list& idx, const Cell& rhs)
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
463 {
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
464 clear_cellstr_cache ();
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
465 octave_base_matrix<Cell>::assign (idx, rhs);
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
466 }
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
467
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
468 void
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
469 octave_cell::assign (const octave_value_list& idx, const octave_value& rhs)
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
470 {
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
471 clear_cellstr_cache ();
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
472 octave_base_matrix<Cell>::assign (idx, rhs);
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
473 }
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
474
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
475
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
476 void
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
477 octave_cell::delete_elements (const octave_value_list& idx)
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
478 {
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
479 clear_cellstr_cache ();
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
480 octave_base_matrix<Cell>::delete_elements (idx);
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
481 }
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
482
4791
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
483 size_t
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
484 octave_cell::byte_size (void) const
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
485 {
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
486 size_t retval = 0;
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
487
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
488 for (octave_idx_type i = 0; i < numel (); i++)
4791
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
489 retval += matrix(i).byte_size ();
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
490
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
491 return retval;
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
492 }
62f2fb593455 [project @ 2004-02-20 18:02:59 by jwe]
jwe
parents: 4764
diff changeset
493
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
494 octave_value
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
495 octave_cell::sort (octave_idx_type dim, sortmode mode) const
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
496 {
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
497 octave_value retval;
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
498
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
499 if (is_cellstr ())
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
500 {
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
501 Array<std::string> tmp = cellstr_value ();
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
502
8824
76ddf0ab985d auto-set cellstr cache when sorting cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8823
diff changeset
503 tmp = tmp.sort (dim, mode);
76ddf0ab985d auto-set cellstr cache when sorting cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8823
diff changeset
504
8825
c3445f1c8cb4 reuse cellstr cache in strcmp
Jaroslav Hajek <highegg@gmail.com>
parents: 8824
diff changeset
505 // We already have the cache.
c3445f1c8cb4 reuse cellstr cache in strcmp
Jaroslav Hajek <highegg@gmail.com>
parents: 8824
diff changeset
506 retval = new octave_cell (tmp);
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
507 }
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
508 else
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
509 error ("sort: only cell arrays of character strings may be sorted");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
510
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
511 return retval;
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
512 }
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
513
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
514 octave_value
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
515 octave_cell::sort (Array<octave_idx_type> &sidx, octave_idx_type dim,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
516 sortmode mode) const
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
517 {
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
518 octave_value retval;
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
519
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
520 if (is_cellstr ())
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
521 {
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
522 Array<std::string> tmp = cellstr_value ();
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
523
8824
76ddf0ab985d auto-set cellstr cache when sorting cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8823
diff changeset
524 tmp = tmp.sort (sidx, dim, mode);
76ddf0ab985d auto-set cellstr cache when sorting cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8823
diff changeset
525
9338
650c7efa7234 simplify octave_cell::sort
Jaroslav Hajek <highegg@gmail.com>
parents: 9286
diff changeset
526 // We already have the cache.
650c7efa7234 simplify octave_cell::sort
Jaroslav Hajek <highegg@gmail.com>
parents: 9286
diff changeset
527 retval = new octave_cell (tmp);
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
528 }
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
529 else
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
530 error ("sort: only cell arrays of character strings may be sorted");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
531
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
532 return retval;
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
533 }
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
534
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
535 sortmode
8823
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
536 octave_cell::is_sorted (sortmode mode) const
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
537 {
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
538 sortmode retval = UNSORTED;
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
539
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
540 if (is_cellstr ())
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
541 {
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
542 Array<std::string> tmp = cellstr_value ();
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
543
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
544 retval = tmp.is_sorted (mode);
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
545 }
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
546 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
547 error ("issorted: A is not a cell array of strings");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
548
8823
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
549 return retval;
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
550 }
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
551
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
552
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
553 Array<octave_idx_type>
8733
3ef774603887 rename all uses of sortrows_idx to sort_rows_idx
John W. Eaton <jwe@octave.org>
parents: 8732
diff changeset
554 octave_cell::sort_rows_idx (sortmode mode) const
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
555 {
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
556 Array<octave_idx_type> retval;
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
557
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
558 if (is_cellstr ())
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
559 {
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
560 Array<std::string> tmp = cellstr_value ();
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
561
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
562 retval = tmp.sort_rows_idx (mode);
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
563 }
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
564 else
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
565 error ("sortrows: only cell arrays of character strings may be sorted");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
566
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
567 return retval;
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
568 }
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
569
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
570 sortmode
8823
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
571 octave_cell::is_sorted_rows (sortmode mode) const
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
572 {
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
573 sortmode retval = UNSORTED;
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
574
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
575 if (is_cellstr ())
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
576 {
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
577 Array<std::string> tmp = cellstr_value ();
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
578
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
579 retval = tmp.is_sorted_rows (mode);
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
580 }
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
581 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
582 error ("issorted: A is not a cell array of strings");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
583
8823
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
584 return retval;
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
585 }
3efa512a0957 make issorted work for cells
Jaroslav Hajek <highegg@gmail.com>
parents: 8815
diff changeset
586
8626
1dce30ab0e72 don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents: 8587
diff changeset
587 bool
1dce30ab0e72 don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents: 8587
diff changeset
588 octave_cell::is_true (void) const
1dce30ab0e72 don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents: 8587
diff changeset
589 {
1dce30ab0e72 don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents: 8587
diff changeset
590 error ("invalid conversion from cell array to logical value");
1dce30ab0e72 don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents: 8587
diff changeset
591 return false;
1dce30ab0e72 don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents: 8587
diff changeset
592 }
1dce30ab0e72 don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents: 8587
diff changeset
593
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
594 octave_value_list
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
595 octave_cell::list_value (void) const
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
596 {
8580
188d38a553c7 further indexing optimization touches
Jaroslav Hajek <highegg@gmail.com>
parents: 8579
diff changeset
597 return octave_value_list (matrix);
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
598 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
599
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
600 string_vector
5715
edf82d02be75 [project @ 2006-03-24 16:42:43 by jwe]
jwe
parents: 5707
diff changeset
601 octave_cell::all_strings (bool pad) const
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
602 {
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
603 string_vector retval;
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
604
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
605 octave_idx_type nel = numel ();
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
606
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
607 int n_elts = 0;
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
608
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
609 octave_idx_type max_len = 0;
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
610
9370
4ff6f8efdda2 fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 9338
diff changeset
611 std::queue<string_vector> strvec_queue;
4ff6f8efdda2 fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 9338
diff changeset
612
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
613 for (octave_idx_type i = 0; i < nel; i++)
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
614 {
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
615 string_vector s = matrix(i).all_strings ();
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
616
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
617 if (error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
618 return retval;
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
619
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
620 octave_idx_type s_len = s.length ();
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
621
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
622 n_elts += s_len ? s_len : 1;
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
623
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
624 octave_idx_type s_max_len = s.max_length ();
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
625
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
626 if (s_max_len > max_len)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
627 max_len = s_max_len;
9370
4ff6f8efdda2 fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 9338
diff changeset
628
4ff6f8efdda2 fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 9338
diff changeset
629 strvec_queue.push (s);
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
630 }
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
631
9370
4ff6f8efdda2 fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 9338
diff changeset
632 retval = string_vector (n_elts);
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
633
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
634 octave_idx_type k = 0;
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
635
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
636 for (octave_idx_type i = 0; i < nel; i++)
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
637 {
9370
4ff6f8efdda2 fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 9338
diff changeset
638 const string_vector s = strvec_queue.front ();
4ff6f8efdda2 fix slow cellstr -> char matrix conversions
Jaroslav Hajek <highegg@gmail.com>
parents: 9338
diff changeset
639 strvec_queue.pop ();
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
640
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
641 octave_idx_type s_len = s.length ();
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4247
diff changeset
642
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
643 if (s_len)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
644 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
645 for (octave_idx_type j = 0; j < s_len; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
646 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
647 std::string t = s[j];
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
648 int t_len = t.length ();
5715
edf82d02be75 [project @ 2006-03-24 16:42:43 by jwe]
jwe
parents: 5707
diff changeset
649
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
650 if (pad && max_len > t_len)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
651 t += std::string (max_len - t_len, ' ');
5715
edf82d02be75 [project @ 2006-03-24 16:42:43 by jwe]
jwe
parents: 5707
diff changeset
652
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
653 retval[k++] = t;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
654 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
655 }
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
656 else if (pad)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
657 retval[k++] = std::string (max_len, ' ');
7285
c8d362c69013 [project @ 2007-12-11 01:54:19 by jwe]
jwe
parents: 7040
diff changeset
658 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
659 retval[k++] = std::string ();
4243
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
660 }
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
661
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
662 return retval;
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
663 }
7e4d5b5520e5 [project @ 2002-12-27 05:30:59 by jwe]
jwe
parents: 4219
diff changeset
664
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
665 Array<std::string>
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
666 octave_cell::cellstr_value (void) const
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
667 {
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
668 Array<std::string> retval;
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
669
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
670 if (is_cellstr ())
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
671 {
10065
64a06079cae4 improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents: 10030
diff changeset
672 if (cellstr_cache->is_empty ())
64a06079cae4 improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents: 10030
diff changeset
673 *cellstr_cache = matrix.cellstr_value ();
64a06079cae4 improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents: 10030
diff changeset
674
64a06079cae4 improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents: 10030
diff changeset
675 return *cellstr_cache;
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
676 }
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
677 else
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
678 error ("invalid conversion from cell array to array of strings");
8732
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
679
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
680 return retval;
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
681 }
a669df7beb73 [mq]: x
John W. Eaton <jwe@octave.org>
parents: 8679
diff changeset
682
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4587
diff changeset
683 bool
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4587
diff changeset
684 octave_cell::print_as_scalar (void) const
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4587
diff changeset
685 {
11474
8a40037533e2 struct printing changes
John W. Eaton <jwe@octave.org>
parents: 11450
diff changeset
686 return true;
4604
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4587
diff changeset
687 }
cba347c642e2 [project @ 2003-11-13 04:38:05 by jwe]
jwe
parents: 4587
diff changeset
688
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
689 void
18416
bcd71a2531d3 Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18409
diff changeset
690 octave_cell::print (std::ostream& os, bool)
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
691 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
692 print_raw (os);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
693 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
694
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
695 void
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
696 octave_cell::print_raw (std::ostream& os, bool) const
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
697 {
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4582
diff changeset
698 int nd = matrix.ndims ();
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
699
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4582
diff changeset
700 if (nd == 2)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
701 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
702 octave_idx_type nr = rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
703 octave_idx_type nc = columns ();
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
704
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
705 if (nr > 0 && nc > 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
706 {
11474
8a40037533e2 struct printing changes
John W. Eaton <jwe@octave.org>
parents: 11450
diff changeset
707 newline (os);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
708 indent (os);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
709 os << "{";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
710 newline (os);
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
711
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
712 increment_indent_level ();
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
713
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
714 for (octave_idx_type j = 0; j < nc; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
715 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
716 for (octave_idx_type i = 0; i < nr; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
717 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
718 octave_quit ();
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
719
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
720 std::ostringstream buf;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
721 buf << "[" << i+1 << "," << j+1 << "]";
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
722
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
723 octave_value val = matrix(i,j);
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
724
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
725 val.print_with_name (os, buf.str ());
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
726 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
727 }
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
728
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
729 decrement_indent_level ();
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
730
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
731 indent (os);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
732 os << "}";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
733 newline (os);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
734 }
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
735 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
736 {
9781
ea88eece12f5 fix printing of empty cells
Jaroslav Hajek <highegg@gmail.com>
parents: 9370
diff changeset
737 indent (os);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
738 os << "{}";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
739 if (Vprint_empty_dimensions)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
740 os << "(" << nr << "x" << nc << ")";
9781
ea88eece12f5 fix printing of empty cells
Jaroslav Hajek <highegg@gmail.com>
parents: 9370
diff changeset
741 newline (os);
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
742 }
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
743 }
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
744 else
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
745 {
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
746 indent (os);
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
747 dim_vector dv = matrix.dims ();
4587
7b957b442818 [project @ 2003-11-10 15:50:39 by jwe]
jwe
parents: 4582
diff changeset
748 os << "{" << dv.str () << " Cell Array}";
3933
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
749 newline (os);
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
750 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
751 }
f9ea3dcf58ee [project @ 2002-05-15 03:21:00 by jwe]
jwe
parents: 3928
diff changeset
752
17870
1d2e709bbbda rework short_disp methods
John W. Eaton <jwe@octave.org>
parents: 17866
diff changeset
753 void
1d2e709bbbda rework short_disp methods
John W. Eaton <jwe@octave.org>
parents: 17866
diff changeset
754 octave_cell::short_disp (std::ostream& os) const
17866
ea0ecbe2eaf5 display matrix values in GUI workspace viewer (bug #40499)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
755 {
17874
28e9562d708b Fix display of '{}' for empty cells in GUI Variable window.
Rik <rik@octave.org>
parents: 17870
diff changeset
756 os << (matrix.is_empty () ? "{}" : "...");
17866
ea0ecbe2eaf5 display matrix values in GUI workspace viewer (bug #40499)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
757 }
ea0ecbe2eaf5 display matrix values in GUI workspace viewer (bug #40499)
John W. Eaton <jwe@octave.org>
parents: 17787
diff changeset
758
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
759 #define CELL_ELT_TAG "<cell-element>"
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
760
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
761 bool
6974
9e32bb109980 [project @ 2007-10-08 11:06:47 by jwe]
jwe
parents: 6833
diff changeset
762 octave_cell::save_ascii (std::ostream& os)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
763 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
764 dim_vector d = dims ();
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
765 if (d.length () > 2)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
766 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
767 os << "# ndims: " << d.length () << "\n";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
768
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
769 for (int i = 0; i < d.length (); i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
770 os << " " << d (i);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
771 os << "\n";
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
772
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
773 Cell tmp = cell_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
774
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
775 for (octave_idx_type i = 0; i < d.numel (); i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
776 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
777 octave_value o_val = tmp.elem (i);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
778
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
779 // Recurse to print sub-value.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
780 bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, false, 0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
781
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
782 if (! b)
18384
bd9d34f28b0f Use std::ostream::fail instead of unsafe implicit bool conversion (bug #41335)
Mike Miller <mtmiller@ieee.org>
parents: 17874
diff changeset
783 return ! os.fail ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
784 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
785 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
786 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
787 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
788 // Keep this case, rather than use generic code above for backward
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
789 // compatiability. Makes load_ascii much more complex!!
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
790 os << "# rows: " << rows () << "\n"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
791 << "# columns: " << columns () << "\n";
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
792
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
793 Cell tmp = cell_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
794
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
795 for (octave_idx_type j = 0; j < tmp.cols (); j++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
796 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
797 for (octave_idx_type i = 0; i < tmp.rows (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
798 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
799 octave_value o_val = tmp.elem (i, j);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
800
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
801 // Recurse to print sub-value.
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
802 bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, false, 0);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
803
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
804 if (! b)
18384
bd9d34f28b0f Use std::ostream::fail instead of unsafe implicit bool conversion (bug #41335)
Mike Miller <mtmiller@ieee.org>
parents: 17874
diff changeset
805 return ! os.fail ();
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
806 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
807
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
808 os << "\n";
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
809 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
810 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
811
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
812 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
813 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
814
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
815 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
816 octave_cell::load_ascii (std::istream& is)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
817 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
818 bool success = true;
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
819
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
820 clear_cellstr_cache ();
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
821
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
822 string_vector keywords(2);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
823
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
824 keywords[0] = "ndims";
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
825 keywords[1] = "rows";
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
826
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
827 std::string kw;
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
828 octave_idx_type val = 0;
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
829
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
830 if (extract_keyword (is, keywords, kw, val, true))
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
831 {
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
832 if (kw == "ndims")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
833 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
834 int mdims = static_cast<int> (val);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
835
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
836 if (mdims >= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
837 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
838 dim_vector dv;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
839 dv.resize (mdims);
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
840
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
841 for (int i = 0; i < mdims; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
842 is >> dv(i);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
843
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
844 Cell tmp(dv);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
845
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
846 for (octave_idx_type i = 0; i < dv.numel (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
847 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
848 octave_value t2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
849 bool dummy;
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
850
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
851 // recurse to read cell elements
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
852 std::string nm = read_ascii_data (is, std::string (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
853 dummy, t2, i);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
854
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
855 if (nm == CELL_ELT_TAG)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
856 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
857 if (is)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
858 tmp.elem (i) = t2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
859 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
860 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
861 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
862 error ("load: cell array element had unexpected name");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
863 success = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
864 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
865 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
866 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
867
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
868 if (is)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
869 matrix = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
870 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
871 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
872 error ("load: failed to load matrix constant");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
873 success = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
874 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
875 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
876 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
877 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
878 error ("load: failed to extract number of rows and columns");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
879 success = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
880 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
881 }
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
882 else if (kw == "rows")
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
883 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
884 octave_idx_type nr = val;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
885 octave_idx_type nc = 0;
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
886
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
887 if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
888 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
889 if (nr > 0 && nc > 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
890 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
891 Cell tmp (nr, nc);
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
892
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
893 for (octave_idx_type j = 0; j < nc; j++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
894 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
895 for (octave_idx_type i = 0; i < nr; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
896 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
897 octave_value t2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
898 bool dummy;
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
899
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
900 // recurse to read cell elements
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
901 std::string nm = read_ascii_data (is, std::string (),
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
902 dummy, t2, i);
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
903
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
904 if (nm == CELL_ELT_TAG)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
905 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
906 if (is)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
907 tmp.elem (i, j) = t2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
908 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
909 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
910 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
911 error ("load: cell array element had unexpected name");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
912 success = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
913 goto cell_read_error;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
914 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
915 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
916 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
917
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
918 cell_read_error:
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
919
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
920 if (is)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
921 matrix = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
922 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
923 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
924 error ("load: failed to load cell element");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
925 success = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
926 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
927 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
928 else if (nr == 0 || nc == 0)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
929 matrix = Cell (nr, nc);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
930 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
931 panic_impossible ();
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
932 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
933 else
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
934 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
935 error ("load: failed to extract number of rows and columns for cell array");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
936 success = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
937 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
938 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
939 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
940 panic_impossible ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
941 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
942 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
943 {
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
944 error ("load: failed to extract number of rows and columns");
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 5060
diff changeset
945 success = false;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
946 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
947
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
948 return success;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
949 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
950
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
951 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
952 octave_cell::save_binary (std::ostream& os, bool& save_as_floats)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
953 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
954 dim_vector d = dims ();
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
955 if (d.length () < 1)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
956 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
957
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
958 // Use negative value for ndims
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14429
diff changeset
959 int32_t di = - d.length ();
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
960 os.write (reinterpret_cast<char *> (&di), 4);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
961 for (int i = 0; i < d.length (); i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
962 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
963 di = d(i);
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
964 os.write (reinterpret_cast<char *> (&di), 4);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
965 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
966
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
967 Cell tmp = cell_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
968
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
969 for (octave_idx_type i = 0; i < d.numel (); i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
970 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
971 octave_value o_val = tmp.elem (i);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
972
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
973 // Recurse to print sub-value.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
974 bool b = save_binary_data (os, o_val, CELL_ELT_TAG, "", 0,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
975 save_as_floats);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
976
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
977 if (! b)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
978 return false;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
979 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
980
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
981 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
982 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
983
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
984 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
985 octave_cell::load_binary (std::istream& is, bool swap,
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
986 oct_mach_info::float_format fmt)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
987 {
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
988 clear_cellstr_cache ();
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
989
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
990 bool success = true;
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5823
diff changeset
991 int32_t mdims;
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
992 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
993 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
994 if (swap)
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4941
diff changeset
995 swap_bytes<4> (&mdims);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
996 if (mdims >= 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
997 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
998
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
999 mdims = -mdims;
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5823
diff changeset
1000 int32_t di;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1001 dim_vector dv;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1002 dv.resize (mdims);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1003
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1004 for (int i = 0; i < mdims; i++)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1005 {
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
1006 if (! is.read (reinterpret_cast<char *> (&di), 4))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1007 return false;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1008 if (swap)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1009 swap_bytes<4> (&di);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1010 dv(i) = di;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1011 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1012
5157
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1013 // Convert an array with a single dimension to be a row vector.
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1014 // Octave should never write files like this, other software
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1015 // might.
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1016
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1017 if (mdims == 1)
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1018 {
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1019 mdims = 2;
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1020 dv.resize (mdims);
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1021 dv(1) = dv(0);
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1022 dv(0) = 1;
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1023 }
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
1024
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
1025 octave_idx_type nel = dv.numel ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1026 Cell tmp(dv);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1027
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
1028 for (octave_idx_type i = 0; i < nel; i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1029 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1030 octave_value t2;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1031 bool dummy;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1032 std::string doc;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1033
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1034 // recurse to read cell elements
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1035 std::string nm = read_binary_data (is, swap, fmt, std::string (),
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1036 dummy, t2, doc);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1037
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1038 if (nm == CELL_ELT_TAG)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1039 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1040 if (is)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1041 tmp.elem (i) = t2;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1042 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1043 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1044 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1045 error ("load: cell array element had unexpected name");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1046 success = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1047 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1048 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1049 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1050
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1051 if (is)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1052 matrix = tmp;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1053 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1054 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1055 error ("load: failed to load matrix constant");
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1056 success = false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1057 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1058
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1059 return success;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1060 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1061
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
1062 void *
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
1063 octave_cell::mex_get_data (void) const
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
1064 {
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
1065 clear_cellstr_cache ();
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
1066 return matrix.mex_get_data ();
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
1067 }
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
1068
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1069 bool
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1070 octave_cell::save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats)
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1071 {
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1072 #if defined (HAVE_HDF5)
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1073
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1074 dim_vector dv = dims ();
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1075 int empty = save_hdf5_empty (loc_id, name, dv);
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1076 if (empty)
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1077 return (empty > 0);
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1078
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1079 hsize_t rank = dv.length ();
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17874
diff changeset
1080 hid_t space_hid, data_hid, size_hid;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17874
diff changeset
1081 space_hid = data_hid = size_hid = -1;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1082
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1083 #if HAVE_HDF5_18
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1084 data_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1085 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1086 data_hid = H5Gcreate (loc_id, name, 0);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1087 #endif
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1088
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1089 if (data_hid < 0)
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1090 return false;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1091
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1092 // Have to save cell array shape, since can't have a
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1093 // dataset of groups....
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1094
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1095 space_hid = H5Screate_simple (1, &rank, 0);
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1096
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1097 if (space_hid < 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1098 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1099 H5Gclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1100 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1101 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1102
5351
05adf9de7657 [project @ 2005-05-16 20:07:36 by dbateman]
dbateman
parents: 5307
diff changeset
1103 OCTAVE_LOCAL_BUFFER (octave_idx_type, hdims, rank);
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1104
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1105 // Octave uses column-major, while HDF5 uses row-major ordering
4933
cd58733c326b [project @ 2004-08-05 16:08:28 by jwe]
jwe
parents: 4837
diff changeset
1106 for (hsize_t i = 0; i < rank; i++)
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1107 hdims[i] = dv(rank-i-1);
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1108
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1109 #if HAVE_HDF5_18
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1110 size_hid = H5Dcreate (data_hid, "dims", H5T_NATIVE_IDX, space_hid,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1111 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1112 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1113 size_hid = H5Dcreate (data_hid, "dims", H5T_NATIVE_IDX, space_hid,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1114 H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1115 #endif
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1116 if (size_hid < 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1117 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1118 H5Sclose (space_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1119 H5Gclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1120 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1121 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1122
6276
d26c558691cd [project @ 2007-02-07 09:01:24 by jwe]
jwe
parents: 6116
diff changeset
1123 if (H5Dwrite (size_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1124 H5P_DEFAULT, hdims) < 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1125 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1126 H5Dclose (size_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1127 H5Sclose (space_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1128 H5Gclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1129 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1130 }
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1131
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1132 H5Dclose (size_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1133 H5Sclose (space_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1134
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1135 // Recursively add each element of the cell to this group.
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1136
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1137 Cell tmp = cell_value ();
5850
426b94346d70 [project @ 2006-06-09 15:44:35 by jwe]
jwe
parents: 5846
diff changeset
1138
426b94346d70 [project @ 2006-06-09 15:44:35 by jwe]
jwe
parents: 5846
diff changeset
1139 octave_idx_type nel = dv.numel ();
426b94346d70 [project @ 2006-06-09 15:44:35 by jwe]
jwe
parents: 5846
diff changeset
1140
426b94346d70 [project @ 2006-06-09 15:44:35 by jwe]
jwe
parents: 5846
diff changeset
1141 for (octave_idx_type i = 0; i < nel; i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1142 {
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
1143 std::ostringstream buf;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1144 int digits = static_cast<int> (gnulib::floor (::log10 (static_cast<double>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1145 (nel)) + 1.0));
5850
426b94346d70 [project @ 2006-06-09 15:44:35 by jwe]
jwe
parents: 5846
diff changeset
1146 buf << "_" << std::setw (digits) << std::setfill ('0') << i;
5765
7ba9ad1fec11 [project @ 2006-04-17 05:05:15 by jwe]
jwe
parents: 5760
diff changeset
1147 std::string s = buf.str ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1148
5850
426b94346d70 [project @ 2006-06-09 15:44:35 by jwe]
jwe
parents: 5846
diff changeset
1149 if (! add_hdf5_data (data_hid, tmp.elem (i), s.c_str (), "", false,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1150 save_as_floats))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1151 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1152 H5Gclose (data_hid);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1153 return false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1154 }
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1155 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1156
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1157 H5Gclose (data_hid);
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1158
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1159 return true;
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1160
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1161 #else
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1162 gripe_save ("hdf5");
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1163 return false;
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1164 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1165 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1166
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1167 bool
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1168 octave_cell::load_hdf5 (octave_hdf5_id loc_id, const char *name)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1169 {
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1170 bool retval = false;
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1171
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1172 #if defined (HAVE_HDF5)
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1173
8815
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
1174 clear_cellstr_cache ();
af907aeedbf4 cache cellstr_value in ov-cell
Jaroslav Hajek <highegg@gmail.com>
parents: 8733
diff changeset
1175
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1176 dim_vector dv;
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1177 int empty = load_hdf5_empty (loc_id, name, dv);
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1178 if (empty > 0)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1179 matrix.resize (dv);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1180 if (empty)
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1181 return (empty > 0);
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1182
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1183 #if HAVE_HDF5_18
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1184 hid_t group_id = H5Gopen (loc_id, name, H5P_DEFAULT);
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1185 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1186 hid_t group_id = H5Gopen (loc_id, name);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1187 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1188
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1189 if (group_id < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1190 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1191
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1192 #if HAVE_HDF5_18
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1193 hid_t data_hid = H5Dopen (group_id, "dims", H5P_DEFAULT);
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1194 #else
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1195 hid_t data_hid = H5Dopen (group_id, "dims");
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1196 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1197 hid_t space_hid = H5Dget_space (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1198 hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1199 if (rank != 1)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1200 {
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1201 H5Dclose (data_hid);
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1202 H5Gclose (group_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1203 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1204 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1205
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1206 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1207 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1208
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1209 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1210
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1211 // Octave uses column-major, while HDF5 uses row-major ordering.
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1212
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1213 dv.resize (hdims[0]);
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1214
5351
05adf9de7657 [project @ 2005-05-16 20:07:36 by dbateman]
dbateman
parents: 5307
diff changeset
1215 OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, hdims[0]);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1216
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1217 if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1218 H5P_DEFAULT, tmp) < 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1219 {
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1220 H5Dclose (data_hid);
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4817
diff changeset
1221 H5Gclose (group_id);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1222 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1223 }
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1224
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1225 H5Dclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1226 H5Gclose (group_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1227
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1228 for (hsize_t i = 0, j = hdims[0] - 1; i < hdims[0]; i++, j--)
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1229 dv(j) = tmp[i];
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1230
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1231 hdf5_callback_data dsub;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1232
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1233 herr_t retval2 = -1;
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1234
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1235 Cell m (dv);
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1236
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1237 int current_item = 0;
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1238
4696
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1239 hsize_t num_obj = 0;
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1240 #if HAVE_HDF5_18
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1241 group_id = H5Gopen (loc_id, name, H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1242 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1243 group_id = H5Gopen (loc_id, name);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
1244 #endif
5060
34a904ac130d [project @ 2004-11-02 03:08:10 by jwe]
jwe
parents: 4994
diff changeset
1245 H5Gget_num_objs (group_id, &num_obj);
34a904ac130d [project @ 2004-11-02 03:08:10 by jwe]
jwe
parents: 4994
diff changeset
1246 H5Gclose (group_id);
4696
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1247
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5164
diff changeset
1248 for (octave_idx_type i = 0; i < dv.numel (); i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1249 {
4696
fcab389ad291 [project @ 2004-01-15 02:11:59 by jwe]
jwe
parents: 4687
diff changeset
1250
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1251 if (current_item >= static_cast<int> (num_obj))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1252 retval2 = -1;
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1253 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1254 retval2 = H5Giterate (loc_id, name, &current_item,
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1255 hdf5_read_next_data, &dsub);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1256
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1257 if (retval2 <= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1258 break;
4814
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1259
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1260 octave_value ov = dsub.tc;
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1261 m.elem (i) = ov;
495e9df75836 [project @ 2004-03-03 23:46:38 by jwe]
jwe
parents: 4791
diff changeset
1262
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1263 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1264
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1265 if (retval2 >= 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1266 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1267 matrix = m;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1268 retval = true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1269 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1270
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1271 #else
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1272 gripe_load ("hdf5");
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1273 #endif
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
1274
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1275 return retval;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
1276 }
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4814
diff changeset
1277
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1278 DEFUN (iscell, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1279 "-*- texinfo -*-\n\
3448
0fb75d95b14f [project @ 2000-01-17 20:38:31 by jwe]
jwe
parents: 3354
diff changeset
1280 @deftypefn {Built-in Function} {} iscell (@var{x})\n\
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10871
diff changeset
1281 Return true if @var{x} is a cell array object.\n\
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10871
diff changeset
1282 @seealso{ismatrix, isstruct, iscellstr, isa}\n\
3448
0fb75d95b14f [project @ 2000-01-17 20:38:31 by jwe]
jwe
parents: 3354
diff changeset
1283 @end deftypefn")
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1284 {
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1285 octave_value retval;
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1286
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1287 if (args.length () == 1)
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1288 retval = args(0).is_cell ();
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1289 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5805
diff changeset
1290 print_usage ();
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1291
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1292 return retval;
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1293 }
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1294
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1295 DEFUN (cell, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1296 "-*- texinfo -*-\n\
12715
25f8acbb6be2 doc: Add additional calling forms to cell()
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1297 @deftypefn {Built-in Function} {} cell (@var{n})\n\
25f8acbb6be2 doc: Add additional calling forms to cell()
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1298 @deftypefnx {Built-in Function} {} cell (@var{m}, @var{n})\n\
25f8acbb6be2 doc: Add additional calling forms to cell()
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1299 @deftypefnx {Built-in Function} {} cell (@var{m}, @var{n}, @var{k}, @dots{})\n\
25f8acbb6be2 doc: Add additional calling forms to cell()
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1300 @deftypefnx {Built-in Function} {} cell ([@var{m} @var{n} @dots{}])\n\
25f8acbb6be2 doc: Add additional calling forms to cell()
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1301 Create a new cell array object.\n\
18533
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1302 \n\
12715
25f8acbb6be2 doc: Add additional calling forms to cell()
Rik <octave@nomad.inbox5.com>
parents: 12483
diff changeset
1303 If invoked with a single scalar integer argument, return a square\n\
20163
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1304 @nospell{NxN} cell array. If invoked with two or more scalar integer\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1305 arguments, or a vector of integer values, return an array with the given\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1306 dimensions.\n\
18533
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1307 @seealso{cellstr, mat2cell, num2cell, struct2cell}\n\
3448
0fb75d95b14f [project @ 2000-01-17 20:38:31 by jwe]
jwe
parents: 3354
diff changeset
1308 @end deftypefn")
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1309 {
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1310 octave_value retval;
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1311
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1312 int nargin = args.length ();
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1313
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1314 dim_vector dims;
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1315
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1316 switch (nargin)
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1317 {
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1318 case 0:
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1319 dims = dim_vector (0, 0);
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1320 break;
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1321
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1322 case 1:
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1323 get_dimensions (args(0), "cell", dims);
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1324 break;
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1325
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1326 default:
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1327 {
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1328 dims.resize (nargin);
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1329
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1330 for (int i = 0; i < nargin; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1331 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1332 dims(i) = args(i).is_empty () ? 0 : args(i).nint_value ();
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1333
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1334 if (error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1335 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1336 error ("cell: expecting scalar arguments");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1337 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1338 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1339 }
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1340 }
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1341 break;
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1342 }
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1343
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1344 if (! error_state)
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1345 {
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
1346 dims.chop_trailing_singletons ();
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1347
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1348 check_dimensions (dims, "cell");
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1349
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1350 if (! error_state)
8290
7cbe01c21986 improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents: 8150
diff changeset
1351 retval = Cell (dims, Matrix ());
4563
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1352 }
742993a501b9 [project @ 2003-10-29 06:25:12 by jwe]
jwe
parents: 4519
diff changeset
1353
3354
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1354 return retval;
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1355 }
87721841efd7 [project @ 1999-11-17 19:06:11 by jwe]
jwe
parents: 3353
diff changeset
1356
4610
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1357 DEFUN (iscellstr, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1358 "-*- texinfo -*-\n\
4610
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1359 @deftypefn {Built-in Function} {} iscellstr (@var{cell})\n\
20163
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1360 Return true if every element of the cell array @var{cell} is a character\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1361 string.\n\
11431
0d9640d755b1 Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents: 10871
diff changeset
1362 @seealso{ischar}\n\
4610
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1363 @end deftypefn")
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1364 {
4699
5e2c68946f30 [project @ 2004-01-20 23:04:46 by jwe]
jwe
parents: 4696
diff changeset
1365 octave_value retval;
4610
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1366
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1367 if (args.length () == 1)
6116
b64fb24bf4a0 [project @ 2006-10-27 18:04:49 by jwe]
jwe
parents: 5992
diff changeset
1368 retval = args(0).is_cellstr ();
4610
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1369 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5805
diff changeset
1370 print_usage ();
4610
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1371
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1372 return retval;
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1373 }
02d2fcf835fc [project @ 2003-11-14 17:08:59 by jwe]
jwe
parents: 4604
diff changeset
1374
4817
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1375 // Note that since Fcellstr calls Fiscellstr, we need to have
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1376 // Fiscellstr defined first (to provide a declaration) and also we
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1377 // should keep it in the same file (so we don't have to provide a
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1378 // declaration) and so we don't have to use feval to call it.
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1379
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1380 DEFUN (cellstr, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1381 "-*- texinfo -*-\n\
18533
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1382 @deftypefn {Built-in Function} {@var{cstr} =} cellstr (@var{strmat})\n\
20163
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1383 Create a new cell array object from the elements of the string array\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1384 @var{strmat}.\n\
18533
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1385 \n\
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1386 Each row of @var{strmat} becomes an element of @var{cstr}. Any trailing\n\
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1387 spaces in a row are deleted before conversion.\n\
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1388 \n\
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1389 To convert back from a cellstr to a character array use @code{char}.\n\
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1390 @seealso{cell, char}\n\
4817
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1391 @end deftypefn")
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1392 {
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1393 octave_value retval;
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1394
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1395 if (args.length () == 1)
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1396 {
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1397 octave_value_list tmp = Fiscellstr (args, 1);
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1398
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1399 if (tmp(0).is_true ())
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1400 retval = args(0);
4817
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1401 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1402 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1403 string_vector s = args(0).all_strings ();
4817
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1404
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1405 if (! error_state)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1406 retval = (s.is_empty ()
7813
12a68443191c [mq]: cellstr
Jaroslav Hajek <highegg@gmail.com>
parents: 7760
diff changeset
1407 ? Cell (octave_value (std::string ()))
12a68443191c [mq]: cellstr
Jaroslav Hajek <highegg@gmail.com>
parents: 7760
diff changeset
1408 : Cell (s, true));
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1409 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
1410 error ("cellstr: argument STRING must be a 2-D character array");
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1411 }
4817
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1412 }
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1413 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5805
diff changeset
1414 print_usage ();
4817
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1415
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1416 return retval;
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1417 }
6430596f2238 [project @ 2004-03-04 21:13:33 by jwe]
jwe
parents: 4815
diff changeset
1418
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1419 DEFUN (struct2cell, args, ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1420 "-*- texinfo -*-\n\
18533
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1421 @deftypefn {Built-in Function} {@var{c} =} struct2cell (@var{s})\n\
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1422 Create a new cell array from the objects stored in the struct object.\n\
20163
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1423 \n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1424 If @var{f} is the number of fields in the structure, the resulting cell\n\
075a5e2e1ba5 doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19863
diff changeset
1425 array will have a dimension vector corresponding to\n\
18533
ea0d4dea1a17 doc: Update documentation for functions in octave-value dir.
Rik <rik@octave.org>
parents: 18384
diff changeset
1426 @code{[@var{f} size(@var{s})]}. For example:\n\
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1427 \n\
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1428 @example\n\
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1429 @group\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1430 s = struct (\"name\", @{\"Peter\", \"Hannah\", \"Robert\"@},\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1431 \"age\", @{23, 16, 3@});\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1432 c = struct2cell (s)\n\
15877
596b26e11ddb fix bug #38010 struct2cell documentation error
Andreas Weber <andy.weber.aw@gmail.com>
parents: 15195
diff changeset
1433 @result{} c = @{2x1x3 Cell Array@}\n\
14360
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1434 c(1,1,:)(:)\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1435 @result{}\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1436 @{\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1437 [1,1] = Peter\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1438 [2,1] = Hannah\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1439 [3,1] = Robert\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1440 @}\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1441 c(2,1,:)(:)\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1442 @result{}\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1443 @{\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1444 [1,1] = 23\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1445 [2,1] = 16\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1446 [3,1] = 3\n\
97883071e8e4 doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
1447 @}\n\
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1448 @end group\n\
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1449 @end example\n\
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1450 \n\
5642
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
1451 @seealso{cell2struct, fieldnames}\n\
2618a0750ae6 [project @ 2006-03-06 21:26:48 by jwe]
jwe
parents: 5360
diff changeset
1452 @end deftypefn")
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1453 {
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1454 octave_value retval;
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1455
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1456 int nargin = args.length ();
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1457
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1458 if (nargin == 1)
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1459 {
10772
687586b99f9d improve struct2cell
Jaroslav Hajek <highegg@gmail.com>
parents: 10711
diff changeset
1460 const octave_map m = args(0).map_value ();
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1461
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1462 if (! error_state)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1463 {
10772
687586b99f9d improve struct2cell
Jaroslav Hajek <highegg@gmail.com>
parents: 10711
diff changeset
1464 const dim_vector m_dv = m.dims ();
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1465
10772
687586b99f9d improve struct2cell
Jaroslav Hajek <highegg@gmail.com>
parents: 10711
diff changeset
1466 octave_idx_type num_fields = m.nfields ();
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1467
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1468 // The resulting dim_vector should have dimensions:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1469 // [numel(fields) size(struct)]
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1470 // except if the struct is a column vector.
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1471
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1472 dim_vector result_dv;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1473 if (m_dv (m_dv.length () - 1) == 1)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1474 result_dv.resize (m_dv.length ());
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1475 else
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1476 result_dv.resize (m_dv.length () + 1); // Add 1 for the fields.
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1477
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1478 result_dv(0) = num_fields;
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1479
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1480 for (int i = 1; i < result_dv.length (); i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1481 result_dv(i) = m_dv(i-1);
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1482
10772
687586b99f9d improve struct2cell
Jaroslav Hajek <highegg@gmail.com>
parents: 10711
diff changeset
1483 NoAlias<Cell> c (result_dv);
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1484
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1485 octave_idx_type n_elts = m.numel ();
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1486
10772
687586b99f9d improve struct2cell
Jaroslav Hajek <highegg@gmail.com>
parents: 10711
diff changeset
1487 // Fill c in one sweep. Note that thanks to octave_map structure,
687586b99f9d improve struct2cell
Jaroslav Hajek <highegg@gmail.com>
parents: 10711
diff changeset
1488 // we don't need a key lookup at all.
687586b99f9d improve struct2cell
Jaroslav Hajek <highegg@gmail.com>
parents: 10711
diff changeset
1489 for (octave_idx_type j = 0; j < n_elts; j++)
687586b99f9d improve struct2cell
Jaroslav Hajek <highegg@gmail.com>
parents: 10711
diff changeset
1490 for (octave_idx_type i = 0; i < num_fields; i++)
687586b99f9d improve struct2cell
Jaroslav Hajek <highegg@gmail.com>
parents: 10711
diff changeset
1491 c(i,j) = m.contents(i)(j);
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1492
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1493 retval = c;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
1494 }
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1495 else
12483
7a5aacf65f81 Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents: 11586
diff changeset
1496 error ("struct2cell: argument S must be a structure");
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1497 }
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1498 else
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5805
diff changeset
1499 print_usage ();
4764
86c748d5f0af [project @ 2004-02-16 05:14:59 by jwe]
jwe
parents: 4762
diff changeset
1500
4762
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1501 return retval;
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1502 }
bec345670e56 [project @ 2004-02-16 05:07:23 by jwe]
jwe
parents: 4722
diff changeset
1503
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1504 /*
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1505 %!test
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1506 %! keys = cellstr (char (floor (rand (11,10)*24+65)))';
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1507 %! vals = cellfun (@(x) mat2cell (rand (19,1), ones (19,1), 1), ...
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1508 %! mat2cell ([1:11]', ones (11,1), 1), "uniformoutput", false)';
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1509 %! s = struct ([keys; vals]{:});
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1510 %! t = cell2struct ([vals{:}], keys, 2);
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1511 %! assert (s, t);
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1512 %! assert (struct2cell (s), [vals{:}]');
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
1513 %! assert (fieldnames (s), keys');
10122
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1514 */
9d1a14e12431 Update docs and add tests for container functions
Thorsten Meyer <thorsten.meyier@gmx.de>
parents: 10065
diff changeset
1515
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1516 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1517 octave_cell::as_mxArray (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1518 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1519 mxArray *retval = new mxArray (dims ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1520
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1521 mxArray **elts = static_cast<mxArray **> (retval->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1522
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6276
diff changeset
1523 mwSize nel = numel ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1524
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1525 const octave_value *p = matrix.data ();
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1526
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6276
diff changeset
1527 for (mwIndex i = 0; i < nel; i++)
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1528 elts[i] = new mxArray (p[i]);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1529
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1530 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1531 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5850
diff changeset
1532
9813
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1533 octave_value
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1534 octave_cell::map (unary_mapper_t umap) const
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1535 {
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1536 switch (umap)
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1537 {
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1538 #define FORWARD_MAPPER(UMAP) \
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1539 case umap_ ## UMAP: \
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1540 return matrix.UMAP ()
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1541 FORWARD_MAPPER (xisalnum);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1542 FORWARD_MAPPER (xisalpha);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1543 FORWARD_MAPPER (xisascii);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1544 FORWARD_MAPPER (xiscntrl);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1545 FORWARD_MAPPER (xisdigit);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1546 FORWARD_MAPPER (xisgraph);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1547 FORWARD_MAPPER (xislower);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1548 FORWARD_MAPPER (xisprint);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1549 FORWARD_MAPPER (xispunct);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1550 FORWARD_MAPPER (xisspace);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1551 FORWARD_MAPPER (xisupper);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1552 FORWARD_MAPPER (xisxdigit);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1553 FORWARD_MAPPER (xtoascii);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1554 FORWARD_MAPPER (xtolower);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1555 FORWARD_MAPPER (xtoupper);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1556
9813
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1557 default:
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1558 return octave_base_value::map (umap);
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1559 }
8fa32b527d9a improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents: 9781
diff changeset
1560 }