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