Mercurial > octave-nkf
annotate liboctave/util/data-conv.cc @ 17413:e89e86e1a551
eliminate unnecessary volatile declarations
* byte-swap.h (swap_bytes<T>): Don't declare point arg as volatile.
Update all instantiations.
* data-conv.cc: Delete explicit instantiations of byte_swap template.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 12 Sep 2013 14:10:41 -0400 |
parents | 0b644adf4f31 |
children | 3856298f1ff8 |
rev | line source |
---|---|
1960 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
1960 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1960 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1960 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
2317 | 27 #include <cctype> |
6482 | 28 #include <cstdlib> |
2317 | 29 |
3503 | 30 #include <iostream> |
17396 | 31 #include <limits> |
5760 | 32 #include <vector> |
1960 | 33 |
34 #include "byte-swap.h" | |
35 #include "data-conv.h" | |
36 #include "lo-error.h" | |
7991
139f47cf17ab
Change NA value to support single to double precision conversion
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
37 #include "lo-ieee.h" |
8377
25bc2d31e1bf
improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents:
7991
diff
changeset
|
38 #include "oct-locbuf.h" |
1960 | 39 |
4944 | 40 #if defined HAVE_LONG_LONG_INT |
41 #define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \ | |
42 do \ | |
43 { \ | |
17396 | 44 int sz = BITS / std::numeric_limits<unsigned char>::digits; \ |
4944 | 45 if (sizeof (TQ char) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
46 VAL = oct_data_conv::dt_ ## Q ## char; \ |
4944 | 47 else if (sizeof (TQ short) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
48 VAL = oct_data_conv::dt_ ## Q ## short; \ |
4944 | 49 else if (sizeof (TQ int) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
50 VAL = oct_data_conv::dt_ ## Q ## int; \ |
4944 | 51 else if (sizeof (TQ long) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
52 VAL = oct_data_conv::dt_ ## Q ## long; \ |
4944 | 53 else if (sizeof (TQ long long) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
54 VAL = oct_data_conv::dt_ ## Q ## longlong; \ |
4944 | 55 else \ |
56 VAL = oct_data_conv::dt_unknown; \ | |
57 } \ | |
58 while (0) | |
59 #else | |
3359 | 60 #define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \ |
3358 | 61 do \ |
62 { \ | |
17396 | 63 int sz = BITS / std::numeric_limits<unsigned char>::digits; \ |
3358 | 64 if (sizeof (TQ char) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
65 VAL = oct_data_conv::dt_ ## Q ## char; \ |
3358 | 66 else if (sizeof (TQ short) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
67 VAL = oct_data_conv::dt_ ## Q ## short; \ |
3358 | 68 else if (sizeof (TQ int) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
69 VAL = oct_data_conv::dt_ ## Q ## int; \ |
3358 | 70 else if (sizeof (TQ long) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
71 VAL = oct_data_conv::dt_ ## Q ## long; \ |
3358 | 72 else \ |
73 VAL = oct_data_conv::dt_unknown; \ | |
74 } \ | |
75 while (0) | |
4944 | 76 #endif |
3358 | 77 |
3359 | 78 #define FIND_SIZED_FLOAT_TYPE(VAL, BITS) \ |
3358 | 79 do \ |
80 { \ | |
17396 | 81 int sz = BITS / std::numeric_limits<unsigned char>::digits; \ |
3358 | 82 if (sizeof (float) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
83 VAL = oct_data_conv::dt_float; \ |
3358 | 84 else if (sizeof (double) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
85 VAL = oct_data_conv::dt_double; \ |
3358 | 86 else \ |
87 VAL = oct_data_conv::dt_unknown; \ | |
88 } \ | |
89 while (0) | |
90 | |
91 // I'm not sure it is worth the trouble, but let's use a lookup table | |
92 // for the types that are supposed to be a specific number of bits | |
17396 | 93 // wide. Given the macros above, this should work as long as |
94 // std::numeric_limits<unsigned char>::digits is a multiple of 8 and | |
95 // there are types with the right sizes. | |
3358 | 96 // |
97 // The sized data type lookup table has the following format: | |
98 // | |
99 // bits | |
100 // +----+----+----+----+ | |
101 // | 8 | 16 | 32 | 64 | | |
102 // +----+----+----+----+ | |
103 // signed integer | | | | | | |
104 // +----+----+----+----+ | |
105 // unsigned integer | | | | | | |
106 // +----+----+----+----+ | |
107 // floating point | | | | | | |
108 // +----+----+----+----+ | |
109 // | |
110 // So, the 0,3 element is supposed to contain the oct_data_conv enum | |
111 // value corresponding to the correct native data type for a signed | |
112 // 32-bit integer. | |
113 | |
114 static void | |
115 init_sized_type_lookup_table (oct_data_conv::data_type table[3][4]) | |
116 { | |
117 int bits = 8; | |
118 | |
119 for (int i = 0; i < 4; i++) | |
120 { | |
3359 | 121 FIND_SIZED_INT_TYPE (table[0][i], bits, , ); |
3358 | 122 |
3359 | 123 FIND_SIZED_INT_TYPE (table[1][i], bits, unsigned, u); |
3358 | 124 |
3359 | 125 FIND_SIZED_FLOAT_TYPE (table[2][i], bits); |
3358 | 126 |
127 bits *= 2; | |
128 } | |
129 } | |
130 | |
4944 | 131 static std::string |
132 strip_spaces (const std::string& str) | |
133 { | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
134 size_t n = str.length (); |
4944 | 135 |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
136 size_t k = 0; |
4944 | 137 |
138 std::string s (n, ' '); | |
139 | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
140 for (size_t i = 0; i < n; i++) |
4944 | 141 if (! isspace (str[i])) |
142 s[k++] = tolower (str[i]); | |
143 | |
144 s.resize (k); | |
145 | |
146 return s; | |
147 } | |
148 | |
149 #define GET_SIZED_INT_TYPE(T, U) \ | |
150 do \ | |
151 { \ | |
152 switch (sizeof (T)) \ | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
153 { \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
154 case 1: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
155 retval = dt_ ## U ## int8; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
156 break; \ |
4944 | 157 \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
158 case 2: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
159 retval = dt_ ## U ## int16; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
160 break; \ |
4944 | 161 \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
162 case 4: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
163 retval = dt_ ## U ## int32; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
164 break; \ |
4944 | 165 \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
166 case 8: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
167 retval = dt_ ## U ## int64; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
168 break; \ |
4944 | 169 \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
170 default: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
171 retval = dt_unknown; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
172 break; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
173 } \ |
4944 | 174 } \ |
175 while (0) | |
176 | |
2317 | 177 oct_data_conv::data_type |
3504 | 178 oct_data_conv::string_to_data_type (const std::string& str) |
2317 | 179 { |
180 data_type retval = dt_unknown; | |
181 | |
3358 | 182 static bool initialized = false; |
183 | |
184 static data_type sized_type_table[3][4]; | |
2317 | 185 |
3358 | 186 if (! initialized) |
187 { | |
188 init_sized_type_lookup_table (sized_type_table); | |
189 | |
190 initialized = true; | |
191 } | |
192 | |
4944 | 193 std::string s = strip_spaces (str); |
2317 | 194 |
4944 | 195 if (s == "int8" || s == "integer*1") |
196 retval = dt_int8; | |
197 else if (s == "uint8") | |
198 retval = dt_uint8; | |
199 else if (s == "int16" || s == "integer*2") | |
200 retval = dt_int16; | |
201 else if (s == "uint16") | |
202 retval = dt_uint16; | |
203 else if (s == "int32" || s == "integer*4") | |
204 retval = dt_int32; | |
205 else if (s == "uint32") | |
206 retval = dt_uint32; | |
207 else if (s == "int64" || s == "integer*8") | |
208 retval = dt_int64; | |
209 else if (s == "uint64") | |
210 retval = dt_uint64; | |
211 else if (s == "single" || s == "float32" || s == "real*4") | |
212 retval = dt_single; | |
213 else if (s == "double" || s == "float64" || s == "real*8") | |
214 retval = dt_double; | |
215 else if (s == "char" || s == "char*1") | |
2317 | 216 retval = dt_char; |
217 else if (s == "schar" || s == "signedchar") | |
218 retval = dt_schar; | |
219 else if (s == "uchar" || s == "unsignedchar") | |
220 retval = dt_uchar; | |
221 else if (s == "short") | |
4944 | 222 GET_SIZED_INT_TYPE (short, ); |
2317 | 223 else if (s == "ushort" || s == "unsignedshort") |
4944 | 224 GET_SIZED_INT_TYPE (unsigned short, u); |
2317 | 225 else if (s == "int") |
4944 | 226 GET_SIZED_INT_TYPE (int, ); |
2317 | 227 else if (s == "uint" || s == "unsignedint") |
4944 | 228 GET_SIZED_INT_TYPE (unsigned int, u); |
2317 | 229 else if (s == "long") |
4944 | 230 GET_SIZED_INT_TYPE (long, ); |
2317 | 231 else if (s == "ulong" || s == "unsignedlong") |
4944 | 232 GET_SIZED_INT_TYPE (unsigned long, u); |
233 else if (s == "longlong") | |
234 GET_SIZED_INT_TYPE (long long, ); | |
235 else if (s == "ulonglong" || s == "unsignedlonglong") | |
236 GET_SIZED_INT_TYPE (unsigned long long, u); | |
3358 | 237 else if (s == "float") |
4944 | 238 { |
239 if (sizeof (float) == sizeof (double)) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
240 retval = dt_double; |
4944 | 241 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
242 retval = dt_single; |
4944 | 243 } |
4970 | 244 else if (s == "logical") |
245 retval = dt_logical; | |
2317 | 246 else |
247 (*current_liboctave_error_handler) ("invalid data type specified"); | |
248 | |
3358 | 249 if (retval == dt_unknown) |
250 (*current_liboctave_error_handler) | |
251 ("unable to find matching native data type for %s", s.c_str ()); | |
252 | |
2317 | 253 return retval; |
254 } | |
255 | |
4944 | 256 void |
257 oct_data_conv::string_to_data_type | |
258 (const std::string& str, int& block_size, | |
259 oct_data_conv::data_type& input_type, | |
260 oct_data_conv::data_type& output_type) | |
261 { | |
262 block_size = 1; | |
263 input_type = dt_uchar; | |
264 output_type = dt_double; | |
265 | |
266 bool input_is_output = false; | |
267 | |
268 std::string s = strip_spaces (str); | |
269 | |
270 size_t pos = 0; | |
271 | |
272 if (s[0] == '*') | |
273 input_is_output = true; | |
274 else | |
275 { | |
276 size_t len = s.length (); | |
277 | |
278 while (pos < len && isdigit (s[pos])) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
279 pos++; |
4944 | 280 |
281 if (pos > 0) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
282 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
283 if (s[pos] == '*') |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
284 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
285 block_size = atoi (s.c_str ()); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
286 s = s.substr (pos+1); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
287 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
288 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
289 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
290 (*current_liboctave_error_handler) |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
291 ("invalid repeat count in '%s'", str.c_str ()); |
4944 | 292 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
293 return; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
294 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
295 } |
4944 | 296 } |
297 | |
298 pos = s.find ('='); | |
299 | |
300 if (pos != std::string::npos) | |
301 { | |
302 if (s[pos+1] == '>') | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
303 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
304 std::string s1; |
5870 | 305 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
306 if (input_is_output) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
307 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
308 input_is_output = false; |
4944 | 309 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
310 s1 = s.substr (1, pos-1); |
5870 | 311 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
312 (*current_liboctave_warning_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
313 ("warning: ignoring leading * in fread precision"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
314 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
315 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
316 s1 = s.substr (0, pos); |
4944 | 317 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
318 input_type = string_to_data_type (s1); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
319 output_type = string_to_data_type (s.substr (pos+2)); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
320 } |
4944 | 321 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
322 (*current_liboctave_error_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
323 ("fread: invalid precision specified"); |
4944 | 324 } |
325 else | |
326 { | |
5870 | 327 if (input_is_output) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
328 s = s.substr (1); |
5870 | 329 |
4944 | 330 input_type = string_to_data_type (s); |
331 | |
332 if (input_is_output) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
333 output_type = input_type; |
4944 | 334 } |
335 } | |
336 | |
337 void | |
338 oct_data_conv::string_to_data_type | |
339 (const std::string& str, int& block_size, | |
340 oct_data_conv::data_type& output_type) | |
341 { | |
342 block_size = 1; | |
343 output_type = dt_double; | |
344 | |
345 std::string s = strip_spaces (str); | |
346 | |
347 size_t pos = 0; | |
348 | |
349 size_t len = s.length (); | |
350 | |
351 while (pos < len && isdigit (s[pos])) | |
352 pos++; | |
353 | |
354 if (pos > 0) | |
355 { | |
356 if (s[pos] == '*') | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
357 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
358 block_size = atoi (s.c_str ()); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
359 s = s.substr (pos+1); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
360 } |
4944 | 361 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
362 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
363 (*current_liboctave_error_handler) |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
364 ("invalid repeat count in '%s'", str.c_str ()); |
4944 | 365 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
366 return; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
367 } |
4944 | 368 } |
369 | |
370 output_type = string_to_data_type (s); | |
371 } | |
372 | |
373 std::string | |
374 oct_data_conv::data_type_as_string (oct_data_conv::data_type dt) | |
375 { | |
376 std::string retval; | |
377 | |
378 switch (dt) | |
379 { | |
380 case oct_data_conv::dt_int8: | |
381 retval = "int8"; | |
382 break; | |
383 | |
384 case oct_data_conv::dt_uint8: | |
385 retval = "uint8"; | |
386 break; | |
387 | |
388 case oct_data_conv::dt_int16: | |
389 retval = "int16"; | |
390 break; | |
391 | |
392 case oct_data_conv::dt_uint16: | |
393 retval = "uint16"; | |
394 break; | |
395 | |
396 case oct_data_conv::dt_int32: | |
397 retval = "int32"; | |
398 break; | |
399 | |
400 case oct_data_conv::dt_uint32: | |
401 retval = "uint32"; | |
402 break; | |
403 | |
404 case oct_data_conv::dt_int64: | |
405 retval = "int64"; | |
406 break; | |
407 | |
408 case oct_data_conv::dt_uint64: | |
409 retval = "uint64"; | |
410 break; | |
411 | |
412 case oct_data_conv::dt_single: | |
413 retval = "single"; | |
414 break; | |
415 | |
416 case oct_data_conv::dt_double: | |
417 retval = "double"; | |
418 break; | |
419 | |
420 case oct_data_conv::dt_char: | |
421 retval = "char"; | |
422 break; | |
423 | |
424 case oct_data_conv::dt_schar: | |
425 retval = "signed char"; | |
426 break; | |
427 | |
428 case oct_data_conv::dt_uchar: | |
429 retval = "usigned char"; | |
430 break; | |
431 | |
432 case oct_data_conv::dt_short: | |
433 retval = "short"; | |
434 break; | |
435 | |
436 case oct_data_conv::dt_ushort: | |
437 retval = "unsigned short"; | |
438 break; | |
439 | |
440 case oct_data_conv::dt_int: | |
441 retval = "int"; | |
442 break; | |
443 | |
444 case oct_data_conv::dt_uint: | |
445 retval = "usigned int"; | |
446 break; | |
447 | |
448 case oct_data_conv::dt_long: | |
449 retval = "long"; | |
450 break; | |
451 | |
452 case oct_data_conv::dt_ulong: | |
453 retval = "usigned long"; | |
454 break; | |
455 | |
456 case oct_data_conv::dt_longlong: | |
457 retval = "long long"; | |
458 break; | |
459 | |
460 case oct_data_conv::dt_ulonglong: | |
461 retval = "unsigned long long"; | |
462 break; | |
463 | |
464 case oct_data_conv::dt_float: | |
465 retval = "float"; | |
466 break; | |
467 | |
4970 | 468 case oct_data_conv::dt_logical: |
469 retval = "logical"; | |
470 break; | |
471 | |
4944 | 472 case oct_data_conv::dt_unknown: |
473 default: | |
474 retval = "unknown"; | |
475 break; | |
476 } | |
477 | |
478 return retval; | |
479 } | |
1960 | 480 |
3359 | 481 #define LS_DO_READ(TYPE, swap, data, size, len, stream) \ |
1960 | 482 do \ |
483 { \ | |
3867 | 484 if (len > 0) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
485 { \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
486 OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \ |
16074
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
487 std::streamsize n_bytes = size * len; \ |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
488 stream.read (reinterpret_cast<char *> (ptr), n_bytes); \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
489 if (swap) \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
490 swap_bytes< size > (ptr, len); \ |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
491 for (octave_idx_type i = 0; i < len; i++) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
492 data[i] = ptr[i]; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
493 } \ |
1960 | 494 } \ |
495 while (0) | |
496 | |
497 // Have to use copy here to avoid writing over data accessed via | |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
498 // Matrix::data (). |
1960 | 499 |
3359 | 500 #define LS_DO_WRITE(TYPE, data, size, len, stream) \ |
1960 | 501 do \ |
502 { \ | |
3867 | 503 if (len > 0) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
504 { \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
505 char tmp_type = type; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
506 stream.write (&tmp_type, 1); \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
507 OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \ |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
508 for (octave_idx_type i = 0; i < len; i++) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
509 ptr[i] = static_cast <TYPE> (data[i]); \ |
16074
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
510 std::streamsize n_bytes = size * len; \ |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
511 stream.write (reinterpret_cast<char *> (ptr), n_bytes); \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
512 } \ |
1960 | 513 } \ |
514 while (0) | |
515 | |
516 // Loading variables from files. | |
517 | |
518 static void | |
519 gripe_unrecognized_float_fmt (void) | |
520 { | |
521 (*current_liboctave_error_handler) | |
522 ("unrecognized floating point format requested"); | |
523 } | |
524 | |
525 static void | |
526 gripe_data_conversion (const char *from, const char *to) | |
527 { | |
528 (*current_liboctave_error_handler) | |
529 ("unable to convert from %s to %s format", from, to); | |
530 } | |
531 | |
532 // But first, some data conversion routines. | |
533 | |
534 // Currently, we only handle conversions for the IEEE types. To fix | |
535 // that, make more of the following routines work. | |
536 | |
5775 | 537 // FIXME -- assumes sizeof (Complex) == 8 |
538 // FIXME -- assumes sizeof (double) == 8 | |
539 // FIXME -- assumes sizeof (float) == 4 | |
1960 | 540 |
541 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
542 IEEE_big_double_to_IEEE_little_double (void *d, octave_idx_type len) |
1960 | 543 { |
4944 | 544 swap_bytes<8> (d, len); |
1960 | 545 } |
546 | |
547 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
548 VAX_D_double_to_IEEE_little_double (void * /* d */, octave_idx_type /* len */) |
1960 | 549 { |
550 gripe_data_conversion ("VAX D float", "IEEE little endian format"); | |
551 } | |
552 | |
553 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
554 VAX_G_double_to_IEEE_little_double (void * /* d */, octave_idx_type /* len */) |
1960 | 555 { |
556 gripe_data_conversion ("VAX G float", "IEEE little endian format"); | |
557 } | |
558 | |
559 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
560 Cray_to_IEEE_little_double (void * /* d */, octave_idx_type /* len */) |
1960 | 561 { |
562 gripe_data_conversion ("Cray", "IEEE little endian format"); | |
563 } | |
564 | |
565 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
566 IEEE_big_float_to_IEEE_little_float (void *d, octave_idx_type len) |
1960 | 567 { |
4944 | 568 swap_bytes<4> (d, len); |
1960 | 569 } |
570 | |
571 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
572 VAX_D_float_to_IEEE_little_float (void * /* d */, octave_idx_type /* len */) |
1960 | 573 { |
574 gripe_data_conversion ("VAX D float", "IEEE little endian format"); | |
575 } | |
576 | |
577 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
578 VAX_G_float_to_IEEE_little_float (void * /* d */, octave_idx_type /* len */) |
1960 | 579 { |
580 gripe_data_conversion ("VAX G float", "IEEE little endian format"); | |
581 } | |
582 | |
583 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
584 Cray_to_IEEE_little_float (void * /* d */, octave_idx_type /* len */) |
1960 | 585 { |
586 gripe_data_conversion ("Cray", "IEEE little endian format"); | |
587 } | |
588 | |
589 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
590 IEEE_little_double_to_IEEE_big_double (void *d, octave_idx_type len) |
1960 | 591 { |
4944 | 592 swap_bytes<8> (d, len); |
1960 | 593 } |
594 | |
595 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
596 VAX_D_double_to_IEEE_big_double (void * /* d */, octave_idx_type /* len */) |
1960 | 597 { |
598 gripe_data_conversion ("VAX D float", "IEEE big endian format"); | |
599 } | |
600 | |
601 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
602 VAX_G_double_to_IEEE_big_double (void * /* d */, octave_idx_type /* len */) |
1960 | 603 { |
604 gripe_data_conversion ("VAX G float", "IEEE big endian format"); | |
605 } | |
606 | |
607 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
608 Cray_to_IEEE_big_double (void * /* d */, octave_idx_type /* len */) |
1960 | 609 { |
610 gripe_data_conversion ("Cray", "IEEE big endian format"); | |
611 } | |
612 | |
613 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
614 IEEE_little_float_to_IEEE_big_float (void *d, octave_idx_type len) |
1960 | 615 { |
4944 | 616 swap_bytes<4> (d, len); |
1960 | 617 } |
618 | |
619 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
620 VAX_D_float_to_IEEE_big_float (void * /* d */, octave_idx_type /* len */) |
1960 | 621 { |
622 gripe_data_conversion ("VAX D float", "IEEE big endian format"); | |
623 } | |
624 | |
625 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
626 VAX_G_float_to_IEEE_big_float (void * /* d */, octave_idx_type /* len */) |
1960 | 627 { |
628 gripe_data_conversion ("VAX G float", "IEEE big endian format"); | |
629 } | |
630 | |
631 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
632 Cray_to_IEEE_big_float (void * /* d */, octave_idx_type /* len */) |
1960 | 633 { |
634 gripe_data_conversion ("Cray", "IEEE big endian format"); | |
635 } | |
636 | |
637 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
638 IEEE_little_double_to_VAX_D_double (void * /* d */, octave_idx_type /* len */) |
1960 | 639 { |
640 gripe_data_conversion ("IEEE little endian", "VAX D"); | |
641 } | |
642 | |
643 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
644 IEEE_big_double_to_VAX_D_double (void * /* d */, octave_idx_type /* len */) |
1960 | 645 { |
646 gripe_data_conversion ("IEEE big endian", "VAX D"); | |
647 } | |
648 | |
649 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
650 VAX_G_double_to_VAX_D_double (void * /* d */, octave_idx_type /* len */) |
1960 | 651 { |
652 gripe_data_conversion ("VAX G float", "VAX D"); | |
653 } | |
654 | |
655 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
656 Cray_to_VAX_D_double (void * /* d */, octave_idx_type /* len */) |
1960 | 657 { |
658 gripe_data_conversion ("Cray", "VAX D"); | |
659 } | |
660 | |
661 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
662 IEEE_little_float_to_VAX_D_float (void * /* d */, octave_idx_type /* len */) |
1960 | 663 { |
664 gripe_data_conversion ("IEEE little endian", "VAX D"); | |
665 } | |
666 | |
667 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
668 IEEE_big_float_to_VAX_D_float (void * /* d */, octave_idx_type /* len */) |
1960 | 669 { |
670 gripe_data_conversion ("IEEE big endian", "VAX D"); | |
671 } | |
672 | |
673 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
674 VAX_G_float_to_VAX_D_float (void * /* d */, octave_idx_type /* len */) |
1960 | 675 { |
676 gripe_data_conversion ("VAX G float", "VAX D"); | |
677 } | |
678 | |
679 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
680 Cray_to_VAX_D_float (void * /* d */, octave_idx_type /* len */) |
1960 | 681 { |
682 gripe_data_conversion ("Cray", "VAX D"); | |
683 } | |
684 | |
685 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
686 IEEE_little_double_to_VAX_G_double (void * /* d */, octave_idx_type /* len */) |
1960 | 687 { |
688 gripe_data_conversion ("IEEE little endian", "VAX G"); | |
689 } | |
690 | |
691 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
692 IEEE_big_double_to_VAX_G_double (void * /* d */, octave_idx_type /* len */) |
1960 | 693 { |
694 gripe_data_conversion ("IEEE big endian", "VAX G"); | |
695 } | |
696 | |
697 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
698 VAX_D_double_to_VAX_G_double (void * /* d */, octave_idx_type /* len */) |
1960 | 699 { |
700 gripe_data_conversion ("VAX D float", "VAX G"); | |
701 } | |
702 | |
703 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
704 Cray_to_VAX_G_double (void * /* d */, octave_idx_type /* len */) |
1960 | 705 { |
706 gripe_data_conversion ("VAX G float", "VAX G"); | |
707 } | |
708 | |
709 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
710 IEEE_little_float_to_VAX_G_float (void * /* d */, octave_idx_type /* len */) |
1960 | 711 { |
712 gripe_data_conversion ("IEEE little endian", "VAX G"); | |
713 } | |
714 | |
715 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
716 IEEE_big_float_to_VAX_G_float (void * /* d */, octave_idx_type /* len */) |
1960 | 717 { |
718 gripe_data_conversion ("IEEE big endian", "VAX G"); | |
719 } | |
720 | |
721 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
722 VAX_D_float_to_VAX_G_float (void * /* d */, octave_idx_type /* len */) |
1960 | 723 { |
724 gripe_data_conversion ("VAX D float", "VAX G"); | |
725 } | |
726 | |
727 static void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
728 Cray_to_VAX_G_float (void * /* d */, octave_idx_type /* len */) |
1960 | 729 { |
730 gripe_data_conversion ("VAX G float", "VAX G"); | |
731 } | |
732 | |
733 void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
734 do_double_format_conversion (void *data, octave_idx_type len, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
735 oct_mach_info::float_format from_fmt, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
736 oct_mach_info::float_format to_fmt) |
1960 | 737 { |
4944 | 738 switch (to_fmt) |
1960 | 739 { |
4574 | 740 case oct_mach_info::flt_fmt_ieee_little_endian: |
4944 | 741 switch (from_fmt) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
742 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
743 case oct_mach_info::flt_fmt_ieee_little_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
744 break; |
1960 | 745 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
746 case oct_mach_info::flt_fmt_ieee_big_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
747 IEEE_big_double_to_IEEE_little_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
748 break; |
1960 | 749 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
750 case oct_mach_info::flt_fmt_vax_d: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
751 VAX_D_double_to_IEEE_little_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
752 break; |
1960 | 753 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
754 case oct_mach_info::flt_fmt_vax_g: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
755 VAX_G_double_to_IEEE_little_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
756 break; |
1960 | 757 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
758 case oct_mach_info::flt_fmt_cray: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
759 Cray_to_IEEE_little_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
760 break; |
1960 | 761 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
762 default: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
763 gripe_unrecognized_float_fmt (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
764 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
765 } |
1960 | 766 break; |
767 | |
4574 | 768 case oct_mach_info::flt_fmt_ieee_big_endian: |
4944 | 769 switch (from_fmt) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
770 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
771 case oct_mach_info::flt_fmt_ieee_little_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
772 IEEE_little_double_to_IEEE_big_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
773 break; |
1960 | 774 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
775 case oct_mach_info::flt_fmt_ieee_big_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
776 break; |
1960 | 777 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
778 case oct_mach_info::flt_fmt_vax_d: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
779 VAX_D_double_to_IEEE_big_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
780 break; |
1960 | 781 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
782 case oct_mach_info::flt_fmt_vax_g: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
783 VAX_G_double_to_IEEE_big_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
784 break; |
1960 | 785 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
786 case oct_mach_info::flt_fmt_cray: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
787 Cray_to_IEEE_big_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
788 break; |
1960 | 789 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
790 default: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
791 gripe_unrecognized_float_fmt (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
792 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
793 } |
1960 | 794 break; |
795 | |
4574 | 796 case oct_mach_info::flt_fmt_vax_d: |
4944 | 797 switch (from_fmt) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
798 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
799 case oct_mach_info::flt_fmt_ieee_little_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
800 IEEE_little_double_to_VAX_D_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
801 break; |
1960 | 802 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
803 case oct_mach_info::flt_fmt_ieee_big_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
804 IEEE_big_double_to_VAX_D_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
805 break; |
1960 | 806 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
807 case oct_mach_info::flt_fmt_vax_d: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
808 break; |
1960 | 809 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
810 case oct_mach_info::flt_fmt_vax_g: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
811 VAX_G_double_to_VAX_D_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
812 break; |
1960 | 813 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
814 case oct_mach_info::flt_fmt_cray: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
815 Cray_to_VAX_D_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
816 break; |
1960 | 817 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
818 default: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
819 gripe_unrecognized_float_fmt (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
820 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
821 } |
1960 | 822 break; |
823 | |
4574 | 824 case oct_mach_info::flt_fmt_vax_g: |
4944 | 825 switch (from_fmt) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
826 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
827 case oct_mach_info::flt_fmt_ieee_little_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
828 IEEE_little_double_to_VAX_G_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
829 break; |
1960 | 830 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
831 case oct_mach_info::flt_fmt_ieee_big_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
832 IEEE_big_double_to_VAX_G_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
833 break; |
1960 | 834 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
835 case oct_mach_info::flt_fmt_vax_d: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
836 VAX_D_double_to_VAX_G_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
837 break; |
1960 | 838 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
839 case oct_mach_info::flt_fmt_vax_g: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
840 break; |
1960 | 841 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
842 case oct_mach_info::flt_fmt_cray: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
843 Cray_to_VAX_G_double (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
844 break; |
1960 | 845 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
846 default: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
847 gripe_unrecognized_float_fmt (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
848 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
849 } |
1960 | 850 break; |
851 | |
852 default: | |
853 (*current_liboctave_error_handler) | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
854 ("impossible state reached in file '%s' at line %d", |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
855 __FILE__, __LINE__); |
1960 | 856 break; |
857 } | |
858 } | |
859 | |
860 void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
861 do_float_format_conversion (void *data, octave_idx_type len, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
862 oct_mach_info::float_format from_fmt, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
863 oct_mach_info::float_format to_fmt) |
1960 | 864 { |
4944 | 865 switch (to_fmt) |
1960 | 866 { |
4574 | 867 case oct_mach_info::flt_fmt_ieee_little_endian: |
4944 | 868 switch (from_fmt) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
869 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
870 case oct_mach_info::flt_fmt_ieee_little_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
871 break; |
1960 | 872 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
873 case oct_mach_info::flt_fmt_ieee_big_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
874 IEEE_big_float_to_IEEE_little_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
875 break; |
1960 | 876 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
877 case oct_mach_info::flt_fmt_vax_d: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
878 VAX_D_float_to_IEEE_little_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
879 break; |
1960 | 880 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
881 case oct_mach_info::flt_fmt_vax_g: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
882 VAX_G_float_to_IEEE_little_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
883 break; |
1960 | 884 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
885 case oct_mach_info::flt_fmt_cray: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
886 Cray_to_IEEE_little_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
887 break; |
1960 | 888 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
889 default: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
890 gripe_unrecognized_float_fmt (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
891 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
892 } |
1960 | 893 break; |
894 | |
4574 | 895 case oct_mach_info::flt_fmt_ieee_big_endian: |
4944 | 896 switch (from_fmt) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
897 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
898 case oct_mach_info::flt_fmt_ieee_little_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
899 IEEE_little_float_to_IEEE_big_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
900 break; |
1960 | 901 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
902 case oct_mach_info::flt_fmt_ieee_big_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
903 break; |
1960 | 904 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
905 case oct_mach_info::flt_fmt_vax_d: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
906 VAX_D_float_to_IEEE_big_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
907 break; |
1960 | 908 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
909 case oct_mach_info::flt_fmt_vax_g: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
910 VAX_G_float_to_IEEE_big_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
911 break; |
1960 | 912 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
913 case oct_mach_info::flt_fmt_cray: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
914 Cray_to_IEEE_big_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
915 break; |
1960 | 916 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
917 default: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
918 gripe_unrecognized_float_fmt (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
919 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
920 } |
1960 | 921 break; |
922 | |
4574 | 923 case oct_mach_info::flt_fmt_vax_d: |
4944 | 924 switch (from_fmt) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
925 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
926 case oct_mach_info::flt_fmt_ieee_little_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
927 IEEE_little_float_to_VAX_D_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
928 break; |
1960 | 929 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
930 case oct_mach_info::flt_fmt_ieee_big_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
931 IEEE_big_float_to_VAX_D_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
932 break; |
1960 | 933 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
934 case oct_mach_info::flt_fmt_vax_d: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
935 break; |
1960 | 936 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
937 case oct_mach_info::flt_fmt_vax_g: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
938 VAX_G_float_to_VAX_D_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
939 break; |
1960 | 940 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
941 case oct_mach_info::flt_fmt_cray: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
942 Cray_to_VAX_D_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
943 break; |
1960 | 944 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
945 default: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
946 gripe_unrecognized_float_fmt (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
947 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
948 } |
1960 | 949 break; |
950 | |
4574 | 951 case oct_mach_info::flt_fmt_vax_g: |
4944 | 952 switch (from_fmt) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
953 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
954 case oct_mach_info::flt_fmt_ieee_little_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
955 IEEE_little_float_to_VAX_G_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
956 break; |
1960 | 957 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
958 case oct_mach_info::flt_fmt_ieee_big_endian: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
959 IEEE_big_float_to_VAX_G_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
960 break; |
1960 | 961 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
962 case oct_mach_info::flt_fmt_vax_d: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
963 VAX_D_float_to_VAX_G_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
964 break; |
1960 | 965 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
966 case oct_mach_info::flt_fmt_vax_g: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
967 break; |
1960 | 968 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
969 case oct_mach_info::flt_fmt_cray: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
970 Cray_to_VAX_G_float (data, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
971 break; |
1960 | 972 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
973 default: |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
974 gripe_unrecognized_float_fmt (); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
975 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
976 } |
1960 | 977 break; |
978 | |
979 default: | |
980 (*current_liboctave_error_handler) | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
981 ("impossible state reached in file '%s' at line %d", |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
982 __FILE__, __LINE__); |
1960 | 983 break; |
984 } | |
985 } | |
986 | |
987 void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
988 do_float_format_conversion (void *data, size_t sz, octave_idx_type len, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
989 oct_mach_info::float_format from_fmt, |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
990 oct_mach_info::float_format to_fmt) |
4944 | 991 { |
992 switch (sz) | |
993 { | |
994 case sizeof (float): | |
995 do_float_format_conversion (data, len, from_fmt, to_fmt); | |
996 break; | |
997 | |
998 case sizeof (double): | |
999 do_double_format_conversion (data, len, from_fmt, to_fmt); | |
1000 break; | |
1001 | |
1002 default: | |
1003 (*current_liboctave_error_handler) | |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
1004 ("impossible state reached in file '%s' at line %d", |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1005 __FILE__, __LINE__); |
4944 | 1006 break; |
1007 } | |
1008 } | |
1009 | |
1010 void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1011 read_doubles (std::istream& is, double *data, save_type type, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1012 octave_idx_type len, bool swap, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1013 oct_mach_info::float_format fmt) |
1960 | 1014 { |
1015 switch (type) | |
1016 { | |
1017 case LS_U_CHAR: | |
5828 | 1018 LS_DO_READ (uint8_t, swap, data, 1, len, is); |
1960 | 1019 break; |
1020 | |
1021 case LS_U_SHORT: | |
5828 | 1022 LS_DO_READ (uint16_t, swap, data, 2, len, is); |
1960 | 1023 break; |
1024 | |
1025 case LS_U_INT: | |
5828 | 1026 LS_DO_READ (uint32_t, swap, data, 4, len, is); |
1960 | 1027 break; |
1028 | |
1029 case LS_CHAR: | |
5828 | 1030 LS_DO_READ (int8_t, swap, data, 1, len, is); |
1960 | 1031 break; |
1032 | |
1033 case LS_SHORT: | |
5828 | 1034 LS_DO_READ (int16_t, swap, data, 2, len, is); |
1960 | 1035 break; |
1036 | |
1037 case LS_INT: | |
5828 | 1038 LS_DO_READ (int32_t, swap, data, 4, len, is); |
1960 | 1039 break; |
1040 | |
1041 case LS_FLOAT: | |
1042 { | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1043 OCTAVE_LOCAL_BUFFER (float, ptr, len); |
16074
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1044 std::streamsize n_bytes = 4 * len; |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1045 is.read (reinterpret_cast<char *> (ptr), n_bytes); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1046 do_float_format_conversion (ptr, len, fmt); |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1047 for (octave_idx_type i = 0; i < len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1048 data[i] = ptr[i]; |
1960 | 1049 } |
1050 break; | |
1051 | |
3359 | 1052 case LS_DOUBLE: // No conversion necessary. |
7991
139f47cf17ab
Change NA value to support single to double precision conversion
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
1053 { |
16074
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1054 std::streamsize n_bytes = 8 * static_cast<std::streamsize> (len); |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1055 is.read (reinterpret_cast<char *> (data), n_bytes); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1056 do_double_format_conversion (data, len, fmt); |
7991
139f47cf17ab
Change NA value to support single to double precision conversion
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
1057 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1058 for (int i = 0; i < len; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1059 data[i] = __lo_ieee_replace_old_NA (data[i]); |
7991
139f47cf17ab
Change NA value to support single to double precision conversion
David Bateman <dbateman@free.fr>
parents:
7789
diff
changeset
|
1060 } |
1960 | 1061 break; |
1062 | |
1063 default: | |
3504 | 1064 is.clear (std::ios::failbit|is.rdstate ()); |
1960 | 1065 break; |
1066 } | |
1067 } | |
1068 | |
1069 void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1070 read_floats (std::istream& is, float *data, save_type type, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1071 octave_idx_type len, bool swap, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1072 oct_mach_info::float_format fmt) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1073 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1074 switch (type) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1075 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1076 case LS_U_CHAR: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1077 LS_DO_READ (uint8_t, swap, data, 1, len, is); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1078 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1079 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1080 case LS_U_SHORT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1081 LS_DO_READ (uint16_t, swap, data, 2, len, is); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1082 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1083 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1084 case LS_U_INT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1085 LS_DO_READ (uint32_t, swap, data, 4, len, is); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1086 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1087 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1088 case LS_CHAR: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1089 LS_DO_READ (int8_t, swap, data, 1, len, is); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1090 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1091 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1092 case LS_SHORT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1093 LS_DO_READ (int16_t, swap, data, 2, len, is); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1094 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1095 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1096 case LS_INT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1097 LS_DO_READ (int32_t, swap, data, 4, len, is); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1098 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1099 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1100 case LS_FLOAT: // No conversion necessary. |
16074
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1101 { |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1102 std::streamsize n_bytes = 4 * len; |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1103 is.read (reinterpret_cast<char *> (data), n_bytes); |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1104 do_float_format_conversion (data, len, fmt); |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1105 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1106 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1107 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1108 case LS_DOUBLE: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1109 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1110 OCTAVE_LOCAL_BUFFER (double, ptr, len); |
16074
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1111 std::streamsize n_bytes = 8 * len; |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1112 is.read (reinterpret_cast<char *> (ptr), n_bytes); |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1113 do_double_format_conversion (ptr, len, fmt); |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1114 for (octave_idx_type i = 0; i < len; i++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1115 data[i] = ptr[i]; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1116 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1117 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1118 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1119 default: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1120 is.clear (std::ios::failbit|is.rdstate ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1121 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1122 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1123 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1124 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1125 void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1126 write_doubles (std::ostream& os, const double *data, save_type type, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1127 octave_idx_type len) |
1960 | 1128 { |
1129 switch (type) | |
1130 { | |
1131 case LS_U_CHAR: | |
5828 | 1132 LS_DO_WRITE (uint8_t, data, 1, len, os); |
1960 | 1133 break; |
1134 | |
1135 case LS_U_SHORT: | |
5828 | 1136 LS_DO_WRITE (uint16_t, data, 2, len, os); |
1960 | 1137 break; |
1138 | |
1139 case LS_U_INT: | |
5828 | 1140 LS_DO_WRITE (uint32_t, data, 4, len, os); |
1960 | 1141 break; |
1142 | |
1143 case LS_CHAR: | |
5828 | 1144 LS_DO_WRITE (int8_t, data, 1, len, os); |
1960 | 1145 break; |
1146 | |
1147 case LS_SHORT: | |
5828 | 1148 LS_DO_WRITE (int16_t, data, 2, len, os); |
1960 | 1149 break; |
1150 | |
1151 case LS_INT: | |
5828 | 1152 LS_DO_WRITE (int32_t, data, 4, len, os); |
1960 | 1153 break; |
1154 | |
1155 case LS_FLOAT: | |
1156 LS_DO_WRITE (float, data, 4, len, os); | |
1157 break; | |
1158 | |
3359 | 1159 case LS_DOUBLE: // No conversion necessary. |
1960 | 1160 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1161 char tmp_type = static_cast<char> (type); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1162 os.write (&tmp_type, 1); |
16074
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1163 std::streamsize n_bytes = 8 * static_cast<std::streamsize> (len); |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1164 os.write (reinterpret_cast <const char *> (data), n_bytes); |
1960 | 1165 } |
1166 break; | |
1167 | |
1168 default: | |
1169 (*current_liboctave_error_handler) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1170 ("unrecognized data format requested"); |
1960 | 1171 break; |
1172 } | |
1173 } | |
1174 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1175 void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1176 write_floats (std::ostream& os, const float *data, save_type type, |
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1177 octave_idx_type len) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1178 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1179 switch (type) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1180 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1181 case LS_U_CHAR: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1182 LS_DO_WRITE (uint8_t, data, 1, len, os); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1183 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1184 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1185 case LS_U_SHORT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1186 LS_DO_WRITE (uint16_t, data, 2, len, os); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1187 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1188 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1189 case LS_U_INT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1190 LS_DO_WRITE (uint32_t, data, 4, len, os); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1191 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1192 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1193 case LS_CHAR: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1194 LS_DO_WRITE (int8_t, data, 1, len, os); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1195 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1196 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1197 case LS_SHORT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1198 LS_DO_WRITE (int16_t, data, 2, len, os); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1199 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1200 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1201 case LS_INT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1202 LS_DO_WRITE (int32_t, data, 4, len, os); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1203 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1204 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1205 case LS_FLOAT: // No conversion necessary. |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1206 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1207 char tmp_type = static_cast<char> (type); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1208 os.write (&tmp_type, 1); |
16074
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1209 std::streamsize n_bytes = 4 * len; |
821922270b66
Fix saving binary matrices with up to 2^31 elements (Bug #38326).
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
1210 os.write (reinterpret_cast <const char *> (data), n_bytes); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1211 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1212 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1213 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1214 case LS_DOUBLE: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1215 LS_DO_WRITE (double, data, 8, len, os); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1216 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1217 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1218 default: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1219 (*current_liboctave_error_handler) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1220 ("unrecognized data format requested"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1221 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1222 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1223 } |