27 #if defined (HAVE_CONFIG_H) 71 std::ostringstream buf;
88 if (parse_status == 0)
111 parent_scope = curr_fcn->
scope ();
120 error (
"inline: unable to define function");
130 m.
assign (
"version", 1.0);
131 m.
assign (
"isEmpty", 0.0);
139 std::ostringstream buf;
141 for (
int i = 0;
i < args.
numel ();
i++)
142 buf << args(
i) <<
" = INLINE_INPUTS_{" <<
i + 1 <<
"}; ";
144 m.
assign (
"inputExpr", buf.str ());
155 if (
nm.length () < 1)
171 for (
int i = 0;
i < nargs;
i++)
204 os.
write (reinterpret_cast<char *> (&
tmp), 4);
208 os.
write (reinterpret_cast<char *> (&
tmp), 4);
212 os.
write (reinterpret_cast<char *> (&
tmp), 4);
215 os.
write (reinterpret_cast<char *> (&
tmp), 4);
225 if (!
is.read (reinterpret_cast<char *> (&nargs), 4))
236 for (
int i = 0;
i < nargs;
i++)
238 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
251 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
257 is.read (ctmp1,
tmp);
263 if (!
is.read (reinterpret_cast<char *> (&
tmp), 4))
269 is.read (ctmp2,
tmp);
287 #if defined (HAVE_HDF5) 289 hid_t group_hid = -1;
291 #if defined (HAVE_HDF5_18) 295 group_hid = H5Gcreate (loc_id,
name, 0);
297 if (group_hid < 0)
return false;
304 hid_t space_hid, data_hid, type_hid;
305 space_hid = data_hid = type_hid = -1;
316 space_hid = H5Screate_simple (2, hdims,
nullptr);
319 H5Gclose (group_hid);
322 #if defined (HAVE_HDF5_18) 323 data_hid = H5Dcreate (group_hid,
"args", H5T_NATIVE_CHAR, space_hid,
326 data_hid = H5Dcreate (group_hid,
"args", H5T_NATIVE_CHAR, space_hid,
331 H5Sclose (space_hid);
332 H5Gclose (group_hid);
341 const char *cptr =
ifargs(
i).c_str ();
343 s[
i*(len+1)+j] = *cptr++;
351 H5Sclose (space_hid);
355 H5Gclose (group_hid);
360 type_hid = H5Tcopy (H5T_C_S1);
361 H5Tset_size (type_hid,
nm.length () + 1);
364 H5Gclose (group_hid);
369 space_hid = H5Screate_simple (0 , hdims,
nullptr);
373 H5Gclose (group_hid);
376 #if defined (HAVE_HDF5_18) 377 data_hid = H5Dcreate (group_hid,
"nm", type_hid, space_hid,
380 data_hid = H5Dcreate (group_hid,
"nm", type_hid, space_hid,
387 H5Sclose (space_hid);
389 H5Gclose (group_hid);
395 H5Tset_size (type_hid,
iftext.length () + 1);
398 H5Gclose (group_hid);
402 #if defined (HAVE_HDF5_18) 403 data_hid = H5Dcreate (group_hid,
"iftext", type_hid, space_hid,
406 data_hid = H5Dcreate (group_hid,
"iftext", type_hid, space_hid,
413 H5Sclose (space_hid);
415 H5Gclose (group_hid);
420 H5Sclose (space_hid);
422 H5Gclose (group_hid);
425 octave_unused_parameter (loc_id);
426 octave_unused_parameter (
name);
437 #if defined (HAVE_HDF5) 439 hid_t group_hid, data_hid, space_hid, type_hid, type_class_hid, st_id;
443 #if defined (HAVE_HDF5_18) 446 group_hid = H5Gopen (loc_id,
name);
448 if (group_hid < 0)
return false;
450 #if defined (HAVE_HDF5_18) 453 data_hid = H5Dopen (group_hid,
"args");
455 space_hid = H5Dget_space (data_hid);
456 rank = H5Sget_simple_extent_ndims (space_hid);
461 H5Sclose (space_hid);
462 H5Gclose (group_hid);
469 H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
479 H5Sclose (space_hid);
480 H5Gclose (group_hid);
485 H5Sclose (space_hid);
487 for (
size_t i = 0;
i < hdims[1];
i++)
490 #if defined (HAVE_HDF5_18) 493 data_hid = H5Dopen (group_hid,
"nm");
498 H5Gclose (group_hid);
502 type_hid = H5Dget_type (data_hid);
503 type_class_hid = H5Tget_class (type_hid);
505 if (type_class_hid != H5T_STRING)
509 H5Gclose (group_hid);
513 space_hid = H5Dget_space (data_hid);
514 rank = H5Sget_simple_extent_ndims (space_hid);
518 H5Sclose (space_hid);
521 H5Gclose (group_hid);
525 slen = H5Tget_size (type_hid);
528 H5Sclose (space_hid);
531 H5Gclose (group_hid);
538 st_id = H5Tcopy (H5T_C_S1);
539 H5Tset_size (st_id, slen);
544 H5Sclose (space_hid);
546 H5Gclose (group_hid);
553 #if defined (HAVE_HDF5_18) 556 data_hid = H5Dopen (group_hid,
"iftext");
561 H5Gclose (group_hid);
565 type_hid = H5Dget_type (data_hid);
566 type_class_hid = H5Tget_class (type_hid);
568 if (type_class_hid != H5T_STRING)
572 H5Gclose (group_hid);
576 space_hid = H5Dget_space (data_hid);
577 rank = H5Sget_simple_extent_ndims (space_hid);
581 H5Sclose (space_hid);
584 H5Gclose (group_hid);
588 slen = H5Tget_size (type_hid);
591 H5Sclose (space_hid);
594 H5Gclose (group_hid);
601 st_id = H5Tcopy (H5T_C_S1);
602 H5Tset_size (st_id, slen);
607 H5Sclose (space_hid);
609 H5Gclose (group_hid);
622 octave_unused_parameter (loc_id);
623 octave_unused_parameter (
name);
641 std::ostringstream buf;
696 int nargin = args.length ();
701 std::string fun = args(0).xstring_value (
"inline: STR argument must be a string");
708 bool in_string =
false;
711 size_t fun_length = fun.length ();
713 while (
i < fun_length)
715 bool terminate_arg =
false;
720 if (
c ==
'\'' ||
c ==
'\"')
723 else if (
c ==
'\'' ||
c ==
'\"')
727 terminate_arg =
true;
729 else if (! isalpha (
c) &&
c !=
'_')
732 else if (isdigit (
c))
733 tmp_arg.append (1,
c);
737 while (
i < fun_length && isspace (
c))
742 terminate_arg =
true;
751 if (
c ==
'e' ||
c ==
'E')
754 if (isdigit (fun[
i]) || fun[
i] ==
'-' || fun[
i] ==
'+')
758 tmp_arg.append (1,
c);
762 tmp_arg.append (1,
c);
765 if (terminate_arg || (
i == fun_length && is_arg))
767 bool have_arg =
false;
769 for (
int j = 0; j < fargs.
numel (); j++)
770 if (tmp_arg == fargs (j))
776 if (! have_arg && tmp_arg !=
"i" && tmp_arg !=
"j" 777 && tmp_arg !=
"NaN" && tmp_arg !=
"nan" 778 && tmp_arg !=
"Inf" && tmp_arg !=
"inf" 779 && tmp_arg !=
"NA" && tmp_arg !=
"pi" 780 && tmp_arg !=
"e" && tmp_arg !=
"eps")
797 if (! args(1).is_scalar_type ())
798 error (
"inline: N must be an integer");
800 int n = args(1).int_value (
"inline: N must be an integer");
803 error (
"inline: N must be a positive integer or zero");
809 for (
int i = 1;
i < n+1;
i++)
811 std::ostringstream buf;
813 fargs(
i) = buf.str ();
822 std::string s = args(
i).xstring_value (
"inline: additional arguments must be strings");
847 DEFUN (formula, args, ,
857 if (args.length () != 1)
863 error (
"formula: FUN must be an inline function");
878 DEFUN (argnames, args, ,
886 if (args.length () != 1)
892 error (
"argnames: FUN must be an inline function");
898 for (
int i = 0;
i < t1.
numel ();
i++)
915 DEFUN (vectorize, args, ,
935 if (args.length () != 1)
940 bool func_is_string =
true;
942 if (args(0).is_string ())
946 func_is_string =
false;
950 error (
"vectorize: FUN must be a string or inline function");
955 size_t len = old_func.length ();
957 new_func.reserve (len + 10);
962 char t1 = old_func[
i];
964 if (t1 ==
'*' || t1 ==
'/' || t1 ==
'\\' || t1 ==
'^')
966 if (
i && old_func[
i-1] !=
'.')
967 new_func.push_back (
'.');
970 if (t1 ==
'*' &&
i < (len - 1) && old_func[
i+1] ==
'*')
972 new_func.push_back (
'*');
976 new_func.push_back (t1);
981 return ovl (new_func);
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 fcn_val(void) 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
virtual octave::symbol_scope scope(void)
std::string read_until_newline(std::istream &is, bool keep_newline)
std::string fcn_text(void) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
OCTINTERP_API void print_usage(void)
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
int current_print_indent_level(void) const
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 const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE * f
const octave_hdf5_id octave_H5S_ALL
void newline(std::ostream &os) const
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
bool save_binary(std::ostream &os, bool &save_as_floats)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
void skip_preceeding_newline(std::istream &is)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
bool load_ascii(std::istream &is)
void resize(octave_idx_type n, const std::string &rfv="")
OCTAVE_EXPORT octave_value_list isnumeric
void print(std::ostream &os, bool pr_as_read_syntax=false)
void warn_load(const char *type) const
octave_map map_value(void) 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
string_vector fcn_arg_names(void) const
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)
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
OCTINTERP_API octave_value_list eval_string(const std::string &, bool silent, int &parse_status, int nargout)
string_vector & append(const std::string &s)
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
#define DEFUNX(name, fname, args_name, nargout_name, doc)
Macro to define a builtin function with certain internal name.
octave_user_function * user_function_value(bool silent=false) const
void warn_save(const char *type) const
string_vector & sort(bool make_uniq=false)
friend class octave_value
bool save_ascii(std::ostream &os)
octave_function * current(void) const
octave_fcn_handle * fcn_handle_value(bool silent=false) const
bool is_undefined(void) const
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
octave_value convert_to_str_internal(bool, bool, char) const
void assign(const std::string &k, const octave_value &val)
call_stack & __get_call_stack__(const std::string &who)
void stash_parent_fcn_scope(const octave::symbol_scope &ps)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
const octave_hdf5_id octave_H5P_DEFAULT
octave_idx_type numel(void) const
Number of elements in the array.
write the output to stdout if nargout is
virtual octave::symbol_scope parent_fcn_scope(void) const
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
octave_idx_type length(void) const
Number of elements in the array.
virtual std::string string_value(bool force=false) const
octave_fcn_inline * fcn_inline_value(bool=false)