26 #if defined (HAVE_CONFIG_H)
82 #if defined (HAVE_ZLIB)
86 #define READ_PAD(is_small_data_element, l) ((is_small_data_element) ? 4 : (((l)+7)/8)*8)
87 #define PAD(l) (((l) > 0 && (l) <= 4) ? 4 : (((l)+7)/8)*8)
88 #define INT8(l) ((l) == miINT8 || (l) == miUINT8 || (l) == miUTF8)
128 read_mat5_binary_data (std::istream& is,
double *data,
193 read_mat5_binary_data (std::istream& is,
float *data,
257 template <
typename T>
263 #define READ_INTEGER_DATA(TYPE, swap, data, size, len, stream) \
268 OCTAVE_LOCAL_BUFFER (TYPE, ptr, len); \
269 std::streamsize n_bytes = size * static_cast<std::streamsize> (len); \
270 stream.read (reinterpret_cast<char *> (ptr), n_bytes); \
272 swap_bytes< size > (ptr, len); \
273 for (octave_idx_type i = 0; i < len; i++) \
325 #undef READ_INTEGER_DATA
374 #define OCTAVE_MAT5_INTEGER_READ(TYP) \
378 std::streampos tmp_pos; \
380 if (read_mat5_tag (is, swap, type, len, is_small_data_element)) \
381 error ("load: reading matrix data for '%s'", retval.c_str ()); \
383 octave_idx_type n = re.numel (); \
384 tmp_pos = is.tellg (); \
385 read_mat5_integer_data (is, re.fortran_vec (), n, swap, \
386 static_cast<enum mat5_data_type> (type)); \
389 error ("load: reading matrix data for '%s'", retval.c_str ()); \
391 is.seekg (tmp_pos + static_cast<std::streamoff> \
392 (READ_PAD (is_small_data_element, len))); \
399 if (read_mat5_tag (is, swap, type, len, is_small_data_element)) \
400 error ("load: reading matrix data for '%s'", \
404 read_mat5_binary_data (is, im.fortran_vec (), n, swap, \
405 static_cast<enum mat5_data_type> (type), flt_fmt); \
408 error ("load: reading imaginary matrix data for '%s'", \
411 ComplexNDArray ctmp (dims); \
413 for (octave_idx_type i = 0; i < n; i++) \
414 ctmp(i) = Complex (re(i).double_value (), im(i)); \
427 read_mat5_tag (std::istream& is,
bool swap, int32_t& type, int32_t& bytes,
428 bool& is_small_data_element)
433 if (! is.read (
reinterpret_cast<char *
> (&temp), 4))
439 upper = (temp >> 16) & 0xffff;
440 type = temp & 0xffff;
446 is_small_data_element =
true;
450 if (! is.read (
reinterpret_cast<char *
> (&temp), 4))
455 is_small_data_element =
false;
462 read_int (std::istream& is,
bool swap, int32_t& val)
464 is.read (
reinterpret_cast<char *
> (&val), 4);
491 bool isclass =
false;
496 std::string classname;
498 bool flt_fmt_is_big_endian
504 if ((flt_fmt_is_big_endian && ! swap) || (! flt_fmt_is_big_endian && swap))
511 int32_t element_length;
512 bool is_small_data_element;
513 if (read_mat5_tag (is, swap, type, element_length, is_small_data_element))
520 #if defined (HAVE_ZLIB)
527 is.read (inbuf, element_length);
532 uLongf elt_len = element_length;
534 if (uncompress2 (
reinterpret_cast<Bytef *
> (tmp), &destLen,
535 reinterpret_cast<Bytef *
> (inbuf), &elt_len)
537 error (
"load: error probing size of compressed data element");
543 destLen = tmp[1] + 8;
544 std::string outbuf (destLen,
' ');
548 elt_len = element_length;
549 int err = uncompress2 (
reinterpret_cast<Bytef *
>
550 (
const_cast<char *
> (outbuf.c_str ())),
551 &destLen,
reinterpret_cast<Bytef *
> (inbuf),
558 if (err == Z_BUF_ERROR && destLen == tmp[1] + 8
559 && elt_len ==
static_cast<uLongf
> (element_length))
580 msg =
"stream error";
595 case Z_VERSION_ERROR:
596 msg =
"version error";
600 error (
"load: error uncompressing data element (%s from zlib)",
605 std::istringstream gz_is (outbuf);
622 error (
"load: invalid element type = %d", type);
625 if (element_length == 0)
635 if (read_mat5_tag (is, swap, type,
len, is_small_data_element)
636 || type !=
miUINT32 ||
len != 8 || is_small_data_element)
637 error (
"load: invalid array flags subelement");
642 imag = (flags & 0x0800) != 0;
644 global = (flags & 0x0400) != 0;
646 logicalvar = (flags & 0x0200) != 0;
659 if (read_mat5_tag (is, swap, type, dim_len, is_small_data_element)
661 error (
"load: invalid dimensions array subelement");
663 int ndims = dim_len / 4;
673 for (
int i = 0; i < ndims; i++)
680 std::streampos tmp_pos = is.tellg ();
681 is.seekg (tmp_pos +
static_cast<std::streamoff
>
682 (
READ_PAD (is_small_data_element, dim_len) - dim_len));
692 if (read_mat5_tag (is, swap, type,
len, is_small_data_element)
694 error (
"load: invalid array name subelement");
701 std::streampos tmp_pos = is.tellg ();
705 if (! is.read (name,
len))
706 goto data_read_error;
708 is.seekg (tmp_pos +
static_cast<std::streamoff
>
720 Cell cell_array (dims);
732 error (
"load: reading cell data for '%s'", nm.c_str ());
768 std::streampos tmp_pos;
770 if (read_mat5_tag (is, swap, type,
len, is_small_data_element))
771 error (
"load: reading sparse row data for '%s'", retval.c_str ());
773 tmp_pos = is.tellg ();
779 error (
"load: reading sparse row data for '%s'", retval.c_str ());
781 is.seekg (tmp_pos +
static_cast<std::streamoff
>
785 if (read_mat5_tag (is, swap, type,
len, is_small_data_element))
786 error (
"load: reading sparse column data for '%s'",
789 tmp_pos = is.tellg ();
795 error (
"load: reading sparse column data for '%s'",
798 is.seekg (tmp_pos +
static_cast<std::streamoff
>
802 if (read_mat5_tag (is, swap, type,
len, is_small_data_element))
803 error (
"load: reading sparse matrix data for '%s'",
814 tmp_pos = is.tellg ();
815 read_mat5_binary_data (is, data, nnz, swap,
820 error (
"load: reading sparse matrix data for '%s'",
823 is.seekg (tmp_pos +
static_cast<std::streamoff
>
831 if (read_mat5_tag (is, swap, type,
len, is_small_data_element))
832 error (
"load: reading sparse matrix data for '%s'",
835 read_mat5_binary_data (is, im.
fortran_vec (), nnz, swap,
840 error (
"load: reading imaginary sparse matrix data for '%s'",
860 goto data_read_error;
872 if (ftype ==
"simple" || ftype ==
"scopedfunction")
876 octave::tree_evaluator& tw = interp.get_evaluator ();
880 tc = tw.make_fcn_handle (fname);
886 if ((fpath.length () >= mroot.length ())
887 && fpath.substr (0, mroot.length ()) == mroot
900 + fpath.substr (mroot.length ()));
907 std::string dir_name = str.substr (0, xpos);
921 std::list<std::string> names;
922 names.push_back (fname +
".oct");
923 names.push_back (fname +
".mex");
924 names.push_back (fname +
".m");
926 octave::load_path& lp = interp.get_load_path ();
928 octave::directory_path p (lp.system_path ());
930 str = octave::sys::env::make_absolute (p.find_first_of (names));
935 std::string dir_name = str.substr (0, xpos);
948 "load: can't find the file %s",
959 std::string dir_name = fpath.substr (0, xpos);
971 "load: can't find the file %s",
978 else if (ftype ==
"nested")
981 "load: can't load nested function");
984 else if (ftype ==
"anonymous")
995 octave::stack_frame::local_vars_map local_vars;
1005 for (
auto p0 = m2.
begin (); p0 != m2.
end (); p0++)
1007 std::string key = m2.
key (p0);
1010 local_vars[key] = val;
1020 octave::tree_evaluator& tw = interp.get_evaluator ();
1021 tw.push_dummy_scope (
"read_mat5_binary_element");
1023 octave::unwind_action act ([&tw] () { tw.pop_scope (); });
1034 = interp.eval_string (fname.substr (4),
true, parse_status);
1036 if (parse_status != 0)
1037 error (
"load: failed to load anonymous function handle");
1042 error (
"load: failed to load anonymous function handle");
1049 error (
"load: invalid function handle type");
1059 for (
int i = 0; i < n_fields; i++)
1063 if (read_mat5_tag (is, swap, fn_type, fn_len, is_small_data_element)
1065 error (
"load: invalid field name subelement");
1069 std::streampos tmp_pos = is.tellg ();
1073 if (! is.read (elname, fn_len))
1074 goto data_read_error;
1076 is.seekg (tmp_pos +
static_cast<std::streamoff
>
1077 (
READ_PAD (is_small_data_element, fn_len)));
1080 elname[fn_len] =
'\0';
1085 std::vector<Cell> elt (n_fields);
1088 elt[i] =
Cell (dims);
1097 if (field(i) ==
"MCOS")
1103 goto data_read_error;
1105 elt[i](j) = fieldtc;
1113 m.assign (field (i), elt[i]);
1122 if (read_mat5_tag (is, swap, type,
len, is_small_data_element)
1124 error (
"load: invalid class name");
1129 std::streampos tmp_pos = is.tellg ();
1133 if (! is.read (name,
len))
1134 goto data_read_error;
1136 is.seekg (tmp_pos +
static_cast<std::streamoff
>
1151 int32_t field_name_length;
1157 if (read_mat5_tag (is, swap, fn_type, fn_len, is_small_data_element)
1159 error (
"load: invalid field name length subelement");
1161 if (! is.read (
reinterpret_cast<char *
> (&field_name_length), fn_len))
1162 goto data_read_error;
1169 if (read_mat5_tag (is, swap, fn_type, fn_len, is_small_data_element)
1171 error (
"load: invalid field name subelement");
1177 fn_len =
READ_PAD (is_small_data_element, fn_len);
1181 if (! is.read (elname, fn_len))
1182 goto data_read_error;
1184 std::vector<Cell> elt (n_fields);
1187 elt[i] =
Cell (dims);
1199 elt[i](j) = fieldtc;
1205 const char *key = elname + i*field_name_length;
1207 m.assign (key, elt[i]);
1213 octave::cdef_manager& cdm = interp.get_cdef_manager ();
1215 if (cdm.find_class (classname,
false,
true).ok ())
1219 "load: classdef element has been converted to a struct");
1225 std::list<std::string> ());
1232 "load: unable to reconstruct object inheritance");
1236 octave::load_path& lp = interp.get_load_path ();
1238 if (lp.find_method (classname,
"loadobj") !=
"")
1246 catch (
const octave::execution_exception&)
1248 goto data_read_error;
1256 "load: element has been converted to a structure");
1284 out(i) = in(i).bool_value ();
1321 std::streampos tmp_pos;
1323 if (read_mat5_tag (is, swap, type,
len, is_small_data_element))
1324 error (
"load: reading matrix data for '%s'", retval.c_str ());
1327 tmp_pos = is.tellg ();
1333 error (
"load: reading matrix data for '%s'", retval.c_str ());
1335 is.seekg (tmp_pos +
static_cast<std::streamoff
>
1344 if (read_mat5_tag (is, swap, type,
len, is_small_data_element))
1345 error (
"load: reading matrix data for '%s'", retval.c_str ());
1353 error (
"load: reading imaginary matrix data for '%s'",
1378 std::streampos tmp_pos;
1380 if (read_mat5_tag (is, swap, type,
len, is_small_data_element))
1381 error (
"load: reading matrix data for '%s'", retval.c_str ());
1384 tmp_pos = is.tellg ();
1390 error (
"load: reading matrix data for '%s'", retval.c_str ());
1392 is.seekg (tmp_pos +
static_cast<std::streamoff
>
1404 out (i) =
static_cast<bool> (re (i));
1414 if (read_mat5_tag (is, swap, type,
len, is_small_data_element))
1415 error (
"load: reading matrix data for '%s'", retval.c_str ());
1423 error (
"load: reading imaginary matrix data for '%s'",
1429 ctmp(i) =
Complex (re(i), im(i));
1435 bool converted =
false;
1439 const uint16_t *u16_str
1440 =
reinterpret_cast<const uint16_t *
> (u16.
data ());
1451 tc =
charMatrix (std::string (
reinterpret_cast<char *
> (u8_str), n8));
1459 const uint32_t *u32_str
1460 =
reinterpret_cast<const uint32_t *
> (u32.
data ());
1471 tc =
charMatrix (std::string (
reinterpret_cast<char *
> (u8_str), n8));
1489 bool found_big_char =
false;
1495 found_big_char =
true;
1501 "load: failed to convert from input to UTF-8; "
1502 "replacing non-ASCII characters with '?'");
1514 is.seekg (pos +
static_cast<std::streamoff
> (element_length));
1523 error (
"load: trouble reading binary file '%s'", filename.c_str ());
1527 "load: skipping over '%s'", retval.c_str ());
1528 is.seekg (pos +
static_cast<std::streamoff
> (element_length));
1534 const std::string& filename)
1536 int16_t version = 0;
1538 uint64_t subsys_offset;
1540 is.seekg (116, std::ios::beg);
1541 is.read (
reinterpret_cast<char *
> (&subsys_offset), 8);
1543 is.seekg (124, std::ios::beg);
1544 is.read (
reinterpret_cast<char *
> (&version), 2);
1545 is.read (
reinterpret_cast<char *
> (&magic), 2);
1547 if (magic == 0x4d49)
1549 else if (magic == 0x494d)
1554 error (
"load: can't read binary file");
1560 version = ((version >> 8) & 0xff) + ((version & 0xff) << 8);
1562 if (version != 1 && ! quiet)
1564 "load: found version %d binary MAT file, but only prepared for version 1",
1570 if (subsys_offset != UINT64_C (0x2020202020202020)
1571 && subsys_offset != UINT64_C (0))
1574 is.seekg (subsys_offset, std::ios::beg);
1589 std::string outbuf (ilen - 7,
' ');
1592 char *ctmp =
const_cast<char *
> (outbuf.c_str ());
1594 ctmp[j-8] = itmp(j).char_value ();
1596 std::istringstream fh_ws (outbuf);
1607 is.seekg (128, std::ios::beg);
1618 if (bytes > 0 && bytes <= 4)
1619 temp = (bytes << 16) + type;
1623 if (! is.write (
reinterpret_cast<char *
> (&temp), 4))
1628 if (! is.write (
reinterpret_cast<char *
> (&temp), 4))
1637 #define MAT5_DO_WRITE(TYPE, data, count, stream) \
1640 OCTAVE_LOCAL_BUFFER (TYPE, ptr, count); \
1641 for (octave_idx_type i = 0; i < count; i++) \
1642 ptr[i] = static_cast<TYPE> (data[i]); \
1643 std::streamsize n_bytes = sizeof (TYPE) * static_cast<std::streamsize> (count); \
1644 stream.write (reinterpret_cast<char *> (ptr), n_bytes); \
1651 write_mat5_array (std::ostream& os,
const NDArray&
m,
bool save_as_floats)
1654 const double *data =
m.data ();
1658 if (
m.too_large_for_float ())
1661 "save: some values too large to save as floats -- saving as doubles instead");
1667 double max_val, min_val;
1668 if (
m.all_integers (max_val, min_val))
1689 write_mat5_tag (os, mst,
len);
1731 os.write (
reinterpret_cast<const char *
> (data),
len);
1735 error (
"unrecognized data format requested");
1741 static char buf[9]=
"\x00\x00\x00\x00\x00\x00\x00\x00";
1747 write_mat5_array (std::ostream& os,
const FloatNDArray&
m,
bool)
1750 const float *data =
m.data ();
1752 float max_val, min_val;
1753 if (
m.all_integers (max_val, min_val))
1774 write_mat5_tag (os, mst,
len);
1812 os.write (
reinterpret_cast<const char *
> (data),
len);
1820 error (
"unrecognized data format requested");
1826 static char buf[9]=
"\x00\x00\x00\x00\x00\x00\x00\x00";
1831 template <
typename T>
1873 write_mat5_tag (os, mst,
len);
1875 os.write (
reinterpret_cast<const char *
> (
m),
len);
1879 static char buf[9]=
"\x00\x00\x00\x00\x00\x00\x00\x00";
1924 write_mat5_cell_array (std::ostream& os,
const Cell& cell,
1925 bool mark_global,
bool save_as_floats)
1934 false, save_as_floats))
1943 bool save_as_floats)
1954 double tmp = val[i];
2009 return 8 + nel * size;
2065 return PAD ((nel * size <= 4 ? 4 : 8) + nel * size);
2073 bool save_as_floats)
2094 bool save_as_floats)
2114 maybe_convert_to_u16 (
const charNDArray& chm, std::size_t& n16_str)
2119 if (chm.
ndims () == 2 && dv(0) == 1)
2121 const uint8_t *u8_str =
reinterpret_cast<const uint8_t *
> (chm.
data ());
2133 bool save_as_floats,
bool mat7_format)
2135 std::size_t max_namelen = 63;
2136 std::size_t
len = name.length ();
2141 ret +=
PAD (
len > max_namelen ? max_namelen :
len);
2149 std::size_t n16_str;
2150 uint16_t *u16_str = maybe_convert_to_u16 (chm, n16_str);
2154 std::size_t sz_of = 1;
2163 str_len = chm.
numel ();
2166 ret +=
PAD (sz_of * str_len);
2178 ret +=
PAD (nnz *
sizeof (int32_t));
2180 ret +=
PAD ((nc + 1) *
sizeof (int32_t));
2190 ret +=
PAD (nnz *
sizeof (int32_t));
2192 ret +=
PAD ((nc + 1) *
sizeof (int32_t));
2196 #define INT_LEN(nel, size) \
2199 octave_idx_type sz = nel * size; \
2204 else if (cname ==
"int8")
2206 else if (cname ==
"int16")
2208 else if (cname ==
"int32")
2210 else if (cname ==
"int64")
2212 else if (cname ==
"uint8")
2214 else if (cname ==
"uint16")
2216 else if (cname ==
"uint32")
2218 else if (cname ==
"uint64")
2240 for (
int i = 0; i < nel; i++)
2267 std::size_t classlen = tc.
class_name ().length ();
2269 ret += 8 +
PAD (classlen > max_namelen ? max_namelen : classlen);
2272 for (
auto i =
m.begin (); i !=
m.end (); i++)
2275 ret += 16 + fieldcnt * (max_namelen + 1);
2279 for (
auto i =
m.begin (); i !=
m.end (); i++)
2281 const Cell elts =
m.contents (i);
2295 write_mat5_sparse_index_vector (std::ostream& os,
2299 int tmp =
sizeof (int32_t);
2304 tmp_idx[i] = idx[i];
2310 warn_dim_too_large (
const std::string& name)
2313 "save: skipping %s: dimension too large for MAT format",
2323 bool mark_global,
bool mat7_format,
2324 bool save_as_floats,
bool compressing)
2329 std::size_t max_namelen = 63;
2332 int nd = tc.
ndims ();
2337 for (
int i = 0; i < nd; i++)
2339 if (dv(i) > max_dim_val)
2341 warn_dim_too_large (name);
2364 if (nnz > max_dim_val || nc + 1 > max_dim_val)
2366 warn_dim_too_large (name);
2372 else if (dv.
numel () > max_dim_val)
2374 warn_dim_too_large (name);
2378 #if defined (HAVE_ZLIB)
2380 if (mat7_format && ! compressing)
2384 std::ostringstream buf;
2389 save_as_floats,
true);
2395 std::string buf_str = buf.str ();
2396 uLongf srcLen = buf_str.length ();
2397 uLongf destLen = compressBound (srcLen);
2400 if (compress (
reinterpret_cast<Bytef *
> (out_buf), &destLen,
2401 reinterpret_cast<const Bytef *
> (buf_str.c_str ()),
2404 error (
"save: error compressing data element");
2409 os.write (out_buf, destLen);
2417 octave_unused_parameter (compressing);
2422 (tc, name, save_as_floats, mat7_format));
2438 else if (cname ==
"int8")
2440 else if (cname ==
"int16")
2442 else if (cname ==
"int32")
2444 else if (cname ==
"int64")
2446 else if (cname ==
"uint8" || tc.
islogical ())
2448 else if (cname ==
"uint16")
2450 else if (cname ==
"uint32")
2452 else if (cname ==
"uint64")
2474 error (
"save: error while writing '%s' to MAT file", name.c_str ());
2477 os.write (
reinterpret_cast<char *
> (&flags), 4);
2482 os.write (
reinterpret_cast<char *
> (&nnz_32), 4);
2484 write_mat5_tag (os,
miINT32, dim_len);
2489 std::size_t n16_str;
2490 bool conv_u16 =
false;
2494 u16_str = maybe_convert_to_u16 (chm, n16_str);
2503 os.write (
reinterpret_cast<char *
> (&
n), 4);
2504 os.write (
reinterpret_cast<char *
> (&n16_str), 4);
2507 for (
int i = 0; i < nd; i++)
2510 os.write (
reinterpret_cast<char *
> (&
n), 4);
2513 if (
PAD (dim_len) > dim_len)
2515 static char buf[9] =
"\x00\x00\x00\x00\x00\x00\x00\x00";
2516 os.write (buf,
PAD (dim_len) - dim_len);
2521 std::size_t namelen = name.length ();
2523 if (namelen > max_namelen)
2524 namelen = max_namelen;
2526 int paddedlength =
PAD (namelen);
2528 write_mat5_tag (os,
miINT8, namelen);
2530 memset (paddedname, 0, paddedlength);
2531 strncpy (paddedname, name.c_str (), namelen);
2532 os.write (paddedname, paddedlength);
2545 paddedlength =
PAD (
len);
2549 os.write (
reinterpret_cast<char *
> (u16_str),
len);
2557 paddedlength =
PAD (
len);
2564 if (paddedlength >
len)
2566 static char padbuf[9] =
"\x00\x00\x00\x00\x00\x00\x00\x00";
2567 os.write (padbuf, paddedlength -
len);
2578 write_mat5_sparse_index_vector (os,
m.ridx (), nnz);
2579 write_mat5_sparse_index_vector (os,
m.cidx (), nc + 1);
2586 write_mat5_array (os, buf, save_as_floats);
2591 write_mat5_array (os, buf, save_as_floats);
2599 write_mat5_sparse_index_vector (os,
m.ridx (), nnz);
2600 write_mat5_sparse_index_vector (os,
m.cidx (), nc + 1);
2606 for (
int i = 0; i < nnz; i++)
2607 buf (i) =
m.data (i);
2609 write_mat5_array (os, buf, save_as_floats);
2612 else if (cname ==
"int8")
2618 else if (cname ==
"int16")
2624 else if (cname ==
"int32")
2630 else if (cname ==
"int64")
2636 else if (cname ==
"uint8")
2642 else if (cname ==
"uint16")
2648 else if (cname ==
"uint32")
2654 else if (cname ==
"uint64")
2672 write_mat5_array (os,
m, save_as_floats);
2678 write_mat5_array (os,
m, save_as_floats);
2685 if (! write_mat5_cell_array (os, cell, mark_global, save_as_floats))
2686 error (
"save: error while writing '%s' to MAT file", name.c_str ());
2694 write_mat5_array (os, ::
real (m_cmplx), save_as_floats);
2695 write_mat5_array (os, ::
imag (m_cmplx), save_as_floats);
2701 write_mat5_array (os, ::
real (m_cmplx), save_as_floats);
2702 write_mat5_array (os, ::
imag (m_cmplx), save_as_floats);
2711 std::size_t namelen = classname.length ();
2713 if (namelen > max_namelen)
2714 namelen = max_namelen;
2716 int paddedlength =
PAD (namelen);
2718 write_mat5_tag (os,
miINT8, namelen);
2720 memset (paddedname, 0, paddedlength);
2721 strncpy (paddedname, classname.c_str (), namelen);
2722 os.write (paddedname, paddedlength);
2729 octave::load_path& lp = interp.get_load_path ();
2732 && lp.find_method (tc.
class_name (),
"saveobj") !=
"")
2738 m = tmp(0).map_value ();
2740 catch (
const octave::execution_exception&)
2742 error (
"save: error while writing '%s' to MAT file",
2753 int32_t maxfieldnamelength = max_namelen + 1;
2757 write_mat5_tag (os,
miINT32, 4);
2758 os.write (
reinterpret_cast<char *
> (&maxfieldnamelength), 4);
2759 write_mat5_tag (os,
miINT8, nf*maxfieldnamelength);
2767 std::string key = keys(i);
2770 memset (buf, 0, max_namelen + 1);
2772 strncpy (buf, key.c_str (), max_namelen);
2773 os.write (buf, max_namelen + 1);
2780 std::vector<const octave_value *> elts (nf);
2782 elts[i] =
m.contents (keys(i)).data ();
2797 error (
"save: error while writing '%s' to MAT file",
void swap_bytes< 8 >(void *ptr)
void swap_bytes< 4 >(void *ptr)
charNDArray max(char d, const charNDArray &m)
T * fortran_vec()
Size of the specified dimension.
bool isvector() const
Size of the specified dimension.
int ndims() const
Size of the specified dimension.
const T * data() const
Size of the specified dimension.
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
octave_idx_type numel() const
Number of elements in the array.
octave_idx_type cols() const
octave_idx_type nzmax() const
Amount of storage for nonzero elements.
Vector representing the dimensions (size) of an Array.
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
void resize(int n, int fill_value=0)
bool reconstruct_parents()
bool reconstruct_exemplar()
const_iterator end() const
const octave_value & contents(const_iterator p) const
const_iterator begin() const
octave_idx_type nfields() const
std::string key(const_iterator p) const
boolNDArray bool_array_value(bool warn=false) const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
std::string class_name() const
bool is_inline_function() const
bool is_real_scalar() const
int32NDArray int32_array_value() const
uint16NDArray uint16_array_value() const
int16NDArray int16_array_value() const
int8NDArray int8_array_value() const
octave_scalar_map scalar_map_value() const
bool is_complex_scalar() const
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
bool is_single_type() const
charNDArray char_array_value(bool frc_str_conv=false) const
bool is_uint8_type() const
uint64NDArray uint64_array_value() const
octave_map map_value() const
bool is_real_matrix() const
octave_fcn_handle * fcn_handle_value(bool silent=false) const
std::string string_value(bool force=false) const
int64NDArray int64_array_value() const
NDArray array_value(bool frc_str_conv=false) const
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
uint8NDArray uint8_array_value() const
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
uint32NDArray uint32_array_value() const
bool is_complex_matrix() const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
void read_int(std::istream &is, bool swap_bytes, T &val)
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
void read_floats(std::istream &is, float *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
void warning_with_id(const char *id, const char *fmt,...)
void() error(const char *fmt,...)
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
void warn_wrong_type_arg(const char *name, const octave_value &tc)
interpreter & __get_interpreter__()
bool file_exists(const std::string &filename, bool is_dir)
bool too_large_for_float(double x)
#define READ_INTEGER_DATA(TYPE, swap, data, size, len, stream)
void write_mat5_integer_data(std::ostream &os, const T *m, int size, octave_idx_type nel)
#define MAT5_DO_WRITE(TYPE, data, count, stream)
int save_mat5_array_length(const double *val, octave_idx_type nel, bool save_as_floats)
#define OCTAVE_MAT5_INTEGER_READ(TYP)
@ MAT_FILE_WORKSPACE_CLASS
@ MAT_FILE_FUNCTION_CLASS
int read_mat5_binary_file_header(std::istream &is, bool &swap, bool quiet, const std::string &filename)
#define INT_LEN(nel, size)
bool save_mat5_binary_element(std::ostream &os, const octave_value &tc, const std::string &name, bool mark_global, bool mat7_format, bool save_as_floats, bool compressing)
int save_mat5_element_length(const octave_value &tc, const std::string &name, bool save_as_floats, bool mat7_format)
std::string read_mat5_binary_element(std::istream &is, const std::string &filename, bool swap, bool &global, octave_value &tc)
#define READ_PAD(is_small_data_element, l)
void read_mat5_integer_data(std::istream &is, T *m, octave_idx_type count, bool swap, mat5_data_type type)
save_type get_save_type(double, double)
float_format native_float_format()
@ flt_fmt_ieee_big_endian
@ flt_fmt_ieee_little_endian
std::string octave_exec_home()
std::string dir_sep_chars()
octave_value load_fcn_from_file(const std::string &file_name, const std::string &dir_name, const std::string &dispatch_type, const std::string &package_name, const std::string &fcn_name, bool autoload)
std::complex< double > Complex
std::complex< float > FloatComplex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
uint8_t * octave_u16_to_u8_wrapper(const uint16_t *src, size_t src_len, uint8_t *result_buf, size_t *lengthp)
uint16_t * octave_u8_to_u16_wrapper(const uint8_t *src, size_t src_len, uint16_t *result_buf, size_t *lengthp)
uint8_t * octave_u32_to_u8_wrapper(const uint32_t *src, size_t src_len, uint8_t *result_buf, size_t *lengthp)