Index: /branches/eam_branch_20081124/Ohana/src/libautocode/def/common.h
===================================================================
--- /branches/eam_branch_20081124/Ohana/src/libautocode/def/common.h	(revision 20826)
+++ /branches/eam_branch_20081124/Ohana/src/libautocode/def/common.h	(revision 20827)
@@ -38,5 +38,5 @@
 # endif
 
-# define e_time unsigned int
+# define e_time int
 # define e_void long long
 # define rawshort short
Index: /branches/eam_branch_20081124/Ohana/src/opihi/include/dvomath.h
===================================================================
--- /branches/eam_branch_20081124/Ohana/src/opihi/include/dvomath.h	(revision 20826)
+++ /branches/eam_branch_20081124/Ohana/src/opihi/include/dvomath.h	(revision 20827)
@@ -5,7 +5,10 @@
 
 # define NCHARS 256
+# define opihi_float float
+# define opihi_int unsigned int
 
 enum {ANYVECTOR, NEWVECTOR, OLDVECTOR};
 enum {ANYBUFFER, NEWBUFFER, OLDBUFFER};
+enum {OPIHI_FLOAT, OPIHI_INT};
 
 typedef struct {			/* representation of a variable (0-D) */
@@ -16,5 +19,7 @@
 typedef struct {			/* representation of a vector (1-D) */
   char name[1024];
+  char type;
   float *elements;
+  unsigned int *elementsInt;
   int Nelements;
 } Vector;
Index: /branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/VectorOps.c
===================================================================
--- /branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/VectorOps.c	(revision 20826)
+++ /branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/VectorOps.c	(revision 20827)
@@ -18,5 +18,10 @@
 
   for (i = 0; i < Nvectors; i++) {
-    free (vectors[i][0].elements);
+    if (vectors[i][0].elements) {
+      free (vectors[i][0].elements);
+    }
+    if (vectors[i][0].elementsInt) {
+      free (vectors[i][0].elementsInt);
+    }
     free (vectors[i]);
   }
@@ -28,5 +33,9 @@
 
   ALLOCATE (vec, Vector, 1);
-  ALLOCATE (vec[0].elements, float, 1);
+
+  vec[0].elementsInt = NULL;
+  ALLOCATE (vec[0].elements, opihi_float, 1);
+  vec[0].type = OPIHI_FLOAT;			  /* is a float unless specified otherwise */
+
   bzero (vec[0].name, 1024);
   vec[0].Nelements = 0;
@@ -95,5 +104,6 @@
   if (i == Nvectors) return (FALSE);
 
-  free (vectors[i][0].elements);
+  if (vectors[i][0].elements)    free (vectors[i][0].elements);
+  if (vectors[i][0].elementsInt) free (vectors[i][0].elementsInt);
   free (vectors[i]);
 
@@ -115,5 +125,6 @@
   if (i == Nvectors) return (FALSE);
 
-  free (vectors[i][0].elements);
+  if (vectors[i][0].elements)    free (vectors[i][0].elements);
+  if (vectors[i][0].elementsInt) free (vectors[i][0].elementsInt);
   free (vectors[i]);
 
@@ -137,6 +148,15 @@
   free (out[0].elements);
   out[0].Nelements = in[0].Nelements;
-  ALLOCATE (out[0].elements, float, out[0].Nelements);
-  memcpy (out[0].elements, in[0].elements, out[0].Nelements*sizeof(float));
+  if (in[0].elements) {
+    assert (in[0].type == OPIHI_FLOAT);
+    ALLOCATE (out[0].elements, opihi_float, out[0].Nelements);
+    memcpy (out[0].elements, in[0].elements, out[0].Nelements*sizeof(opihi_float));
+    out[0].type = OPIHI_FLOAT;
+  } else {
+    assert (in[0].type == OPIHI_INT);
+    ALLOCATE (out[0].elementsInt, opihi_int, out[0].Nelements);
+    memcpy (out[0].elementsInt, in[0].elementsInt, out[0].Nelements*sizeof(opihi_int));
+    out[0].type = OPIHI_INT;
+  }
   return (TRUE);
 }
@@ -154,6 +174,8 @@
 
   free (out[0].elements);
-  out[0].Nelements = in[0].Nelements;
-  out[0].elements =  in[0].elements;
+  out[0].Nelements   = in[0].Nelements;
+  out[0].elements    = in[0].elements;
+  out[0].elementsInt = in[0].elementsInt;
+  out[0].type        = in[0].type;
 
   /* delete vector entry from vector list, if it exists */
Index: /branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/stack_math.c
===================================================================
--- /branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/stack_math.c	(revision 20826)
+++ /branches/eam_branch_20081124/Ohana/src/opihi/lib.shell/stack_math.c	(revision 20827)
@@ -35,9 +35,90 @@
   out = OUT[0].ptr = (float *)OUT[0].vector[0].elements;
 
