25 #if defined (HAVE_CONFIG_H)
47 return (str.find (c) != std::string::npos
48 || str.find (std::toupper (c)) != std::string::npos);
52 struct icmp_char_lt :
public std::binary_function<char, char, bool>
55 {
return std::toupper (x) < std::toupper (y); }
58 struct icmp_char_gt :
public std::binary_function<char, char, bool>
61 {
return std::toupper (x) > std::toupper (y); }
71 return std::lexicographical_compare (a.begin (), a.end (),
80 return std::lexicographical_compare (a.begin (), a.end (),
93 if (n > 1 && desc_comp (array (0), array (n-1)))
103 #define INT_ARRAY_LOOKUP(TYPE) \
104 (table.is_ ## TYPE ## _type () && y.is_ ## TYPE ## _type ()) \
105 retval = do_numeric_lookup (table.TYPE ## _array_value (), \
106 y.TYPE ## _array_value (), \
107 left_inf, right_inf, \
108 match_idx, match_bool);
109 template <
typename ArrayT>
112 bool left_inf,
bool right_inf,
113 bool match_idx,
bool match_bool)
133 else if (match_idx || left_inf || right_inf)
142 ridx.xelem (
i) = (j != 0 &&
values(
i) ==
array(j-1)) ? j : 0;
147 else if (left_inf && right_inf)
243 if (nargin < 2 || nargin > 3)
249 warning (
"lookup: table is not a vector");
256 bool left_inf =
false;
257 bool right_inf =
false;
258 bool match_idx =
false;
259 bool match_bool =
false;
263 std::string opt =
args(2).xstring_value (
"lookup: OPT must be a string");
268 if (opt.find_first_not_of (
"lrmb") != std::string::npos)
269 error (
"lookup: unrecognized option: %c",
270 opt[opt.find_first_not_of (
"lrmb")]);
273 if ((match_idx || match_bool) && (left_inf || right_inf))
274 error (
"lookup: m, b cannot be specified with l or r");
275 else if (match_idx && match_bool)
276 error (
"lookup: only one of m or b can be specified");
277 else if (str_case && (left_inf || right_inf))
278 error (
"lookup: l, r are not recognized for string lookups");
285 table = table.
abs ();
305 match_idx, match_bool);
310 match_idx, match_bool);
315 match_idx, match_bool);
337 match.xelem (
i) = j != 0 && str_y(
i) == str_table(j-1);
350 ridx.xelem (
i) = (j != 0 && str_y(
i) == str_table(j-1)) ? j
charNDArray char_array_value(bool frc_str_conv=false) const
octave_idx_type rows(void) const
OCTINTERP_API void print_usage(void)
octave_idx_type numel(void) const
Number of elements in the array.
OCTAVE_EXPORT octave_value_list uint16
sortmode get_sort_mode(const Array< T > &array, typename octave_sort< T >::compare_fcn_type desc_comp=octave_sort< T >::descending_compare)
bool is_numeric_type(void) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
octave_idx_type lookup(const T *x, octave_idx_type n, T y)
static octave_value do_numeric_lookup(const ArrayT &array, const ArrayT &values, bool left_inf, bool right_inf, bool match_idx, bool match_bool)
octave_idx_type lookup(const T &value, sortmode mode=UNSORTED) const
Do a binary lookup in a sorted array.
cell array If invoked with two or more scalar integer or a vector of integer values
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
Array< std::string > cellstr_value(void) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
octave_idx_type columns(void) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
bool is_char_matrix(void) const
std::string string_value(bool force=false) const
OCTAVE_EXPORT octave_value_list uint32
then the function must return scalars which will be concatenated into the return array(s).If code
bool is_string(void) const
OCTAVE_EXPORT octave_value_list int16
bool is_complex_type(void) const
bool is_cellstr(void) const
OCTAVE_EXPORT octave_value_list int32
octave_value abs(void) const
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
T & xelem(octave_idx_type n)
OCTAVE_EXPORT octave_value_list int64
void warning(const char *fmt,...)
N Dimensional Array with copy-on-write semantics.
charNDArray max(char d, const charNDArray &m)
static bool contains_char(const std::string &str, char c)
NDArray array_value(bool frc_str_conv=false) const
bool operator()(char x, char y) const
=val(i)}if ode{val(i)}occurs in table i
the element is set to zero In other the statement xample y
#define INT_ARRAY_LOOKUP(TYPE)
bool is_single_type(void) 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
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 * x
bool operator()(char x, char y) const
charNDArray min(char d, const charNDArray &m)