GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
data-conv.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2018 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
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License 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 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (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 // FIXME: Almost all platform-dependent sizes such as "short" are now defined
41 // to take fixed values (such as 2B). This was instigated for Matlab
42 // compatibility (bug #41672). It means a lot of this code is probably
43 // obsolete and could be pared down or removed entirely.
44 
45 #if defined (OCTAVE_HAVE_LONG_LONG_INT)
46 # define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \
47  do \
48  { \
49  int sz = BITS / std::numeric_limits<unsigned char>::digits; \
50  if (sizeof (TQ char) == sz) \
51  VAL = oct_data_conv::dt_ ## Q ## char; \
52  else if (sizeof (TQ short) == sz) \
53  VAL = oct_data_conv::dt_ ## Q ## short; \
54  else if (sizeof (TQ int) == sz) \
55  VAL = oct_data_conv::dt_ ## Q ## int; \
56  else if (sizeof (TQ long) == sz) \
57  VAL = oct_data_conv::dt_ ## Q ## long; \
58  else if (sizeof (TQ long long) == sz) \
59  VAL = oct_data_conv::dt_ ## Q ## longlong; \
60  else \
61  VAL = oct_data_conv::dt_unknown; \
62  } \
63  while (0)
64 #else
65 # define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q) \
66  do \
67  { \
68  int sz = BITS / std::numeric_limits<unsigned char>::digits; \
69  if (sizeof (TQ char) == sz) \
70  VAL = oct_data_conv::dt_ ## Q ## char; \
71  else if (sizeof (TQ short) == sz) \
72  VAL = oct_data_conv::dt_ ## Q ## short; \
73  else if (sizeof (TQ int) == sz) \
74  VAL = oct_data_conv::dt_ ## Q ## int; \
75  else if (sizeof (TQ long) == sz) \
76  VAL = oct_data_conv::dt_ ## Q ## long; \
77  else \
78  VAL = oct_data_conv::dt_unknown; \
79  } \
80  while (0)
81 #endif
82 
83 #define FIND_SIZED_FLOAT_TYPE(VAL, BITS) \
84  do \
85  { \
86  int sz = BITS / std::numeric_limits<unsigned char>::digits; \
87  if (sizeof (float) == sz) \
88  VAL = oct_data_conv::dt_float; \
89  else if (sizeof (double) == sz) \
90  VAL = oct_data_conv::dt_double; \
91  else \
92  VAL = oct_data_conv::dt_unknown; \
93  } \
94  while (0)
95 
96 // I'm not sure it is worth the trouble, but let's use a lookup table
97 // for the types that are supposed to be a specific number of bits
98 // wide. Given the macros above, this should work as long as
99 // std::numeric_limits<unsigned char>::digits is a multiple of 8 and
100 // there are types with the right sizes.
101 //
102 // The sized data type lookup table has the following format:
103 //
104 // bits
105 // +----+----+----+----+
106 // | 8 | 16 | 32 | 64 |
107 // +----+----+----+----+
108 // signed integer | | | | |
109 // +----+----+----+----+
110 // unsigned integer | | | | |
111 // +----+----+----+----+
112 // floating point | | | | |
113 // +----+----+----+----+
114 //
115 // So, the 0,3 element is supposed to contain the oct_data_conv enum
116 // value corresponding to the correct native data type for a signed
117 // 32-bit integer.
118 
119 static void
121 {
122  int bits = 8;
123 
124  for (int i = 0; i < 4; i++)
125  {
126  FIND_SIZED_INT_TYPE (table[0][i], bits, , );
127 
128  FIND_SIZED_INT_TYPE (table[1][i], bits, unsigned, u);
129 
130  FIND_SIZED_FLOAT_TYPE (table[2][i], bits);
131 
132  bits *= 2;
133  }
134 }
135 
136 static std::string
138 {
139  size_t n = str.length ();
140 
141  size_t k = 0;
142 
143  std::string s (n, '\0');
144 
145  for (size_t i = 0; i < n; i++)
146  if (! isspace (str[i]))
147  s[k++] = tolower (str[i]);
148 
149  s.resize (k);
150 
151  return s;
152 }
153 
154 #define GET_SIZED_INT_TYPE(T, U) \
155  do \
156  { \
157  switch (sizeof (T)) \
158  { \
159  case 1: \
160  retval = dt_ ## U ## int8; \
161  break; \
162  \
163  case 2: \
164  retval = dt_ ## U ## int16; \
165  break; \
166  \
167  case 4: \
168  retval = dt_ ## U ## int32; \
169  break; \
170  \
171  case 8: \
172  retval = dt_ ## U ## int64; \
173  break; \
174  \
175  default: \
176  retval = dt_unknown; \
177  break; \
178  } \
179  } \
180  while (0)
181 
182 size_t
184 {
185  size_t retval = -1;
186 
187  switch (dt)
188  {
190  retval = sizeof (int8_t);
191  break;
192 
194  retval = sizeof (uint8_t);
195  break;
196 
198  retval = sizeof (int16_t);
199  break;
200 
202  retval = sizeof (uint16_t);
203  break;
204 
206  retval = sizeof (int32_t);
207  break;
208 
210  retval = sizeof (uint32_t);
211  break;
212 
214  retval = sizeof (int64_t);
215  break;
216 
218  retval = sizeof (uint64_t);
219  break;
220 
223  retval = sizeof (float);
224  break;
225 
227  retval = sizeof (double);
228  break;
229 
231  retval = sizeof (char);
232  break;
233 
235  retval = sizeof (signed char);
236  break;
237 
239  retval = sizeof (unsigned char);
240  break;
241 
243  retval = sizeof (short);
244  break;
245 
247  retval = sizeof (unsigned short);
248  break;
249 
251  retval = sizeof (int);
252  break;
253 
255  retval = sizeof (unsigned int);
256  break;
257 
259  retval = sizeof (long);
260  break;
261 
263  retval = sizeof (unsigned long);
264  break;
265 
267  retval = sizeof (long long);
268  break;
269 
271  retval = sizeof (unsigned long long);
272  break;
273 
275  retval = sizeof (bool);
276  break;
277 
279  default:
280  (*current_liboctave_error_handler)
281  ("oct_data_conv::data_type_size: unknown data type");
282  break;
283  }
284 
285  return retval;
286 }
287 
290 {
292 
293  static bool initialized = false;
294 
295  static data_type sized_type_table[3][4];
296 
297  if (! initialized)
298  {
299  init_sized_type_lookup_table (sized_type_table);
300 
301  initialized = true;
302  }
303 
305 
306  // Organized so most frequent precision appears first
307  if (s == "uint8")
308  retval = dt_uint8;
309  else if (s == "double" || s == "float64" || s == "real*8")
310  retval = dt_double;
311  else if (s == "single" || s == "float" || s == "float32" || s == "real*4")
312  retval = dt_single;
313  else if (s == "char" || s == "char*1")
314  retval = dt_char;
315  else if (s == "int")
316  retval = dt_int32;
317  else if (s == "uchar" || s == "unsignedchar")
318  retval = dt_uint8;
319  else if (s == "schar" || s == "signedchar")
320  retval = dt_int8;
321  else if (s == "int8" || s == "integer*1")
322  retval = dt_int8;
323  else if (s == "int16" || s == "integer*2")
324  retval = dt_int16;
325  else if (s == "uint16")
326  retval = dt_uint16;
327  else if (s == "int32" || s == "integer*4")
328  retval = dt_int32;
329  else if (s == "uint32")
330  retval = dt_uint32;
331  else if (s == "int64" || s == "integer*8")
332  retval = dt_int64;
333  else if (s == "uint64")
334  retval = dt_uint64;
335  else if (s == "short")
336  retval = dt_int16;
337  else if (s == "ushort" || s == "unsignedshort")
338  retval = dt_uint16;
339  else if (s == "uint" || s == "unsignedint")
340  retval = dt_uint32;
341  else if (s == "long")
342  retval = dt_int32;
343  else if (s == "ulong" || s == "unsignedlong")
344  retval = dt_uint32;
345  // FIXME: The following are undocumented precisions
346  else if (s == "longlong")
347  GET_SIZED_INT_TYPE (long long, );
348  else if (s == "ulonglong" || s == "unsignedlonglong")
349  GET_SIZED_INT_TYPE (unsigned long long, u);
350  else if (s == "logical")
351  retval = dt_logical;
352  else
353  (*current_liboctave_error_handler) ("invalid data type specified");
354 
355  if (retval == dt_unknown)
356  (*current_liboctave_error_handler)
357  ("unable to find matching native data type for %s", s.c_str ());
358 
359  return retval;
360 }
361 
362 void
364  oct_data_conv::data_type& input_type,
365  oct_data_conv::data_type& output_type)
366 {
367  block_size = 1;
368  input_type = dt_uchar;
369  output_type = dt_double;
370 
371  bool input_is_output = false;
372 
374 
375  size_t pos = 0;
376 
377  if (s[0] == '*')
378  input_is_output = true;
379  else
380  {
381  size_t len = s.length ();
382 
383  while (pos < len && isdigit (s[pos]))
384  pos++;
385 
386  if (pos > 0)
387  {
388  if (s[pos] == '*')
389  {
390  block_size = atoi (s.c_str ());
391  s = s.substr (pos+1);
392  }
393  else
395  ("invalid repeat count in '%s'", str.c_str ());
396  }
397  }
398 
399  pos = s.find ('=');
400 
401  if (pos != std::string::npos)
402  {
403  if (s[pos+1] == '>')
404  {
405  std::string s1;
406 
407  if (input_is_output)
408  {
409  s1 = s.substr (1, pos-1);
410 
411  (*current_liboctave_warning_with_id_handler)
412  ("Octave:fread-precision-syntax",
413  "warning: ignoring leading * in fread precision");
414  }
415  else
416  s1 = s.substr (0, pos);
417 
418  input_type = string_to_data_type (s1);
419  output_type = string_to_data_type (s.substr (pos+2));
420  }
421  else
423  ("fread: invalid precision specified");
424  }
425  else
426  {
427  if (input_is_output)
428  s = s.substr (1);
429 
430  input_type = string_to_data_type (s);
431 
432  if (input_is_output)
433  output_type = input_type;
434  }
435 }
436 
437 void
439  oct_data_conv::data_type& output_type)
440 {
441  block_size = 1;
442  output_type = dt_double;
443 
445 
446  size_t pos = 0;
447 
448  size_t len = s.length ();
449 
450  while (pos < len && isdigit (s[pos]))
451  pos++;
452 
453  if (pos > 0)
454  {
455  if (s[pos] == '*')
456  {
457  block_size = atoi (s.c_str ());
458  s = s.substr (pos+1);
459  }
460  else
462  ("invalid repeat count in '%s'", str.c_str ());
463  }
464 
465  output_type = string_to_data_type (s);
466 }
467 
470 {
472 
473  switch (dt)
474  {
476  retval = "int8";
477  break;
478 
480  retval = "uint8";
481  break;
482 
484  retval = "int16";
485  break;
486 
488  retval = "uint16";
489  break;
490 
492  retval = "int32";
493  break;
494 
496  retval = "uint32";
497  break;
498 
500  retval = "int64";
501  break;
502 
504  retval = "uint64";
505  break;
506 
508  retval = "single";
509  break;
510 
512  retval = "double";
513  break;
514 
516  retval = "char";
517  break;
518 
520  retval = "signed char";
521  break;
522 
524  retval = "unsigned char";
525  break;
526 
528  retval = "short";
529  break;
530 
532  retval = "unsigned short";
533  break;
534 
536  retval = "int";
537  break;
538 
540  retval = "unsigned int";
541  break;
542 
544  retval = "long";
545  break;
546 
548  retval = "unsigned long";
549  break;
550 
552  retval = "long long";
553  break;
554 
556  retval = "unsigned long long";
557  break;
558 
560  retval = "float";
561  break;
562 
564  retval = "logical";
565  break;
566 
568  default:
569  retval = "unknown";
570  break;
571  }
572 
573  return retval;
574 }
575 
576 #define LS_DO_READ(TYPE, swap, data, size, len, stream) \
577  do \
578  { \
579  if (len > 0) \
580  { \
581  OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \
582  std::streamsize n_bytes = size * static_cast<std::streamsize> (len); \
583  stream.read (reinterpret_cast<char *> (ptr), n_bytes); \
584  if (swap) \
585  swap_bytes< size > (ptr, len); \
586  for (octave_idx_type i = 0; i < len; i++) \
587  data[i] = ptr[i]; \
588  } \
589  } \
590  while (0)
591 
592 // Have to use copy here to avoid writing over data accessed via
593 // Matrix::data ().
594 
595 #define LS_DO_WRITE(TYPE, data, size, len, stream) \
596  do \
597  { \
598  if (len > 0) \
599  { \
600  char tmp_type = type; \
601  stream.write (&tmp_type, 1); \
602  OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \
603  for (octave_idx_type i = 0; i < len; i++) \
604  ptr[i] = static_cast<TYPE> (data[i]); \
605  std::streamsize n_bytes = size * static_cast<std::streamsize> (len); \
606  stream.write (reinterpret_cast<char *> (ptr), n_bytes); \
607  } \
608  } \
609  while (0)
610 
611 // Loading variables from files.
612 
613 OCTAVE_NORETURN static
614 void
616 {
617  (*current_liboctave_error_handler)
618  ("unrecognized floating point format requested");
619 }
620 
621 // But first, some data conversion routines.
622 
623 // Currently, we only handle conversions for the IEEE types. To fix
624 // that, make more of the following routines work.
625 
626 // FIXME: assumes sizeof (Complex) == 8
627 // FIXME: assumes sizeof (double) == 8
628 // FIXME: assumes sizeof (float) == 4
629 
630 static void
632 {
633  swap_bytes<8> (d, len);
634 }
635 
636 static void
638 {
639  swap_bytes<4> (d, len);
640 }
641 
642 static void
644 {
645  swap_bytes<8> (d, len);
646 }
647 
648 static void
650 {
651  swap_bytes<4> (d, len);
652 }
653 
654 void
658 {
659  switch (to_fmt)
660  {
662  switch (from_fmt)
663  {
665  break;
666 
669  break;
670 
671  default:
673  break;
674  }
675  break;
676 
678  switch (from_fmt)
679  {
682  break;
683 
685  break;
686 
687  default:
689  break;
690  }
691  break;
692 
693  default:
694  (*current_liboctave_error_handler)
695  ("impossible state reached in file '%s' at line %d",
696  __FILE__, __LINE__);
697  break;
698  }
699 }
700 
701 void
705 {
706  switch (to_fmt)
707  {
709  switch (from_fmt)
710  {
712  break;
713 
716  break;
717 
718  default:
720  break;
721  }
722  break;
723 
725  switch (from_fmt)
726  {
729  break;
730 
732  break;
733 
734  default:
736  break;
737  }
738  break;
739 
740  default:
741  (*current_liboctave_error_handler)
742  ("impossible state reached in file '%s' at line %d",
743  __FILE__, __LINE__);
744  break;
745  }
746 }
747 
748 void
752 {
753  switch (sz)
754  {
755  case sizeof (float):
756  do_float_format_conversion (data, len, from_fmt, to_fmt);
757  break;
758 
759  case sizeof (double):
760  do_double_format_conversion (data, len, from_fmt, to_fmt);
761  break;
762 
763  default:
764  (*current_liboctave_error_handler)
765  ("impossible state reached in file '%s' at line %d",
766  __FILE__, __LINE__);
767  break;
768  }
769 }
770 
771 void
772 read_doubles (std::istream& is, double *data, save_type type,
773  octave_idx_type len, bool swap,
775 {
776  switch (type)
777  {
778  case LS_U_CHAR:
779  LS_DO_READ (uint8_t, swap, data, 1, len, is);
780  break;
781 
782  case LS_U_SHORT:
783  LS_DO_READ (uint16_t, swap, data, 2, len, is);
784  break;
785 
786  case LS_U_INT:
787  LS_DO_READ (uint32_t, swap, data, 4, len, is);
788  break;
789 
790  case LS_CHAR:
791  LS_DO_READ (int8_t, swap, data, 1, len, is);
792  break;
793 
794  case LS_SHORT:
795  LS_DO_READ (int16_t, swap, data, 2, len, is);
796  break;
797 
798  case LS_INT:
799  LS_DO_READ (int32_t, swap, data, 4, len, is);
800  break;
801 
802  case LS_FLOAT:
803  {
804  OCTAVE_LOCAL_BUFFER (float, ptr, len);
805  std::streamsize n_bytes = 4 * static_cast<std::streamsize> (len);
806  is.read (reinterpret_cast<char *> (ptr), n_bytes);
807  do_float_format_conversion (ptr, len, fmt);
808  for (octave_idx_type i = 0; i < len; i++)
809  data[i] = ptr[i];
810  }
811  break;
812 
813  case LS_DOUBLE: // No conversion necessary.
814  {
815  std::streamsize n_bytes = 8 * static_cast<std::streamsize> (len);
816  is.read (reinterpret_cast<char *> (data), n_bytes);
817  do_double_format_conversion (data, len, fmt);
818 
819  for (int i = 0; i < len; i++)
820  data[i] = __lo_ieee_replace_old_NA (data[i]);
821  }
822  break;
823 
824  default:
825  is.clear (std::ios::failbit | is.rdstate ());
826  break;
827  }
828 }
829 
830 void
831 read_floats (std::istream& is, float *data, save_type type,
832  octave_idx_type len, bool swap,
834 {
835  switch (type)
836  {
837  case LS_U_CHAR:
838  LS_DO_READ (uint8_t, swap, data, 1, len, is);
839  break;
840 
841  case LS_U_SHORT:
842  LS_DO_READ (uint16_t, swap, data, 2, len, is);
843  break;
844 
845  case LS_U_INT:
846  LS_DO_READ (uint32_t, swap, data, 4, len, is);
847  break;
848 
849  case LS_CHAR:
850  LS_DO_READ (int8_t, swap, data, 1, len, is);
851  break;
852 
853  case LS_SHORT:
854  LS_DO_READ (int16_t, swap, data, 2, len, is);
855  break;
856 
857  case LS_INT:
858  LS_DO_READ (int32_t, swap, data, 4, len, is);
859  break;
860 
861  case LS_FLOAT: // No conversion necessary.
862  {
863  std::streamsize n_bytes = 4 * static_cast<std::streamsize> (len);
864  is.read (reinterpret_cast<char *> (data), n_bytes);
865  do_float_format_conversion (data, len, fmt);
866  }
867  break;
868 
869  case LS_DOUBLE:
870  {
871  OCTAVE_LOCAL_BUFFER (double, ptr, len);
872  std::streamsize n_bytes = 8 * static_cast<std::streamsize> (len);
873  is.read (reinterpret_cast<char *> (ptr), n_bytes);
874  do_double_format_conversion (ptr, len, fmt);
875  for (octave_idx_type i = 0; i < len; i++)
876  data[i] = ptr[i];
877  }
878  break;
879 
880  default:
881  is.clear (std::ios::failbit | is.rdstate ());
882  break;
883  }
884 }
885 
886 void
887 write_doubles (std::ostream& os, const double *data, save_type type,
888  octave_idx_type len)
889 {
890  switch (type)
891  {
892  case LS_U_CHAR:
893  LS_DO_WRITE (uint8_t, data, 1, len, os);
894  break;
895 
896  case LS_U_SHORT:
897  LS_DO_WRITE (uint16_t, data, 2, len, os);
898  break;
899 
900  case LS_U_INT:
901  LS_DO_WRITE (uint32_t, data, 4, len, os);
902  break;
903 
904  case LS_CHAR:
905  LS_DO_WRITE (int8_t, data, 1, len, os);
906  break;
907 
908  case LS_SHORT:
909  LS_DO_WRITE (int16_t, data, 2, len, os);
910  break;
911 
912  case LS_INT:
913  LS_DO_WRITE (int32_t, data, 4, len, os);
914  break;
915 
916  case LS_FLOAT:
917  LS_DO_WRITE (float, data, 4, len, os);
918  break;
919 
920  case LS_DOUBLE: // No conversion necessary.
921  {
922  char tmp_type = static_cast<char> (type);
923  os.write (&tmp_type, 1);
924  std::streamsize n_bytes = 8 * static_cast<std::streamsize> (len);
925  os.write (reinterpret_cast<const char *> (data), n_bytes);
926  }
927  break;
928 
929  default:
930  (*current_liboctave_error_handler)
931  ("unrecognized data format requested");
932  break;
933  }
934 }
935 
936 void
937 write_floats (std::ostream& os, const float *data, save_type type,
938  octave_idx_type len)
939 {
940  switch (type)
941  {
942  case LS_U_CHAR:
943  LS_DO_WRITE (uint8_t, data, 1, len, os);
944  break;
945 
946  case LS_U_SHORT:
947  LS_DO_WRITE (uint16_t, data, 2, len, os);
948  break;
949 
950  case LS_U_INT:
951  LS_DO_WRITE (uint32_t, data, 4, len, os);
952  break;
953 
954  case LS_CHAR:
955  LS_DO_WRITE (int8_t, data, 1, len, os);
956  break;
957 
958  case LS_SHORT:
959  LS_DO_WRITE (int16_t, data, 2, len, os);
960  break;
961 
962  case LS_INT:
963  LS_DO_WRITE (int32_t, data, 4, len, os);
964  break;
965 
966  case LS_FLOAT: // No conversion necessary.
967  {
968  char tmp_type = static_cast<char> (type);
969  os.write (&tmp_type, 1);
970  std::streamsize n_bytes = 4 * static_cast<std::streamsize> (len);
971  os.write (reinterpret_cast<const char *> (data), n_bytes);
972  }
973  break;
974 
975  case LS_DOUBLE:
976  LS_DO_WRITE (double, data, 8, len, os);
977  break;
978 
979  default:
980  (*current_liboctave_error_handler)
981  ("unrecognized data format requested");
982  break;
983  }
984 }
save_type
Definition: data-conv.h:85
static void init_sized_type_lookup_table(oct_data_conv::data_type table[3][4])
Definition: data-conv.cc:120
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, mach_info::float_format flt_fmt)
Definition: oct-stream.cc:6704
void write_floats(std::ostream &os, const float *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:937
double __lo_ieee_replace_old_NA(double x)
Definition: lo-ieee.cc:66
#define FIND_SIZED_INT_TYPE(VAL, BITS, TQ, Q)
Definition: data-conv.cc:65
#define LS_DO_WRITE(TYPE, data, size, len, stream)
Definition: data-conv.cc:595
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
Definition: lo-error.c:38
for large enough k
Definition: lu.cc:617
void swap_bytes< 8 >(void *ptr)
Definition: byte-swap.h:68
static OCTAVE_NORETURN void err_unrecognized_float_fmt(void)
Definition: data-conv.cc:615
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:887
#define LS_DO_READ(TYPE, swap, data, size, len, stream)
Definition: data-conv.cc:576
u
Definition: lu.cc:138
static void IEEE_little_float_to_IEEE_big_float(void *d, octave_idx_type len)
Definition: data-conv.cc:649
void read_floats(std::istream &is, float *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
Definition: data-conv.cc:831
s
Definition: file-io.cc:2729
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
bool swap
Definition: load-save.cc:738
void do_double_format_conversion(void *data, octave_idx_type len, octave::mach_info::float_format from_fmt, octave::mach_info::float_format to_fmt)
Definition: data-conv.cc:655
static void IEEE_big_double_to_IEEE_little_double(void *d, octave_idx_type len)
Definition: data-conv.cc:631
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:60
static void IEEE_big_float_to_IEEE_little_float(void *d, octave_idx_type len)
Definition: data-conv.cc:637
#define FIND_SIZED_FLOAT_TYPE(VAL, BITS)
Definition: data-conv.cc:83
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
Definition: data-conv.cc:772
std::string str
Definition: hash.cc:118
octave_value retval
Definition: data.cc:6246
idx type
Definition: ov.cc:3114
static std::string data_type_as_string(data_type dt)
Definition: data-conv.cc:469
sz
Definition: data.cc:5264
static bool initialized
Definition: defaults.cc:48
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:41
void do_float_format_conversion(void *data, octave_idx_type len, octave::mach_info::float_format from_fmt, octave::mach_info::float_format to_fmt)
Definition: data-conv.cc:702
for i
Definition: data.cc:5264
static data_type string_to_data_type(const std::string &s)
Definition: data-conv.cc:289
write the output to stdout if nargout is
Definition: load-save.cc:1612
#define GET_SIZED_INT_TYPE(T, U)
Definition: data-conv.cc:154
static size_t data_type_size(data_type dt)
Definition: data-conv.cc:183
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
static std::string strip_spaces(const std::string &str)
Definition: data-conv.cc:137
octave::stream os
Definition: file-io.cc:627
static void IEEE_little_double_to_IEEE_big_double(void *d, octave_idx_type len)
Definition: data-conv.cc:643