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 ();
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");
251 retval.
clear (nr, 1);
260 bool pr_as_read_syntax)
const
274 size_t max_len = 100;
276 os << (tmp.length () > max_len ? tmp.substr (0, 100) :
tmp);
287 os <<
"# ndims: " << dv.
ndims () <<
"\n";
300 os <<
"# elements: " << elements <<
"\n";
303 unsigned len = chm.
cols ();
304 os <<
"# length: " << len <<
"\n";
306 const char *
tmp = tstr.data ();
307 if (tstr.length () > len)
322 keywords[0] =
"ndims";
323 keywords[1] =
"elements";
324 keywords[2] =
"length";
330 error (
"load: failed to extract number of rows and columns");
337 error (
"load: failed to extract matrix size");
342 for (
int i = 0;
i < mdims;
i++)
346 error (
"load: failed to read dimensions");
358 if (! is.read (ftmp, dv.
numel ()) || ! is)
359 error (
"load: failed to load string constant");
364 else if (kw ==
"elements")
369 error (
"load: failed to extract number of string elements");
375 for (
int i = 0;
i < elements;
i++)
379 error (
"load: failed to extract string length for element %d",
388 if (len > 0 && ! is.read (ptmp, len))
389 error (
"load: failed to load string constant");
394 chm.
resize (elements, max_len, 0);
402 else if (kw ==
"length")
416 if (len > 0 && ! is.read (ptmp, len))
417 error (
"load: failed to load string constant");
420 error (
"load: failed to load string constant");
441 os.write (reinterpret_cast<char *> (&tmp), 4);
445 os.write (reinterpret_cast<char *> (&tmp), 4);
458 if (! is.read (reinterpret_cast<char *> (&elements), 4))
465 int32_t mdims = - elements;
470 for (
int i = 0;
i < mdims;
i++)
472 if (! is.read (reinterpret_cast<char *> (&di), 4))
493 is.read (tmp, dv.
numel ());
504 for (
int i = 0;
i < elements;
i++)
507 if (! is.read (reinterpret_cast<char *> (&len), 4))
512 char *pbtmp = btmp.fortran_vec ();
513 if (! is.read (pbtmp, len))
518 chm.
resize (elements, max_len, 0);
533 #if defined (HAVE_HDF5)
540 int rank = dv.
ndims ();
541 hid_t space_hid, data_hid;
542 space_hid = data_hid = -1;
548 for (
int i = 0;
i < rank;
i++)
549 hdims[
i] =
dv(rank-
i-1);
551 space_hid = H5Screate_simple (rank, hdims, 0);
554 #if defined (HAVE_HDF5_18)
555 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_CHAR, space_hid,
558 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_CHAR, space_hid,
563 H5Sclose (space_hid);
569 for (
int i = 0;
i < dv.
numel (); ++
i)
576 H5Sclose (space_hid);
579 octave_unused_parameter (loc_id);
580 octave_unused_parameter (name);
593 #if defined (HAVE_HDF5)
602 #if defined (HAVE_HDF5_18)
605 hid_t data_hid = H5Dopen (loc_id, name);
607 hid_t space_hid = H5Dget_space (data_hid);
608 hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
609 hid_t type_hid = H5Dget_type (data_hid);
610 hid_t type_class_hid = H5Tget_class (type_hid);
612 if (type_class_hid == H5T_INTEGER)
617 H5Sclose (space_hid);
625 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
637 for (hsize_t
i = 0, j = rank - 1;
i < rank;
i++, j--)
651 H5Sclose (space_hid);
662 int slen = H5Tget_size (type_hid);
666 H5Sclose (space_hid);
675 hid_t st_id = H5Tcopy (H5T_C_S1);
676 H5Tset_size (st_id, slen+1);
682 H5Sclose (space_hid);
691 H5Sclose (space_hid);
699 hsize_t elements, maxdim;
700 H5Sget_simple_extent_dims (space_hid, &elements, &maxdim);
701 int slen = H5Tget_size (type_hid);
705 H5Sclose (space_hid);
719 hid_t st_id = H5Tcopy (H5T_C_S1);
720 H5Tset_size (st_id, slen+1);
727 H5Sclose (space_hid);
733 for (hsize_t
i = 0;
i < elements; ++
i)
742 H5Sclose (space_hid);
750 H5Sclose (space_hid);
757 octave_unused_parameter (loc_id);
758 octave_unused_parameter (name);
bool is_empty(void) const
octave_value do_index_op_internal(const octave_value_list &idx, bool resize_ok, char type= '"')
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
void short_disp(std::ostream &os) const
octave_idx_type numel(void) const
Number of elements in the array.
identity matrix If supplied two scalar respectively For allows like xample val
const octave_hdf5_id octave_H5S_ALL
void set_pos_if_unset(octave_idx_type nd_arg, octave_idx_type dim_arg)
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector d)
octave_idx_type length(void) const
bool save_binary(std::ostream &os, bool &save_as_floats)
octave_idx_type numel(void) const
void resize(int n, int fill_value=0)
octave_value resize(const dim_vector &dv, bool fill=false) const
#define CHAR_MATRIX_CONV(TNAME, FCN)
void error(const char *fmt,...)
double double_value(bool=false) const
NDArray array_value(bool=false) const
Array< std::string > cellstr_value(void) const
#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)
Complex complex_value(bool=false) const
std::string row_as_string(octave_idx_type, bool strip_ws=false) const
std::string string_value(bool force=false) const
void resize(octave_idx_type n, const std::string &rfv="")
octave_idx_type rows(void) const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
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)
void warn_load(const char *type) 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 swap_bytes< 4 >(void *ptr)
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)
nd deftypefn *octave_map m
string_vector string_vector_value(bool pad=false) const
static int static_type_id(void)
void resize(const dim_vector &dv, const T &rfv)
#define panic_impossible()
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
void resize(octave_idx_type nr, octave_idx_type nc, char rfv=0)
bool load_ascii(std::istream &is)
charMatrix char_matrix_value(bool=false) const
virtual bool is_sq_string(void) const
void warn_save(const char *type) const
ComplexNDArray complex_array_value(bool=false) const
friend class octave_value
T & xelem(octave_idx_type n)
type_conv_info numeric_conversion_function(void) const
dim_vector dims(void) const
N Dimensional Array with copy-on-write semantics.
charNDArray char_array_value(bool=false) const
=val(i)}if ode{val(i)}occurs in table i
int current_print_indent_level(void) const
bool save_ascii(std::ostream &os)
void octave_print_internal(std::ostream &, char, bool)
octave_idx_type ndims(void) const
Number of dimensions.
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
const octave_hdf5_id octave_H5P_DEFAULT
std::complex< double > Complex
const T * fortran_vec(void) const
octave_idx_type cols(void) const
static const char *const keywords[]
write the output to stdout if nargout is
ComplexMatrix complex_matrix_value(bool=false) const
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
Matrix matrix_value(bool=false) const
Array< T > index(const idx_vector &i) const
Indexing without resizing.