97 "real matrix",
"real scalar");
115 "real matrix",
"real scalar");
149 "real matrix",
"complex scalar");
169 "real matrix",
"complex scalar");
273 retval = mat.
diag (m, n);
276 error (
"diag: expecting vector argument");
315 ::warning (
"range error for conversion to character value");
320 chm (i) =
static_cast<char> (ival);
338 os <<
"# ndims: " << d.
length () <<
"\n";
340 for (
int i=0; i < d.
length (); i++)
349 os <<
"# rows: " <<
rows () <<
"\n"
350 <<
"# columns: " <<
columns () <<
"\n";
365 keywords[0] =
"ndims";
366 keywords[1] =
"rows";
375 int mdims =
static_cast<int> (val);
382 for (
int i = 0; i < mdims; i++)
395 error (
"load: failed to load matrix constant");
401 error (
"load: failed to read dimensions");
407 error (
"load: failed to extract number of dimensions");
411 else if (kw ==
"rows")
418 if (nr > 0 && nc > 0)
426 error (
"load: failed to load matrix constant");
430 else if (nr == 0 || nc == 0)
437 error (
"load: failed to extract number of rows and columns");
446 error (
"load: failed to extract number of rows and columns");
462 int32_t tmp = - d.
length ();
463 os.write (reinterpret_cast<char *> (&tmp), 4);
464 for (
int i = 0; i < d.
length (); i++)
467 os.write (reinterpret_cast<char *> (&tmp), 4);
472 if (d.
numel () > 8192)
474 float max_val, min_val;
479 const float *mtmp = m.
data ();
491 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
502 for (
int i = 0; i < mdims; i++)
504 if (! is.read (reinterpret_cast<char *> (&di), 4))
523 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
538 if (! is.read (reinterpret_cast<char *> (&nc), 4))
542 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
547 read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt);
555 #if defined (HAVE_HDF5)
566 hid_t space_hid = -1, data_hid = -1;
573 for (
int i = 0; i < rank; i++)
574 hdims[i] = dv (rank-i-1);
576 space_hid = H5Screate_simple (rank, hdims, 0);
578 if (space_hid < 0)
return false;
580 hid_t save_type_hid = H5T_NATIVE_FLOAT;
582 #if HAVE_HDF5_INT2FLOAT_CONVERSIONS
586 float max_val, min_val;
594 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
595 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
597 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
602 H5Sclose (space_hid);
607 retval = H5Dwrite (data_hid, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
608 H5P_DEFAULT, mtmp) >= 0;
611 H5Sclose (space_hid);
629 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
631 hid_t data_hid = H5Dopen (loc_id, name);
633 hid_t space_id = H5Dget_space (data_hid);
635 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
647 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
659 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
665 if (H5Dread (data_hid, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
666 H5P_DEFAULT, re) >= 0)
682 bool pr_as_read_syntax)
const
693 float *pr =
static_cast<float *
> (retval->
get_data ());
699 for (
mwIndex i = 0; i < nel; i++)
719 if (tmp.imag () == 0.0)
757 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
758 case umap_ ## UMAP: \
759 return octave_value (matrix.FCN ())
766 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
767 case umap_ ## UMAP: \
768 return octave_value (matrix.map<TYPE> (FCN))
770 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
771 case umap_ ## UMAP: \
772 return do_rc_map (matrix, FCN)
821 @deftypefn {Built-in Function} {} single (@var{x})\n\
822 Convert @var{x} to single precision type.\n\
830 if (args.length () == 1)
832 if (args(0).is_diag_matrix ())
834 if (args(0).is_complex_type ())
845 else if (args(0).is_sparse_type ())
847 error (
"single: sparse type does not support single precision");
849 else if (args(0).is_complex_type ())