80template <
typename T,
bool is_
signed = true,
bool can_be_too_big = true>
151 if (this->matrix.numel () == 1)
174 typename T::element_type tmp = this->matrix(i);
176 typedef typename T::element_type::val_type val_type;
178 val_type ival = tmp.value ();
180 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
181 static const bool can_be_larger_than_uchar_max
185 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
193 ::warning (
"range error for conversion to character value");
198 chm (i) =
static_cast<char> (ival);
206template <
typename MT>
213template <
typename MT>
220template <
typename MT>
227template <
typename MT>
234template <
typename MT>
241template <
typename MT>
248template <
typename MT>
255template <
typename MT>
262template <
typename MT>
269template <
typename MT>
282 std::ostringstream buf;
293 os <<
"# ndims: " << dv.
ndims () <<
"\n";
295 for (
int i = 0; i < dv.
ndims (); i++)
298 os <<
"\n" << this->matrix;
310 error (
"load: failed to extract number of dimensions");
313 error (
"load: failed to extract number of rows and columns");
318 for (
int i = 0; i < mdims; i++)
326 error (
"load: failed to load matrix constant");
342 int32_t tmp = - dv.
ndims ();
343 os.write (
reinterpret_cast<char *
> (&tmp), 4);
344 for (
int i=0; i < dv.
ndims (); i++)
347 os.write (
reinterpret_cast<char *
> (&tmp), 4);
350 os.write (
reinterpret_cast<const char *
> (this->matrix.data ()),
362 if (! is.read (
reinterpret_cast<char *
> (&mdims), 4))
374 for (
int i = 0; i < mdims; i++)
376 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
397 if (! is.read (
reinterpret_cast<char *
> (m.fortran_vec ()), m.byte_size ()))
402 int nel = dv.
numel ();
403 int bytes = nel / m.byte_size ();
404 for (
int i = 0; i < nel; i++)
430 const char *
name,
bool)
434#if defined (HAVE_HDF5)
442 int rank = dv.
ndims ();
443 hid_t space_hid, data_hid;
444 space_hid = data_hid = -1;
448 for (
int i = 0; i < rank; i++)
449 hdims[i] = dv(rank-i-1);
451 space_hid = H5Screate_simple (rank, hdims,
nullptr);
453 if (space_hid < 0)
return false;
454#if defined (HAVE_HDF5_18)
455 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
458 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
463 H5Sclose (space_hid);
471 H5Sclose (space_hid);
474 octave_unused_parameter (loc_id);
476 octave_unused_parameter (
name);
478 this->warn_save (
"hdf5");
492#if defined (HAVE_HDF5)
498 this->matrix.resize (dv);
502#if defined (HAVE_HDF5_18)
505 hid_t data_hid = H5Dopen (loc_id,
name);
507 hid_t space_id = H5Dget_space (data_hid);
509 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
521 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
533 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
549 octave_unused_parameter (loc_id);
551 octave_unused_parameter (
name);
553 this->warn_load (
"hdf5");
562 bool pr_as_read_syntax)
const
565 this->current_print_indent_level ());
576 typedef typename T::val_type val_type;
578 val_type ival = tmp.value ();
580 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
581 static const bool can_be_larger_than_uchar_max
585 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
591 ::warning (
"range error for conversion to character value");
594 retval =
octave_value (std::string (1,
static_cast<char> (ival)), type);
603 return static_cast<double> (this->
scalar);
610 return static_cast<float> (this->
scalar);
669template <
typename ST>
675 std::ostringstream buf;
684 os << this->
scalar <<
"\n";
694 error (
"load: failed to load scalar constant");
703 os.write (
reinterpret_cast<char *
> (&(this->
scalar)), this->byte_size ());
714 if (! is.read (
reinterpret_cast<char *
> (&tmp), this->byte_size ()))
718 swap_bytes<sizeof (T)> (&tmp);
729 const char *
name,
bool)
733#if defined (HAVE_HDF5)
736 hsize_t dimens[3] = {0};
737 hid_t space_hid, data_hid;
738 space_hid = data_hid = -1;
740 space_hid = H5Screate_simple (0, dimens,
nullptr);
741 if (space_hid < 0)
return false;
743#if defined (HAVE_HDF5_18)
744 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
747 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
752 H5Sclose (space_hid);
760 H5Sclose (space_hid);
763 octave_unused_parameter (loc_id);
765 octave_unused_parameter (
name);
767 this->warn_save (
"hdf5");
779#if defined (HAVE_HDF5)
782#if defined (HAVE_HDF5_18)
785 hid_t data_hid = H5Dopen (loc_id,
name);
787 hid_t space_id = H5Dget_space (data_hid);
789 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
812 octave_unused_parameter (loc_id);
814 octave_unused_parameter (
name);
816 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.
OCTINTERP_API octave_value as_int8(void) const
OCTINTERP_API octave_value as_uint16(void) const
OCTINTERP_API void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
OCTINTERP_API octave_value as_uint32(void) const
OCTINTERP_API octave_value as_int16(void) const
OCTINTERP_API octave_value as_int32(void) const
OCTINTERP_API octave_value as_double(void) const
OCTINTERP_API octave_value as_uint64(void) const
OCTINTERP_API bool save_ascii(std::ostream &os)
OCTINTERP_API bool load_ascii(std::istream &is)
OCTINTERP_API std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
OCTINTERP_API octave_value as_uint8(void) const
OCTINTERP_API octave_value as_int64(void) const
OCTINTERP_API octave_value as_single(void) const
OCTINTERP_API bool save_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name, bool)
OCTINTERP_API bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format)
OCTINTERP_API octave_base_value * try_narrowing_conversion(void)
OCTINTERP_API octave_value convert_to_str_internal(bool, bool, char type) const
OCTINTERP_API bool save_binary(std::ostream &os, bool)
OCTINTERP_API bool load_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name)
OCTINTERP_API bool load_ascii(std::istream &is)
OCTINTERP_API octave_value as_double(void) const
OCTINTERP_API bool save_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name, bool)
OCTINTERP_API bool load_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name)
OCTINTERP_API octave_value as_uint16(void) const
OCTINTERP_API octave_value convert_to_str_internal(bool, bool, char type) const
OCTINTERP_API octave_value as_int16(void) const
OCTINTERP_API octave_value as_uint64(void) const
OCTINTERP_API octave_value as_single(void) const
OCTINTERP_API octave_value as_int8(void) const
OCTINTERP_API octave_value as_int32(void) const
OCTINTERP_API std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
OCTINTERP_API octave_value as_int64(void) const
OCTINTERP_API octave_value as_uint8(void) const
OCTINTERP_API bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format)
OCTINTERP_API octave_value as_uint32(void) const
OCTINTERP_API bool save_ascii(std::ostream &os)
OCTINTERP_API 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)
class OCTAVE_API FloatNDArray
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)
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