25 #if defined (HAVE_CONFIG_H) 47 return (
str.find (
c) != std::string::npos
48 ||
str.find (std::toupper (
c)) != std::string::npos);
58 if (n > 1 && desc_comp (
array (0),
array (n-1)))
68 #define INT_ARRAY_LOOKUP(TYPE) \ 69 (table.is_ ## TYPE ## _type () && y.is_ ## TYPE ## _type ()) \ 70 retval = do_numeric_lookup (table.TYPE ## _array_value (), \ 71 y.TYPE ## _array_value (), \ 72 left_inf, right_inf, \ 73 match_idx, match_bool); 74 template <
typename ArrayT>
77 bool left_inf,
bool right_inf,
78 bool match_idx,
bool match_bool)
98 else if (match_idx || left_inf || right_inf)
107 ridx.xelem (
i) = (j != 0 &&
values(
i) ==
array(j-1)) ? j : 0;
112 else if (left_inf && right_inf)
205 int nargin = args.length ();
213 warning (
"lookup: table is not a vector");
217 bool num_case = ((table.
isnumeric () &&
y.isnumeric ())
219 bool str_case = table.
iscellstr () && (
y.is_string () ||
y.iscellstr ());
220 bool left_inf =
false;
221 bool right_inf =
false;
222 bool match_idx =
false;
223 bool match_bool =
false;
227 std::string opt = args(2).xstring_value (
"lookup: OPT must be a string");
232 if (opt.find_first_not_of (
"lrmb") != std::string::npos)
233 error (
"lookup: unrecognized option: %c",
234 opt[opt.find_first_not_of (
"lrmb")]);
237 if ((match_idx || match_bool) && (left_inf || right_inf))
238 error (
"lookup: m, b cannot be specified with l or r");
239 else if (match_idx && match_bool)
240 error (
"lookup: only one of m or b can be specified");
241 else if (str_case && (left_inf || right_inf))
242 error (
"lookup: l, r are not recognized for string lookups");
249 table = table.
abs ();
267 y.char_array_value (),
269 match_idx, match_bool);
272 y.float_array_value (),
274 match_idx, match_bool);
279 match_idx, match_bool);
287 str_y =
y.cellstr_value ();
289 str_y(0) =
y.string_value ();
301 match.xelem (
i) = j != 0 && str_y(
i) == str_table(j-1);
312 ridx.xelem (
i) = (j != 0 && str_y(
i) == str_table(j-1) ? j : 0);
OCTINTERP_API void print_usage(void)
sortmode get_sort_mode(const Array< T > &array, typename octave_sort< T >::compare_fcn_type desc_comp=octave_sort< T >::descending_compare)
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol zero divided by zero($0/0$)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
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)
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
FloatNDArray float_array_value(bool frc_str_conv=false) const
cell array If invoked with two or more scalar integer or a vector of integer values
charNDArray char_array_value(bool frc_str_conv=false) const
bool iscellstr(void) const
then the function must return scalars which will be concatenated into the return array(s). If code
octave_idx_type lookup(const T &value, sortmode mode=UNSORTED) const
Do a binary lookup in a sorted array.
octave_idx_type columns(void) const
bool is_single_type(void) const
octave_idx_type rows(void) const
bool is_char_matrix(void) const
T & xelem(octave_idx_type n)
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)
the element is set to zero In other the statement xample y
bool iscomplex(void) const
#define INT_ARRAY_LOOKUP(TYPE)
octave_idx_type numel(void) const
Number of elements in the array.
octave_value abs(void) const
Vector representing the dimensions (size) of an Array.
Array< std::string > cellstr_value(void) const
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
NDArray array_value(bool frc_str_conv=false) const
bool isnumeric(void) const
charNDArray min(char d, const charNDArray &m)