58 "bool matrix",
"logical");
87 if (nr == 1 && nc == 1)
102 "bool matrix",
"real scalar");
120 "bool matrix",
"real scalar");
140 "bool matrix",
"complex scalar");
160 "bool matrix",
"complex scalar");
180 bool pr_as_read_syntax)
const
193 os <<
"# ndims: " << d.
length () <<
"\n";
195 for (
int i = 0; i < d.
length (); i++)
204 os <<
"# rows: " <<
rows () <<
"\n"
205 <<
"# columns: " <<
columns () <<
"\n";
222 keywords[0] =
"ndims";
223 keywords[1] =
"rows";
232 int mdims =
static_cast<int> (val);
239 for (
int i = 0; i < mdims; i++)
256 btmp.
elem (i) = (tmp.elem (i) != 0.);
262 error (
"load: failed to load matrix constant");
269 error (
"load: failed to extract dimensions");
275 error (
"load: failed to extract number of dimensions");
279 else if (kw ==
"rows")
286 if (nr > 0 && nc > 0)
295 btmp.
elem (i,j) = (tmp.elem (i, j) != 0.);
301 error (
"load: failed to load matrix constant");
305 else if (nr == 0 || nc == 0)
312 error (
"load: failed to extract number of rows and columns");
321 error (
"load: failed to extract number of rows and columns");
337 int32_t tmp = - d.
length ();
338 os.write (reinterpret_cast<char *> (&tmp), 4);
339 for (
int i = 0; i < d.
length (); i++)
342 os.write (reinterpret_cast<char *> (&tmp), 4);
351 htmp[i] = (mtmp[i] ? 1 : 0);
353 os.write (htmp, nel);
363 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
378 for (
int i = 0; i < mdims; i++)
380 if (! is.read (reinterpret_cast<char *> (&di), 4))
401 if (! is.read (htmp, nel))
406 mtmp[i] = (htmp[i] ? 1 : 0);
412 #if defined (HAVE_HDF5)
424 hid_t space_hid = -1, data_hid = -1;
431 for (
int i = 0; i < rank; i++)
432 hdims[i] = dv (rank-i-1);
434 space_hid = H5Screate_simple (rank, hdims, 0);
435 if (space_hid < 0)
return false;
437 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_HBOOL, space_hid,
438 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
440 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_HBOOL, space_hid,
445 H5Sclose (space_hid);
456 retval = H5Dwrite (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL,
457 H5P_DEFAULT, htmp) >= 0;
460 H5Sclose (space_hid);
478 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
480 hid_t data_hid = H5Dopen (loc_id, name);
482 hid_t space_id = H5Dget_space (data_hid);
484 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
495 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
507 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
513 if (H5Dread (data_hid, H5T_NATIVE_HBOOL, H5S_ALL, H5S_ALL, H5P_DEFAULT, htmp)
520 btmp.
elem (i) = htmp[i];
537 bool *pr =
static_cast<bool *
> (retval->
get_data ());
543 for (
mwIndex i = 0; i < nel; i++)
551 @deftypefn {Built-in Function} {} logical (@var{x})\n\
552 Convert @var{x} to logical type.\n\
553 @seealso{double, single, char}\n\
558 if (args.length () == 1)