64 "complex matrix",
"double");
107 if (! force_conversion)
109 "complex matrix",
"real scalar");
114 "complex matrix",
"real scalar");
129 if (! force_conversion)
131 "complex matrix",
"real scalar");
136 "complex matrix",
"real scalar");
151 if (! force_conversion)
153 "complex matrix",
"real matrix");
165 if (! force_conversion)
167 "complex matrix",
"real matrix");
184 "complex matrix",
"complex scalar");
204 "complex matrix",
"complex scalar");
232 ||
real (
matrix).any_element_not_one_or_zero ()))
245 "complex matrix",
"string");
269 if (! force_conversion)
271 "complex matrix",
"real matrix");
307 retval = mat.
diag (m, n);
310 error (
"diag: expecting vector argument");
323 os <<
"# ndims: " << d.
length () <<
"\n";
325 for (
int i = 0; i < d.
length (); i++)
334 os <<
"# rows: " <<
rows () <<
"\n"
335 <<
"# columns: " <<
columns () <<
"\n";
350 keywords[0] =
"ndims";
351 keywords[1] =
"rows";
360 int mdims =
static_cast<int> (val);
367 for (
int i = 0; i < mdims; i++)
380 error (
"load: failed to load matrix constant");
386 error (
"load: failed to read dimensions");
392 error (
"load: failed to extract number of dimensions");
396 else if (kw ==
"rows")
403 if (nr > 0 && nc > 0)
411 error (
"load: failed to load matrix constant");
415 else if (nr == 0 || nc == 0)
422 error (
"load: failed to extract number of rows and columns");
431 error (
"load: failed to extract number of rows and columns");
446 int32_t tmp = - d.
length ();
447 os.write (reinterpret_cast<char *> (&tmp), 4);
448 for (
int i = 0; i < d.
length (); i++)
451 os.write (reinterpret_cast<char *> (&tmp), 4);
460 warning (
"save: some values too large to save as floats --");
461 warning (
"save: saving as doubles instead");
466 else if (d.
numel () > 4096)
468 double max_val, min_val;
475 write_doubles (os, reinterpret_cast<const double *> (mtmp), st,
487 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
498 for (
int i = 0; i < mdims; i++)
500 if (! is.read (reinterpret_cast<char *> (&di), 4))
519 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
525 static_cast<save_type> (tmp), 2 * dv.
numel (), swap, fmt);
534 if (! is.read (reinterpret_cast<char *> (&nc), 4))
538 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
544 static_cast<save_type> (tmp), 2*len, swap, fmt);
552 #if defined (HAVE_HDF5)
564 hid_t space_hid = -1, data_hid = -1, type_hid = -1;
571 for (
int i = 0; i < rank; i++)
572 hdims[i] = dv (rank-i-1);
574 space_hid = H5Screate_simple (rank, hdims, 0);
575 if (space_hid < 0)
return false;
577 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
583 warning (
"save: some values too large to save as floats --");
584 warning (
"save: saving as doubles instead");
587 save_type_hid = H5T_NATIVE_FLOAT;
589 #if HAVE_HDF5_INT2FLOAT_CONVERSIONS
593 double max_val, min_val;
604 H5Sclose (space_hid);
608 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
609 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
611 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, H5P_DEFAULT);
615 H5Sclose (space_hid);
621 if (complex_type_hid < 0) retval =
false;
626 if (H5Dwrite (data_hid, complex_type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
629 H5Tclose (complex_type_hid);
634 H5Tclose (complex_type_hid);
637 H5Sclose (space_hid);
655 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
657 hid_t data_hid = H5Dopen (loc_id, name);
659 hid_t type_hid = H5Dget_type (data_hid);
665 H5Tclose (complex_type);
670 hid_t space_id = H5Dget_space (data_hid);
672 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
676 H5Tclose (complex_type);
685 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
697 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
703 if (H5Dread (data_hid, complex_type, H5S_ALL, H5S_ALL, H5P_DEFAULT,
710 H5Tclose (complex_type);
721 bool pr_as_read_syntax)
const
732 double *pr =
static_cast<double *
> (retval->
get_data ());
733 double *pi =
static_cast<double *
> (retval->
get_imag_data ());
739 for (
mwIndex i = 0; i < nel; i++)
761 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
762 case umap_ ## UMAP: \
763 return octave_value (matrix.FCN ())
770 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
771 case umap_ ## UMAP: \
772 return octave_value (matrix.map<TYPE> (FCN))