-  switch (op[0]) { 
+// XXX this is not quite there:
+// 1) do I drop the .ptr element of StackVar?
+// 2) things below are using type from a StackVar to get the vector type -- wrong place
+// 3) the temp would need lots of work -- is it worth it?
+// 4) some operators force the output to be float -- we cannot use a single bit of code to 
+//    define the output type based on which is a float and which is not.  getting ugly.
+// ??? how much more work to bring the MV, etc functions into shape ???
+
+# define VV_FUNC(OP) \
+  if ((M1->type == OPIHI_FLOAT) && (M2->type == OPIHI_FLOAT)) { \
+    // output must be float, can use either as a temp \
+    opihi_float *M1 = V1[0].vector[0].elements; \
+    opihi_float *M2 = V2[0].vector[0].elements; \
+    for (i = 0; i < Nx; i++, out++, M1++, M2++) { \
+  	*out = *M1 OP *M2; \
+    } \
+    break; \
+  } \
+  if ((M1->type != OPIHI_FLOAT) && (M2->type == OPIHI_FLOAT)) { \
+    // output must be float, can use M2 as a temp \
+    opihi_float *M1 = V1[0].vector[0].elementsInt; \
+    opihi_float *M2 = V2[0].vector[0].elements; \
+    for (i = 0; i < Nx; i++, out++, M1++, M2++) { \
+  	*out = *M1 OP *M2; \
+    } \
+    break; \
+  } \
+  if ((M1->type == OPIHI_FLOAT) && (M2->type != OPIHI_FLOAT)) { \
+    // output must be float, can use M1 as a temp \
+    opihi_float *M1 = V1[0].vector[0].elements; \
+    opihi_float *M2 = V2[0].vector[0].elementsInt; \
+    for (i = 0; i < Nx; i++, out++, M1++, M2++) { \
+  	*out = *M1 OP *M2; \
+    } \
+    break; \
+  } \
+  if ((M1->type != OPIHI_FLOAT) && (M2->type != OPIHI_FLOAT)) { \
+    // output may be int, can use either as temp \
+    opihi_float *M1 = V1[0].vector[0].elementsInt; \
+    opihi_float *M2 = V2[0].vector[0].elementsInt; \
+    for (i = 0; i < Nx; i++, out++, M1++, M2++) { \
+  	*out = *M1 OP *M2; \
+    } \
+    break; \
+  }
+
+  switch (op[0]) {
   case '+': 
-    for (i = 0; i < Nx; i++, out++, M1++, M2++)
-      *out = *M1 + *M2;
-    break; 
+    VV_FUNC
+
+    if ((M1->type == OPIHI_FLOAT) && (M2->type == OPIHI_FLOAT)) {
+      // output must be float, can use either as a temp
+      M1 = V1[0].vector[0].elements;
+      M2 = V2[0].vector[0].elements;
+      for (i = 0; i < Nx; i++, out++, M1++, M2++) {
+	*out = *M1 + *M2;
+      }
+      break;
+    }
+    if ((M1->type != OPIHI_FLOAT) && (M2->type == OPIHI_FLOAT)) {
+      // output must be float, can use M2 as a temp
+      M1 = V1[0].vector[0].elementsInt;
+      M2 = V2[0].vector[0].elements;
+      for (i = 0; i < Nx; i++, out++, M1++, M2++) {
+	*out = *M1 + *M2;
+      }
+      break;
+    }
+    if ((M1->type == OPIHI_FLOAT) && (M2->type != OPIHI_FLOAT)) {
+      // output must be float, can use M1 as a temp
+      M1 = V1[0].vector[0].elements;
+      M2 = V2[0].vector[0].elementsInt;
+      for (i = 0; i < Nx; i++, out++, M1++, M2++) {
+	*out = *M1 + *M2;
+      }
+      break;
+    }
+    if ((M1->type != OPIHI_FLOAT) && (M2->type != OPIHI_FLOAT)) {
+      // output may be int, can use either as temp
+      M1 = V1[0].vector[0].elementsInt;
+      M2 = V2[0].vector[0].elementsInt;
+      for (i = 0; i < Nx; i++, out++, M1++, M2++) {
+	*out = *M1 + *M2;
+      }
+      break;
+    }
   case '-': 
     for (i = 0; i < Nx; i++, out++, M1++, M2++)
Index: /trunk/Ohana/src/opihi/doc/opihi-vectors.txt
===================================================================
--- /trunk/Ohana/src/opihi/doc/opihi-vectors.txt	(revision 20827)
+++ /trunk/Ohana/src/opihi/doc/opihi-vectors.txt	(revision 20827)
@@ -0,0 +1,21 @@
+
+2008.04.20
+
+  I am trying to update the opihi vector code for two important upgrades:
+
+  1) I want to convert the float vector to double vectors
+  2) I want to allow the option of int (unsigned int) vectors, especially for flags
+
+  I've define opihi_float and opihi_int types.  A major portion of the
+  upgrade is to convert all of the places where a vector is allocated
+  or manipulated as a float to use 'opihi_float' which can then be
+  re-defined.  The other trick here is to identify the functions which
+  require a vector to be a float and set assserts or error reporting.
+
+  The other major change is to modify the dvo math code.  for the
+  moment, all functions should result in opihi_float vectors except
+  for the explicit cases of the db extractions which return flags.
+
+  Some math operations on the vectors will force conversion to floats,
+  but some are sensible as functions from int to int, and those
+  results can be kept in their native format.
