Mercurial > hg > octave-lyh
annotate liboctave/data-conv.cc @ 15466:d174210ce1ec stable
use ' instead of ` in error messages, warnings and most comments
* intro.txi, io.txi, munge-texi.cc, octave.texi, cmd-edit.cc,
data-conv.cc, file-ops.cc, glob-match.h, kpse.cc, oct-env.cc,
oct-locbuf.h, oct-md5.cc, oct-rand.cc, general/interp2.m, doc.m,
get_first_help_sentence.m, help.m, print_usage.m,
__additional_help_message__.m, type.m, unimplemented.m, which.m,
cast.m, dir.m, license.m, mkoctfile.m, recycle.m, tempdir.m,
optimset.m, pkg/pkg.m, closereq.m, colstyle.m, __fltk_print__.m,
__gnuplot_print__.m, __go_draw_figure__.m, __pie__.m, __pltopt__.m,
__print_parse_opts__.m, uigetdir.m, uigetfile.m, uiputfile.m, stft.m,
mean.m, anova.m, cor_test.m, t_test_regression.m, __magick_read__.cc,
dlmread.cc, schur.cc, data.cc, debug.cc, defun-dld.h, defun.cc,
defun.h, dynamic-ld.cc, error.cc, error.h, gl-render.cc, graphics.cc,
gripes.cc, input.cc, lex.ll, load-path.cc, load-save.cc, ls-hdf5.cc,
ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-ascii.cc,
ls-oct-binary.cc, oct-hist.cc, oct-parse.yy, oct-stream.cc,
oct-stream.h, octave.cc, ov-base-diag.cc, ov-base.cc, ov-class.cc,
ov-colon.h, ov-struct.cc, ov-typeinfo.cc, ov.cc, pager.cc,
pr-output.cc, pt-binop.cc, pt-eval.cc, pt-id.cc, pt-idx.cc,
pt-misc.cc, pt-unop.cc, symtab.cc, symtab.h, toplev.cc, txt-eng-ft.cc,
utils.cc, variables.cc, test_eval-catch.m, test_try.m:
Use ' instead of ` in error messages, warnings, and most comments.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 01 Oct 2012 17:18:49 -0400 |
parents | 72c96de7a403 |
children |
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> |
5760 | 31 #include <vector> |
1960 | 32 |
33 #include "byte-swap.h" | |
34 #include "data-conv.h" | |
35 #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
|
36 #include "lo-ieee.h" |
8377
25bc2d31e1bf
improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents:
7991
diff
changeset
|
37 #include "oct-locbuf.h" |
1960 | 38 |
5892 | 39 template void swap_bytes<2> (volatile void *, int); |
40 template void swap_bytes<4> (volatile void *, int); | |
41 template void swap_bytes<8> (volatile void *, int); | |
42 | |
4944 | 43 #if defined HAVE_LONG_LONG_INT |
44 #define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \ | |
45 do \ | |
46 { \ | |
47 int sz = BITS / CHAR_BIT; \ | |
48 if (sizeof (TQ char) == sz) \ | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
49 VAL = oct_data_conv::dt_ ## Q ## char; \ |
4944 | 50 else if (sizeof (TQ short) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
51 VAL = oct_data_conv::dt_ ## Q ## short; \ |
4944 | 52 else if (sizeof (TQ int) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
53 VAL = oct_data_conv::dt_ ## Q ## int; \ |
4944 | 54 else if (sizeof (TQ long) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
55 VAL = oct_data_conv::dt_ ## Q ## long; \ |
4944 | 56 else if (sizeof (TQ long long) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
57 VAL = oct_data_conv::dt_ ## Q ## longlong; \ |
4944 | 58 else \ |
59 VAL = oct_data_conv::dt_unknown; \ | |
60 } \ | |
61 while (0) | |
62 #else | |
3359 | 63 #define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \ |
3358 | 64 do \ |
65 { \ | |
66 int sz = BITS / CHAR_BIT; \ | |
67 if (sizeof (TQ char) == sz) \ | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
68 VAL = oct_data_conv::dt_ ## Q ## char; \ |
3358 | 69 else if (sizeof (TQ short) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
70 VAL = oct_data_conv::dt_ ## Q ## short; \ |
3358 | 71 else if (sizeof (TQ int) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
72 VAL = oct_data_conv::dt_ ## Q ## int; \ |
3358 | 73 else if (sizeof (TQ long) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
74 VAL = oct_data_conv::dt_ ## Q ## long; \ |
3358 | 75 else \ |
76 VAL = oct_data_conv::dt_unknown; \ | |
77 } \ | |
78 while (0) | |
4944 | 79 #endif |
3358 | 80 |
3359 | 81 #define FIND_SIZED_FLOAT_TYPE(VAL, BITS) \ |
3358 | 82 do \ |
83 { \ | |
84 int sz = BITS / CHAR_BIT; \ | |
85 if (sizeof (float) == sz) \ | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
86 VAL = oct_data_conv::dt_float; \ |
3358 | 87 else if (sizeof (double) == sz) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
88 VAL = oct_data_conv::dt_double; \ |
3358 | 89 else \ |
90 VAL = oct_data_conv::dt_unknown; \ | |
91 } \ | |
92 while (0) | |
93 | |
94 // I'm not sure it is worth the trouble, but let's use a lookup table | |
95 // for the types that are supposed to be a specific number of bits | |
96 // wide. Given the macros above, this should work as long as CHAR_BIT | |
97 // is a multiple of 8 and there are types with the right sizes. | |
98 // | |
99 // The sized data type lookup table has the following format: | |
100 // | |
101 // bits | |
102 // +----+----+----+----+ | |
103 // | 8 | 16 | 32 | 64 | | |
104 // +----+----+----+----+ | |
105 // signed integer | | | | | | |
106 // +----+----+----+----+ | |
107 // unsigned integer | | | | | | |
108 // +----+----+----+----+ | |
109 // floating point | | | | | | |
110 // +----+----+----+----+ | |
111 // | |
112 // So, the 0,3 element is supposed to contain the oct_data_conv enum | |
113 // value corresponding to the correct native data type for a signed | |
114 // 32-bit integer. | |
115 | |
116 static void | |
117 init_sized_type_lookup_table (oct_data_conv::data_type table[3][4]) | |
118 { | |
119 int bits = 8; | |
120 | |
121 for (int i = 0; i < 4; i++) | |
122 { | |
3359 | 123 FIND_SIZED_INT_TYPE (table[0][i], bits, , ); |
3358 | 124 |
3359 | 125 FIND_SIZED_INT_TYPE (table[1][i], bits, unsigned, u); |
3358 | 126 |
3359 | 127 FIND_SIZED_FLOAT_TYPE (table[2][i], bits); |
3358 | 128 |
129 bits *= 2; | |
130 } | |
131 } | |
132 | |
4944 | 133 static std::string |
134 strip_spaces (const std::string& str) | |
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 n = str.length (); |
4944 | 137 |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
138 size_t k = 0; |
4944 | 139 |
140 std::string s (n, ' '); | |
141 | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
142 for (size_t i = 0; i < n; i++) |
4944 | 143 if (! isspace (str[i])) |
144 s[k++] = tolower (str[i]); | |
145 | |
146 s.resize (k); | |
147 | |
148 return s; | |
149 } | |
150 | |
151 #define GET_SIZED_INT_TYPE(T, U) \ | |
152 do \ | |
153 { \ | |
154 switch (sizeof (T)) \ | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
155 { \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
156 case 1: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
157 retval = dt_ ## U ## int8; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
158 break; \ |
4944 | 159 \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
160 case 2: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
161 retval = dt_ ## U ## int16; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
162 break; \ |
4944 | 163 \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
164 case 4: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
165 retval = dt_ ## U ## int32; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
166 break; \ |
4944 | 167 \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
168 case 8: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
169 retval = dt_ ## U ## int64; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
170 break; \ |
4944 | 171 \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
172 default: \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
173 retval = dt_unknown; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
174 break; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
175 } \ |
4944 | 176 } \ |
177 while (0) | |
178 | |
2317 | 179 oct_data_conv::data_type |
3504 | 180 oct_data_conv::string_to_data_type (const std::string& str) |
2317 | 181 { |
182 data_type retval = dt_unknown; | |
183 | |
3358 | 184 static bool initialized = false; |
185 | |
186 static data_type sized_type_table[3][4]; | |
2317 | 187 |
3358 | 188 if (! initialized) |
189 { | |
190 init_sized_type_lookup_table (sized_type_table); | |
191 | |
192 initialized = true; | |
193 } | |
194 | |
4944 | 195 std::string s = strip_spaces (str); |
2317 | 196 |
4944 | 197 if (s == "int8" || s == "integer*1") |
198 retval = dt_int8; | |
199 else if (s == "uint8") | |
200 retval = dt_uint8; | |
201 else if (s == "int16" || s == "integer*2") | |
202 retval = dt_int16; | |
203 else if (s == "uint16") | |
204 retval = dt_uint16; | |
205 else if (s == "int32" || s == "integer*4") | |
206 retval = dt_int32; | |
207 else if (s == "uint32") | |
208 retval = dt_uint32; | |
209 else if (s == "int64" || s == "integer*8") | |
210 retval = dt_int64; | |
211 else if (s == "uint64") | |
212 retval = dt_uint64; | |
213 else if (s == "single" || s == "float32" || s == "real*4") | |
214 retval = dt_single; | |
215 else if (s == "double" || s == "float64" || s == "real*8") | |
216 retval = dt_double; | |
217 else if (s == "char" || s == "char*1") | |
2317 | 218 retval = dt_char; |
219 else if (s == "schar" || s == "signedchar") | |
220 retval = dt_schar; | |
221 else if (s == "uchar" || s == "unsignedchar") | |
222 retval = dt_uchar; | |
223 else if (s == "short") | |
4944 | 224 GET_SIZED_INT_TYPE (short, ); |
2317 | 225 else if (s == "ushort" || s == "unsignedshort") |
4944 | 226 GET_SIZED_INT_TYPE (unsigned short, u); |
2317 | 227 else if (s == "int") |
4944 | 228 GET_SIZED_INT_TYPE (int, ); |
2317 | 229 else if (s == "uint" || s == "unsignedint") |
4944 | 230 GET_SIZED_INT_TYPE (unsigned int, u); |
2317 | 231 else if (s == "long") |
4944 | 232 GET_SIZED_INT_TYPE (long, ); |
2317 | 233 else if (s == "ulong" || s == "unsignedlong") |
4944 | 234 GET_SIZED_INT_TYPE (unsigned long, u); |
235 else if (s == "longlong") | |
236 GET_SIZED_INT_TYPE (long long, ); | |
237 else if (s == "ulonglong" || s == "unsignedlonglong") | |
238 GET_SIZED_INT_TYPE (unsigned long long, u); | |
3358 | 239 else if (s == "float") |
4944 | 240 { |
241 if (sizeof (float) == sizeof (double)) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
242 retval = dt_double; |
4944 | 243 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
244 retval = dt_single; |
4944 | 245 } |
4970 | 246 else if (s == "logical") |
247 retval = dt_logical; | |
2317 | 248 else |
249 (*current_liboctave_error_handler) ("invalid data type specified"); | |
250 | |
3358 | 251 if (retval == dt_unknown) |
252 (*current_liboctave_error_handler) | |
253 ("unable to find matching native data type for %s", s.c_str ()); | |
254 | |
2317 | 255 return retval; |
256 } | |
257 | |
4944 | 258 void |
259 oct_data_conv::string_to_data_type | |
260 (const std::string& str, int& block_size, | |
261 oct_data_conv::data_type& input_type, | |
262 oct_data_conv::data_type& output_type) | |
263 { | |
264 block_size = 1; | |
265 input_type = dt_uchar; | |
266 output_type = dt_double; | |
267 | |
268 bool input_is_output = false; | |
269 | |
270 std::string s = strip_spaces (str); | |
271 | |
272 size_t pos = 0; | |
273 | |
274 if (s[0] == '*') | |
275 input_is_output = true; | |
276 else | |
277 { | |
278 size_t len = s.length (); | |
279 | |
280 while (pos < len && isdigit (s[pos])) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
281 pos++; |
4944 | 282 |
283 if (pos > 0) | |
10314
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 if (s[pos] == '*') |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
286 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
287 block_size = atoi (s.c_str ()); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
288 s = s.substr (pos+1); |
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 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
291 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
292 (*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
|
293 ("invalid repeat count in '%s'", str.c_str ()); |
4944 | 294 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
295 return; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
296 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
297 } |
4944 | 298 } |
299 | |
300 pos = s.find ('='); | |
301 | |
302 if (pos != std::string::npos) | |
303 { | |
304 if (s[pos+1] == '>') | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
305 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
306 std::string s1; |
5870 | 307 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
308 if (input_is_output) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
309 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
310 input_is_output = false; |
4944 | 311 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
312 s1 = s.substr (1, pos-1); |
5870 | 313 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
314 (*current_liboctave_warning_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
315 ("warning: ignoring leading * in fread precision"); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
316 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
317 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
318 s1 = s.substr (0, pos); |
4944 | 319 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
320 input_type = string_to_data_type (s1); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
321 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
|
322 } |
4944 | 323 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
324 (*current_liboctave_error_handler) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
325 ("fread: invalid precision specified"); |
4944 | 326 } |
327 else | |
328 { | |
5870 | 329 if (input_is_output) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
330 s = s.substr (1); |
5870 | 331 |
4944 | 332 input_type = string_to_data_type (s); |
333 | |
334 if (input_is_output) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
335 output_type = input_type; |
4944 | 336 } |
337 } | |
338 | |
339 void | |
340 oct_data_conv::string_to_data_type | |
341 (const std::string& str, int& block_size, | |
342 oct_data_conv::data_type& output_type) | |
343 { | |
344 block_size = 1; | |
345 output_type = dt_double; | |
346 | |
347 std::string s = strip_spaces (str); | |
348 | |
349 size_t pos = 0; | |
350 | |
351 size_t len = s.length (); | |
352 | |
353 while (pos < len && isdigit (s[pos])) | |
354 pos++; | |
355 | |
356 if (pos > 0) | |
357 { | |
358 if (s[pos] == '*') | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
359 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
360 block_size = atoi (s.c_str ()); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
361 s = s.substr (pos+1); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
362 } |
4944 | 363 else |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
364 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
365 (*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
|
366 ("invalid repeat count in '%s'", str.c_str ()); |
4944 | 367 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
368 return; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
369 } |
4944 | 370 } |
371 | |
372 output_type = string_to_data_type (s); | |
373 } | |
374 | |
375 std::string | |
376 oct_data_conv::data_type_as_string (oct_data_conv::data_type dt) | |
377 { | |
378 std::string retval; | |
379 | |
380 switch (dt) | |
381 { | |
382 case oct_data_conv::dt_int8: | |
383 retval = "int8"; | |
384 break; | |
385 | |
386 case oct_data_conv::dt_uint8: | |
387 retval = "uint8"; | |
388 break; | |
389 | |
390 case oct_data_conv::dt_int16: | |
391 retval = "int16"; | |
392 break; | |
393 | |
394 case oct_data_conv::dt_uint16: | |
395 retval = "uint16"; | |
396 break; | |
397 | |
398 case oct_data_conv::dt_int32: | |
399 retval = "int32"; | |
400 break; | |
401 | |
402 case oct_data_conv::dt_uint32: | |
403 retval = "uint32"; | |
404 break; | |
405 | |
406 case oct_data_conv::dt_int64: | |
407 retval = "int64"; | |
408 break; | |
409 | |
410 case oct_data_conv::dt_uint64: | |
411 retval = "uint64"; | |
412 break; | |
413 | |
414 case oct_data_conv::dt_single: | |
415 retval = "single"; | |
416 break; | |
417 | |
418 case oct_data_conv::dt_double: | |
419 retval = "double"; | |
420 break; | |
421 | |
422 case oct_data_conv::dt_char: | |
423 retval = "char"; | |
424 break; | |
425 | |
426 case oct_data_conv::dt_schar: | |
427 retval = "signed char"; | |
428 break; | |
429 | |
430 case oct_data_conv::dt_uchar: | |
431 retval = "usigned char"; | |
432 break; | |
433 | |
434 case oct_data_conv::dt_short: | |
435 retval = "short"; | |
436 break; | |
437 | |
438 case oct_data_conv::dt_ushort: | |
439 retval = "unsigned short"; | |
440 break; | |
441 | |
442 case oct_data_conv::dt_int: | |
443 retval = "int"; | |
444 break; | |
445 | |
446 case oct_data_conv::dt_uint: | |
447 retval = "usigned int"; | |
448 break; | |
449 | |
450 case oct_data_conv::dt_long: | |
451 retval = "long"; | |
452 break; | |
453 | |
454 case oct_data_conv::dt_ulong: | |
455 retval = "usigned long"; | |
456 break; | |
457 | |
458 case oct_data_conv::dt_longlong: | |
459 retval = "long long"; | |
460 break; | |
461 | |
462 case oct_data_conv::dt_ulonglong: | |
463 retval = "unsigned long long"; | |
464 break; | |
465 | |
466 case oct_data_conv::dt_float: | |
467 retval = "float"; | |
468 break; | |
469 | |
4970 | 470 case oct_data_conv::dt_logical: |
471 retval = "logical"; | |
472 break; | |
473 | |
4944 | 474 case oct_data_conv::dt_unknown: |
475 default: | |
476 retval = "unknown"; | |
477 break; | |
478 } | |
479 | |
480 return retval; | |
481 } | |
1960 | 482 |
3359 | 483 #define LS_DO_READ(TYPE, swap, data, size, len, stream) \ |
1960 | 484 do \ |
485 { \ | |
3867 | 486 if (len > 0) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
487 { \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
488 OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
489 stream.read (reinterpret_cast<char *> (ptr), size * len); \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
490 if (swap) \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
491 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
|
492 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
|
493 data[i] = ptr[i]; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
494 } \ |
1960 | 495 } \ |
496 while (0) | |
497 | |
498 // Have to use copy here to avoid writing over data accessed via | |
499 // Matrix::data(). | |
500 | |
3359 | 501 #define LS_DO_WRITE(TYPE, data, size, len, stream) \ |
1960 | 502 do \ |
503 { \ | |
3867 | 504 if (len > 0) \ |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
505 { \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
506 char tmp_type = type; \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
507 stream.write (&tmp_type, 1); \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
508 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
|
509 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
|
510 ptr[i] = static_cast <TYPE> (data[i]); \ |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
511 stream.write (reinterpret_cast<char *> (ptr), size * len); \ |
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 | |
1011 void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1012 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
|
1013 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
|
1014 oct_mach_info::float_format fmt) |
1960 | 1015 { |
1016 switch (type) | |
1017 { | |
1018 case LS_U_CHAR: | |
5828 | 1019 LS_DO_READ (uint8_t, swap, data, 1, len, is); |
1960 | 1020 break; |
1021 | |
1022 case LS_U_SHORT: | |
5828 | 1023 LS_DO_READ (uint16_t, swap, data, 2, len, is); |
1960 | 1024 break; |
1025 | |
1026 case LS_U_INT: | |
5828 | 1027 LS_DO_READ (uint32_t, swap, data, 4, len, is); |
1960 | 1028 break; |
1029 | |
1030 case LS_CHAR: | |
5828 | 1031 LS_DO_READ (int8_t, swap, data, 1, len, is); |
1960 | 1032 break; |
1033 | |
1034 case LS_SHORT: | |
5828 | 1035 LS_DO_READ (int16_t, swap, data, 2, len, is); |
1960 | 1036 break; |
1037 | |
1038 case LS_INT: | |
5828 | 1039 LS_DO_READ (int32_t, swap, data, 4, len, is); |
1960 | 1040 break; |
1041 | |
1042 case LS_FLOAT: | |
1043 { | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1044 OCTAVE_LOCAL_BUFFER (float, ptr, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1045 is.read (reinterpret_cast<char *> (ptr), 4 * len); |
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 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1054 is.read (reinterpret_cast<char *> (data), 8 * len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1055 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
|
1056 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1057 for (int i = 0; i < len; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1058 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
|
1059 } |
1960 | 1060 break; |
1061 | |
1062 default: | |
3504 | 1063 is.clear (std::ios::failbit|is.rdstate ()); |
1960 | 1064 break; |
1065 } | |
1066 } | |
1067 | |
1068 void | |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1069 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
|
1070 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
|
1071 oct_mach_info::float_format fmt) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1072 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1073 switch (type) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1074 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1075 case LS_U_CHAR: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1076 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
|
1077 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1078 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1079 case LS_U_SHORT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1080 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
|
1081 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1082 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1083 case LS_U_INT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1084 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
|
1085 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1086 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1087 case LS_CHAR: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1088 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
|
1089 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1090 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1091 case LS_SHORT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1092 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
|
1093 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1094 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1095 case LS_INT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1096 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
|
1097 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1098 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1099 case LS_FLOAT: // No conversion necessary. |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1100 is.read (reinterpret_cast<char *> (data), 4 * len); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1101 do_float_format_conversion (data, len, fmt); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1102 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1103 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1104 case LS_DOUBLE: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1105 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1106 OCTAVE_LOCAL_BUFFER (double, ptr, len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1107 is.read (reinterpret_cast<char *> (ptr), 8 * len); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1108 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
|
1109 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
|
1110 data[i] = ptr[i]; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1111 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1112 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1113 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1114 default: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1115 is.clear (std::ios::failbit|is.rdstate ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1116 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1117 } |
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 void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1121 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
|
1122 octave_idx_type len) |
1960 | 1123 { |
1124 switch (type) | |
1125 { | |
1126 case LS_U_CHAR: | |
5828 | 1127 LS_DO_WRITE (uint8_t, data, 1, len, os); |
1960 | 1128 break; |
1129 | |
1130 case LS_U_SHORT: | |
5828 | 1131 LS_DO_WRITE (uint16_t, data, 2, len, os); |
1960 | 1132 break; |
1133 | |
1134 case LS_U_INT: | |
5828 | 1135 LS_DO_WRITE (uint32_t, data, 4, len, os); |
1960 | 1136 break; |
1137 | |
1138 case LS_CHAR: | |
5828 | 1139 LS_DO_WRITE (int8_t, data, 1, len, os); |
1960 | 1140 break; |
1141 | |
1142 case LS_SHORT: | |
5828 | 1143 LS_DO_WRITE (int16_t, data, 2, len, os); |
1960 | 1144 break; |
1145 | |
1146 case LS_INT: | |
5828 | 1147 LS_DO_WRITE (int32_t, data, 4, len, os); |
1960 | 1148 break; |
1149 | |
1150 case LS_FLOAT: | |
1151 LS_DO_WRITE (float, data, 4, len, os); | |
1152 break; | |
1153 | |
3359 | 1154 case LS_DOUBLE: // No conversion necessary. |
1960 | 1155 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1156 char tmp_type = static_cast<char> (type); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1157 os.write (&tmp_type, 1); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1158 os.write (reinterpret_cast <const char *> (data), 8 * len); |
1960 | 1159 } |
1160 break; | |
1161 | |
1162 default: | |
1163 (*current_liboctave_error_handler) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1164 ("unrecognized data format requested"); |
1960 | 1165 break; |
1166 } | |
1167 } | |
1168 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1169 void |
10349
d4d13389c957
make load-save to matlab format work when using --enable-64
John W. Eaton <jwe@octave.org>
parents:
10314
diff
changeset
|
1170 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
|
1171 octave_idx_type len) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1172 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1173 switch (type) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1174 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1175 case LS_U_CHAR: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1176 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
|
1177 break; |
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 case LS_U_SHORT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1180 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
|
1181 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1182 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1183 case LS_U_INT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1184 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
|
1185 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1186 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1187 case LS_CHAR: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1188 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
|
1189 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1190 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1191 case LS_SHORT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1192 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
|
1193 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1194 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1195 case LS_INT: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1196 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
|
1197 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1198 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1199 case LS_FLOAT: // No conversion necessary. |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1200 { |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1201 char tmp_type = static_cast<char> (type); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1202 os.write (&tmp_type, 1); |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1203 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
|
1204 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1205 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1206 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1207 case LS_DOUBLE: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1208 LS_DO_WRITE (double, data, 8, len, os); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1209 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1210 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1211 default: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1212 (*current_liboctave_error_handler) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
1213 ("unrecognized data format requested"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1214 break; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1215 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
1216 } |