24 #if defined (HAVE_CONFIG_H)
76 if (! s || ! (isalpha (*s) || *s ==
'_' || *s ==
'$'))
80 if (! (isalnum (*s) || *s ==
'_' || *s ==
'$'))
99 if (
args.length () != 1)
139 int stdlen = std.length ();
140 int slen = s.length ();
142 return (slen <= stdlen
143 && slen >= min_match_len
145 ? (
strncmp (std.c_str (), s.c_str (), slen) == 0)
154 int min_toks_to_match,
int max_toks)
158 int toks_matched = 0;
160 if (s.empty () || max_toks < 1)
163 char *kw =
strsave (s.c_str ());
180 const char **to_match =
new const char * [max_toks + 1];
181 const char *
const *s1 = std;
182 const char **
s2 = to_match;
189 while ((end = strchr (beg,
' ')) != 0)
201 if (tok_count >= max_toks)
212 if (!
almost_match (*s1, *s2, min_len[toks_matched], 0))
222 status = (toks_matched >= min_toks_to_match);
241 return (nr == 0 || nc == 0);
306 if (nargin < 1 || nargin > 2)
309 string_vector names =
args(0).xstring_vector_value (
"file_in_loadpath: FILE argument must be a string");
312 error (
"file_in_loadpath: FILE argument must not be empty");
318 std::string opt =
args(1).xstring_value (
"file_in_loadpath: optional second argument must be a string");
321 error (
"file_in_loadpath: \"all\" is only valid second argument");
375 if (nargin < 2 || nargin > 3)
378 std::string path =
args(0).xstring_value (
"file_in_path: PATH must be a string");
380 string_vector names =
args(1).xstring_vector_value (
"file_in_path: FILE argument must be a string");
383 error (
"file_in_path: FILE argument must not be empty");
389 std::string opt =
args(2).xstring_value (
"file_in_path: optional third argument must be a string");
392 error (
"file_in_path: \"all\" is only valid third argument");
425 if (! suffix.empty ())
434 bool require_regular_file)
486 else if (len > 2 && name[len - 2] ==
'.' && name[len - 1] ==
'm')
492 if (pos != std::string::npos)
493 fname = name.substr (0, pos);
510 if (dir.length () > 0)
533 int len = name.length ();
544 else if (len > 4 && name.find (
".oct", len-5))
562 int len = name.length ();
573 else if (len > 4 && name.find (
".mex", len-5))
591 size_t len = s.length ();
597 if (s[j] ==
'\\' && j+1 < len)
651 int tmpi = s[j] -
'0';
652 for (k = j+1; k <
std::min (j+3, len); k++)
654 int digit = s[
k] -
'0';
655 if (digit < 0 || digit > 7)
669 for (k = j+1; k <
std::min (j+3, len); k++)
671 if (! isxdigit (s[k]))
677 tmpi += digit -
'a' + 10;
678 else if (digit >=
'A')
679 tmpi += digit -
'A' + 10;
685 warning (
"malformed hex escape sequence '\\x' -- converting to '\\0'");
693 warning (
"unrecognized escape sequence '\\%c' -- converting to '%c'", s[j], s[j]);
721 if (
args.length () != 1)
724 std::string str =
args(0).xstring_value (
"do_string_escapes: STRING argument must be of type string");
806 static char retval[2] =
"\0";
819 for (
size_t i = 0; i < s.length (); i++)
856 if (
args.length () != 1)
859 std::string str =
args(0).xstring_value (
"undo_string_escapes: S argument must be a string");
893 if (
args.length () != 1)
896 return ovl (
args(0).is_string ()
914 if (
args.length () != 1)
917 return ovl (
args(0).is_string ()
938 if (
args.length () != 1)
941 std::string nm =
args(0).xstring_value (
"make_absolute_filename: FILE argument must be a filename");
970 int nargin =
args.length ();
972 if (nargin < 1 || nargin > 2)
977 dir =
args(0).xstring_value (
"dir_in_loadpath: DIR must be a directory name");
1015 int nargin =
args.length ();
1024 if (
args(0).is_string ())
1032 int val =
args(0).xint_value (
"errno: argument must be string or integer");
1065 if (
args.length () != 0)
1080 if (nr < 0 || nc < 0)
1083 "%s: converting negative dimension to zero", warnfor);
1085 nr = (nr < 0) ? 0 : nr;
1086 nc = (nc < 0) ? 0 : nc;
1095 for (
int i = 0; i < dim.
ndims (); i++)
1106 "%s: converting negative dimension to zero", warnfor);
1117 error (
"%s (A): use %s (size (A)) instead", warn_for, warn_for);
1153 if ((nr != 1 || nc != 2) && (nr != 2 || nc != 1))
1154 error (
"%s (A): use %s (size (A)) instead", warn_for, warn_for);
1169 ? 0 : a.
idx_type_value (
"%s: row dimension must be a scalar", warn_for);
1171 ? 0 : b.
idx_type_value (
"%s: column dimension must be a scalar", warn_for);
1184 retval = dims.
numel ();
1195 retval *= idxi.
numel ();
1209 error (
"dims_to_numel: Invalid IDX %s. %s",
1210 idx.c_str (), msg.c_str ());
1224 if (nr > 0 && nc > 0)
1240 if (nr > 0 && nc > 0)
1257 va_start (args, fmt);
1300 va_start (args, fmt);
1315 double fraction = std::modf (seconds, &seconds);
1316 fraction =
std::floor (fraction * 1000000000);
1320 :
static_cast<time_t
> (seconds));
1322 struct timespec delay = { sec,
static_cast<long> (fraction) };
1323 struct timespec remaining;
1329 DEFUN (isindex, args, ,
1347 int nargin = args.length ();
1349 if (nargin < 1 || nargin > 2)
1354 n =
args(1).idx_type_value ();
1368 retval = idx.
extent (n) <= n;
1372 catch (
const octave::execution_exception&)
1399 int nargin = args.
length ();
1404 const Cell *ccells = cells;
1409 for (
int i = 0; i <
nargin; i++)
1420 new_args(i) = ccells[
i](0);
1422 else if (numel == 1)
1425 dims = ccells[
i].
dims ();
1427 else if (dims != ccells[i].dims ())
1428 error (
"%s: cell arguments must have matching sizes", fun_name);
1432 for (
int i = 0; i <
nargout; i++)
1433 rcells[i].
clear (dims);
1437 for (
int i = 0; i <
nargin; i++)
1439 new_args(i) = ccells[
i](j);
1446 error (
"%s: do_simple_cellfun: internal error", fun_name);
1448 for (
int i = 0; i <
nargout; i++)
1449 rcells[i](j) =
tmp(i);
1454 for (
int i = 0; i <
nargout; i++)
1474 DEFUN (isstudent, args, ,
void warning_with_id(const char *id, const char *fmt,...)
OCTINTERP_API void octave_sleep(double seconds)
For example cd octave end example noindent changes the current working directory to file
octave_idx_type length(octave_idx_type n=0) const
static string_vector find_matching_dirs(const std::string &dir)
bool same_file(const std::string &f, const std::string &g)
OCTINTERP_API std::string oct_file_in_path(const std::string &)
octave_idx_type rows(void) const
std::string find_first_of(const std::list< std::string > &names)
bool is_vector(void) const
OCTAVE_EXPORT octave_value_list who nd deftypefn *octave_value retval
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
OCTINTERP_API size_t octave_vformat(std::ostream &os, const char *fmt, va_list args)
identity matrix If supplied two scalar respectively For allows like xample val
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
octave_idx_type length(void) const
OCTINTERP_API std::string undo_string_escapes(const std::string &s)
OCTINTERP_API std::string fcn_file_in_path(const std::string &)
bool is_scalar_type(void) const
octave_value_list & append(const octave_value &val)
bool is_numeric_type(void) const
static char * strsave(const char *s)
static std::string find_file(const std::string &file)
static string_vector make_absolute(const string_vector &sv)
void resize(int n, int fill_value=0)
static std::string find_first_of(const string_vector &files)
#define DEFUN(name, args_name, nargout_name, doc)
OCTINTERP_API octave_idx_type dims_to_numel(const dim_vector &dims, const octave_value_list &idx)
void error(const char *fmt,...)
std::string idx(void) const
int empty_arg(const char *, octave_idx_type nr, octave_idx_type nc)
OCTINTERP_API std::string file_in_path(const std::string &, const std::string &)
static bool rooted_relative_pathname(const std::string &s)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
octave_idx_type idx_type_value(bool req_int=false, bool frc_str_conv=false) const
OCTAVE_API int octave_strncasecmp(const char *s1, const char *s2, size_t n)
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
Cell cell_value(void) const
idx_vector index_vector(bool require_integers=false) const
int almost_match(const std::string &std, const std::string &s, int min_match_len, int case_sens)
static std::string find_mex_file(const std::string &fcn, const std::string &pack_name="")
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
int octave_vasprintf_wrapper(char **buf, const char *fmt, va_list args)
static std::string make_absolute(const std::string &s, const std::string &dot_path=get_current_directory())
OCTINTERP_API std::string contents_file_in_path(const std::string &)
octave_idx_type columns(void) const
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
void warn_data_file_in_path(const std::string &fcn, const std::string &file)
OCTINTERP_API std::string octave_asprintf(const char *fmt,...)
bool valid_identifier(const char *s)
octave_idx_type numel(const octave_value_list &idx)
bool same_file_internal(const std::string &file1, const std::string &file2)
nd deftypefn *octave_map m
OCTINTERP_API std::string octave_vasprintf(const char *fmt, va_list args)
static bool absolute_pathname(const std::string &s)
static std::string find_oct_file(const std::string &fcn, const std::string &pack_name="")
#define DEFUNX(name, fname, args_name, nargout_name, doc)
bool is_magic_colon(void) const
dim_vector redim(int n) const
std::list< std::string > find_all_first_of(const std::list< std::string > &names)
OCTINTERP_API octave_value_list Ferrno(const octave_value_list &=octave_value_list(), int=0)
OCTAVE_EXPORT octave_value_list is_rooted_relative_filename
int keyword_almost_match(const char *const *std, int *min_len, const std::string &s, int min_toks_to_match, int max_toks)
bool is_keyword(const std::string &s)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
OCTINTERP_API size_t octave_format(std::ostream &os, const char *fmt,...)
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
return ovl(undo_string_escapes(str))
dim_vector dims(void) const
With real return the complex result
static std::string concat(const std::string &, const std::string &)
std::string search_path_for_file(const std::string &path, const string_vector &names)
OCTINTERP_API void get_dimensions(const octave_value &a, const char *warn_for, dim_vector &dim)
OCTINTERP_API FloatMatrix float_identity_matrix(octave_idx_type nr, octave_idx_type nc)
void warning(const char *fmt,...)
octave::unwind_protect frame
void recover_from_exception(void)
charNDArray max(char d, const charNDArray &m)
bool is_empty(void) const
octave_idx_type extent(octave_idx_type n) const
static std::string find_fcn_file(const std::string &fcn, const std::string &pack_name="")
T::size_type numel(const T &str)
OCTINTERP_API std::string find_data_file_in_load_path(const std::string &fcn, const std::string &file, bool require_regular_file=false)
OCTINTERP_API const char * undo_string_escape(char c)
OCTINTERP_API std::string do_string_escapes(const std::string &s)
=val(i)}if ode{val(i)}occurs in table i
static int lookup(const std::string &name)
OCTINTERP_API Matrix identity_matrix(octave_idx_type nr, octave_idx_type nc)
Array< double > vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
OCTINTERP_API octave_value_list do_simple_cellfun(octave_value_list(*fun)(const octave_value_list &, int), const char *fun_name, const octave_value_list &args, int nargout)
octave_idx_type ndims(void) const
Number of dimensions.
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
OCTINTERP_API std::string mex_file_in_path(const std::string &)
octave::sys::file_stat fs(filename)
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
static std::string find_dir(const std::string &dir)
std::list< std::string > std_list(void) const
static octave_scalar_map list(void)
Array< int > int_vector_value(bool req_int=false, bool frc_str_conv=false, bool frc_vec_conv=false) const
string_vector search_path_for_all_files(const std::string &path, const string_vector &names)
bool strncmp(const T &str_a, const T &str_b, const typename T::size_type n)
True if the first N characters are the same.
virtual std::string details(void) const =0
Vector representing the dimensions (size) of an Array.
bool discard_error_messages
int octave_nanosleep_wrapper(const struct timespec *requested, struct timespec *remaining)
static void clear(octave::dynamic_library &oct_file)
OCTINTERP_API void check_dimensions(dim_vector &dim, const char *warnfor)
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
static string_vector find_all_first_of(const string_vector &files)
charNDArray min(char d, const charNDArray &m)