63 template <
class T,
bool is_
signed = true,
bool can_be_too_big = true>
131 if (this->matrix.nelem () == 1)
154 typename T::element_type tmp = this->matrix(i);
156 typedef typename T::element_type::val_type val_type;
158 val_type ival = tmp.value ();
160 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
161 static const bool can_be_larger_than_uchar_max
165 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
173 ::warning (
"range error for conversion to character value");
178 chm (i) =
static_cast<char> (ival);
192 os <<
"# ndims: " << d.
length () <<
"\n";
194 for (
int i = 0; i < d.
length (); i++)
197 os <<
"\n" << this->matrix;
216 for (
int i = 0; i < mdims; i++)
225 error (
"load: failed to load matrix constant");
233 error (
"load: failed to extract number of rows and columns");
238 error (
"load: failed to extract number of dimensions");
252 int32_t tmp = - d.
length ();
253 os.write (reinterpret_cast<char *> (&tmp), 4);
254 for (
int i=0; i < d.
length (); i++)
257 os.write (reinterpret_cast<char *> (&tmp), 4);
260 os.write (reinterpret_cast<const char *> (this->matrix.data ()),
272 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
284 for (
int i = 0; i < mdims; i++)
286 if (! is.read (reinterpret_cast<char *> (&di), 4))
307 if (! is.read (reinterpret_cast<char *> (m.fortran_vec ()), m.byte_size ()))
312 int nel = dv.
numel ();
313 int bytes = nel / m.byte_size ();
314 for (
int i = 0; i < nel; i++)
336 #if defined (HAVE_HDF5)
350 hid_t space_hid = -1, data_hid = -1;
354 for (
int i = 0; i < rank; i++)
355 hdims[i] = dv (rank-i-1);
357 space_hid = H5Screate_simple (rank, hdims, 0);
359 if (space_hid < 0)
return false;
361 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
362 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
364 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
369 H5Sclose (space_hid);
373 retval = H5Dwrite (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
374 H5P_DEFAULT, this->matrix.data ()) >= 0;
377 H5Sclose (space_hid);
391 this->matrix.resize (dv);
396 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
398 hid_t data_hid = H5Dopen (loc_id, name);
400 hid_t space_id = H5Dget_space (data_hid);
402 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
414 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
426 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
431 if (H5Dread (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
432 H5P_DEFAULT, m.fortran_vec ()) >= 0)
449 bool pr_as_read_syntax)
const
452 this->current_print_indent_level ());
463 typedef typename T::val_type val_type;
465 val_type ival = tmp.value ();
467 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
468 static const bool can_be_larger_than_uchar_max
472 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
478 ::warning (
"range error for conversion to character value");
481 retval =
octave_value (std::string (1, static_cast<char> (ival)), type);
490 os << this->
scalar <<
"\n";
501 error (
"load: failed to load scalar constant");
511 os.write (reinterpret_cast<char *> (&(this->
scalar)), this->byte_size ());
521 if (! is.read (reinterpret_cast<char *> (&tmp), this->byte_size ()))
525 switch (this->byte_size ())
544 #if defined (HAVE_HDF5)
553 hid_t space_hid = -1, data_hid = -1;
555 space_hid = H5Screate_simple (0, dimens, 0);
556 if (space_hid < 0)
return false;
559 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
560 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
562 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
567 H5Sclose (space_hid);
571 retval = H5Dwrite (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
572 H5P_DEFAULT, &(this->
scalar)) >= 0;
575 H5Sclose (space_hid);
586 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
588 hid_t data_hid = H5Dopen (loc_id, name);
590 hid_t space_id = H5Dget_space (data_hid);
592 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
601 if (H5Dread (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
602 H5P_DEFAULT, &tmp) < 0)