Index: trunk/Ohana/src/opihi/cmd.data/peak.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/peak.c	(revision 7917)
+++ trunk/Ohana/src/opihi/cmd.data/peak.c	(revision 20936)
@@ -5,5 +5,4 @@
   int i, N, imax, QUIET;
   double start, end, xmax, ymax;
-  float *X, *Y;
   Vector *vecx, *vecy;
 
@@ -26,23 +25,60 @@
     end   = atof (argv[4]);
   } else {
-    start = vecx[0].elements[0];
-    end   = vecx[0].elements[vecx[0].Nelements - 1];
+    start = (vecx[0].type == OPIHI_FLT) ? vecx[0].elements.Flt[0] : vecx[0].elements.Int[0];
+    end   = (vecx[0].type == OPIHI_FLT) ? vecx[0].elements.Flt[vecx[0].Nelements - 1] : vecx[0].elements.Int[vecx[0].Nelements - 1];
   }
 
-  X = vecx[0].elements;
-  Y = vecy[0].elements;
+  imax = -1;
+  xmax = -HUGE_VAL;
+  ymax = -HUGE_VAL;
 
-  imax = -1;
-  xmax = *X;
-  ymax = *Y;
-  for (i = 1; i < vecx[0].Nelements-1; i++, X++, Y++) {
-    if ((*X >= start) && (*X <= end)) {
-      if ((imax == -1) || (*Y > ymax)) {
-	xmax = *X;
-	ymax = *Y;
-	imax = i;
-      }
-    }
-  }      
+  if ((vecx[0].type == OPIHI_FLT) && (vecy[0].type == OPIHI_FLT)) {
+    opihi_flt *X = vecx[0].elements.Flt;
+    opihi_flt *Y = vecy[0].elements.Flt;
+    for (i = 0; i < vecx[0].Nelements; i++, X++, Y++) {
+      if (*X < start) continue;
+      if (*X > end) continue;
+      if (*Y < ymax) continue;
+      xmax = *X;
+      ymax = *Y;
+      imax = i;
+    }      
+  }
+  if ((vecx[0].type == OPIHI_FLT) && (vecy[0].type == OPIHI_INT)) {
+    opihi_flt *X = vecx[0].elements.Flt;
+    opihi_int *Y = vecy[0].elements.Int;
+    for (i = 0; i < vecx[0].Nelements; i++, X++, Y++) {
+      if (*X < start) continue;
+      if (*X > end) continue;
+      if (*Y < ymax) continue;
+      xmax = *X;
+      ymax = *Y;
+      imax = i;
+    }      
+  }
+  if ((vecx[0].type == OPIHI_INT) && (vecy[0].type == OPIHI_FLT)) {
+    opihi_int *X = vecx[0].elements.Int;
+    opihi_flt *Y = vecy[0].elements.Flt;
+    for (i = 0; i < vecx[0].Nelements; i++, X++, Y++) {
+      if (*X < start) continue;
+      if (*X > end) continue;
+      if (*Y < ymax) continue;
+      xmax = *X;
+      ymax = *Y;
+      imax = i;
+    }      
+  }
+  if ((vecx[0].type == OPIHI_INT) && (vecy[0].type == OPIHI_INT)) {
+    opihi_int *X = vecx[0].elements.Int;
+    opihi_int *Y = vecy[0].elements.Int;
+    for (i = 0; i < vecx[0].Nelements; i++, X++, Y++) {
+      if (*X < start) continue;
+      if (*X > end) continue;
+      if (*Y < ymax) continue;
+      xmax = *X;
+      ymax = *Y;
+      imax = i;
+    }      
+  }
 
   set_variable ("peakval", ymax);
