Mercurial > octave
annotate libinterp/corefcn/Cell.cc @ 33617:ec2635a02328 bytecode-interpreter tip
maint: Merge default to bytecode-interpreter.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 21 May 2024 18:29:03 +0200 |
parents | f53ac65ffba6 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31771
diff
changeset
|
3 // Copyright (C) 1999-2024 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
3353 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21580
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
3353 | 28 #endif |
29 | |
4513 | 30 #include "idx-vector.h" |
31 | |
3353 | 32 #include "Cell.h" |
4919 | 33 #include "error.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20980
diff
changeset
|
34 #include "errwarn.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
35 #include "ovl.h" |
8579
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8290
diff
changeset
|
36 |
7e0f36dfefbe
implement octave_value_list using Array
Jaroslav Hajek <highegg@gmail.com>
parents:
8290
diff
changeset
|
37 Cell::Cell (const octave_value_list& ovl) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9415
diff
changeset
|
38 : Array<octave_value> (ovl.cell_value ()) |
22417
48c00363dc74
maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
39 { } |
3353 | 40 |
5805 | 41 Cell::Cell (const string_vector& sv, bool trim) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9415
diff
changeset
|
42 : Array<octave_value> () |
4216 | 43 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
44 octave_idx_type n = sv.numel (); |
4216 | 45 |
46 if (n > 0) | |
47 { | |
4625 | 48 resize (dim_vector (n, 1)); |
4216 | 49 |
5275 | 50 for (octave_idx_type i = 0; i < n; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
51 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
52 std::string s = sv[i]; |
5805 | 53 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
54 if (trim) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
55 { |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
56 std::size_t pos = s.find_last_not_of (' '); |
5805 | 57 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
58 s = (pos == std::string::npos) ? "" : s.substr (0, pos+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
59 } |
5805 | 60 |
30390
a61e1a0f6024
maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29655
diff
changeset
|
61 elem (i, 0) = s; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
62 } |
4216 | 63 } |
64 } | |
3354 | 65 |
28431
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
66 Cell::Cell (const std::list<std::string>& sl) |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
67 : Array<octave_value> () |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
68 { |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
69 octave_idx_type n = sl.size (); |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
70 |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
71 if (n > 0) |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
72 { |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
73 resize (dim_vector (n, 1)); |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
74 |
32660
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
75 octave_value *dst = rwdata (); |
28431
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
76 auto p = sl.begin (); |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
77 |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
78 for (octave_idx_type i = 0; i < n; i++) |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
79 dst[i] = *p++; |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
80 } |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
81 } |
0ffae065ca03
new cellstring constructor
John W. Eaton <jwe@octave.org>
parents:
27957
diff
changeset
|
82 |
8732 | 83 Cell::Cell (const Array<std::string>& sa) |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9415
diff
changeset
|
84 : Array<octave_value> (sa.dims ()) |
8732 | 85 { |
86 octave_idx_type n = sa.numel (); | |
87 | |
32660
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
88 octave_value *dst = rwdata (); |
8732 | 89 const std::string *src = sa.data (); |
90 | |
91 for (octave_idx_type i = 0; i < n; i++) | |
92 dst[i] = src[i]; | |
93 } | |
94 | |
6116 | 95 // Set size to DV, filling with []. Then fill with as many elements of |
96 // SV as possible. | |
7209 | 97 |
6116 | 98 Cell::Cell (const dim_vector& dv, const string_vector& sv, bool trim) |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
99 : Array<octave_value> (dv, Matrix ()) |
6116 | 100 { |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
101 octave_idx_type n = sv.numel (); |
6116 | 102 |
103 if (n > 0) | |
104 { | |
105 octave_idx_type m = numel (); | |
106 | |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23355
diff
changeset
|
107 octave_idx_type len = (n > m ? m : n); |
6116 | 108 |
109 for (octave_idx_type i = 0; i < len; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
110 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
111 std::string s = sv[i]; |
6116 | 112 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
113 if (trim) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
114 { |
29654
d13d090cb03a
use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
115 std::size_t pos = s.find_last_not_of (' '); |
6116 | 116 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
117 s = (pos == std::string::npos) ? "" : s.substr (0, pos+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
118 } |
6116 | 119 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
120 elem(i) = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
121 } |
6116 | 122 } |
123 } | |
124 | |
125 bool | |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
126 Cell::iscellstr () const |
6116 | 127 { |
128 bool retval = true; | |
129 | |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
130 octave_idx_type n = numel (); |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
131 |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
132 for (octave_idx_type i = 0; i < n; i++) |
6116 | 133 { |
134 if (! elem(i).is_string ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
135 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
136 retval = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
137 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
138 } |
6116 | 139 } |
140 | |
141 return retval; | |
142 } | |
143 | |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
144 Array<std::string> |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
145 Cell::cellstr_value () const |
10065
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
146 { |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
147 Array<std::string> retval (dims ()); |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
148 |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
149 octave_idx_type n = numel (); |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
150 |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
151 for (octave_idx_type i = 0; i < n; i++) |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
152 retval.xelem (i) = elem (i).string_value (); |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
153 |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
154 return retval; |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
155 } |
64a06079cae4
improve cellstr cache implementation
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
156 |
23355
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
157 string_vector |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
158 Cell::string_vector_value () const |
23355
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
159 { |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
160 octave_idx_type n = numel (); |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
161 |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
162 string_vector retval (n); |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
163 |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
164 for (octave_idx_type i = 0; i < n; i++) |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
165 retval.xelem (i) = elem (i).string_value (); |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
166 |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
167 return retval; |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
168 } |
08db4e9dd149
* Cell.h, Cell.cc (Cell::string_vector_value): New function.
John W. Eaton <jwe@octave.org>
parents:
23220
diff
changeset
|
169 |
4513 | 170 Cell |
4587 | 171 Cell::index (const octave_value_list& idx_arg, bool resize_ok) const |
4513 | 172 { |
173 Cell retval; | |
174 | |
5275 | 175 octave_idx_type n = idx_arg.length (); |
4513 | 176 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
177 // If we catch an indexing error in index_vector, we flag an error |
27956
2310164737b3
fix many spelling errors (bug #57613)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
178 // in index k. Ensure it is the right value before each idx_vector |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
179 // call. Same variable as used in for loop in default case. |
5539 | 180 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
181 octave_idx_type k = 0; |
4513 | 182 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
183 try |
4513 | 184 { |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
185 switch (n) |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
186 { |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
187 case 0: |
27061
d61825e693f2
warn about indexing values with () (bug #56167)
John W. Eaton <jwe@octave.org>
parents:
27060
diff
changeset
|
188 warn_empty_index ("cell array"); |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
189 retval = *this; |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
190 break; |
4513 | 191 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
192 case 1: |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
193 { |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
194 octave::idx_vector i = idx_arg(0).index_vector (); |
4513 | 195 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
196 retval = Array<octave_value>::index (i, resize_ok, Matrix ()); |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
197 } |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
198 break; |
4513 | 199 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
200 case 2: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
201 { |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
202 octave::idx_vector i = idx_arg(0).index_vector (); |
4919 | 203 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
204 k = 1; |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
205 octave::idx_vector j = idx_arg(1).index_vector (); |
4919 | 206 |
20667
8742e0b1cc49
eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
207 retval = Array<octave_value>::index (i, j, resize_ok, Matrix ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
208 } |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
209 break; |
4513 | 210 |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
211 default: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
212 { |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
213 Array<octave::idx_vector> iv (dim_vector (n, 1)); |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
214 |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
215 for (k = 0; k < n; k++) |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
216 iv(k) = idx_arg(k).index_vector (); |
4513 | 217 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
218 retval = Array<octave_value>::index (iv, resize_ok, Matrix ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
219 } |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
220 break; |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
221 } |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
222 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28907
diff
changeset
|
223 catch (octave::index_exception& ie) |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
224 { |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
225 // Rethrow to allow more info to be reported later. |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28907
diff
changeset
|
226 ie.set_pos_if_unset (n, k+1); |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
227 throw; |
4513 | 228 } |
229 | |
230 return retval; | |
231 } | |
232 | |
19140
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
233 /* |
27060
3140380861ce
error for x{} for cell array objects (bug #56167)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
234 %% This behavior is required for Matlab compatibility. |
3140380861ce
error for x{} for cell array objects (bug #56167)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
235 %!shared a |
19140
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
236 %! a = {"foo", "bar"}; |
28907
11f1207111c5
maint: Don't use semicolon at end of single-line BIST tests.
Rik <rik@octave.org>
parents:
28431
diff
changeset
|
237 %!assert (a(), a) |
27060
3140380861ce
error for x{} for cell array objects (bug #56167)
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
238 %!error <invalid empty index expression> a{} |
19140
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
239 */ |
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
240 |
10649
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
241 void |
4587 | 242 Cell::assign (const octave_value_list& idx_arg, const Cell& rhs, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
243 const octave_value& fill_val) |
4513 | 244 |
245 { | |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
246 octave_idx_type len = idx_arg.length (); |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
247 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
248 Array<octave::idx_vector> ra_idx (dim_vector (len, 1)); |
4513 | 249 |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
250 for (octave_idx_type i = 0; i < len; i++) |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
251 { |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
252 try |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
253 { |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
254 ra_idx(i) = idx_arg(i).index_vector (); |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
255 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28907
diff
changeset
|
256 catch (octave::index_exception& ie) |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
257 { |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
258 // Rethrow to allow more info to be reported later. |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28907
diff
changeset
|
259 ie.set_pos (len, i+1); |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
260 throw; |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
261 } |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
262 } |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
263 |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
264 Array<octave_value>::assign (ra_idx, rhs, fill_val); |
4513 | 265 } |
266 | |
10649
64472dd48517
cosmetic changes in Cell interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
267 void |
8175
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
8021
diff
changeset
|
268 Cell::delete_elements (const octave_value_list& idx_arg) |
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
8021
diff
changeset
|
269 |
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
8021
diff
changeset
|
270 { |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
271 octave_idx_type len = idx_arg.length (); |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
272 |
29569
29a1f8fd8ee6
move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
273 Array<octave::idx_vector> ra_idx (dim_vector (len, 1)); |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
274 |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
275 for (octave_idx_type i = 0; i < len; i++) |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
276 try |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
277 { |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
278 ra_idx.xelem (i) = idx_arg(i).index_vector (); |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20232
diff
changeset
|
279 } |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28907
diff
changeset
|
280 catch (octave::index_exception& ie) |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
281 { |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
282 // Rethrow to allow more info to be reported later. |
29163
8f67ad8b3103
maint: Updating naming conventions for exceptions and use const where possible.
Rik <rik@octave.org>
parents:
28907
diff
changeset
|
283 ie.set_pos (len, i+1); |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
284 throw; |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
285 } |
8175
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
8021
diff
changeset
|
286 |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
8179
diff
changeset
|
287 Array<octave_value>::delete_elements (ra_idx); |
8175
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
8021
diff
changeset
|
288 } |
977d5204cf67
fix null assignment for structs
Jaroslav Hajek <highegg@gmail.com>
parents:
8021
diff
changeset
|
289 |
5602 | 290 octave_idx_type |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
291 Cell::nnz () const |
5602 | 292 { |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
20980
diff
changeset
|
293 err_wrong_type_arg ("nnz", "cell array"); |
5602 | 294 } |
295 | |
19140
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
296 /* |
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
297 %!error <wrong type argument 'cell array'> nnz ({0, 1, 2}) |
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
298 %!error <wrong type argument 'cell array'> nnz (cell ()) |
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
299 %!error <wrong type argument 'cell array'> nnz ({"foo", "bar"}) |
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
300 */ |
b5a0f11db158
Cell.cc: add tests for Cell::nnz
Carnë Draug <carandraug+dev@gmail.com>
parents:
17744
diff
changeset
|
301 |
4915 | 302 Cell |
5570 | 303 Cell::column (octave_idx_type i) const |
304 { | |
305 Cell retval; | |
306 | |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
307 if (ndims () > 2) |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
308 error ("Cell::column: requires 2-D cell array"); |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20726
diff
changeset
|
309 |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
310 if (i < 0 || i >= cols ()) |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
311 error ("invalid column selection"); |
5570 | 312 |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
313 octave_idx_type nr = rows (); |
5570 | 314 |
20980
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
315 retval.resize (dim_vector (nr, 1)); |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
316 |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
317 for (octave_idx_type j = 0; j < nr; j++) |
81c2b14c209f
maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents:
20940
diff
changeset
|
318 retval.xelem (j) = elem (j, i); |
5570 | 319 |
320 return retval; | |
321 } | |
322 | |
323 Cell | |
5275 | 324 Cell::concat (const Cell& rb, const Array<octave_idx_type>& ra_idx) |
4806 | 325 { |
5073 | 326 return insert (rb, ra_idx); |
4915 | 327 } |
328 | |
329 Cell& | |
5275 | 330 Cell::insert (const Cell& a, octave_idx_type r, octave_idx_type c) |
4915 | 331 { |
332 Array<octave_value>::insert (a, r, c); | |
333 return *this; | |
334 } | |
335 | |
336 Cell& | |
5275 | 337 Cell::insert (const Cell& a, const Array<octave_idx_type>& ra_idx) |
4915 | 338 { |
339 Array<octave_value>::insert (a, ra_idx); | |
340 return *this; | |
4806 | 341 } |
342 | |
7530
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
343 Cell |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
344 Cell::map (ctype_mapper fcn) const |
7530
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
345 { |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
346 Cell retval (dims ()); |
32660
f53ac65ffba6
maint: New method rwdata() as clearer alternative to fortran_vec().
Rik <rik@octave.org>
parents:
32632
diff
changeset
|
347 octave_value *r = retval.rwdata (); |
7530
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
348 |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
349 const octave_value *p = data (); |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
350 |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
351 for (octave_idx_type i = 0; i < numel (); i++) |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
352 r[i] = ((p++)->*fcn) (); |
7530
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
353 |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
354 return retval; |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
355 } |
bb0f2353cff5
new cell array ctype mappers
John W. Eaton <jwe@octave.org>
parents:
7209
diff
changeset
|
356 |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
357 octave_value |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
358 Cell::resize_fill_value () const |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
359 { |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
360 static octave_value rfv = octave_value (Matrix ()); |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
361 return rfv; |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
362 } |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
363 |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7530
diff
changeset
|
364 Cell |
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7530
diff
changeset
|
365 Cell::diag (octave_idx_type k) const |
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7530
diff
changeset
|
366 { |
9732
b4fdfee405b5
remove ArrayN<T> + fix nonhom. diag-scalar ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9415
diff
changeset
|
367 return Array<octave_value>::diag (k); |
7618
3209a584e1ac
Further type preservation tests and fix of diag for cell arrays
David Bateman <dbateman@free.fr>
parents:
7530
diff
changeset
|
368 } |
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
|
369 |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
370 Cell |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
371 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
|
372 { |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
373 return Array<octave_value>::diag (m, n); |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
374 } |