80 template <
typename T,
bool is_
signed = true,
bool can_be_too_big = true>
105 template <
typename T>
117 template <
typename T>
141 template <
typename T>
147 if (this->matrix.numel () == 1)
154 template <
typename T>
170 typename T::element_type tmp = this->matrix(i);
172 typedef typename T::element_type::val_type val_type;
174 val_type ival = tmp.value ();
176 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
177 static const bool can_be_larger_than_uchar_max
181 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
189 ::warning (
"range error for conversion to character value");
194 chm (i) =
static_cast<char> (ival);
202 template <
typename MT>
209 template <
typename MT>
216 template <
typename MT>
223 template <
typename MT>
230 template <
typename MT>
237 template <
typename MT>
244 template <
typename MT>
251 template <
typename MT>
258 template <
typename MT>
265 template <
typename MT>
272 template <
typename T>
278 std::ostringstream buf;
283 template <
typename T>
289 os <<
"# ndims: " << dv.
ndims () <<
"\n";
291 for (
int i = 0; i < dv.
ndims (); i++)
294 os <<
"\n" << this->matrix;
299 template <
typename T>
306 error (
"load: failed to extract number of dimensions");
309 error (
"load: failed to extract number of rows and columns");
314 for (
int i = 0; i < mdims; i++)
322 error (
"load: failed to load matrix constant");
329 template <
typename T>
338 int32_t tmp = - dv.
ndims ();
339 os.write (
reinterpret_cast<char *
> (&tmp), 4);
340 for (
int i=0; i < dv.
ndims (); i++)
343 os.write (
reinterpret_cast<char *
> (&tmp), 4);
346 os.write (
reinterpret_cast<const char *
> (this->matrix.data ()),
352 template <
typename T>
358 if (! is.read (
reinterpret_cast<char *
> (&mdims), 4))
370 for (
int i = 0; i < mdims; i++)
372 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
393 if (! is.read (
reinterpret_cast<char *
> (
m.fortran_vec ()),
m.byte_size ()))
398 int nel = dv.
numel ();
399 int bytes = nel /
m.byte_size ();
400 for (
int i = 0; i < nel; i++)
422 template <
typename T>
426 const char *
name,
bool)
430 #if defined (HAVE_HDF5)
438 int rank = dv.
ndims ();
439 hid_t space_hid, data_hid;
440 space_hid = data_hid = -1;
444 for (
int i = 0; i < rank; i++)
445 hdims[i] = dv(rank-i-1);
447 space_hid = H5Screate_simple (rank, hdims,
nullptr);
449 if (space_hid < 0)
return false;
450 #if defined (HAVE_HDF5_18)
451 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
454 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
459 H5Sclose (space_hid);
467 H5Sclose (space_hid);
470 octave_unused_parameter (loc_id);
472 octave_unused_parameter (
name);
474 this->warn_save (
"hdf5");
480 template <
typename T>
488 #if defined (HAVE_HDF5)
494 this->matrix.resize (dv);
498 #if defined (HAVE_HDF5_18)
501 hid_t data_hid = H5Dopen (loc_id,
name);
503 hid_t space_id = H5Dget_space (data_hid);
505 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
517 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
529 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
545 octave_unused_parameter (loc_id);
547 octave_unused_parameter (
name);
549 this->warn_load (
"hdf5");
555 template <
typename T>
558 bool pr_as_read_syntax)
const
561 this->current_print_indent_level ());
564 template <
typename T>
572 typedef typename T::val_type val_type;
574 val_type ival = tmp.value ();
576 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
577 static const bool can_be_larger_than_uchar_max
581 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
587 ::warning (
"range error for conversion to character value");
595 template <
typename T>
599 return static_cast<double> (this->
scalar);
602 template <
typename T>
606 return static_cast<float> (this->
scalar);
609 template <
typename T>
616 template <
typename T>
623 template <
typename T>
630 template <
typename T>
637 template <
typename T>
644 template <
typename T>
651 template <
typename T>
658 template <
typename T>
665 template <
typename ST>
671 std::ostringstream buf;
676 template <
typename T>
680 os << this->
scalar <<
"\n";
684 template <
typename T>
690 error (
"load: failed to load scalar constant");
695 template <
typename T>
699 os.write (
reinterpret_cast<char *
> (&(this->
scalar)), this->byte_size ());
703 template <
typename T>
710 if (! is.read (
reinterpret_cast<char *
> (&tmp), this->byte_size ()))
714 swap_bytes<sizeof (T)> (&tmp);
721 template <
typename T>
725 const char *
name,
bool)
729 #if defined (HAVE_HDF5)
733 hid_t space_hid, data_hid;
734 space_hid = data_hid = -1;
736 space_hid = H5Screate_simple (0, dimens,
nullptr);
737 if (space_hid < 0)
return false;
739 #if defined (HAVE_HDF5_18)
740 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
743 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
748 H5Sclose (space_hid);
756 H5Sclose (space_hid);
759 octave_unused_parameter (loc_id);
761 octave_unused_parameter (
name);
763 this->warn_save (
"hdf5");
769 template <
typename T>
775 #if defined (HAVE_HDF5)
778 #if defined (HAVE_HDF5_18)
781 hid_t data_hid = H5Dopen (loc_id,
name);
783 hid_t space_id = H5Dget_space (data_hid);
785 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
808 octave_unused_parameter (loc_id);
810 octave_unused_parameter (
name);
812 this->warn_load (
"hdf5");
void swap_bytes< 2 >(void *ptr)
void swap_bytes< 8 >(void *ptr)
void swap_bytes< 4 >(void *ptr)
charNDArray max(char d, const charNDArray &m)
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)
octave_idx_type ndims(void) const
Number of dimensions.
octave_value as_int8(void) const
octave_value as_uint16(void) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
octave_value as_uint32(void) const
octave_value as_int16(void) const
octave_value as_int32(void) const
octave_value as_double(void) const
octave_value as_uint64(void) const
bool save_ascii(std::ostream &os)
bool load_ascii(std::istream &is)
std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
octave_value as_uint8(void) const
octave_value as_int64(void) const
octave_value as_single(void) const
bool save_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name, bool)
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format)
octave_base_value * try_narrowing_conversion(void)
octave_value convert_to_str_internal(bool, bool, char type) const
bool save_binary(std::ostream &os, bool)
bool load_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name)
bool load_ascii(std::istream &is)
octave_value as_double(void) const
bool save_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name, bool)
bool load_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name)
octave_value as_uint16(void) const
octave_value convert_to_str_internal(bool, bool, char type) const
octave_value as_int16(void) const
octave_value as_uint64(void) const
octave_value as_single(void) const
octave_value as_int8(void) const
octave_value as_int32(void) const
std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
octave_value as_int64(void) const
octave_value as_uint8(void) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format)
octave_value as_uint32(void) const
bool save_ascii(std::ostream &os)
bool save_binary(std::ostream &os, bool)
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
void warning(const char *fmt,...)
void error(const char *fmt,...)
intNDArray< octave_int16 > int16NDArray
intNDArray< octave_int32 > int32NDArray
intNDArray< octave_int64 > int64NDArray
intNDArray< octave_int8 > int8NDArray
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
octave_int< uint32_t > octave_uint32
octave_int< int32_t > octave_int32
octave_int< int16_t > octave_int16
octave_int< int8_t > octave_int8
octave_int< int64_t > octave_int64
octave_int< uint64_t > octave_uint64
octave_int< uint16_t > octave_uint16
octave_int< uint8_t > octave_uint8
#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()) ? '\'' :'"'))
static bool scalar(const dim_vector &dims)
octave_value::octave_value(const Array< char > &chm, char type) return retval
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
static bool char_value_out_of_range(T)
static bool char_value_out_of_range(T val)
static bool char_value_out_of_range(T val)
static const bool can_be_larger_than_uchar_max
static bool char_value_out_of_range(T val)
intNDArray< octave_uint16 > uint16NDArray
intNDArray< octave_uint32 > uint32NDArray
intNDArray< octave_uint64 > uint64NDArray
intNDArray< octave_uint8 > uint8NDArray