diff src/DLD-FUNCTIONS/lookup.cc @ 9344:0c4e6a3d6e3e

support char arrays in lookup
author Jaroslav Hajek <highegg@gmail.com>
date Sun, 14 Jun 2009 11:32:25 +0200
parents 9fd5c56ce57a
children e2344f4af0cb
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/lookup.cc	Fri Jun 12 13:29:25 2009 -0400
+++ b/src/DLD-FUNCTIONS/lookup.cc	Sun Jun 14 11:32:25 2009 +0200
@@ -186,7 +186,8 @@
   if (table.ndims () > 2 || (table.columns () > 1 && table.rows () > 1))
     warning ("lookup: table is not a vector");
 
-  bool num_case = table.is_numeric_type () && y.is_numeric_type ();
+  bool num_case = ((table.is_numeric_type () && y.is_numeric_type ())
+                   || (table.is_char_matrix () && y.is_char_matrix ()));
   bool str_case = table.is_cellstr () && (y.is_string () || y.is_cellstr ());
   bool left_inf = false;
   bool right_inf = false;
@@ -239,6 +240,11 @@
       else if INT_ARRAY_LOOKUP (uint16)
       else if INT_ARRAY_LOOKUP (uint32)
       else if INT_ARRAY_LOOKUP (uint64)
+      else if (table.is_char_matrix () && y.is_char_matrix ())
+        retval = do_numeric_lookup (table.char_array_value (),
+                                    y.char_array_value (),
+                                    left_inf, right_inf,
+                                    match_idx, match_bool);
       else if (table.is_single_type () || y.is_single_type ())
         retval = do_numeric_lookup (table.float_array_value (),
                                     y.float_array_value (),