75 template <
typename T,
bool is_
signed = true,
bool can_be_too_big = true>
100 template <
typename T>
112 template <
typename T>
136 template <
typename T>
142 if (this->
matrix.numel () == 1)
149 template <
typename T>
165 typename T::element_type
tmp = this->
matrix(
i);
167 typedef typename T::element_type::val_type val_type;
169 val_type ival =
tmp.value ();
171 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
172 static const bool can_be_larger_than_uchar_max
176 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
184 ::warning (
"range error for conversion to character value");
189 chm (
i) =
static_cast<char> (ival);
197 template <
typename MT>
204 template <
typename MT>
211 template <
typename MT>
218 template <
typename MT>
225 template <
typename MT>
232 template <
typename MT>
239 template <
typename MT>
246 template <
typename MT>
253 template <
typename MT>
260 template <
typename MT>
267 template <
typename T>
273 std::ostringstream buf;
278 template <
typename T>
284 os <<
"# ndims: " <<
dv.
ndims () <<
"\n";
294 template <
typename T>
301 error (
"load: failed to extract number of dimensions");
304 error (
"load: failed to extract number of rows and columns");
309 for (
int i = 0;
i < mdims;
i++)
317 error (
"load: failed to load matrix constant");
324 template <
typename T>
334 os.
write (reinterpret_cast<char *> (&
tmp), 4);
338 os.
write (reinterpret_cast<char *> (&
tmp), 4);
341 os.
write (reinterpret_cast<const char *> (this->
matrix.data ()),
347 template <
typename T>
353 if (!
is.read (reinterpret_cast<char *> (&mdims), 4))
365 for (
int i = 0;
i < mdims;
i++)
367 if (!
is.read (reinterpret_cast<char *> (&di), 4))
388 if (!
is.read (reinterpret_cast<char *> (m.fortran_vec ()), m.byte_size ()))
394 int bytes = nel / m.byte_size ();
395 for (
int i = 0;
i < nel;
i++)
417 template <
typename T>
421 const char *
name,
bool)
425 #if defined (HAVE_HDF5) 434 hid_t space_hid, data_hid;
435 space_hid = data_hid = -1;
439 for (
int i = 0;
i < rank;
i++)
440 hdims[
i] =
dv(rank-
i-1);
442 space_hid = H5Screate_simple (rank, hdims,
nullptr);
444 if (space_hid < 0)
return false;
445 #if defined (HAVE_HDF5_18) 446 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
449 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
454 H5Sclose (space_hid);
462 H5Sclose (space_hid);
465 octave_unused_parameter (loc_id);
467 octave_unused_parameter (
name);
469 this->warn_save (
"hdf5");
475 template <
typename T>
483 #if defined (HAVE_HDF5) 493 #if defined (HAVE_HDF5_18) 496 hid_t data_hid = H5Dopen (loc_id,
name);
498 hid_t space_id = H5Dget_space (data_hid);
500 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
512 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
524 for (hsize_t
i = 0, j = rank - 1;
i < rank;
i++, j--)
540 octave_unused_parameter (loc_id);
542 octave_unused_parameter (
name);
544 this->warn_load (
"hdf5");
550 template <
typename T>
553 bool pr_as_read_syntax)
const 556 this->current_print_indent_level ());
559 template <
typename T>
567 typedef typename T::val_type val_type;
569 val_type ival =
tmp.value ();
571 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
572 static const bool can_be_larger_than_uchar_max
576 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
582 ::warning (
"range error for conversion to character value");
590 template <
typename T>
594 return static_cast<double> (this->
scalar);
597 template <
typename T>
601 return static_cast<float> (this->
scalar);
604 template <
typename T>
611 template <
typename T>
618 template <
typename T>
625 template <
typename T>
632 template <
typename T>
639 template <
typename T>
646 template <
typename T>
653 template <
typename T>
660 template <
typename ST>
666 std::ostringstream buf;
671 template <
typename T>
679 template <
typename T>
685 error (
"load: failed to load scalar constant");
690 template <
typename T>
694 os.
write (reinterpret_cast<char *> (&(this->
scalar)), this->byte_size ());
698 template <
typename T>
704 if (!
is.read (reinterpret_cast<char *> (&
tmp),
this->byte_size ()))
708 switch (this->byte_size ())
727 template <
typename T>
731 const char *
name,
bool)
735 #if defined (HAVE_HDF5) 739 hid_t space_hid, data_hid;
740 space_hid = data_hid = -1;
742 space_hid = H5Screate_simple (0, dimens,
nullptr);
743 if (space_hid < 0)
return false;
745 #if defined (HAVE_HDF5_18) 746 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
749 data_hid = H5Dcreate (loc_id,
name, save_type_hid, space_hid,
754 H5Sclose (space_hid);
762 H5Sclose (space_hid);
765 octave_unused_parameter (loc_id);
767 octave_unused_parameter (
name);
769 this->warn_save (
"hdf5");
775 template <
typename T>
781 #if defined (HAVE_HDF5) 784 #if defined (HAVE_HDF5_18) 787 hid_t data_hid = H5Dopen (loc_id,
name);
789 hid_t space_id = H5Dget_space (data_hid);
791 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
814 octave_unused_parameter (loc_id);
816 octave_unused_parameter (
name);
818 this->warn_load (
"hdf5");
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, mach_info::float_format flt_fmt)
octave_value as_uint8(void) const
octave_int< uint64_t > octave_uint64
intNDArray< octave_int64 > int64NDArray
characters Given a string matrix
bool save_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name, bool)
nd group nd example oindent but is performed more efficiently If only and it is a scalar
static bool char_value_out_of_range(T)
identity matrix If supplied two scalar respectively For allows like xample val
const octave_hdf5_id octave_H5S_ALL
intNDArray< octave_uint32 > uint32NDArray
intNDArray< octave_uint8 > uint8NDArray
octave_value as_double(void) const
intNDArray< octave_uint16 > uint16NDArray
octave_value convert_to_str_internal(bool, bool, char type) const
bool save_binary(std::ostream &os, bool &)
void resize(int n, int fill_value=0)
octave_int< uint16_t > octave_uint16
void swap_bytes< 8 >(void *ptr)
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format)
bool load_ascii(std::istream &is)
void error(const char *fmt,...)
void swap_bytes< 2 >(void *ptr)
octave_value as_int8(void) const
octave_value as_int64(void) const
static bool char_value_out_of_range(T val)
octave_value as_uint16(void) const
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
intNDArray< octave_int16 > int16NDArray
octave_value as_single(void) const
bool save_binary(std::ostream &os, bool &)
octave_value as_double(void) const
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are empty
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
nd deftypefn *std::string name
void swap_bytes< 4 >(void *ptr)
octave_base_value * try_narrowing_conversion(void)
intNDArray< octave_int8 > int8NDArray
octave_value as_uint16(void) const
octave_value as_int16(void) const
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
octave_value as_uint32(void) const
std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
bool load_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name)
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
returns the type of the matrix and caches it for future use Called with more than one the function will not attempt to guess the type if it is still unknown This is useful for debugging purposes The possible matrix types depend on whether the matrix is full or and can be one of the following able sis tem and mark type as unknown tem as the structure of the matrix explicitly gives this(Sparse matrices only) tem code
bool load_ascii(std::istream &is)
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
octave_int< uint32_t > octave_uint32
octave_value as_single(void) const
static bool char_value_out_of_range(T val)
octave_value as_int64(void) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format)
static const bool can_be_larger_than_uchar_max
void warning(const char *fmt,...)
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
charNDArray max(char d, const charNDArray &m)
octave_value convert_to_str_internal(bool, bool, char type) const
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
intNDArray< octave_int32 > int32NDArray
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
bool load_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name)
octave_value as_uint8(void) const
octave_value as_int8(void) const
octave_int< int64_t > octave_int64
octave_value as_uint32(void) const
bool save_ascii(std::ostream &os)
bool save_hdf5_internal(octave_hdf5_id loc_id, octave_hdf5_id save_type, const char *name, bool)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_value as_uint64(void) const
octave_value as_int32(void) const
const octave_hdf5_id octave_H5P_DEFAULT
octave_value as_uint64(void) const
octave_int< int16_t > octave_int16
octave_idx_type ndims(void) const
Number of dimensions.
bool save_ascii(std::ostream &os)
octave_value as_int16(void) const
write the output to stdout if nargout is
octave_int< uint8_t > octave_uint8
Vector representing the dimensions (size) of an Array.
octave_int< int32_t > octave_int32
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
octave_value as_int32(void) const
static bool char_value_out_of_range(T val)
octave_int< int8_t > octave_int8
intNDArray< octave_uint64 > uint64NDArray