Mercurial > hg > octave-nkf
annotate src/ov-range.cc @ 10828:322f43e0e170
Grammarcheck .txi documentation files.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Wed, 28 Jul 2010 12:45:04 -0700 |
parents | d899b2ee6a37 |
children | 89f4d7e294cc |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, |
8920 | 4 2007, 2008 John W. Eaton |
2376 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2376 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2376 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
3503 | 28 #include <iostream> |
2901 | 29 |
2376 | 30 #include "lo-ieee.h" |
31 #include "lo-utils.h" | |
32 | |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
33 #include "defun.h" |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
34 #include "variables.h" |
2376 | 35 #include "gripes.h" |
36 #include "ops.h" | |
3933 | 37 #include "oct-obj.h" |
2376 | 38 #include "ov-range.h" |
39 #include "ov-re-mat.h" | |
2410 | 40 #include "ov-scalar.h" |
2376 | 41 #include "pr-output.h" |
42 | |
4687 | 43 #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
|
44 #include "ls-ascii-helper.h" |
4687 | 45 #include "ls-hdf5.h" |
46 #include "ls-utils.h" | |
47 | |
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
|
48 // If TRUE, allow ranges with non-integer elements as array indices. |
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
|
49 bool Vallow_noninteger_range_as_index = false; |
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
|
50 |
3219 | 51 DEFINE_OCTAVE_ALLOCATOR (octave_range); |
2376 | 52 |
4612 | 53 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_range, "range", "double"); |
2376 | 54 |
5759 | 55 static octave_base_value * |
56 default_numeric_conversion_function (const octave_base_value& a) | |
2376 | 57 { |
58 CAST_CONV_ARG (const octave_range&); | |
59 | |
60 return new octave_matrix (v.matrix_value ()); | |
61 } | |
62 | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
63 octave_base_value::type_conv_info |
2376 | 64 octave_range::numeric_conversion_function (void) const |
65 { | |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
66 return octave_base_value::type_conv_info (default_numeric_conversion_function, |
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
67 octave_matrix::static_type_id ()); |
2376 | 68 } |
69 | |
5759 | 70 octave_base_value * |
2410 | 71 octave_range::try_narrowing_conversion (void) |
72 { | |
5759 | 73 octave_base_value *retval = 0; |
2410 | 74 |
75 switch (range.nelem ()) | |
76 { | |
77 case 1: | |
78 retval = new octave_scalar (range.base ()); | |
79 break; | |
80 | |
81 case 0: | |
4417 | 82 retval = new octave_matrix (Matrix (1, 0)); |
2410 | 83 break; |
84 | |
8971 | 85 case -2: |
86 retval = new octave_matrix (range.matrix_value ()); | |
87 break; | |
88 | |
2410 | 89 default: |
90 break; | |
91 } | |
92 | |
93 return retval; | |
94 } | |
95 | |
2436 | 96 octave_value |
4247 | 97 octave_range::subsref (const std::string& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
98 const std::list<octave_value_list>& idx) |
3933 | 99 { |
100 octave_value retval; | |
101 | |
102 switch (type[0]) | |
103 { | |
104 case '(': | |
105 retval = do_index_op (idx.front ()); | |
106 break; | |
107 | |
108 case '{': | |
109 case '.': | |
110 { | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
111 std::string nm = type_name (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
112 error ("%s cannot be indexed with %c", nm.c_str (), type[0]); |
3933 | 113 } |
114 break; | |
115 | |
116 default: | |
117 panic_impossible (); | |
118 } | |
119 | |
120 return retval.next_subsref (type, idx); | |
121 } | |
122 | |
123 octave_value | |
5885 | 124 octave_range::do_index_op (const octave_value_list& idx, bool resize_ok) |
2436 | 125 { |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
126 if (idx.length () == 1 && ! resize_ok) |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
127 { |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
128 octave_value retval; |
2436 | 129 |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
130 // The range can handle a single subscript. |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
131 idx_vector i = idx(0).index_vector (); |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
132 if (! error_state) |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
133 { |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
134 if (i.is_scalar () && i(0) < range.nelem ()) |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
135 retval = range.elem (i(0)); |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
136 else |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
137 retval = range.index (i); |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
138 } |
2436 | 139 |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
140 return retval; |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
141 } |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
142 else |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
143 { |
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
144 octave_value tmp (new octave_matrix (range.matrix_value ())); |
2436 | 145 |
9986
672e1b49e01e
optimize indexing of ranges by single subscripts
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
146 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
|
147 } |
2436 | 148 } |
149 | |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
150 idx_vector |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
151 octave_range::index_vector (void) const |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
152 { |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
153 if (idx_cache) |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
154 return *idx_cache; |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
155 else |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
156 { |
10616
d61caf612f1e
optimize order of conditions in octave_range::index_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
10613
diff
changeset
|
157 if (! Vallow_noninteger_range_as_index |
d61caf612f1e
optimize order of conditions in octave_range::index_vector
Jaroslav Hajek <highegg@gmail.com>
parents:
10613
diff
changeset
|
158 || range.all_elements_are_ints ()) |
10605
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
159 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
|
160 else |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
161 { |
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
|
162 warning_with_id ("Octave:noninteger-range-as-index", |
10609
58bcda68ac11
improve warning/error message
John W. Eaton <jwe@octave.org>
parents:
10605
diff
changeset
|
163 "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
|
164 |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
165 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
|
166 } |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
167 } |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
168 } |
1834132fb50b
allow non-integer ranges as indices conditionally
John W. Eaton <jwe@octave.org>
parents:
10315
diff
changeset
|
169 |
2376 | 170 double |
171 octave_range::double_value (bool) const | |
172 { | |
4102 | 173 double retval = lo_ieee_nan_value (); |
2376 | 174 |
5275 | 175 octave_idx_type nel = range.nelem (); |
2376 | 176 |
4455 | 177 if (nel > 0) |
178 { | |
5781 | 179 gripe_implicit_conversion ("Octave:array-as-scalar", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
180 "range", "real scalar"); |
4455 | 181 |
182 retval = range.base (); | |
183 } | |
2376 | 184 else |
185 gripe_invalid_conversion ("range", "real scalar"); | |
186 | |
187 return retval; | |
188 } | |
189 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
190 float |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
191 octave_range::float_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
192 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
193 float retval = lo_ieee_float_nan_value (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
194 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
195 octave_idx_type nel = range.nelem (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
196 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
197 if (nel > 0) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
198 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
199 gripe_implicit_conversion ("Octave:array-as-scalar", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
200 "range", "real scalar"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
201 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
202 retval = range.base (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
203 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
204 else |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
205 gripe_invalid_conversion ("range", "real scalar"); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
206 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
207 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
208 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
209 |
9146
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
210 charNDArray |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
211 octave_range::char_array_value (bool) const |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
212 { |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
213 const Matrix matrix = range.matrix_value (); |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
214 charNDArray retval (dims ()); |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
215 |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
216 octave_idx_type nel = numel (); |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
217 |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
218 for (octave_idx_type i = 0; i < nel; i++) |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
219 retval.elem (i) = static_cast<char>(matrix.elem (i)); |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
220 |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
221 return retval; |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
222 } |
a48c500e48e1
support range->string conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
8971
diff
changeset
|
223 |
2376 | 224 octave_value |
4017 | 225 octave_range::all (int dim) const |
2376 | 226 { |
5775 | 227 // FIXME -- this is a potential waste of memory. |
2436 | 228 |
229 Matrix m = range.matrix_value (); | |
230 | |
4017 | 231 return m.all (dim); |
2376 | 232 } |
233 | |
234 octave_value | |
4017 | 235 octave_range::any (int dim) const |
2376 | 236 { |
5775 | 237 // FIXME -- this is a potential waste of memory. |
4017 | 238 |
239 Matrix m = range.matrix_value (); | |
240 | |
241 return m.any (dim); | |
2376 | 242 } |
243 | |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
244 octave_value |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
245 octave_range::diag (octave_idx_type k) const |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
246 { |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
247 return (k == 0 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
248 ? octave_value (DiagMatrix (DiagArray2<double> (range.matrix_value ()))) |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
249 : octave_value (range.diag (k))); |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
250 } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
251 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
252 |
2376 | 253 bool |
254 octave_range::is_true (void) const | |
255 { | |
256 bool retval = false; | |
2436 | 257 |
4478 | 258 if (range.nelem () != 0) |
2436 | 259 { |
5775 | 260 // FIXME -- this is a potential waste of memory. |
2436 | 261 |
262 Matrix m ((range.matrix_value () . all ()) . all ()); | |
263 | |
264 retval = (m.rows () == 1 && m.columns () == 1 && m (0, 0) != 0.0); | |
265 } | |
266 | |
2376 | 267 return retval; |
268 } | |
269 | |
270 Complex | |
271 octave_range::complex_value (bool) const | |
272 { | |
4102 | 273 double tmp = lo_ieee_nan_value (); |
274 | |
275 Complex retval (tmp, tmp); | |
2376 | 276 |
5275 | 277 octave_idx_type nel = range.nelem (); |
2376 | 278 |
4455 | 279 if (nel > 0) |
280 { | |
5781 | 281 gripe_implicit_conversion ("Octave:array-as-scalar", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
282 "range", "complex scalar"); |
4455 | 283 |
284 retval = range.base (); | |
285 } | |
2376 | 286 else |
287 gripe_invalid_conversion ("range", "complex scalar"); | |
288 | |
289 return retval; | |
290 } | |
291 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
292 FloatComplex |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
293 octave_range::float_complex_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
294 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
295 float tmp = lo_ieee_float_nan_value (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
296 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
297 FloatComplex retval (tmp, tmp); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
298 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
299 octave_idx_type nel = range.nelem (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
300 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
301 if (nel > 0) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
302 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
303 gripe_implicit_conversion ("Octave:array-as-scalar", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
304 "range", "complex scalar"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
305 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
306 retval = range.base (); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
307 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
308 else |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
309 gripe_invalid_conversion ("range", "complex scalar"); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
310 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
311 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
312 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
313 |
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
|
314 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
|
315 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
|
316 { |
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
|
317 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
|
318 |
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
|
319 if (m.any_element_is_nan ()) |
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
|
320 error ("invalid conversion from NaN to logical"); |
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
|
321 else if (warn && m.any_element_not_one_or_zero ()) |
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
|
322 gripe_logical_conversion (); |
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
|
323 |
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
|
324 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
|
325 } |
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
|
326 |
5731 | 327 octave_value |
328 octave_range::resize (const dim_vector& dv, bool fill) const | |
329 { | |
330 NDArray retval = array_value (); | |
331 if (fill) | |
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
|
332 retval.resize (dv, NDArray::resize_fill_value ()); |
5731 | 333 else |
334 retval.resize (dv); | |
335 return retval; | |
336 } | |
337 | |
2376 | 338 octave_value |
5279 | 339 octave_range::convert_to_str_internal (bool pad, bool force, char type) const |
2449 | 340 { |
341 octave_value tmp (range.matrix_value ()); | |
5279 | 342 return tmp.convert_to_str (pad, force, type); |
2449 | 343 } |
344 | |
2376 | 345 void |
3523 | 346 octave_range::print (std::ostream& os, bool pr_as_read_syntax) const |
2901 | 347 { |
348 print_raw (os, pr_as_read_syntax); | |
349 newline (os); | |
350 } | |
351 | |
352 void | |
3523 | 353 octave_range::print_raw (std::ostream& os, bool pr_as_read_syntax) const |
2901 | 354 { |
355 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
|
356 current_print_indent_level ()); |
2901 | 357 } |
358 | |
359 bool | |
3523 | 360 octave_range::print_name_tag (std::ostream& os, const std::string& name) const |
2376 | 361 { |
2901 | 362 bool retval = false; |
363 | |
5275 | 364 octave_idx_type n = range.nelem (); |
2901 | 365 |
366 indent (os); | |
367 | |
368 if (n == 0 || n == 1) | |
369 os << name << " = "; | |
370 else | |
371 { | |
372 os << name << " ="; | |
373 newline (os); | |
374 newline (os); | |
375 retval = true; | |
376 } | |
377 | |
378 return retval; | |
2376 | 379 } |
380 | |
4687 | 381 // Skip white space and comments on stream IS. |
382 | |
383 static void | |
384 skip_comments (std::istream& is) | |
385 { | |
386 char c = '\0'; | |
387 while (is.get (c)) | |
388 { | |
389 if (c == ' ' || c == '\t' || c == '\n') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
390 ; // Skip whitespace on way to beginning of next line. |
4687 | 391 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
392 break; |
4687 | 393 } |
394 | |
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
|
395 skip_until_newline (is, false); |
4687 | 396 } |
397 | |
398 bool | |
6974 | 399 octave_range::save_ascii (std::ostream& os) |
4687 | 400 { |
401 Range r = range_value (); | |
402 double base = r.base (); | |
403 double limit = r.limit (); | |
404 double inc = r.inc (); | |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
405 octave_idx_type len = r.nelem (); |
4687 | 406 |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
407 if (inc != 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
408 os << "# base, limit, increment\n"; |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
409 else |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
410 os << "# base, length, increment\n"; |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
411 |
4687 | 412 octave_write_double (os, base); |
413 os << " "; | |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
414 if (inc != 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
415 octave_write_double (os, limit); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
416 else |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
417 os << len; |
4687 | 418 os << " "; |
419 octave_write_double (os, inc); | |
420 os << "\n"; | |
421 | |
422 return true; | |
423 } | |
424 | |
425 bool | |
426 octave_range::load_ascii (std::istream& is) | |
427 { | |
428 // # base, limit, range comment added by save (). | |
429 skip_comments (is); | |
430 | |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
431 double base, limit, inc; |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
432 is >> base >> limit >> inc; |
4687 | 433 |
434 if (!is) | |
435 { | |
436 error ("load: failed to load range constant"); | |
437 return false; | |
438 } | |
439 | |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
440 if (inc != 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
441 range = Range (base, limit, inc); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
442 else |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
443 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
|
444 |
4687 | 445 return true; |
446 } | |
447 | |
448 bool | |
449 octave_range::save_binary (std::ostream& os, bool& /* save_as_floats */) | |
450 { | |
5760 | 451 char tmp = LS_DOUBLE; |
452 os.write (reinterpret_cast<char *> (&tmp), 1); | |
4687 | 453 Range r = range_value (); |
454 double bas = r.base (); | |
455 double lim = r.limit (); | |
456 double inc = r.inc (); | |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
457 if (inc == 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
458 lim = r.nelem (); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
459 |
5760 | 460 os.write (reinterpret_cast<char *> (&bas), 8); |
461 os.write (reinterpret_cast<char *> (&lim), 8); | |
462 os.write (reinterpret_cast<char *> (&inc), 8); | |
4687 | 463 |
464 return true; | |
465 } | |
466 | |
467 bool | |
468 octave_range::load_binary (std::istream& is, bool swap, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
469 oct_mach_info::float_format /* fmt */) |
4687 | 470 { |
471 char tmp; | |
5760 | 472 if (! is.read (reinterpret_cast<char *> (&tmp), 1)) |
4687 | 473 return false; |
474 double bas, lim, inc; | |
5760 | 475 if (! is.read (reinterpret_cast<char *> (&bas), 8)) |
4687 | 476 return false; |
477 if (swap) | |
4944 | 478 swap_bytes<8> (&bas); |
5760 | 479 if (! is.read (reinterpret_cast<char *> (&lim), 8)) |
4687 | 480 return false; |
481 if (swap) | |
4944 | 482 swap_bytes<8> (&lim); |
5760 | 483 if (! is.read (reinterpret_cast<char *> (&inc), 8)) |
4687 | 484 return false; |
485 if (swap) | |
4944 | 486 swap_bytes<8> (&inc); |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
487 if (inc != 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
488 range = Range (bas, lim, inc); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
489 else |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
490 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
|
491 |
4687 | 492 return true; |
493 } | |
494 | |
495 #if defined (HAVE_HDF5) | |
4944 | 496 |
4687 | 497 // The following subroutines creates an HDF5 representation of the way |
498 // we will store Octave range types (triplets of floating-point numbers). | |
499 // NUM_TYPE is the HDF5 numeric type to use for storage (e.g. | |
500 // H5T_NATIVE_DOUBLE to save as 'double'). Note that any necessary | |
501 // conversions are handled automatically by HDF5. | |
502 | |
503 static hid_t | |
504 hdf5_make_range_type (hid_t num_type) | |
505 { | |
506 hid_t type_id = H5Tcreate (H5T_COMPOUND, sizeof (double) * 3); | |
507 | |
508 H5Tinsert (type_id, "base", 0 * sizeof (double), num_type); | |
509 H5Tinsert (type_id, "limit", 1 * sizeof (double), num_type); | |
510 H5Tinsert (type_id, "increment", 2 * sizeof (double), num_type); | |
511 | |
512 return type_id; | |
513 } | |
514 | |
515 bool | |
516 octave_range::save_hdf5 (hid_t loc_id, const char *name, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
517 bool /* save_as_floats */) |
4687 | 518 { |
4792 | 519 hsize_t dimens[3]; |
4687 | 520 hid_t space_hid = -1, type_hid = -1, data_hid = -1; |
521 bool retval = true; | |
522 | |
4815 | 523 space_hid = H5Screate_simple (0, dimens, 0); |
4687 | 524 if (space_hid < 0) return false; |
525 | |
526 type_hid = hdf5_make_range_type (H5T_NATIVE_DOUBLE); | |
527 if (type_hid < 0) | |
528 { | |
529 H5Sclose (space_hid); | |
530 return false; | |
531 } | |
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
|
532 #if HAVE_HDF5_18 |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
533 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
534 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
535 #else |
4687 | 536 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, 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
|
537 #endif |
4687 | 538 if (data_hid < 0) |
539 { | |
540 H5Sclose (space_hid); | |
541 H5Tclose (type_hid); | |
542 return false; | |
543 } | |
544 | |
545 Range r = range_value (); | |
546 double range_vals[3]; | |
547 range_vals[0] = r.base (); | |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
548 range_vals[1] = r.inc () != 0 ? r.limit () : r.nelem (); |
4687 | 549 range_vals[2] = r.inc (); |
550 | |
551 retval = H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
552 range_vals) >= 0; |
4687 | 553 |
554 H5Dclose (data_hid); | |
555 H5Tclose (type_hid); | |
556 H5Sclose (space_hid); | |
4837 | 557 |
4687 | 558 return retval; |
559 } | |
560 | |
561 bool | |
9881
b3089dba88bf
Remove HDF5 cruft for older versions of HDF5
Kacper Kowalik
parents:
9146
diff
changeset
|
562 octave_range::load_hdf5 (hid_t loc_id, const char *name) |
4687 | 563 { |
564 bool retval = false; | |
4837 | 565 |
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
|
566 #if HAVE_HDF5_18 |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
567 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT); |
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
568 #else |
4687 | 569 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
|
570 #endif |
4687 | 571 hid_t type_hid = H5Dget_type (data_hid); |
572 | |
573 hid_t range_type = hdf5_make_range_type (H5T_NATIVE_DOUBLE); | |
574 | |
575 if (! hdf5_types_compatible (type_hid, range_type)) | |
576 { | |
4837 | 577 H5Tclose (range_type); |
4687 | 578 H5Dclose (data_hid); |
579 return false; | |
580 } | |
581 | |
582 hid_t space_hid = H5Dget_space (data_hid); | |
583 hsize_t rank = H5Sget_simple_extent_ndims (space_hid); | |
584 | |
585 if (rank != 0) | |
586 { | |
4837 | 587 H5Tclose (range_type); |
4687 | 588 H5Sclose (space_hid); |
589 H5Dclose (data_hid); | |
590 return false; | |
591 } | |
592 | |
593 double rangevals[3]; | |
594 if (H5Dread (data_hid, range_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
595 rangevals) >= 0) |
4687 | 596 { |
597 retval = true; | |
10735
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
598 if (rangevals[2] != 0) |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
599 range = Range (rangevals[0], rangevals[1], rangevals[2]); |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
600 else |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
601 range = Range (rangevals[0], rangevals[2], |
d899b2ee6a37
fix saving/loading of constant ranges (bug #30289)
Jaroslav Hajek <highegg@gmail.com>
parents:
10711
diff
changeset
|
602 static_cast<octave_idx_type> (rangevals[1])); |
4687 | 603 } |
604 | |
4837 | 605 H5Tclose (range_type); |
4687 | 606 H5Sclose (space_hid); |
607 H5Dclose (data_hid); | |
4837 | 608 |
4687 | 609 return retval; |
610 } | |
4944 | 611 |
4687 | 612 #endif |
613 | |
5900 | 614 mxArray * |
615 octave_range::as_mxArray (void) const | |
616 { | |
617 mxArray *retval = new mxArray (mxDOUBLE_CLASS, dims (), mxREAL); | |
618 | |
619 double *pr = static_cast<double *> (retval->get_data ()); | |
620 | |
6686 | 621 mwSize nel = numel (); |
5900 | 622 |
623 Matrix m = matrix_value (); | |
624 | |
625 const double *p = m.data (); | |
626 | |
6686 | 627 for (mwSize i = 0; i < nel; i++) |
5900 | 628 pr[i] = p[i]; |
629 | |
630 return retval; | |
631 } | |
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
|
632 |
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
|
633 DEFUN (allow_noninteger_range_as_index, args, nargout, |
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
|
634 "-*- texinfo -*-\n\ |
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
|
635 @deftypefn {Built-in Function} {@var{val} =} allow_noninteger_range_as_index ()\n\ |
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
|
636 @deftypefnx {Built-in Function} {@var{old_val} =} allow_noninteger_range_as_index (@var{new_val})\n\ |
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
|
637 Query or set the internal variable that controls whether non-integer\n\ |
10711
fbd7843974fa
Periodic grammar check of documentation files to ensure common format.
Rik <octave@nomad.inbox5.com>
parents:
10616
diff
changeset
|
638 ranges are allowed as indices. This might be useful for @sc{matlab}\n\ |
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
|
639 compatibility; however, it is still not entirely compatible because\n\ |
10711
fbd7843974fa
Periodic grammar check of documentation files to ensure common format.
Rik <octave@nomad.inbox5.com>
parents:
10616
diff
changeset
|
640 @sc{matlab} treats the range expression differently in different contexts.\n\ |
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
|
641 @end deftypefn") |
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
|
642 { |
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
|
643 return SET_INTERNAL_VARIABLE (allow_noninteger_range_as_index); |
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
|
644 } |