24 #if defined (HAVE_CONFIG_H) 72 if (nda.
numel () == 1)
89 bool resize_ok,
char type)
133 for (
k = 0;
k < len;
k++)
134 idx_vec(
k) = idx(
k).index_vector ();
146 e.set_pos_if_unset (len,
k+1);
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);
303 return "[" + dimstr +
" " + tname +
"]";
313 os <<
"# ndims: " <<
dv.
ndims () <<
"\n";
326 os <<
"# elements: " << elements <<
"\n";
329 unsigned len = chm.
cols ();
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");
380 char *ftmp =
tmp.fortran_vec ();
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",
412 char *ptmp =
tmp.fortran_vec ();
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")
440 char *ptmp =
tmp.fortran_vec ();
442 if (len > 0 && !
is.read (ptmp, len))
443 error (
"load: failed to load string constant");
446 error (
"load: failed to load string constant");
467 os.
write (reinterpret_cast<char *> (&
tmp), 4);
471 os.
write (reinterpret_cast<char *> (&
tmp), 4);
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))
530 for (
int i = 0;
i < elements;
i++)
533 if (!
is.read (reinterpret_cast<char *> (&len), 4))
538 char *pbtmp = btmp.fortran_vec ();
539 if (!
is.read (pbtmp, len))
544 chm.
resize (elements, max_len, 0);
559 #if defined (HAVE_HDF5) 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);
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--)
677 H5Sclose (space_hid);
688 int slen = H5Tget_size (type_hid);
692 H5Sclose (space_hid);
701 hid_t st_id = H5Tcopy (H5T_C_S1);
702 H5Tset_size (st_id, slen+1);
708 H5Sclose (space_hid);
717 H5Sclose (space_hid);
725 hsize_t elements, maxdim;
726 H5Sget_simple_extent_dims (space_hid, &elements, &maxdim);
727 int slen = H5Tget_size (type_hid);
731 H5Sclose (space_hid);
745 hid_t st_id = H5Tcopy (H5T_C_S1);
746 H5Tset_size (st_id, slen+1);
753 H5Sclose (space_hid);
759 for (hsize_t
i = 0;
i < elements; ++
i)
768 H5Sclose (space_hid);
776 H5Sclose (space_hid);
783 octave_unused_parameter (loc_id);
784 octave_unused_parameter (
name);
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_idx_type rows(void) const
std::string str(char sep='x') const
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
void short_disp(std::ostream &os) const
ComplexMatrix complex_matrix_value(bool=false) const
std::string string_value(bool force=false) const
int current_print_indent_level(void) const
identity matrix If supplied two scalar respectively For allows like xample val
const octave_hdf5_id octave_H5S_ALL
OCTINTERP_API std::string undo_string_escapes(const std::string &s)
NDArray array_value(bool=false) const
bool save_binary(std::ostream &os, bool &save_as_floats)
void resize(int n, int fill_value=0)
const T * fortran_vec(void) const
#define CHAR_MATRIX_CONV(TNAME, FCN)
octave_value do_index_op_internal(const octave_value_list &idx, bool resize_ok, char type='"')
type_conv_info numeric_conversion_function(void) const
void error(const char *fmt,...)
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
void skip_preceeding_newline(std::istream &is)
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
void warn_load(const char *type) const
octave_idx_type cols(void) const
octave_value resize(const dim_vector &dv, bool fill=false) const
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
charMatrix & insert(const char *s, octave_idx_type r, octave_idx_type c)
string_vector string_vector_value(bool pad=false) 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
Array< T > index(const idx_vector &i) const
Indexing without resizing.
void swap_bytes< 4 >(void *ptr)
bool is_zero_by_zero(void) const
Array< std::string > cellstr_value(void) const
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
charMatrix char_matrix_value(bool=false) const
octave_idx_type rows(void) const
static int static_type_id(void)
void resize(const dim_vector &dv, const T &rfv)
Resizing (with fill).
#define panic_impossible()
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
void warn_save(const char *type) const
void resize(octave_idx_type nr, octave_idx_type nc, char rfv=0)
std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
bool load_ascii(std::istream &is)
double double_value(bool=false) const
friend class octave_value
Complex complex_value(bool=false) const
octave_value resize(const dim_vector &dv, bool fill=false) const
N Dimensional Array with copy-on-write semantics.
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
std::string row_as_string(octave_idx_type, bool strip_ws=false) const
bool save_ascii(std::ostream &os)
virtual bool is_sq_string(void) const
dim_vector dims(void) const
octave_idx_type length(void) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
ComplexNDArray complex_array_value(bool=false) const
octave_idx_type numel(void) const
Matrix matrix_value(bool=false) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
const octave_hdf5_id octave_H5P_DEFAULT
octave_idx_type ndims(void) const
Number of dimensions.
std::complex< double > Complex
octave_idx_type numel(void) const
Number of elements in the array.
write the output to stdout if nargout is
Vector representing the dimensions (size) of an Array.
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
charNDArray char_array_value(bool=false) const
std::string type_name(void) const