Mercurial > octave
annotate libinterp/octave-value/ov-range.cc @ 28126:4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
* mexproto.h, mex.cc, mxarray.h (mxMakeArrayReal, mxMakeArrayComplex,
mxGetDoubles, mxGetSingles, mxGetInt8s, mxGetInt16s, mxGetInt32s,
mxGetInt64s, mxGetUint8s, mxGetUint16s, mxGetUint32s, mxGetUint64s,
mxGetComplexDoubles, mxGetComplexSingles, mxSetDoubles, mxSetSingles,
mxSetInt8s, mxSetInt16s, mxSetInt32s, mxSetInt64s, mxSetUint8s,
mxSetUint16s, mxSetUint32s, mxSetUint64s, mxSetComplexDoubles,
mxSetComplexSingles): New functions. Provide corresponding member
functions in mxArray class hierarchy to handle the actual operations.
(mxGetComplexInt8s, mxGetComplexInt16s, mxGetComplexInt32s,
mxGetComplexInt64s, mxGetComplexUint8s, mxGetComplexUint16s,
mxGetComplexUint32s, mxGetComplexUint64s, mxSetComplexInt8s,
mxSetComplexInt16s, mxSetComplexInt32s, mxSetComplexInt64s,
mxSetComplexUint8s, mxSetComplexUint16s, mxSetComplexUint32s,
mxSetComplexUint64s): Add prototypes and functions, but leave
commented out since we don't have complex integer data.
(class mxArray_number, class mxArray_sparse):
Handle interleaved complex data. In mxArray_octave_value and
mxArray_matlab constructors, handle interleaved flag in constructor to
determine data layout to use when creating mxArray_number or
mxArray_sparse objects.
(mex::make_value): Check flag in mex function to determine whether to
create arrays with interleaved complex.
* ov.h, ov.cc, ov-base.h, ov-base.cc, ov-base-diag.h, ov-base-diag.cc,
ov-bool-mat.h, ov-bool-mat.cc, ov-bool-sparse.h, ov-bool-sparse.cc,
ov-bool.h, ov-bool.cc, ov-cell.h, ov-cell.cc, ov-ch-mat.h,
ov-ch-mat.cc, ov-class.h, ov-class.cc, ov-complex.h, ov-complex.cc,
ov-cx-mat.h, ov-cx-mat.cc, ov-cx-sparse.h, ov-cx-sparse.cc,
ov-float.h, ov-float.cc, ov-flt-complex.h, ov-flt-complex.cc,
ov-flt-cx-mat.h, ov-flt-cx-mat.cc, ov-flt-re-mat.h, ov-flt-re-mat.cc,
ov-intx.h, ov-lazy-idx.h, ov-perm.h, ov-perm.cc, ov-range.h,
ov-range.cc, ov-re-mat.h, ov-re-mat.cc, ov-re-sparse.h,
ov-re-sparse.cc, ov-scalar.h, ov-scalar.cc, ov-struct.h, ov-struct.cc:
In all as_mxArray methods, handle new interleaved input to optionally
create objects that will use interleaved complex data.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 18 Feb 2020 13:16:41 -0500 |
parents | bd51beb6205e |
children | 83172e1c77f2 |
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 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 1996-2020 The Octave Project Developers |
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 //////////////////////////////////////////////////////////////////////// |
2376 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21691
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21211
diff
changeset
|
27 # include "config.h" |
2376 | 28 #endif |
29 | |
25438
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
30 #include <istream> |
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
31 #include <ostream> |
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
32 #include <sstream> |
2901 | 33 |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
34 #include "dNDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
35 #include "fNDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
36 #include "int8NDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
37 #include "int16NDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
38 #include "int32NDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
39 #include "int64NDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
40 #include "uint8NDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
41 #include "uint16NDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
42 #include "uint32NDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
43 #include "uint64NDArray.h" |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
44 |
2376 | 45 #include "lo-ieee.h" |
46 #include "lo-utils.h" | |
47 | |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
48 #include "defun.h" |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
49 #include "variables.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
50 #include "errwarn.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
|
51 #include "mxarray.h" |
2376 | 52 #include "ops.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
53 #include "ovl.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:
19861
diff
changeset
|
54 #include "oct-hdf5.h" |
2376 | 55 #include "ov-range.h" |
56 #include "ov-re-mat.h" | |
2410 | 57 #include "ov-scalar.h" |
2376 | 58 #include "pr-output.h" |
59 | |
4687 | 60 #include "byte-swap.h" |
8946
e7e928088e90
fix CRLF issues with text-mode reading in windows when loading ascii data
Benjamin Lindner <lindnerb@users.sourceforge.net>
parents:
8920
diff
changeset
|
61 #include "ls-ascii-helper.h" |
4687 | 62 #include "ls-hdf5.h" |
63 #include "ls-utils.h" | |
64 | |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
65 |
4612 | 66 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_range, "range", "double"); |
2376 | 67 |
5759 | 68 static octave_base_value * |
69 default_numeric_conversion_function (const octave_base_value& a) | |
2376 | 70 { |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21575
diff
changeset
|
71 const octave_range& v = dynamic_cast<const octave_range&> (a); |
2376 | 72 |
73 return new octave_matrix (v.matrix_value ()); | |
74 } | |
75 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
76 octave_base_value::type_conv_info |
2376 | 77 octave_range::numeric_conversion_function (void) const |
78 { | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
79 return octave_base_value::type_conv_info (default_numeric_conversion_function, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
80 octave_matrix::static_type_id ()); |
2376 | 81 } |
82 | |
5759 | 83 octave_base_value * |
2410 | 84 octave_range::try_narrowing_conversion (void) |
85 { | |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23450
diff
changeset
|
86 octave_base_value *retval = nullptr; |
2410 | 87 |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
88 switch (range.numel ()) |
2410 | 89 { |
90 case 1: | |
91 retval = new octave_scalar (range.base ()); | |
92 break; | |
93 | |
94 case 0: | |
4417 | 95 retval = new octave_matrix (Matrix (1, 0)); |
2410 | 96 break; |
97 | |
8971 | 98 case -2: |
99 retval = new octave_matrix (range.matrix_value ()); | |
100 break; | |
101 | |
2410 | 102 default: |
103 break; | |
104 } | |
105 | |
106 return retval; | |
107 } | |
108 | |
2436 | 109 octave_value |
4247 | 110 octave_range::subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
111 const std::list<octave_value_list>& idx) |
3933 | 112 { |
113 octave_value retval; | |
114 | |
115 switch (type[0]) | |
116 { | |
117 case '(': | |
118 retval = do_index_op (idx.front ()); | |
119 break; | |
120 | |
121 case '{': | |
122 case '.': | |
123 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
124 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
125 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
3933 | 126 } |
127 break; | |
128 | |
129 default: | |
130 panic_impossible (); | |
131 } | |
132 | |
133 return retval.next_subsref (type, idx); | |
134 } | |
135 | |
136 octave_value | |
5885 | 137 octave_range::do_index_op (const octave_value_list& idx, bool resize_ok) |
2436 | 138 { |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
139 if (idx.length () == 1 && ! resize_ok) |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
140 { |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
141 octave_value retval; |
2436 | 142 |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
143 // The range can handle a single subscript. |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
144 |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
145 try |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
146 { |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
147 idx_vector i = idx(0).index_vector (); |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
148 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
149 if (i.is_scalar () && i(0) < range.numel ()) |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
150 retval = range.elem (i(0)); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
151 else |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
152 retval = range.index (i); |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
153 } |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
154 catch (octave::index_exception& e) |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
155 { |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
156 // More info may be added later before displaying error. |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
157 |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
158 e.set_pos_if_unset (1, 1); |
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20228
diff
changeset
|
159 throw; |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
160 } |
2436 | 161 |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
162 return retval; |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
163 } |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
164 else |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
165 { |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
166 octave_value tmp (new octave_matrix (range.matrix_value ())); |
2436 | 167 |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
168 return tmp.do_index_op (idx, resize_ok); |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
169 } |
2436 | 170 } |
171 | |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
172 idx_vector |
18130
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17870
diff
changeset
|
173 octave_range::index_vector (bool require_integers) const |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
174 { |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
175 if (idx_cache) |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
176 return *idx_cache; |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
177 else |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
178 { |
22613
edd04ce99891
Remove functions deprecated in version 4.0.
Rik <rik@octave.org>
parents:
22508
diff
changeset
|
179 if (require_integers || range.all_elements_are_ints ()) |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
180 return set_idx_cache (idx_vector (range)); |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
181 else |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
182 { |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
183 warning_with_id ("Octave:noninteger-range-as-index", |
10609
58bcda68ac11
improve warning/error message
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
184 "non-integer range used as index"); |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
185 |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
186 return octave_value (matrix_value ()).round ().index_vector (); |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
187 } |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
188 } |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
189 } |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
190 |
2376 | 191 double |
192 octave_range::double_value (bool) const | |
193 { | |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
194 octave_idx_type nel = range.numel (); |
2376 | 195 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
196 if (nel == 0) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
197 err_invalid_conversion ("range", "real scalar"); |
4455 | 198 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
199 warn_implicit_conversion ("Octave:array-to-scalar", |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
200 "range", "real scalar"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
201 |
22477
6bf1cbb90705
Remove unnecessary initializations in float_value and double_value methods
Julien Bect <julien.bect@centralesupelec.fr>
parents:
22407
diff
changeset
|
202 return range.base (); |
2376 | 203 } |
204 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
205 float |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
206 octave_range::float_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
207 { |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
208 octave_idx_type nel = range.numel (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
209 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
210 if (nel == 0) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
211 err_invalid_conversion ("range", "real scalar"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
212 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
213 warn_implicit_conversion ("Octave:array-to-scalar", |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
214 "range", "real scalar"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
215 |
22477
6bf1cbb90705
Remove unnecessary initializations in float_value and double_value methods
Julien Bect <julien.bect@centralesupelec.fr>
parents:
22407
diff
changeset
|
216 return range.base (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
217 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
218 |
9146
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
219 charNDArray |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
220 octave_range::char_array_value (bool) const |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
221 { |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
222 const Matrix matrix = range.matrix_value (); |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
223 charNDArray retval (dims ()); |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
224 |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
225 octave_idx_type nel = numel (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
226 |
9146
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
227 for (octave_idx_type i = 0; i < nel; i++) |
25688
b2917b7858ba
maint: Use Octave convention for spacing of C++ cast statements.
Rik <rik@octave.org>
parents:
25438
diff
changeset
|
228 retval.elem (i) = static_cast<char> (matrix.elem (i)); |
9146
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
229 |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
230 return retval; |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
231 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
232 |
2376 | 233 octave_value |
4017 | 234 octave_range::all (int dim) const |
2376 | 235 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
236 // FIXME: this is a potential waste of memory. |
2436 | 237 |
238 Matrix m = range.matrix_value (); | |
239 | |
4017 | 240 return m.all (dim); |
2376 | 241 } |
242 | |
243 octave_value | |
4017 | 244 octave_range::any (int dim) const |
2376 | 245 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
246 // FIXME: this is a potential waste of memory. |
4017 | 247 |
248 Matrix m = range.matrix_value (); | |
249 | |
250 return m.any (dim); | |
2376 | 251 } |
252 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
253 octave_value |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
254 octave_range::diag (octave_idx_type k) const |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
255 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
256 return |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
257 (k == 0 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
258 ? octave_value (DiagMatrix (DiagArray2<double> (range.matrix_value ()))) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
259 : octave_value (range.diag (k))); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
260 } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
261 |
14557
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14469
diff
changeset
|
262 octave_value |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14469
diff
changeset
|
263 octave_range::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:
14469
diff
changeset
|
264 { |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14469
diff
changeset
|
265 Matrix mat = range.matrix_value (); |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14469
diff
changeset
|
266 |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14469
diff
changeset
|
267 return mat.diag (m, n); |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14469
diff
changeset
|
268 } |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
269 |
21990
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
270 // Return true if this range has all true elements (non-zero, not NaN/NA). |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
271 // A range cannot have NaN/NA. |
2376 | 272 bool |
273 octave_range::is_true (void) const | |
274 { | |
275 bool retval = false; | |
2436 | 276 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
277 if (! range.isempty ()) |
2436 | 278 { |
21990
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
279 if (dims ().numel () > 1) |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
280 warn_array_as_logical (dims ()); |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
281 |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
282 Range r = range_value (); |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
283 double base = r.base (); |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
284 double limit = r.limit (); |
2436 | 285 |
21990
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
286 // Can't be zero if we start and finish on the same size of 0 |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
287 if (((base > 0 && limit > 0) || (base < 0 && limit < 0)) && numel () > 0) |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
288 retval = true; |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
289 else |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
290 { |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
291 /* |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
292 // This tells us whether one element is 0, if arithmetic is exact. |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
293 double steps_to_zero = base / r.inc (); |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
294 |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
295 retval = (steps_to_zero != floor (steps_to_zero)); |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
296 */ |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
297 |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
298 // FIXME: this is a waste of memory. |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
299 Matrix m ((range.matrix_value ().all ()).all ()); |
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
300 |
23577
80c42f4cca13
maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents:
23457
diff
changeset
|
301 retval = ! m.isempty () && m(0, 0) != 0.0; |
21990
efce657ceb86
Provide a warning when an array is used in an if/while/until (bug #43098).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21966
diff
changeset
|
302 } |
2436 | 303 } |
304 | |
2376 | 305 return retval; |
306 } | |
307 | |
308 Complex | |
309 octave_range::complex_value (bool) const | |
310 { | |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
311 octave_idx_type nel = range.numel (); |
2376 | 312 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
313 if (nel == 0) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
314 err_invalid_conversion ("range", "complex scalar"); |
4455 | 315 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
316 warn_implicit_conversion ("Octave:array-to-scalar", |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
317 "range", "complex scalar"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
318 |
22508
0b278f54f60a
Remove unnecessary initializations in complex_value methods.
Julien Bect <jbect@users.sourceforge.net>
parents:
22477
diff
changeset
|
319 return Complex (range.base (), 0); |
2376 | 320 } |
321 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
322 FloatComplex |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
323 octave_range::float_complex_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
324 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
325 float tmp = lo_ieee_float_nan_value (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
326 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
327 FloatComplex retval (tmp, tmp); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
328 |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
329 octave_idx_type nel = range.numel (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
330 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
331 if (nel == 0) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
332 err_invalid_conversion ("range", "complex scalar"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
333 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
334 warn_implicit_conversion ("Octave:array-to-scalar", |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
335 "range", "complex scalar"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
336 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
337 retval = range.base (); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
338 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
339 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
340 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
341 |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
342 boolNDArray |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
343 octave_range::bool_array_value (bool warn) const |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
344 { |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
345 Matrix m = range.matrix_value (); |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
346 |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
347 if (m.any_element_is_nan ()) |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
348 octave::err_nan_to_logical_conversion (); |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
349 if (warn && m.any_element_not_one_or_zero ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
350 warn_logical_conversion (); |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
351 |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
352 return boolNDArray (m); |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
353 } |
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
354 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
355 octave_value |
5731 | 356 octave_range::resize (const dim_vector& dv, bool fill) const |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
357 { |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
358 NDArray retval = array_value (); |
5731 | 359 if (fill) |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
360 retval.resize (dv, 0); |
5731 | 361 else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
362 retval.resize (dv); |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
363 return retval; |
5731 | 364 } |
365 | |
2376 | 366 octave_value |
5279 | 367 octave_range::convert_to_str_internal (bool pad, bool force, char type) const |
2449 | 368 { |
369 octave_value tmp (range.matrix_value ()); | |
5279 | 370 return tmp.convert_to_str (pad, force, type); |
2449 | 371 } |
372 | |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
373 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
374 octave_range::as_double (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
375 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
376 return range; |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
377 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
378 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
379 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
380 octave_range::as_single (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
381 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
382 return FloatMatrix (range.matrix_value ()); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
383 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
384 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
385 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
386 octave_range::as_int8 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
387 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
388 return int8NDArray (range.matrix_value ()); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
389 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
390 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
391 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
392 octave_range::as_int16 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
393 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
394 return int16NDArray (range.matrix_value ()); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
395 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
396 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
397 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
398 octave_range::as_int32 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
399 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
400 return int32NDArray (range.matrix_value ()); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
401 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
402 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
403 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
404 octave_range::as_int64 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
405 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
406 return int64NDArray (range.matrix_value ()); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
407 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
408 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
409 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
410 octave_range::as_uint8 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
411 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
412 return uint8NDArray (range.matrix_value ()); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
413 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
414 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
415 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
416 octave_range::as_uint16 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
417 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
418 return uint16NDArray (range.matrix_value ()); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
419 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
420 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
421 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
422 octave_range::as_uint32 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
423 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
424 return uint32NDArray (range.matrix_value ()); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
425 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
426 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
427 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
428 octave_range::as_uint64 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
429 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
430 return uint64NDArray (range.matrix_value ()); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
431 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
432 |
2376 | 433 void |
18416
bcd71a2531d3
Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents:
18132
diff
changeset
|
434 octave_range::print (std::ostream& os, bool pr_as_read_syntax) |
2901 | 435 { |
436 print_raw (os, pr_as_read_syntax); | |
437 newline (os); | |
438 } | |
439 | |
440 void | |
3523 | 441 octave_range::print_raw (std::ostream& os, bool pr_as_read_syntax) const |
2901 | 442 { |
443 octave_print_internal (os, range, pr_as_read_syntax, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
444 current_print_indent_level ()); |
2901 | 445 } |
446 | |
447 bool | |
3523 | 448 octave_range::print_name_tag (std::ostream& os, const std::string& name) const |
2376 | 449 { |
2901 | 450 bool retval = false; |
451 | |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
452 octave_idx_type n = range.numel (); |
2901 | 453 |
454 indent (os); | |
455 | |
456 if (n == 0 || n == 1) | |
457 os << name << " = "; | |
458 else | |
459 { | |
460 os << name << " ="; | |
461 newline (os); | |
13112
969ed305dde5
Remove all blank lines with "format compact"
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12863
diff
changeset
|
462 if (! Vcompact_format) |
969ed305dde5
Remove all blank lines with "format compact"
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12863
diff
changeset
|
463 newline (os); |
969ed305dde5
Remove all blank lines with "format compact"
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
12863
diff
changeset
|
464 |
2901 | 465 retval = true; |
466 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
467 |
2901 | 468 return retval; |
2376 | 469 } |
470 | |
17870 | 471 void |
472 octave_range::short_disp (std::ostream& os) const | |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
473 { |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
474 octave_idx_type len = range.numel (); |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
475 |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
476 if (len == 0) |
17870 | 477 os << "[]"; |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
478 else |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
479 { |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
480 os << range.base () << ':'; |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
481 |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
482 if (len > 1) |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
483 { |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
484 if (range.inc () != 1) |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
485 os << range.inc () << ':'; |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
486 |
17870 | 487 os << range.limit (); |
16468
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
488 } |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
489 } |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
490 } |
0f143f68078d
use signal/slot for updating workspace instead of using event listener
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
491 |
4687 | 492 // Skip white space and comments on stream IS. |
493 | |
494 static void | |
495 skip_comments (std::istream& is) | |
496 { | |
497 char c = '\0'; | |
498 while (is.get (c)) | |
499 { | |
500 if (c == ' ' || c == '\t' || c == '\n') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
501 ; // Skip whitespace on way to beginning of next line. |
4687 | 502 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
503 break; |
4687 | 504 } |
505 | |
8946
e7e928088e90
fix CRLF issues with text-mode reading in windows when loading ascii data
Benjamin Lindner <lindnerb@users.sourceforge.net>
parents:
8920
diff
changeset
|
506 skip_until_newline (is, false); |
4687 | 507 } |
508 | |
24745
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
509 float_display_format |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
510 octave_range::get_edit_display_format (void) const |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
511 { |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
512 return make_format (range_value ()); |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
513 } |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
514 |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
515 std::string |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
516 octave_range::edit_display (const float_display_format& fmt, |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
517 octave_idx_type, octave_idx_type j) const |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
518 { |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
519 std::ostringstream buf; |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
520 octave_print_internal (buf, fmt, range.elem (j)); |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
521 return buf.str (); |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
522 } |
d2467914ce33
enable (or improve) display for more types in the variable editor
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
523 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
524 bool |
6974 | 525 octave_range::save_ascii (std::ostream& os) |
4687 | 526 { |
527 Range r = range_value (); | |
528 double base = r.base (); | |
529 double limit = r.limit (); | |
530 double inc = r.inc (); | |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
531 octave_idx_type len = r.numel (); |
4687 | 532 |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
533 if (inc != 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
534 os << "# base, limit, increment\n"; |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
535 else |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
536 os << "# base, length, increment\n"; |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
537 |
4687 | 538 octave_write_double (os, base); |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
539 os << ' '; |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
540 if (inc != 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
541 octave_write_double (os, limit); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
542 else |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
543 os << len; |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
544 os << ' '; |
4687 | 545 octave_write_double (os, inc); |
546 os << "\n"; | |
547 | |
548 return true; | |
549 } | |
550 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
551 bool |
4687 | 552 octave_range::load_ascii (std::istream& is) |
553 { | |
554 // # base, limit, range comment added by save (). | |
555 skip_comments (is); | |
556 | |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
557 double base, limit, inc; |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
558 is >> base >> limit >> inc; |
4687 | 559 |
20893
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
560 if (! is) |
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
561 error ("load: failed to load range constant"); |
4687 | 562 |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
563 if (inc != 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
564 range = Range (base, limit, inc); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
565 else |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
566 range = Range (base, inc, static_cast<octave_idx_type> (limit)); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
567 |
4687 | 568 return true; |
569 } | |
570 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
571 bool |
26399
586413770c7f
pass save_as_floats by value in octave_value save_binary functions
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
572 octave_range::save_binary (std::ostream& os, bool /* save_as_floats */) |
4687 | 573 { |
5760 | 574 char tmp = LS_DOUBLE; |
575 os.write (reinterpret_cast<char *> (&tmp), 1); | |
4687 | 576 Range r = range_value (); |
577 double bas = r.base (); | |
578 double lim = r.limit (); | |
579 double inc = r.inc (); | |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
580 if (inc == 0) |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
581 lim = r.numel (); |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
582 |
5760 | 583 os.write (reinterpret_cast<char *> (&bas), 8); |
584 os.write (reinterpret_cast<char *> (&lim), 8); | |
585 os.write (reinterpret_cast<char *> (&inc), 8); | |
4687 | 586 |
587 return true; | |
588 } | |
589 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
590 bool |
4687 | 591 octave_range::load_binary (std::istream& is, bool swap, |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
592 octave::mach_info::float_format /* fmt */) |
4687 | 593 { |
594 char tmp; | |
5760 | 595 if (! is.read (reinterpret_cast<char *> (&tmp), 1)) |
4687 | 596 return false; |
597 double bas, lim, inc; | |
5760 | 598 if (! is.read (reinterpret_cast<char *> (&bas), 8)) |
4687 | 599 return false; |
600 if (swap) | |
4944 | 601 swap_bytes<8> (&bas); |
5760 | 602 if (! is.read (reinterpret_cast<char *> (&lim), 8)) |
4687 | 603 return false; |
604 if (swap) | |
4944 | 605 swap_bytes<8> (&lim); |
5760 | 606 if (! is.read (reinterpret_cast<char *> (&inc), 8)) |
4687 | 607 return false; |
608 if (swap) | |
4944 | 609 swap_bytes<8> (&inc); |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
610 if (inc != 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
611 range = Range (bas, lim, inc); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
612 else |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
613 range = Range (bas, inc, static_cast<octave_idx_type> (lim)); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
614 |
4687 | 615 return true; |
616 } | |
617 | |
618 #if defined (HAVE_HDF5) | |
4944 | 619 |
4687 | 620 // The following subroutines creates an HDF5 representation of the way |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
621 // we will store Octave range types (triplets of floating-point numbers). |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
622 // NUM_TYPE is the HDF5 numeric type to use for storage (e.g. |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21739
diff
changeset
|
623 // H5T_NATIVE_DOUBLE to save as 'double'). Note that any necessary |
4687 | 624 // conversions are handled automatically by HDF5. |
625 | |
626 static hid_t | |
627 hdf5_make_range_type (hid_t num_type) | |
628 { | |
629 hid_t type_id = H5Tcreate (H5T_COMPOUND, sizeof (double) * 3); | |
630 | |
631 H5Tinsert (type_id, "base", 0 * sizeof (double), num_type); | |
632 H5Tinsert (type_id, "limit", 1 * sizeof (double), num_type); | |
633 H5Tinsert (type_id, "increment", 2 * sizeof (double), num_type); | |
634 | |
635 return type_id; | |
636 } | |
637 | |
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:
19861
diff
changeset
|
638 #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:
19861
diff
changeset
|
639 |
4687 | 640 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:
19861
diff
changeset
|
641 octave_range::save_hdf5 (octave_hdf5_id loc_id, const char *name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
642 bool /* save_as_floats */) |
4687 | 643 { |
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:
19861
diff
changeset
|
644 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:
19861
diff
changeset
|
645 |
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:
19861
diff
changeset
|
646 #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:
19861
diff
changeset
|
647 |
4792 | 648 hsize_t dimens[3]; |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17870
diff
changeset
|
649 hid_t space_hid, type_hid, data_hid; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17870
diff
changeset
|
650 space_hid = type_hid = data_hid = -1; |
4687 | 651 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23577
diff
changeset
|
652 space_hid = H5Screate_simple (0, dimens, nullptr); |
4687 | 653 if (space_hid < 0) return false; |
654 | |
655 type_hid = hdf5_make_range_type (H5T_NATIVE_DOUBLE); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
656 if (type_hid < 0) |
4687 | 657 { |
658 H5Sclose (space_hid); | |
659 return false; | |
660 } | |
21211
2cf8bc5c7017
use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
661 #if defined (HAVE_HDF5_18) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
662 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
20988
diff
changeset
|
663 octave_H5P_DEFAULT, octave_H5P_DEFAULT, octave_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
|
664 #else |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
20988
diff
changeset
|
665 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, octave_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
|
666 #endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
667 if (data_hid < 0) |
4687 | 668 { |
669 H5Sclose (space_hid); | |
670 H5Tclose (type_hid); | |
671 return false; | |
672 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
673 |
4687 | 674 Range r = range_value (); |
675 double range_vals[3]; | |
676 range_vals[0] = r.base (); | |
23450
855122b993da
maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
677 range_vals[1] = (r.inc () != 0 ? r.limit () : r.numel ()); |
4687 | 678 range_vals[2] = r.inc (); |
679 | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
680 if (H5Dwrite (data_hid, type_hid, octave_H5S_ALL, octave_H5S_ALL, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
681 octave_H5P_DEFAULT, range_vals) |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
682 >= 0) |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
683 { |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
684 octave_idx_type nel = r.numel (); |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
685 retval = hdf5_add_scalar_attr (data_hid, H5T_NATIVE_IDX, |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
686 "OCTAVE_RANGE_NELEM", &nel) >= 0; |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
687 } |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
688 else |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
689 retval = false; |
4687 | 690 |
691 H5Dclose (data_hid); | |
692 H5Tclose (type_hid); | |
693 H5Sclose (space_hid); | |
4837 | 694 |
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:
19861
diff
changeset
|
695 #else |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
696 octave_unused_parameter (loc_id); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
697 octave_unused_parameter (name); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
698 |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
699 warn_save ("hdf5"); |
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:
19861
diff
changeset
|
700 #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:
19861
diff
changeset
|
701 |
4687 | 702 return retval; |
703 } | |
704 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
705 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:
19861
diff
changeset
|
706 octave_range::load_hdf5 (octave_hdf5_id loc_id, const char *name) |
4687 | 707 { |
708 bool retval = false; | |
4837 | 709 |
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:
19861
diff
changeset
|
710 #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:
19861
diff
changeset
|
711 |
21211
2cf8bc5c7017
use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
712 #if defined (HAVE_HDF5_18) |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
20988
diff
changeset
|
713 hid_t data_hid = H5Dopen (loc_id, name, octave_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
|
714 #else |
4687 | 715 hid_t data_hid = H5Dopen (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
|
716 #endif |
4687 | 717 hid_t type_hid = H5Dget_type (data_hid); |
718 | |
719 hid_t range_type = hdf5_make_range_type (H5T_NATIVE_DOUBLE); | |
720 | |
721 if (! hdf5_types_compatible (type_hid, range_type)) | |
722 { | |
4837 | 723 H5Tclose (range_type); |
4687 | 724 H5Dclose (data_hid); |
725 return false; | |
726 } | |
727 | |
728 hid_t space_hid = H5Dget_space (data_hid); | |
729 hsize_t rank = H5Sget_simple_extent_ndims (space_hid); | |
730 | |
731 if (rank != 0) | |
732 { | |
4837 | 733 H5Tclose (range_type); |
4687 | 734 H5Sclose (space_hid); |
735 H5Dclose (data_hid); | |
736 return false; | |
737 } | |
738 | |
739 double rangevals[3]; | |
22407
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
740 if (H5Dread (data_hid, range_type, octave_H5S_ALL, octave_H5S_ALL, |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
741 octave_H5P_DEFAULT, rangevals) |
34ce5be04942
maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents:
22327
diff
changeset
|
742 >= 0) |
4687 | 743 { |
744 retval = true; | |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
745 octave_idx_type nel; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
746 if (hdf5_get_scalar_attr (data_hid, H5T_NATIVE_IDX, |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
747 "OCTAVE_RANGE_NELEM", &nel)) |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
748 range = Range (rangevals[0], rangevals[2], nel); |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
749 else |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
750 { |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
751 if (rangevals[2] != 0) |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
752 range = Range (rangevals[0], rangevals[1], rangevals[2]); |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
753 else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
754 range = Range (rangevals[0], rangevals[2], |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
755 static_cast<octave_idx_type> (rangevals[1])); |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
11129
diff
changeset
|
756 } |
4687 | 757 } |
758 | |
4837 | 759 H5Tclose (range_type); |
4687 | 760 H5Sclose (space_hid); |
761 H5Dclose (data_hid); | |
4837 | 762 |
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:
19861
diff
changeset
|
763 #else |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
764 octave_unused_parameter (loc_id); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
765 octave_unused_parameter (name); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
766 |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
767 warn_load ("hdf5"); |
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:
19861
diff
changeset
|
768 #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:
19861
diff
changeset
|
769 |
4687 | 770 return retval; |
771 } | |
4944 | 772 |
5900 | 773 mxArray * |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
774 octave_range::as_mxArray (bool interleaved) const |
5900 | 775 { |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
776 mxArray *retval = new mxArray (interleaved, mxDOUBLE_CLASS, dims (), mxREAL); |
5900 | 777 |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
778 mxDouble *pd = static_cast<mxDouble *> (retval->get_data ()); |
5900 | 779 |
6686 | 780 mwSize nel = numel (); |
5900 | 781 |
782 Matrix m = matrix_value (); | |
783 | |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
784 const double *pdata = m.data (); |
5900 | 785 |
6686 | 786 for (mwSize i = 0; i < nel; i++) |
28126
4c21f99b4ad5
handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
787 pd[i] = pdata[i]; |
5900 | 788 |
789 return retval; | |
790 } | |
10613
e103fb2182ce
use internal variable instead of warning state to control whether to allow non-integer ranges as indices
John W. Eaton <jwe@octave.org>
parents:
10609
diff
changeset
|
791 |
18650
491b0adfec95
compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents:
18416
diff
changeset
|
792 octave_value |
491b0adfec95
compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents:
18416
diff
changeset
|
793 octave_range::fast_elem_extract (octave_idx_type n) const |
491b0adfec95
compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents:
18416
diff
changeset
|
794 { |
20228
00cf2847355d
Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
20163
diff
changeset
|
795 return (n < range.numel ()) ? octave_value (range.elem (n)) |
19861
19755f4fc851
maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
796 : octave_value (); |
18650
491b0adfec95
compatibility fixes for printf integer format specifiers
John W. Eaton <jwe@octave.org>
parents:
18416
diff
changeset
|
797 } |