26 #if defined (HAVE_CONFIG_H)
74 if (nda.
numel () == 1)
91 bool resize_ok,
char type)
135 for (k = 0; k <
len; k++)
136 idx_vec(k) = idx(k).index_vector ();
164 #define CHAR_MATRIX_CONV(TNAME, FCN) \
166 if (! force_string_conv) \
167 err_invalid_conversion ("string", TNAME); \
169 warn_implicit_conversion ("Octave:str-to-num", "string", TNAME); \
171 return octave_char_matrix::FCN ()
215 error (
"invalid conversion of charNDArray to string_vector");
233 error (
"invalid conversion of charNDArray to string");
247 error (
"cellstr: cannot convert multidimensional arrays");
260 bool pr_as_read_syntax)
const
274 size_t max_len = 100;
276 os << (tmp.length () > max_len ? tmp.substr (0, 100) : tmp);
302 std::string dimstr = dv.
str ();
303 return "[" + dimstr +
" " + tname +
"]";
313 os <<
"# ndims: " << dv.
ndims () <<
"\n";
314 for (
int i=0; i < dv.
ndims (); i++)
326 os <<
"# elements: " << elements <<
"\n";
330 os <<
"# length: " <<
len <<
"\n";
332 const char *tmp = tstr.data ();
333 if (tstr.length () >
len)
348 keywords[0] =
"ndims";
349 keywords[1] =
"elements";
350 keywords[2] =
"length";
356 error (
"load: failed to extract number of rows and columns");
363 error (
"load: failed to extract matrix size");
368 for (
int i = 0; i < mdims; i++)
372 error (
"load: failed to read dimensions");
384 if (! is.read (ftmp, dv.
numel ()) || ! is)
385 error (
"load: failed to load string constant");
390 else if (kw ==
"elements")
395 error (
"load: failed to extract number of string elements");
401 for (
int i = 0; i < elements; i++)
405 error (
"load: failed to extract string length for element %d",
414 if (
len > 0 && ! is.read (ptmp,
len))
415 error (
"load: failed to load string constant");
420 chm.
resize (elements, max_len, 0);
428 else if (kw ==
"length")
442 if (
len > 0 && ! is.read (ptmp,
len))
443 error (
"load: failed to load string constant");
446 error (
"load: failed to load string constant");
466 int32_t tmp = - dv.
ndims ();
467 os.write (
reinterpret_cast<char *
> (&tmp), 4);
468 for (
int i=0; i < dv.
ndims (); i++)
471 os.write (
reinterpret_cast<char *
> (&tmp), 4);
475 os.write (
m.fortran_vec (), dv.
numel ());
484 if (! is.read (
reinterpret_cast<char *
> (&elements), 4))
491 int32_t mdims = - elements;
496 for (
int i = 0; i < mdims; i++)
498 if (! is.read (
reinterpret_cast<char *
> (&di), 4))
518 char *tmp =
m.fortran_vec ();
519 is.read (tmp, dv.
numel ());
530 for (
int i = 0; i < elements; i++)
533 if (! is.read (
reinterpret_cast<char *
> (&
len), 4))
539 if (! is.read (pbtmp,
len))
544 chm.
resize (elements, max_len, 0);
559 #if defined (HAVE_HDF5)
566 int rank = dv.
ndims ();
567 hid_t space_hid, data_hid;
568 space_hid = data_hid = -1;
574 for (
int i = 0; i < rank; i++)
575 hdims[i] = dv(rank-i-1);
577 space_hid = H5Screate_simple (rank, hdims,
nullptr);
580 #if defined (HAVE_HDF5_18)
581 data_hid = H5Dcreate (loc_id,
name, H5T_NATIVE_CHAR, space_hid,
584 data_hid = H5Dcreate (loc_id,
name, H5T_NATIVE_CHAR, space_hid,
589 H5Sclose (space_hid);
595 for (
int i = 0; i < dv.
numel (); ++i)
602 H5Sclose (space_hid);
605 octave_unused_parameter (loc_id);
606 octave_unused_parameter (
name);
619 #if defined (HAVE_HDF5)
628 #if defined (HAVE_HDF5_18)
631 hid_t data_hid = H5Dopen (loc_id,
name);
633 hid_t space_hid = H5Dget_space (data_hid);
634 hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
635 hid_t type_hid = H5Dget_type (data_hid);
636 hid_t type_class_hid = H5Tget_class (type_hid);
638 if (type_class_hid == H5T_INTEGER)
643 H5Sclose (space_hid);
651 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
663 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
668 char *str =
m.fortran_vec ();
677 H5Sclose (space_hid);
687 int slen = H5Tget_size (type_hid);
691 H5Sclose (space_hid);
699 hid_t st_id = H5Tcopy (H5T_C_S1);
700 H5Tset_size (st_id, slen+1);
706 H5Sclose (space_hid);
715 H5Sclose (space_hid);
723 hsize_t elements, maxdim;
724 H5Sget_simple_extent_dims (space_hid, &elements, &maxdim);
725 int slen = H5Tget_size (type_hid);
729 H5Sclose (space_hid);
743 hid_t st_id = H5Tcopy (H5T_C_S1);
744 H5Tset_size (st_id, slen+1);
751 H5Sclose (space_hid);
757 for (hsize_t i = 0; i < elements; ++i)
759 chm.
insert (s + i*(slen+1), i, 0);
766 H5Sclose (space_hid);
774 H5Sclose (space_hid);
781 octave_unused_parameter (loc_id);
782 octave_unused_parameter (
name);
void swap_bytes< 4 >(void *ptr)
N Dimensional Array with copy-on-write semantics.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type cols(void) const
octave_idx_type rows(void) const
Array< T > index(const idx_vector &i) const
Indexing without resizing.
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
int ndims(void) const
Size of the specified dimension.
const T * fortran_vec(void) const
Size of the specified dimension.
bool isempty(void) const
Size of the specified dimension.
void resize(octave_idx_type nr, octave_idx_type nc, char rfv=0)
charMatrix & insert(const char *s, octave_idx_type r, octave_idx_type c)
std::string row_as_string(octave_idx_type, bool strip_ws=false) const
Vector representing the dimensions (size) of an Array.
std::string str(char sep='x') const
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.
void set_pos_if_unset(octave_idx_type nd_arg, octave_idx_type dim_arg)
octave_idx_type numel(void) const
dim_vector dims(void) const
int current_print_indent_level(void) const
bool is_zero_by_zero(void) const
void warn_load(const char *type) const
octave_idx_type rows(void) const
friend class octave_value
virtual bool is_sq_string(void) const
void warn_save(const char *type) const
void short_disp(std::ostream &os) const
ComplexMatrix complex_matrix_value(bool=false) const
NDArray array_value(bool=false) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
bool load_ascii(std::istream &is)
type_conv_info numeric_conversion_function(void) const
std::string type_name(void) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Array< std::string > cellstr_value(void) const
octave_value resize(const dim_vector &dv, bool fill=false) const
string_vector string_vector_value(bool pad=false) const
Matrix matrix_value(bool=false) const
Complex complex_value(bool=false) const
bool save_ascii(std::ostream &os)
double double_value(bool=false) const
std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
octave_value do_index_op_internal(const octave_value_list &idx, bool resize_ok, char type='"')
ComplexNDArray complex_array_value(bool=false) const
std::string string_value(bool force=false) const
bool save_binary(std::ostream &os, bool save_as_floats)
charMatrix char_matrix_value(bool=false) const
charNDArray char_array_value(bool=false) const
static int static_type_id(void)
octave_idx_type length(void) const
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
void error(const char *fmt,...)
#define panic_impossible()
void skip_preceeding_newline(std::istream &is)
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)
std::string undo_string_escapes(const std::string &s)
std::complex< double > Complex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
#define CHAR_MATRIX_CONV(TNAME, FCN)
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
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)