GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
data-conv.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 John W. Eaton
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
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
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
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <cctype>
28 #include <cstdlib>
29 
30 #include <iostream>
31 #include <limits>
32 #include <vector>
33 
34 #include "byte-swap.h"
35 #include "data-conv.h"
36 #include "lo-error.h"
37 #include "lo-ieee.h"
38 #include "oct-locbuf.h"
39 
40 #if defined HAVE_LONG_LONG_INT
41 #define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \
42  do \
43  { \
44  int sz = BITS / std::numeric_limits<unsigned char>::digits; \
45  if (sizeof (TQ char) == sz) \
46  VAL = oct_data_conv::dt_ ## Q ## char; \
47  else if (sizeof (TQ short) == sz) \
48  VAL = oct_data_conv::dt_ ## Q ## short; \
49  else if (sizeof (TQ int) == sz) \
50  VAL = oct_data_conv::dt_ ## Q ## int; \
51  else if (sizeof (TQ long) == sz) \
52  VAL = oct_data_conv::dt_ ## Q ## long; \
53  else if (sizeof (TQ long long) == sz) \
54  VAL = oct_data_conv::dt_ ## Q ## longlong; \
55  else \
56  VAL = oct_data_conv::dt_unknown; \
57  } \
58  while (0)
59 #else
60 #define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \
61  do \
62  { \
63  int sz = BITS / std::numeric_limits<unsigned char>::digits; \
64  if (sizeof (TQ char) == sz) \
65  VAL = oct_data_conv::dt_ ## Q ## char; \
66  else if (sizeof (TQ short) == sz) \
67  VAL = oct_data_conv::dt_ ## Q ## short; \
68  else if (sizeof (TQ int) == sz) \
69  VAL = oct_data_conv::dt_ ## Q ## int; \
70  else if (sizeof (TQ long) == sz) \
71  VAL = oct_data_conv::dt_ ## Q ## long; \
72  else \
73  VAL = oct_data_conv::dt_unknown; \
74  } \
75  while (0)
76 #endif
77 
78 #define FIND_SIZED_FLOAT_TYPE(VAL, BITS) \
79  do \
80  { \
81  int sz = BITS / std::numeric_limits<unsigned char>::digits; \
82  if (sizeof (float) == sz) \
83  VAL = oct_data_conv::dt_float; \
84  else if (sizeof (double) == sz) \
85  VAL = oct_data_conv::dt_double; \
86  else \
87  VAL = oct_data_conv::dt_unknown; \
88  } \
89  while (0)
90 
91 // I'm not sure it is worth the trouble, but let's use a lookup table
92 // for the types that are supposed to be a specific number of bits
93 // wide. Given the macros above, this should work as long as
94 // std::numeric_limits<unsigned char>::digits is a multiple of 8 and
95 // there are types with the right sizes.
96 //
97 // The sized data type lookup table has the following format:
98 //
99 // bits
100 // +----+----+----+----+
101 // | 8 | 16 | 32 | 64 |
102 // +----+----+----+----+
103 // signed integer | | | | |
104 // +----+----+----+----+
105 // unsigned integer | | | | |
106 // +----+----+----+----+
107 // floating point | | | | |
108 // +----+----+----+----+
109 //
110 // So, the 0,3 element is supposed to contain the oct_data_conv enum
111 // value corresponding to the correct native data type for a signed
112 // 32-bit integer.
113 
114 static void
116 {
117  int bits = 8;
118 
119  for (int i = 0; i < 4; i++)
120  {
121  FIND_SIZED_INT_TYPE (table[0][i], bits, , );
122 
123  FIND_SIZED_INT_TYPE (table[1][i], bits, unsigned, u);
124 
125  FIND_SIZED_FLOAT_TYPE (table[2][i], bits);
126 
127  bits *= 2;
128  }
129 }
130 
131 static std::string
132 strip_spaces (const std::string& str)
133 {
134  size_t n = str.length ();
135 
136  size_t k = 0;
137 
138  std::string s (n, ' ');
139 
140  for (size_t i = 0; i < n; i++)
141  if (! isspace (str[i]))
142  s[k++] = tolower (str[i]);
143 
144  s.resize (k);
145 
146  return s;
147 }
148 
149 #define GET_SIZED_INT_TYPE(T, U) \
150  do \
151  { \
152  switch (sizeof (T)) \
153  { \
154  case 1: \
155  retval = dt_ ## U ## int8; \
156  break; \
157  \
158  case 2: \
159  retval = dt_ ## U ## int16; \
160  break; \
161  \
162  case 4: \
163  retval = dt_ ## U ## int32; \
164  break; \
165  \
166  case 8: \
167  retval = dt_ ## U ## int64; \
168  break; \
169  \
170  default: \
171  retval = dt_unknown; \
172  break; \
173  } \
174  } \
175  while (0)
176 
177 size_t
179 {
180  size_t retval = -1;
181 
182  switch (dt)
183  {
185  retval = sizeof (int8_t);
186  break;
187 
189  retval = sizeof (uint8_t);
190  break;
191 
193  retval = sizeof (int16_t);
194  break;
195 
197  retval = sizeof (uint16_t);
198  break;
199 
201  retval = sizeof (int32_t);
202  break;
203 
205  retval = sizeof (uint32_t);
206  break;
207 
209  retval = sizeof (int64_t);
210  break;
211 
213  retval = sizeof (uint64_t);
214  break;
215 
218  retval = sizeof (float);
219  break;
220 
222  retval = sizeof (double);
223  break;
224 
226  retval = sizeof (char);
227  break;
228 
230  retval = sizeof (signed char);
231  break;
232 
234  retval = sizeof (unsigned char);
235  break;
236 
238  retval = sizeof (short);
239  break;
240 
242  retval = sizeof (unsigned short);
243  break;
244 
246  retval = sizeof (int);
247  break;
248 
250  retval = sizeof (unsigned int);
251  break;
252 
254  retval = sizeof (long);
255  break;
256 
258  retval = sizeof (unsigned long);
259  break;
260 
262  retval = sizeof (long long);
263  break;
264 
266  retval = sizeof (unsigned long long);
267  break;
268 
270  retval = sizeof (bool);
271  break;
272 
274  default:
275  abort ();
276  break;
277  }
278 
279  return retval;
280 }
281 
283 oct_data_conv::string_to_data_type (const std::string& str)
284 {
285  data_type retval = dt_unknown;
286 
287  static bool initialized = false;
288 
289  static data_type sized_type_table[3][4];
290 
291  if (! initialized)
292  {
293  init_sized_type_lookup_table (sized_type_table);
294 
295  initialized = true;
296  }
297 
298  std::string s = strip_spaces (str);
299 
300  if (s == "int8" || s == "integer*1")
301  retval = dt_int8;
302  else if (s == "uint8")
303  retval = dt_uint8;
304  else if (s == "int16" || s == "integer*2")
305  retval = dt_int16;
306  else if (s == "uint16")
307  retval = dt_uint16;
308  else if (s == "int32" || s == "integer*4")
309  retval = dt_int32;
310  else if (s == "uint32")
311  retval = dt_uint32;
312  else if (s == "int64" || s == "integer*8")
313  retval = dt_int64;
314  else if (s == "uint64")
315  retval = dt_uint64;
316  else if (s == "single" || s == "float32" || s == "real*4")
317  retval = dt_single;
318  else if (s == "double" || s == "float64" || s == "real*8")
319  retval = dt_double;
320  else if (s == "char" || s == "char*1")
321  retval = dt_char;
322  else if (s == "schar" || s == "signedchar")
323  retval = dt_schar;
324  else if (s == "uchar" || s == "unsignedchar")
325  retval = dt_uchar;
326  else if (s == "short")
327  GET_SIZED_INT_TYPE (short, );
328  else if (s == "ushort" || s == "unsignedshort")
329  GET_SIZED_INT_TYPE (unsigned short, u);
330  else if (s == "int")
331  GET_SIZED_INT_TYPE (int, );
332  else if (s == "uint" || s == "unsignedint")
333  GET_SIZED_INT_TYPE (unsigned int, u);
334  else if (s == "long")
335  GET_SIZED_INT_TYPE (long, );
336  else if (s == "ulong" || s == "unsignedlong")
337  GET_SIZED_INT_TYPE (unsigned long, u);
338  else if (s == "longlong")
339  GET_SIZED_INT_TYPE (long long, );
340  else if (s == "ulonglong" || s == "unsignedlonglong")
341  GET_SIZED_INT_TYPE (unsigned long long, u);
342  else if (s == "float")
343  {
344  if (sizeof (float) == sizeof (double))
345  retval = dt_double;
346  else
347  retval = dt_single;
348  }
349  else if (s == "logical")
350  retval = dt_logical;
351  else
352  (*current_liboctave_error_handler) ("invalid data type specified");
353 
354  if (retval == dt_unknown)
355  (*current_liboctave_error_handler)
356  ("unable to find matching native data type for %s", s.c_str ());
357 
358  return retval;
359 }
360 
361 void
362 oct_data_conv::string_to_data_type (const std::string& str, int& block_size,
363  oct_data_conv::data_type& input_type,
364  oct_data_conv::data_type& output_type)
365 {
366  block_size = 1;
367  input_type = dt_uchar;
368  output_type = dt_double;
369 
370  bool input_is_output = false;
371 
372  std::string s = strip_spaces (str);
373 
374  size_t pos = 0;
375 
376  if (s[0] == '*')
377  input_is_output = true;
378  else
379  {
380  size_t len = s.length ();
381 
382  while (pos < len && isdigit (s[pos]))
383  pos++;
384 
385  if (pos > 0)
386  {
387  if (s[pos] == '*')
388  {
389  block_size = atoi (s.c_str ());
390  s = s.substr (pos+1);
391  }
392  else
393  {
394  (*current_liboctave_error_handler)
395  ("invalid repeat count in '%s'", str.c_str ());
396 
397  return;
398  }
399  }
400  }
401 
402  pos = s.find ('=');
403 
404  if (pos != std::string::npos)
405  {
406  if (s[pos+1] == '>')
407  {
408  std::string s1;
409 
410  if (input_is_output)
411  {
412  s1 = s.substr (1, pos-1);
413 
414  (*current_liboctave_warning_with_id_handler)
415  ("Octave:fread-precision-syntax",
416  "warning: ignoring leading * in fread precision");
417  }
418  else
419  s1 = s.substr (0, pos);
420 
421  input_type = string_to_data_type (s1);
422  output_type = string_to_data_type (s.substr (pos+2));
423  }
424  else
426  ("fread: invalid precision specified");
427  }
428  else
429  {
430  if (input_is_output)
431  s = s.substr (1);
432 
433  input_type = string_to_data_type (s);
434 
435  if (input_is_output)
436  output_type = input_type;
437  }
438 }
439 
440 void
441 oct_data_conv::string_to_data_type (const std::string& str, int& block_size,
442  oct_data_conv::data_type& output_type)
443 {
444  block_size = 1;
445  output_type = dt_double;
446 
447  std::string s = strip_spaces (str);
448 
449  size_t pos = 0;
450 
451  size_t len = s.length ();
452 
453  while (pos < len && isdigit (s[pos]))
454  pos++;
455 
456  if (pos > 0)
457  {
458  if (s[pos] == '*')
459  {
460  block_size = atoi (s.c_str ());
461  s = s.substr (pos+1);
462  }
463  else
464  {
465  (*current_liboctave_error_handler)
466  ("invalid repeat count in '%s'", str.c_str ());
467 
468  return;
469  }
470  }
471 
472  output_type = string_to_data_type (s);
473 }
474 
475 std::string
477 {
478  std::string retval;
479 
480  switch (dt)
481  {
483  retval = "int8";
484  break;
485 
487  retval = "uint8";
488  break;
489 
491  retval = "int16";
492  break;
493 
495  retval = "uint16";
496  break;
497 
499  retval = "int32";
500  break;
501 
503  retval = "uint32";
504  break;
505 
507  retval = "int64";
508  break;
509 
511  retval = "uint64";
512  break;
513 
515  retval = "single";
516  break;
517 
519  retval = "double";
520  break;
521 
523  retval = "char";
524  break;
525 
527  retval = "signed char";
528  break;
529 
531  retval = "unsigned char";
532  break;
533 
535  retval = "short";
536  break;
537 
539  retval = "unsigned short";
540  break;
541 
543  retval = "int";
544  break;
545 
547  retval = "unsigned int";
548  break;
549 
551  retval = "long";
552  break;
553 
555  retval = "unsigned long";
556  break;
557 
559  retval = "long long";
560  break;
561 
563  retval = "unsigned long long";
564  break;
565 
567  retval = "float";
568  break;
569 
571  retval = "logical";
572  break;
573 
575  default:
576  retval = "unknown";
577  break;
578  }
579 
580  return retval;
581 }
582 
583 #define LS_DO_READ(TYPE, swap, data, size, len, stream) \
584  do \
585  { \
586  if (len > 0) \
587  { \
588  OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \
589  std::streamsize n_bytes = size * static_cast<std::streamsize> (len); \
590  stream.read (reinterpret_cast<char *> (ptr), n_bytes); \
591  if (swap) \
592  swap_bytes< size > (ptr, len); \
593  for (octave_idx_type i = 0; i < len; i++) \
594  data[i] = ptr[i]; \
595  } \
596  } \
597  while (0)
598 
599 // Have to use copy here to avoid writing over data accessed via
600 // Matrix::data ().
601 
602 #define LS_DO_WRITE(TYPE, data, size, len, stream) \
603  do \
604  { \
605  if (len > 0) \
606  { \
607  char tmp_type = type; \
608  stream.write (&tmp_type, 1); \
609  OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \
610  for (octave_idx_type i = 0; i < len; i++) \
611  ptr[i] = static_cast<TYPE> (data[i]); \
612  std::streamsize n_bytes = size * static_cast<std::streamsize> (len); \
613  stream.write (reinterpret_cast<char *> (ptr), n_bytes); \
614  } \
615  } \
616  while (0)
617 
618 // Loading variables from files.
619 
620 static void
622 {
623  (*current_liboctave_error_handler)
624  ("unrecognized floating point format requested");
625 }
626 
627 // But first, some data conversion routines.
628 
629 // Currently, we only handle conversions for the IEEE types. To fix
630 // that, make more of the following routines work.
631 
632 // FIXME: assumes sizeof (Complex) == 8
633 // FIXME: assumes sizeof (double) == 8
634 // FIXME: assumes sizeof (float) == 4
635 
636 static void
638 {
639  swap_bytes<8> (d, len);
640 }
641 
642 static void
644 {
645  swap_bytes<4> (d, len);
646 }
647 
648 static void
650 {
651  swap_bytes<8> (d, len);
652 }
653 
654 static void
656 {
657  swap_bytes<4> (d, len);
658 }
659 
660 void
664 {
665  switch (to_fmt)
666  {
668  switch (from_fmt)
669  {
671  break;
672 
675  break;
676 
677  default:
679  break;
680  }
681  break;
682 
684  switch (from_fmt)
685  {
688  break;
689 
691  break;
692 
693  default:
695  break;
696  }
697  break;
698 
699  default:
700  (*current_liboctave_error_handler)
701  ("impossible state reached in file '%s' at line %d",
702  __FILE__, __LINE__);
703  break;
704  }
705 }
706 
707 void
711 {
712  switch (to_fmt)
713  {
715  switch (from_fmt)
716  {
718  break;
719 
722  break;
723 
724  default:
726  break;
727  }
728  break;
729 
731  switch (from_fmt)
732  {
735  break;
736 
738  break;
739 
740  default:
742  break;
743  }
744  break;
745 
746  default:
747  (*current_liboctave_error_handler)
748  ("impossible state reached in file '%s' at line %d",
749  __FILE__, __LINE__);
750  break;
751  }
752 }
753 
754 void
755 do_float_format_conversion (void *data, size_t sz, octave_idx_type len,
758 {
759  switch (sz)
760  {
761  case sizeof (float):
762  do_float_format_conversion (data, len, from_fmt, to_fmt);
763  break;
764 
765  case sizeof (double):
766  do_double_format_conversion (data, len, from_fmt, to_fmt);
767  break;
768 
769  default:
770  (*current_liboctave_error_handler)
771  ("impossible state reached in file '%s' at line %d",
772  __FILE__, __LINE__);
773  break;
774  }
775 }
776 
777 void
778 read_doubles (std::istream& is, double *data, save_type type,
779  octave_idx_type len, bool swap,
781 {
782  switch (type)
783  {
784  case LS_U_CHAR:
785  LS_DO_READ (uint8_t, swap, data, 1, len, is);
786  break;
787 
788  case LS_U_SHORT:
789  LS_DO_READ (uint16_t, swap, data, 2, len, is);
790  break;
791 
792  case LS_U_INT:
793  LS_DO_READ (uint32_t, swap, data, 4, len, is);
794  break;
795 
796  case LS_CHAR:
797  LS_DO_READ (int8_t, swap, data, 1, len, is);
798  break;
799 
800  case LS_SHORT:
801  LS_DO_READ (int16_t, swap, data, 2, len, is);
802  break;
803 
804  case LS_INT:
805  LS_DO_READ (int32_t, swap, data, 4, len, is);
806  break;
807 
808  case LS_FLOAT:
809  {
810  OCTAVE_LOCAL_BUFFER (float, ptr, len);
811  std::streamsize n_bytes = 4 * static_cast<std::streamsize> (len);
812  is.read (reinterpret_cast<char *> (ptr), n_bytes);
813  do_float_format_conversion (ptr, len, fmt);
814  for (octave_idx_type i = 0; i < len; i++)
815  data[i] = ptr[i];
816  }
817  break;
818 
819  case LS_DOUBLE: // No conversion necessary.
820  {
821  std::streamsize n_bytes = 8 * static_cast<std::streamsize> (len);
822  is.read (reinterpret_cast<char *> (data), n_bytes);
823  do_double_format_conversion (data, len, fmt);
824 
825  for (int i = 0; i < len; i++)
826  data[i] = __lo_ieee_replace_old_NA (data[i]);
827  }
828  break;
829 
830  default:
831  is.clear (std::ios::failbit|is.rdstate ());
832  break;
833  }
834 }
835 
836 void
837 read_floats (std::istream& is, float *data, save_type type,
838  octave_idx_type len, bool swap,
840 {
841  switch (type)
842  {
843  case LS_U_CHAR:
844  LS_DO_READ (uint8_t, swap, data, 1, len, is);
845  break;
846 
847  case LS_U_SHORT:
848  LS_DO_READ (uint16_t, swap, data, 2, len, is);
849  break;
850 
851  case LS_U_INT:
852  LS_DO_READ (uint32_t, swap, data, 4, len, is);
853  break;
854 
855  case LS_CHAR:
856  LS_DO_READ (int8_t, swap, data, 1, len, is);
857  break;
858 
859  case LS_SHORT:
860  LS_DO_READ (int16_t, swap, data, 2, len, is);
861  break;
862 
863  case LS_INT:
864  LS_DO_READ (int32_t, swap, data, 4, len, is);
865  break;
866 
867  case LS_FLOAT: // No conversion necessary.
868  {
869  std::streamsize n_bytes = 4 * static_cast<std::streamsize> (len);
870  is.read (reinterpret_cast<char *> (data), n_bytes);
871  do_float_format_conversion (data, len, fmt);
872  }
873  break;
874 
875  case LS_DOUBLE:
876  {
877  OCTAVE_LOCAL_BUFFER (double, ptr, len);
878  std::streamsize n_bytes = 8 * static_cast<std::streamsize> (len);
879  is.read (reinterpret_cast<char *> (ptr), n_bytes);
880  do_double_format_conversion (ptr, len, fmt);
881  for (octave_idx_type i = 0; i < len; i++)
882  data[i] = ptr[i];
883  }
884  break;
885 
886  default:
887  is.clear (std::ios::failbit|is.rdstate ());
888  break;
889  }
890 }
891 
892 void
893 write_doubles (std::ostream& os, const double *data, save_type type,
894  octave_idx_type len)
895 {
896  switch (type)
897  {
898  case LS_U_CHAR:
899  LS_DO_WRITE (uint8_t, data, 1, len, os);
900  break;
901 
902  case LS_U_SHORT:
903  LS_DO_WRITE (uint16_t, data, 2, len, os);
904  break;
905 
906  case LS_U_INT:
907  LS_DO_WRITE (uint32_t, data, 4, len, os);
908  break;
909 
910  case LS_CHAR:
911  LS_DO_WRITE (int8_t, data, 1, len, os);
912  break;
913 
914  case LS_SHORT:
915  LS_DO_WRITE (int16_t, data, 2, len, os);
916  break;
917 
918  case LS_INT:
919  LS_DO_WRITE (int32_t, data, 4, len, os);
920  break;
921 
922  case LS_FLOAT:
923  LS_DO_WRITE (float, data, 4, len, os);
924  break;
925 
926  case LS_DOUBLE: // No conversion necessary.
927  {
928  char tmp_type = static_cast<char> (type);
929  os.write (&tmp_type, 1);
930  std::streamsize n_bytes = 8 * static_cast<std::streamsize> (len);
931  os.write (reinterpret_cast <const char *> (data), n_bytes);
932  }
933  break;
934 
935  default:
936  (*current_liboctave_error_handler)
937  ("unrecognized data format requested");
938  break;
939  }
940 }
941 
942 void
943 write_floats (std::ostream& os, const float *data, save_type type,
944  octave_idx_type len)
945 {
946  switch (type)
947  {
948  case LS_U_CHAR:
949  LS_DO_WRITE (uint8_t, data, 1, len, os);
950  break;
951 
952  case LS_U_SHORT:
953  LS_DO_WRITE (uint16_t, data, 2, len, os);
954  break;
955 
956  case LS_U_INT:
957  LS_DO_WRITE (uint32_t, data, 4, len, os);
958  break;
959 
960  case LS_CHAR:
961  LS_DO_WRITE (int8_t, data, 1, len, os);
962  break;
963 
964  case LS_SHORT:
965  LS_DO_WRITE (int16_t, data, 2, len, os);
966  break;
967 
968  case LS_INT:
969  LS_DO_WRITE (int32_t, data, 4, len, os);
970  break;
971 
972  case LS_FLOAT: // No conversion necessary.
973  {
974  char tmp_type = static_cast<char> (type);
975  os.write (&tmp_type, 1);
976  std::streamsize n_bytes = 4 * static_cast<std::streamsize> (len);
977  os.write (reinterpret_cast <const char *> (data), n_bytes);
978  }
979  break;
980 
981  case LS_DOUBLE:
982  LS_DO_WRITE (double, data, 8, len, os);
983  break;
984 
985  default:
986  (*current_liboctave_error_handler)
987  ("unrecognized data format requested");
988  break;
989  }
990 }
save_type
Definition: data-conv.h:83
static void init_sized_type_lookup_table(oct_data_conv::data_type table[3][4])
Definition: data-conv.cc:115
int bool
Definition: mex.h:56
void write_floats(std::ostream &os, const float *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:943
void do_float_format_conversion(void *data, octave_idx_type len, oct_mach_info::float_format from_fmt, oct_mach_info::float_format to_fmt)
Definition: data-conv.cc:708
double __lo_ieee_replace_old_NA(double x)
Definition: lo-ieee.cc:101
#define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q)
Definition: data-conv.cc:60
#define LS_DO_WRITE(TYPE, data, size, len, stream)
Definition: data-conv.cc:602
void swap_bytes< 8 >(void *ptr)
Definition: byte-swap.h:67
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:893
#define LS_DO_READ(TYPE, swap, data, size, len, stream)
Definition: data-conv.cc:583
static void IEEE_little_float_to_IEEE_big_float(void *d, octave_idx_type len)
Definition: data-conv.cc:655
void do_double_format_conversion(void *data, octave_idx_type len, oct_mach_info::float_format from_fmt, oct_mach_info::float_format to_fmt)
Definition: data-conv.cc:661
F77_RET_T const double const double double * d
static void IEEE_big_double_to_IEEE_little_double(void *d, octave_idx_type len)
Definition: data-conv.cc:637
liboctave_error_handler current_liboctave_error_handler
Definition: lo-error.c:38
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:59
static void IEEE_big_float_to_IEEE_little_float(void *d, octave_idx_type len)
Definition: data-conv.cc:643
#define FIND_SIZED_FLOAT_TYPE(VAL, BITS)
Definition: data-conv.cc:78
static void gripe_unrecognized_float_fmt(void)
Definition: data-conv.cc:621
static std::string data_type_as_string(data_type dt)
Definition: data-conv.cc:476
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, oct_mach_info::float_format fmt)
Definition: data-conv.cc:778
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:197
static data_type string_to_data_type(const std::string &s)
Definition: data-conv.cc:283
#define GET_SIZED_INT_TYPE(T, U)
Definition: data-conv.cc:149
static size_t data_type_size(data_type dt)
Definition: data-conv.cc:178
static std::string strip_spaces(const std::string &str)
Definition: data-conv.cc:132
void read_floats(std::istream &is, float *data, save_type type, octave_idx_type len, bool swap, oct_mach_info::float_format fmt)
Definition: data-conv.cc:837
static void IEEE_little_double_to_IEEE_big_double(void *d, octave_idx_type len)
Definition: data-conv.cc:649