27 #if defined (HAVE_CONFIG_H)
70 std::ostringstream buf;
87 if (parse_status == 0)
106 if (parent_scope < 0)
107 parent_scope = curr_fcn->
scope ();
116 error (
"inline: unable to define function");
126 m.
assign (
"version", 1.0);
127 m.
assign (
"isEmpty", 0.0);
135 std::ostringstream buf;
137 for (
int i = 0;
i < args.
numel ();
i++)
138 buf <<
args(
i) <<
" = INLINE_INPUTS_{" <<
i + 1 <<
"}; ";
140 m.
assign (
"inputExpr", buf.str ());
151 if (
nm.length () < 1)
167 for (
int i = 0;
i < nargs;
i++)
200 os.write (reinterpret_cast<char *> (&tmp), 4);
204 os.write (reinterpret_cast<char *> (&tmp), 4);
208 os.write (reinterpret_cast<char *> (&tmp), 4);
209 os.write (
nm.c_str (),
nm.length ());
211 os.write (reinterpret_cast<char *> (&tmp), 4);
221 if (! is.read (reinterpret_cast<char *> (&nargs), 4))
232 for (
int i = 0;
i < nargs;
i++)
234 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
247 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
253 is.read (ctmp1, tmp);
259 if (! is.read (reinterpret_cast<char *> (&tmp), 4))
265 is.read (ctmp2, tmp);
283 #if defined (HAVE_HDF5)
285 hid_t group_hid = -1;
287 #if defined (HAVE_HDF5_18)
291 group_hid = H5Gcreate (loc_id, name, 0);
293 if (group_hid < 0)
return false;
300 hid_t space_hid, data_hid, type_hid;
301 space_hid = data_hid = type_hid = -1;
312 space_hid = H5Screate_simple (2, hdims, 0);
315 H5Gclose (group_hid);
318 #if defined (HAVE_HDF5_18)
319 data_hid = H5Dcreate (group_hid,
"args", H5T_NATIVE_CHAR, space_hid,
322 data_hid = H5Dcreate (group_hid,
"args", H5T_NATIVE_CHAR, space_hid,
327 H5Sclose (space_hid);
328 H5Gclose (group_hid);
337 const char * cptr =
ifargs(
i).c_str ();
339 s[
i*(len+1)+j] = *cptr++;
347 H5Sclose (space_hid);
351 H5Gclose (group_hid);
356 type_hid = H5Tcopy (H5T_C_S1);
357 H5Tset_size (type_hid,
nm.length () + 1);
360 H5Gclose (group_hid);
365 space_hid = H5Screate_simple (0 , hdims, 0);
369 H5Gclose (group_hid);
372 #if defined (HAVE_HDF5_18)
373 data_hid = H5Dcreate (group_hid,
"nm", type_hid, space_hid,
376 data_hid = H5Dcreate (group_hid,
"nm", type_hid, space_hid,
383 H5Sclose (space_hid);
385 H5Gclose (group_hid);
391 H5Tset_size (type_hid,
iftext.length () + 1);
394 H5Gclose (group_hid);
398 #if defined (HAVE_HDF5_18)
399 data_hid = H5Dcreate (group_hid,
"iftext", type_hid, space_hid,
402 data_hid = H5Dcreate (group_hid,
"iftext", type_hid, space_hid,
409 H5Sclose (space_hid);
411 H5Gclose (group_hid);
416 H5Sclose (space_hid);
418 H5Gclose (group_hid);
421 octave_unused_parameter (loc_id);
422 octave_unused_parameter (name);
433 #if defined (HAVE_HDF5)
435 hid_t group_hid, data_hid, space_hid, type_hid, type_class_hid, st_id;
439 #if defined (HAVE_HDF5_18)
442 group_hid = H5Gopen (loc_id, name);
444 if (group_hid < 0)
return false;
446 #if defined (HAVE_HDF5_18)
449 data_hid = H5Dopen (group_hid,
"args");
451 space_hid = H5Dget_space (data_hid);
452 rank = H5Sget_simple_extent_ndims (space_hid);
457 H5Sclose (space_hid);
458 H5Gclose (group_hid);
465 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
475 H5Sclose (space_hid);
476 H5Gclose (group_hid);
481 H5Sclose (space_hid);
483 for (
size_t i = 0;
i < hdims[1];
i++)
486 #if defined (HAVE_HDF5_18)
489 data_hid = H5Dopen (group_hid,
"nm");
494 H5Gclose (group_hid);
498 type_hid = H5Dget_type (data_hid);
499 type_class_hid = H5Tget_class (type_hid);
501 if (type_class_hid != H5T_STRING)
505 H5Gclose (group_hid);
509 space_hid = H5Dget_space (data_hid);
510 rank = H5Sget_simple_extent_ndims (space_hid);
514 H5Sclose (space_hid);
517 H5Gclose (group_hid);
521 slen = H5Tget_size (type_hid);
524 H5Sclose (space_hid);
527 H5Gclose (group_hid);
534 st_id = H5Tcopy (H5T_C_S1);
535 H5Tset_size (st_id, slen);
540 H5Sclose (space_hid);
542 H5Gclose (group_hid);
549 #if defined (HAVE_HDF5_18)
552 data_hid = H5Dopen (group_hid,
"iftext");
557 H5Gclose (group_hid);
561 type_hid = H5Dget_type (data_hid);
562 type_class_hid = H5Tget_class (type_hid);
564 if (type_class_hid != H5T_STRING)
568 H5Gclose (group_hid);
572 space_hid = H5Dget_space (data_hid);
573 rank = H5Sget_simple_extent_ndims (space_hid);
577 H5Sclose (space_hid);
580 H5Gclose (group_hid);
584 slen = H5Tget_size (type_hid);
587 H5Sclose (space_hid);
590 H5Gclose (group_hid);
597 st_id = H5Tcopy (H5T_C_S1);
598 H5Tset_size (st_id, slen);
603 H5Sclose (space_hid);
605 H5Gclose (group_hid);
618 octave_unused_parameter (loc_id);
619 octave_unused_parameter (name);
637 std::ostringstream buf;
697 std::string fun =
args(0).xstring_value (
"inline: STR argument must be a string");
704 bool in_string =
false;
707 size_t fun_length = fun.length ();
709 while (i < fun_length)
711 bool terminate_arg =
false;
716 if (c ==
'\'' || c ==
'\"')
719 else if (c ==
'\'' || c ==
'\"')
723 terminate_arg =
true;
725 else if (! isalpha (c) && c !=
'_')
728 else if (isdigit (c))
729 tmp_arg.append (1, c);
733 while (i < fun_length && isspace (c))
738 terminate_arg =
true;
747 if (c ==
'e' || c ==
'E')
750 if (isdigit (fun[i]) || fun[i] ==
'-' || fun[i] ==
'+')
754 tmp_arg.append (1, c);
758 tmp_arg.append (1, c);
761 if (terminate_arg || (i == fun_length && is_arg))
763 bool have_arg =
false;
765 for (
int j = 0; j < fargs.
numel (); j++)
766 if (tmp_arg == fargs (j))
772 if (! have_arg && tmp_arg !=
"i" && tmp_arg !=
"j"
773 && tmp_arg !=
"NaN" && tmp_arg !=
"nan"
774 && tmp_arg !=
"Inf" && tmp_arg !=
"inf"
775 && tmp_arg !=
"NA" && tmp_arg !=
"pi"
776 && tmp_arg !=
"e" && tmp_arg !=
"eps")
791 else if (nargin == 2 &&
args(1).is_numeric_type ())
793 if (!
args(1).is_scalar_type ())
794 error (
"inline: N must be an integer");
796 int n =
args(1).int_value (
"inline: N must be an integer");
799 error (
"inline: N must be a positive integer or zero");
805 for (
int i = 1;
i < n+1;
i++)
807 std::ostringstream buf;
809 fargs(i) = buf.str ();
814 fargs.
resize (nargin - 1);
818 std::string s =
args(
i).xstring_value (
"inline: additional arguments must be strings");
853 if (
args.length () != 1)
859 error (
"formula: FUN must be an inline function");
882 if (
args.length () != 1)
888 error (
"argnames: FUN must be an inline function");
894 for (
int i = 0;
i < t1.
numel ();
i++)
931 if (
args.length () != 1)
936 bool func_is_string =
true;
938 if (
args(0).is_string ())
939 old_func =
args(0).string_value ();
942 old =
args(0).fcn_inline_value (
true);
943 func_is_string =
false;
948 error (
"vectorize: FUN must be a string or inline function");
954 while (i < old_func.length ())
958 if (t1 ==
"*" || t1 ==
"/" || t1 ==
"\\" || t1 ==
"^")
960 if (i && old_func.substr (i-1, 1) !=
".")
964 if (t1 ==
"*" && i < (old_func.length () - 1)
965 && old_func.substr (i+1, 1) ==
"*")
971 new_func.append (t1);
976 return ovl (new_func);
std::string read_until_newline(std::istream &is, bool keep_newline)
bool is_empty(void) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
OCTINTERP_API void print_usage(void)
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
octave_idx_type numel(void) const
Number of elements in the array.
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
const octave_hdf5_id octave_H5S_ALL
octave_map map_value(void) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
bool save_binary(std::ostream &os, bool &save_as_floats)
static octave_function * current(void)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
void skip_preceeding_newline(std::istream &is)
octave_value fcn_val(void) const
octave_fcn_handle * fcn_handle_value(bool silent=false) const
OCTAVE_EXPORT octave_value_list Finline(const octave_value_list &args, int) the arguments of the generated function are extracted from the function itself.The generated function arguments will then be in alphabetical order.It should be noted that i and j are ignored as arguments due to the ambiguity between their use as a variable or their use as an built-in const ant.All arguments followed by a parenthesis are considered to be functions.If no arguments are found
bool load_ascii(std::istream &is)
void newline(std::ostream &os) const
void resize(octave_idx_type n, const std::string &rfv="")
std::string fcn_text(void) const
void print(std::ostream &os, bool pr_as_read_syntax=false)
virtual symbol_table::scope_id scope(void)
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
void warn_load(const char *type) const
void swap_bytes< 4 >(void *ptr)
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
nd deftypefn *octave_map m
octave_user_function * user_function_value(bool silent=false) const
string_vector & append(const std::string &s)
void stash_parent_fcn_scope(symbol_table::scope_id ps)
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
#define DEFUNX(name, fname, args_name, nargout_name, doc)
virtual symbol_table::scope_id parent_fcn_scope(void) const
string_vector & sort(bool make_uniq=false)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
void warn_save(const char *type) const
octave_value convert_to_str_internal(bool, bool, char) const
friend class octave_value
bool save_ascii(std::ostream &os)
octave_idx_type length(void) const
Number of elements in the array.
=val(i)}if ode{val(i)}occurs in table i
int current_print_indent_level(void) const
void assign(const std::string &k, const octave_value &val)
void octave_print_internal(std::ostream &, char, bool)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
bool is_undefined(void) const
const octave_hdf5_id octave_H5P_DEFAULT
string_vector fcn_arg_names(void) const
OCTINTERP_API octave_value_list eval_string(const std::string &, bool silent, int &parse_status, int nargout)
write the output to stdout if nargout is
Vector representing the dimensions (size) of an Array.
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
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