Index: trunk/Ohana/src/opihi/cmd.data/select.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/select.c	(revision 7917)
+++ trunk/Ohana/src/opihi/cmd.data/select.c	(revision 20936)
@@ -27,10 +27,51 @@
   /* check size of in1, in2, tvec: must match */
 
-  REALLOCATE (ovec[0].elements, float, MAX (tvec[0].Nelements, 1));
-  for (i = 0; i < tvec[0].Nelements; i++) {
-    ovec[0].elements[i] = tvec[0].elements[i] ? in1[0].elements[i] : in2[0].elements[i];
+  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_INT)) {
+    ResetVector (ovec, OPIHI_INT, MAX (tvec[0].Nelements, 1));
+  } else {
+    ResetVector (ovec, OPIHI_FLT, MAX (tvec[0].Nelements, 1));
   }
-  ovec[0].Nelements = tvec[0].Nelements;
-  REALLOCATE (ovec[0].elements, float, MAX (ovec[0].Nelements, 1));
+
+  // (in1 and in2) == (flt or int) and tvec == (flt or int)
+  if ((in1->type == OPIHI_FLT) && (in2->type == OPIHI_FLT) && (tvec->type == OPIHI_FLT)) {
+    for (i = 0; i < tvec[0].Nelements; i++) {
+      ovec[0].elements.Flt[i] = tvec[0].elements.Flt[i] ? in1[0].elements.Flt[i] : in2[0].elements.Flt[i];
+    }
+  }
+  if ((in1->type == OPIHI_FLT) && (in2->type == OPIHI_FLT) && (tvec->type == OPIHI_INT)) {
+    for (i = 0; i < tvec[0].Nelements; i++) {
+      ovec[0].elements.Flt[i] = tvec[0].elements.Int[i] ? in1[0].elements.Flt[i] : in2[0].elements.Flt[i];
+    }
+  }
+  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_FLT) && (tvec->type == OPIHI_FLT)) {
+    for (i = 0; i < tvec[0].Nelements; i++) {
+      ovec[0].elements.Flt[i] = tvec[0].elements.Flt[i] ? in1[0].elements.Int[i] : in2[0].elements.Flt[i];
+    }
+  }
+  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_FLT) && (tvec->type == OPIHI_INT)) {
+    for (i = 0; i < tvec[0].Nelements; i++) {
+      ovec[0].elements.Flt[i] = tvec[0].elements.Int[i] ? in1[0].elements.Int[i] : in2[0].elements.Flt[i];
+    }
+  }
+  if ((in1->type == OPIHI_FLT) && (in2->type == OPIHI_INT) && (tvec->type == OPIHI_FLT)) {
+    for (i = 0; i < tvec[0].Nelements; i++) {
+      ovec[0].elements.Flt[i] = tvec[0].elements.Flt[i] ? in1[0].elements.Flt[i] : in2[0].elements.Int[i];
+    }
+  }
+  if ((in1->type == OPIHI_FLT) && (in2->type == OPIHI_INT) && (tvec->type == OPIHI_INT)) {
+    for (i = 0; i < tvec[0].Nelements; i++) {
+      ovec[0].elements.Flt[i] = tvec[0].elements.Int[i] ? in1[0].elements.Flt[i] : in2[0].elements.Int[i];
+    }
+  }
+  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_INT) && (tvec->type == OPIHI_FLT)) {
+    for (i = 0; i < tvec[0].Nelements; i++) {
+      ovec[0].elements.Int[i] = tvec[0].elements.Flt[i] ? in1[0].elements.Int[i] : in2[0].elements.Int[i];
+    }
+  }
+  if ((in1->type == OPIHI_INT) && (in2->type == OPIHI_INT) && (tvec->type == OPIHI_INT)) {
+    for (i = 0; i < tvec[0].Nelements; i++) {
+      ovec[0].elements.Int[i] = tvec[0].elements.Int[i] ? in1[0].elements.Int[i] : in2[0].elements.Int[i];
+    }
+  }
   
   DeleteVector (tvec);
