Mercurial > octave
annotate libinterp/corefcn/Cell.h @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
3353 | 1 /* |
2 | |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 Copyright (C) 1999-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27023
diff
changeset
|
4 |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27023
diff
changeset
|
5 See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27023
diff
changeset
|
6 or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27023
diff
changeset
|
7 |
3353 | 8 |
9 This file is part of Octave. | |
10 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23677
diff
changeset
|
11 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23677
diff
changeset
|
13 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 (at your option) any later version. |
3353 | 15 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
16 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
17 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
19 GNU General Public License for more details. |
3353 | 20 |
21 You should have received a copy of the GNU General Public License | |
7016 | 22 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23677
diff
changeset
|
23 <https://www.gnu.org/licenses/>. |
3353 | 24 |
25 */ | |
26 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
27 #if ! defined (octave_Cell_h) |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
28 #define octave_Cell_h 1 |
3353 | 29 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
30 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21139
diff
changeset
|
31 |
3353 | 32 #include <string> |
33 | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
34 #include "Array.h" |
3353 | 35 #include "str-vec.h" |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
36 #include "ov.h" |
3353 | 37 |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
38 class octave_value_list; |
3353 | 39 |
40 class | |
6169 | 41 OCTINTERP_API |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
42 Cell : public Array<octave_value> |
3353 | 43 { |
44 public: | |
45 | |
27023
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
46 Cell (void) = default; |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
47 |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
48 Cell (const Cell& c) = default; |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
49 |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
50 Cell& operator = (const Cell& c) = default; |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
51 |
fc256e9d882e
use default ctors, dtors, and assignment ops in Matrix, intNDArray, and Cell
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
52 ~Cell (void) = default; |
3928 | 53 |
54 Cell (const octave_value& val) | |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
55 : Array<octave_value> (dim_vector (1, 1), val) { } |
4513 | 56 |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8333
diff
changeset
|
57 Cell (const octave_value_list& ovl); |
3353 | 58 |
7209 | 59 Cell (octave_idx_type n, octave_idx_type m, |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
60 const octave_value& val = Matrix ()) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
61 : Array<octave_value> (dim_vector (n, m), val) { } |
3353 | 62 |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
63 Cell (const dim_vector& dv, const octave_value& val = Matrix ()) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
64 : Array<octave_value> (dv, val) { } |
3354 | 65 |
4567 | 66 Cell (const Array<octave_value>& c) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
67 : Array<octave_value> (c) { } |
4567 | 68 |
5275 | 69 Cell (const Array<octave_value>& c, octave_idx_type nr, octave_idx_type nc) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
70 : Array<octave_value> (c, dim_vector (nr, nc)) { } |
3933 | 71 |
5805 | 72 Cell (const string_vector& sv, bool trim = false); |
4216 | 73 |
23677
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
74 // Constructor for standard containers. V must be convertible to an |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
75 // octave_value object. |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
76 template <typename V, template <typename...> class C> |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
77 explicit |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
78 Cell (const C<V>& container) |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
79 : Array<octave_value> () |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
80 { |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
81 size_t n = container.size (); |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
82 |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
83 if (n > 0) |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
84 { |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
85 resize (dim_vector (n, 1)); |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
86 |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
87 octave_idx_type i = 0; |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
88 |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
89 for (const auto& val : container) |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
90 elem(i++,0) = val; |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
91 } |
66c4d224f7cb
use generic template for construction from standard containers
John W. Eaton <jwe@octave.org>
parents:
23575
diff
changeset
|
92 } |
11037
e7864673c31f
new Cell (std::list<std::string>&) constructor
John W. Eaton <jwe@octave.org>
parents:
10757
diff
changeset
|
93 |
8732 | 94 Cell (const Array<std::string>& sa); |
95 | |
6116 | 96 Cell (const dim_vector& dv, const string_vector& sv, bool trim = false); |
97 | |
23575
e95738a119da
maint: Deprecate is_cellstr and replace with iscellstr.
Rik <rik@octave.org>
parents:
23355
diff
changeset
|
98 bool iscellstr (void) const; |
6116 | 99 |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
100 Array<std::string> cellstr_value (void) const; |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
101 |
23355
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
102 string_vector string_vector_value (void) const; |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
103 |
10649
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
104 using Array<octave_value>::index; |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
105 |
4513 | 106 Cell index (const octave_value_list& idx, bool resize_ok = false) const; |
107 | |
10649
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
108 using Array<octave_value>::delete_elements; |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
109 |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
110 void delete_elements (const octave_value_list& idx); |
8175
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
7620
diff
changeset
|
111 |
10649
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
112 using Array<octave_value>::assign; |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
113 |
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
114 void assign (const octave_value_list& idx, const Cell& rhs, |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
115 const octave_value& fill_val = Matrix ()); |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8175
diff
changeset
|
116 |
4901 | 117 Cell reshape (const dim_vector& new_dims) const |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
118 { return Array<octave_value>::reshape (new_dims); } |
4901 | 119 |
5602 | 120 octave_idx_type nnz (void) const; |
121 | |
5570 | 122 Cell column (octave_idx_type i) const; |
123 | |
5775 | 124 // FIXME |
4932 | 125 boolMatrix all (int /* dim */ = 0) const { return boolMatrix (); } |
3933 | 126 |
5775 | 127 // FIXME |
4932 | 128 boolMatrix any (int /* dim */ = 0) const { return boolMatrix (); } |
3933 | 129 |
5275 | 130 Cell concat (const Cell& rb, const Array<octave_idx_type>& ra_idx); |
4915 | 131 |
5275 | 132 Cell& insert (const Cell& a, octave_idx_type r, octave_idx_type c); |
133 Cell& insert (const Cell& a, const Array<octave_idx_type>& ra_idx); | |
4806 | 134 |
5775 | 135 // FIXME |
8626
1dce30ab0e72
don't convert NaN to logical in bool expressions
John W. Eaton <jwe@octave.org>
parents:
8579
diff
changeset
|
136 bool any_element_is_nan (void) const { return false; } |
3933 | 137 bool is_true (void) const { return false; } |
138 | |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
139 octave_value resize_fill_value (void) const; |
7530
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
140 |
7620
36594d5bbe13
Move diag function into the octave_value class
David Bateman <dbateman@free.fr>
parents:
7618
diff
changeset
|
141 Cell diag (octave_idx_type k = 0) const; |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7530
diff
changeset
|
142 |
14557
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
143 Cell diag (octave_idx_type m, octave_idx_type n) const; |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
144 |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
145 Cell xisalnum (void) const { return map (&octave_value::xisalnum); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
146 Cell xisalpha (void) const { return map (&octave_value::xisalpha); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
147 Cell xisascii (void) const { return map (&octave_value::xisascii); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
148 Cell xiscntrl (void) const { return map (&octave_value::xiscntrl); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
149 Cell xisdigit (void) const { return map (&octave_value::xisdigit); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
150 Cell xisgraph (void) const { return map (&octave_value::xisgraph); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
151 Cell xislower (void) const { return map (&octave_value::xislower); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
152 Cell xisprint (void) const { return map (&octave_value::xisprint); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
153 Cell xispunct (void) const { return map (&octave_value::xispunct); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
154 Cell xisspace (void) const { return map (&octave_value::xisspace); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
155 Cell xisupper (void) const { return map (&octave_value::xisupper); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
156 Cell xisxdigit (void) const { return map (&octave_value::xisxdigit); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
157 Cell xtolower (void) const { return map (&octave_value::xtolower); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
158 Cell xtoupper (void) const { return map (&octave_value::xtoupper); } |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
159 |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
160 private: |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
161 |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
162 typedef octave_value (octave_value::*ctype_mapper) (void) const; |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
163 |
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
164 Cell map (ctype_mapper) const; |
3353 | 165 }; |
166 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20791
diff
changeset
|
167 template <> |
10757
1cc44f3ec814
templated extractors for maps and cells
Jaroslav Hajek <highegg@gmail.com>
parents:
10649
diff
changeset
|
168 inline Cell octave_value_extract<Cell> (const octave_value& v) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
169 { return v.cell_value (); } |
10757
1cc44f3ec814
templated extractors for maps and cells
Jaroslav Hajek <highegg@gmail.com>
parents:
10649
diff
changeset
|
170 |
3353 | 171 #endif |