Index: /branches/eam_branches/ohana.20150429/src/opihi/cmd.data/read_vectors.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/opihi/cmd.data/read_vectors.c	(revision 38340)
+++ /branches/eam_branches/ohana.20150429/src/opihi/cmd.data/read_vectors.c	(revision 38341)
@@ -1,3 +1,5 @@
 # include "data.h"
+int dump_raw_table (FTable *table, char *message);
+int dump_cmp_table (FTable *table, char *message);
 
 FILE *f = (FILE *) NULL;
@@ -412,7 +414,5 @@
   table.header = &header;
 
-  int IsCompressed = FALSE;
-
-  /* load appropriate extension (if extname is a number, use count) */
+  /**** find the appropriate extension and read header (if extname is a number, use count) ****/
   if (Nextend > -1) {
     // first extension is PHU, cannot be a table. 
@@ -431,42 +431,4 @@
     }
     if (!gfits_load_header (f, &header)) ESCAPE ("error reading header for extension %d\n", Nextend);
-
-    IsCompressed = gfits_extension_is_compressed_table (&header);
-
-    if (getSizes && !IsCompressed) {
-      read_table_sizes (&header);
-      if (CCDKeyword != NULL) free (CCDKeyword); 
-      gfits_free_header (&header); 
-      return TRUE;
-    }
-    if (IsCompressed) {
-      if (getSizes) {
-	gprint (GP_ERR, "%s[%s] is compressed: -sizes is invalid\n", filename, extname);
-	gfits_free_header (&header); 
-	return FALSE;
-      }
-      if ((start > 0) || (Nrows > -1)) {
-	gprint (GP_ERR, "%s[%s] is compressed: must read entire table\n", filename, extname);
-	gfits_free_header (&header); 
-	return FALSE;
-      }
-    }
-
-    if (Nrows == -1) {
-      Nrows = header.Naxis[1] - start;
-    }
-    if (start < 0) ESCAPE ("invalid range: start < 0\n");
-    if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);
-    if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");
-
-    // just a warning:
-    if (start + Nrows > header.Naxis[1]) {
-      if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start);
-    }
-
-    // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100
-    // Ny = 100, start = 10, Nrows = 90
-
-    if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);
   } else {
     if (CCDKeyword == NULL) {
@@ -476,5 +438,4 @@
       CCDKeyword = strcreate ("EXTNAME");
     }
-
     while (1) {
       if (!gfits_load_header (f, &header)) {
@@ -485,5 +446,4 @@
 	return (TRUE);  
       }
-
       Nbytes = gfits_data_size (&header);
 
@@ -498,41 +458,48 @@
 	continue;
       }
-
-      IsCompressed = gfits_extension_is_compressed_table (&header);
-
-      if (getSizes && !IsCompressed) {
-	read_table_sizes (&header);
-	if (CCDKeyword != NULL) free (CCDKeyword); 
-	gfits_free_header (&header); 
-	return TRUE;
-      }
-      if (IsCompressed) {
-	if (getSizes) {
-	  gprint (GP_ERR, "%s[%s] is compressed: -sizes is invalid\n", filename, extname);
-	  gfits_free_header (&header); 
-	  return FALSE;
-	}
-	if ((start > 0) || (Nrows > -1)) {
-	  gprint (GP_ERR, "%s[%s] is compressed: must read entire table\n", filename, extname);
-	  gfits_free_header (&header); 
-	  return FALSE;
-	}
-      }
-
-      if (Nrows == -1) {
-	Nrows = header.Naxis[1] - start;
-      }
-      if (start < 0) ESCAPE ("invalid range: start < 0\n");
-      if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);
-      if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");
-
-      // just a warning:
-      if (start + Nrows > header.Naxis[1]) {
-	if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start);
-      }
-
-      if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);
       break;
     }
+  }
+
+  int IsCompressed = gfits_extension_is_compressed_table (&header);
+
+  if (getSizes && !IsCompressed) {
+    read_table_sizes (&header);
+    if (CCDKeyword != NULL) free (CCDKeyword); 
+    gfits_free_header (&header); 
+    return TRUE;
+  }
+  if (IsCompressed) {
+    if (getSizes) {
+      gprint (GP_ERR, "%s[%s] is compressed: -sizes is invalid\n", filename, extname);
+      gfits_free_header (&header); 
+      return FALSE;
+    }
+    if ((start > 0) || (Nrows > -1)) {
+      gprint (GP_ERR, "%s[%s] is compressed: must read entire table\n", filename, extname);
+      gfits_free_header (&header); 
+      return FALSE;
+    }
+  }
+
+  if (Nrows == -1) {
+    Nrows = header.Naxis[1] - start;
+  }
+  if (start < 0) ESCAPE ("invalid range: start < 0\n");
+  if (start >= header.Naxis[1]) ESCAPE ("invalid range: start >= Ny (%d)\n", header.Naxis[1]);
+  if (Nrows < 0) ESCAPE ("invalid range: Nrows < 0\n");
+
+  // just a warning:
+  if (start + Nrows > header.Naxis[1]) {
+    if (VERBOSE) gprint (GP_ERR, "NOTE: reading last block will return only %d rows\n", header.Naxis[1] - start);
+  }
+
+  // Ny = 100, start = 0, Nrows = -1 -> Nrows => 100
+  // Ny = 100, start = 10, Nrows = 90
+
+  if (IsCompressed) {
+    if (!gfits_fread_ftable_data (f, &table, padIfShort)) ESCAPE ("error reading table for extension %d\n", Nextend);
+  } else {
+    if (!gfits_fread_ftable_range (f, padIfShort, &table, start, Nrows)) ESCAPE ("error reading table for extension %d\n", Nextend);
   }
 
@@ -553,5 +520,9 @@
   if (IsCompressed) {
     rawtable.header = &rawheader;
+
+    dump_cmp_table (&table, "rd cmp");
     if (!gfits_uncompress_table (&table, &rawtable)) ESCAPE ("failed to uncompress table");
+    dump_raw_table (&rawtable, "rd raw");
+
     outheader = &rawheader;
     outtable  = &rawtable;
Index: /branches/eam_branches/ohana.20150429/src/opihi/cmd.data/wd.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/opihi/cmd.data/wd.c	(revision 38340)
+++ /branches/eam_branches/ohana.20150429/src/opihi/cmd.data/wd.c	(revision 38341)
@@ -3,5 +3,5 @@
 int wd (int argc, char **argv) {
   
-  int N, Extend, Compress;
+  int N, Extend;
   int newUnsign, newBitpix, newScale, newZero;
   int outUnsign, outBitpix;
@@ -18,10 +18,4 @@
   }
 
-  Compress = FALSE;
-  if ((N = get_argument (argc, argv, "-compress"))) {
-    remove_argument (N, &argc, argv);
-    Compress = TRUE;
-  }
-
   char *CompressMode = NULL;
   if ((N = get_argument (argc, argv, "-compress-mode"))) {
@@ -29,6 +23,8 @@
     CompressMode = strcreate(argv[N]);
     remove_argument (N, &argc, argv);
-  }
-  if (!CompressMode) CompressMode = strcreate("GZIP_1");
+  } else if ((N = get_argument (argc, argv, "-compress"))) {
+    remove_argument (N, &argc, argv);
+    CompressMode = strcreate("GZIP_1");
+  }
 
   outZero = 0;
@@ -180,5 +176,5 @@
   
   // not compatible with extend
-  if (Compress) {
+  if (CompressMode) {
     Header myHeader;
     Matrix myMatrix;
Index: /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/VectorIO.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/VectorIO.c	(revision 38340)
+++ /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/VectorIO.c	(revision 38341)
@@ -71,4 +71,35 @@
 }
   
+# define VERBOSE 0
+int dump_raw_table (FTable *table, char *message) {
+# if (VERBOSE)
+  int i;
+  fprintf (stderr, "%s data: ", message);
+  for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
+    fprintf (stderr, "0x%02hhx ", table->buffer[i]);
+  }
+  fprintf (stderr, "\n");
+# endif
+  return TRUE;
+}
+
+int dump_cmp_table (FTable *table, char *message) {
+# if (VERBOSE)
+  int i;
+  fprintf (stderr, "%s pntr: ", message);
+  for (i = 0; i < table->header->Naxis[0]*table->header->Naxis[1]; i++) {
+    fprintf (stderr, "0x%02hhx ", table->buffer[i]);
+  }
+  fprintf (stderr, "\n");
+
+  fprintf (stderr, "%s data: ", message);
+  for (i = 0; i < table->header->pcount; i++) {
+    fprintf (stderr, "0x%02hhx ", table->buffer[table->heap_start + i]);
+  }
+  fprintf (stderr, "\n");
+# endif
+  return TRUE;
+}
+
 // write a set of vectors to a FITS file (vectors names become fits column names)
 int WriteVectorTableFITS (char *filename, char *extname, Vector **vec, int Nvec, int append, char *compress, char *format) {
@@ -106,5 +137,9 @@
   if (compress) {
     cmptable.header = &cmpheader;
+
+    dump_raw_table (&rawtable, "wd raw");
     if (!gfits_compress_table (&rawtable, &cmptable, 10, compress)) goto escape;
+    dump_cmp_table (&cmptable, "wd cmp");
+
     outtable = &cmptable;
     outheader = &cmpheader;
Index: /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/convert_to_RPN.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/convert_to_RPN.c	(revision 38340)
+++ /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/convert_to_RPN.c	(revision 38341)
@@ -58,4 +58,7 @@
     if (!strcmp (argv[i], "lgamma")) { type = ST_UNARY; goto gotit; }
     if (!strcmp (argv[i], "rnd"))    { type = ST_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "drnd"))   { type = ST_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "lrnd"))   { type = ST_UNARY; goto gotit; }
+    if (!strcmp (argv[i], "mrnd"))   { type = ST_UNARY; goto gotit; }
     if (!strcmp (argv[i], "xramp"))  { type = ST_UNARY; goto gotit; }
     if (!strcmp (argv[i], "yramp"))  { type = ST_UNARY; goto gotit; }
Index: /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/stack_math.c
===================================================================
--- /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/stack_math.c	(revision 38340)
+++ /branches/eam_branches/ohana.20150429/src/opihi/lib.shell/stack_math.c	(revision 38341)
@@ -12,19 +12,19 @@
   // set up the possible operations : int OP int -> int, all else yield float
   // OP is the operation performed on *M1 and *M2
-# define SSS_FUNC(OP) {						\
+# define SSS_FUNC(OP) {							\
     if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT) && (V3->type == ST_SCALAR_FLT)) { \
-      opihi_flt M1  =  V1[0].FltValue;			\
-      opihi_flt M2  =  V2[0].FltValue;			\
-      opihi_flt M3  =  V3[0].FltValue;			\
-      OUT[0].type = ST_SCALAR_FLT;			\
-      OUT[0].FltValue = OP;							\
+      opihi_flt M1  =  V1[0].FltValue;					\
+      opihi_flt M2  =  V2[0].FltValue;					\
+      opihi_flt M3  =  V3[0].FltValue;					\
+      OUT[0].type = ST_SCALAR_FLT;					\
+      OUT[0].FltValue = OP;						\
       break;								\
     }									\
     if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT) && (V3->type == ST_SCALAR_INT)) { \
-      opihi_int M1  =  V1[0].IntValue;			\
-      opihi_int M2  =  V2[0].IntValue;			\
-      opihi_int M3  =  V3[0].IntValue;			\
-      OUT[0].type = ST_SCALAR_INT;			\
-      OUT[0].IntValue = OP;							\
+      opihi_int M1  =  V1[0].IntValue;					\
+      opihi_int M2  =  V2[0].IntValue;					\
+      opihi_int M3  =  V3[0].IntValue;					\
+      OUT[0].type = ST_SCALAR_INT;					\
+      OUT[0].IntValue = OP;						\
       break;								\
     }									\
@@ -32,10 +32,10 @@
 
   switch (op[0]) {
-    case '?': SSS_FUNC(M1 ? M2: M3);
-    default:
-      snprintf (line, 512, "error: op %c not defined!", op[0]);
-      push_error (line);
-      return (FALSE);
-  }
+  case '?': SSS_FUNC(M1 ? M2: M3);
+  default:
+    snprintf (line, 512, "error: op %c not defined!", op[0]);
+    push_error (line);
+    return (FALSE);
+}
 # undef SSS_FUNC
 
@@ -68,5 +68,5 @@
   // set up the possible operations : int OP int -> int, all else yield float
   // OP is the operation performed on *M1 and *M2
-# define VVV_FUNC(OP) {						\
+# define VVV_FUNC(OP) {							\
     if ((V1->vector->type == OPIHI_FLT) && (V2->vector->type == OPIHI_FLT) && (V3->vector->type == OPIHI_FLT)) { \
       CopyVector (OUT[0].vector, V1[0].vector);				\
@@ -394,5 +394,5 @@
   // OP is the operation performed on *M1 and *M2
 # define SV_FUNC(FTYPE,OP) {						\
-    if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type == OPIHI_FLT)) {		\
+    if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type == OPIHI_FLT)) { \
       CopyVector (OUT[0].vector, V2[0].vector);				\
       opihi_flt  M1  =  V1[0].FltValue;					\
@@ -404,5 +404,5 @@
       break;								\
     }									\
-    if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type != OPIHI_FLT)) {		\
+    if ((V1->type == ST_SCALAR_FLT) && (V2->vector->type != OPIHI_FLT)) { \
       MatchVector (OUT[0].vector, V2[0].vector, OPIHI_FLT);		\
       opihi_flt  M1  =  V1[0].FltValue;					\
@@ -414,5 +414,5 @@
       break;								\
     }									\
-    if ((V1->type == ST_SCALAR_INT) && (V2->vector->type == OPIHI_FLT)) {		\
+    if ((V1->type == ST_SCALAR_INT) && (V2->vector->type == OPIHI_FLT)) { \
       CopyVector (OUT[0].vector, V2[0].vector);				\
       opihi_int  M1  =  V1[0].IntValue;					\
@@ -434,5 +434,5 @@
       break;								\
     }									\
-    if ((V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) {		\
+    if ((V1->type == ST_SCALAR_INT) && (V2->vector->type != OPIHI_FLT)) { \
       CopyVector (OUT[0].vector, V2[0].vector);				\
       opihi_int  M1  =  V1[0].IntValue;					\
@@ -447,36 +447,36 @@
 
   switch (op[0]) { 
-    case '+': SV_FUNC(ST_SCALAR_INT, M1 + *M2);
-    case '-': SV_FUNC(ST_SCALAR_INT, M1 - *M2);
-    case '*': SV_FUNC(ST_SCALAR_INT, M1 * *M2);
-    case '/': SV_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) *M2);
-    case '%': SV_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) *M2);
-    case '^': SV_FUNC(ST_SCALAR_FLT, pow (M1, *M2));
-    case '@': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2));
-    case 'a': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2));
-    case 'D': SV_FUNC(ST_SCALAR_INT, MIN (M1, *M2));
-    case 'U': SV_FUNC(ST_SCALAR_INT, MAX (M1, *M2));
-    case '<': SV_FUNC(ST_SCALAR_INT, (M1 < *M2) ? 1 : 0);
-    case '>': SV_FUNC(ST_SCALAR_INT, (M1 > *M2) ? 1 : 0);
-    case '&': SV_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)*M2));
-    case '|': SV_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)*M2));
-    case 'E': SV_FUNC(ST_SCALAR_INT, (M1 == *M2) ? 1 : 0);
-    case 'N': SV_FUNC(ST_SCALAR_INT, (M1 != *M2) ? 1 : 0);
-    case 'L': SV_FUNC(ST_SCALAR_INT, (M1 <= *M2) ? 1 : 0);
-    case 'G': SV_FUNC(ST_SCALAR_INT, (M1 >= *M2) ? 1 : 0);
-    case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0);
-    case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0);
-    default:
-      snprintf (line, 512, "error: op %c not defined!", op[0]);
-      push_error (line);
-      return (FALSE);
-  }
+  case '+': SV_FUNC(ST_SCALAR_INT, M1 + *M2);
+  case '-': SV_FUNC(ST_SCALAR_INT, M1 - *M2);
+  case '*': SV_FUNC(ST_SCALAR_INT, M1 * *M2);
+  case '/': SV_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) *M2);
+  case '%': SV_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) *M2);
+  case '^': SV_FUNC(ST_SCALAR_FLT, pow (M1, *M2));
+  case '@': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2));
+  case 'a': SV_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, *M2));
+  case 'D': SV_FUNC(ST_SCALAR_INT, MIN (M1, *M2));
+  case 'U': SV_FUNC(ST_SCALAR_INT, MAX (M1, *M2));
+  case '<': SV_FUNC(ST_SCALAR_INT, (M1 < *M2) ? 1 : 0);
+  case '>': SV_FUNC(ST_SCALAR_INT, (M1 > *M2) ? 1 : 0);
+  case '&': SV_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)*M2));
+  case '|': SV_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)*M2));
+  case 'E': SV_FUNC(ST_SCALAR_INT, (M1 == *M2) ? 1 : 0);
+  case 'N': SV_FUNC(ST_SCALAR_INT, (M1 != *M2) ? 1 : 0);
+  case 'L': SV_FUNC(ST_SCALAR_INT, (M1 <= *M2) ? 1 : 0);
+  case 'G': SV_FUNC(ST_SCALAR_INT, (M1 >= *M2) ? 1 : 0);
+  case 'A': SV_FUNC(ST_SCALAR_INT, (M1 && *M2) ? 1 : 0);
+  case 'O': SV_FUNC(ST_SCALAR_INT, (M1 || *M2) ? 1 : 0);
+  default:
+    snprintf (line, 512, "error: op %c not defined!", op[0]);
+    push_error (line);
+    return (FALSE);
+}
 # undef SV_FUNC
 
   /** free up any temporary buffers: **/
   if (V2[0].type == ST_VECTOR_TMP) {
-    free (V2[0].vector[0].elements.Ptr);
-    free (V2[0].vector);
-  }
+  free (V2[0].vector[0].elements.Ptr);
+  free (V2[0].vector);
+}
 
   clear_stack (V1);
@@ -501,5 +501,5 @@
   // OP is the operation performed on *M1 and *M2
 # define VS_FUNC(FTYPE,OP) {						\
-    if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type == OPIHI_FLT)) {		\
+    if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type == OPIHI_FLT)) { \
       CopyVector (OUT[0].vector, V1[0].vector);				\
       opihi_flt *M1  =  V1[0].vector[0].elements.Flt;			\
@@ -511,5 +511,5 @@
       break;								\
     }									\
-    if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT)) {		\
+    if ((V2->type == ST_SCALAR_FLT) && (V1->vector->type != OPIHI_FLT)) { \
       MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT);		\
       opihi_int *M1  =  V1[0].vector[0].elements.Int;			\
@@ -521,5 +521,5 @@
       break;								\
     }									\
-    if ((V2->type == ST_SCALAR_INT) && (V1->vector->type == OPIHI_FLT)) {		\
+    if ((V2->type == ST_SCALAR_INT) && (V1->vector->type == OPIHI_FLT)) { \
       CopyVector (OUT[0].vector, V1[0].vector);				\
       opihi_flt *M1  =  V1[0].vector[0].elements.Flt;			\
@@ -541,5 +541,5 @@
       break;								\
     }									\
-    if ((V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) {		\
+    if ((V2->type == ST_SCALAR_INT) && (V1->vector->type != OPIHI_FLT)) { \
       CopyVector (OUT[0].vector, V1[0].vector);				\
       opihi_int *M1  =  V1[0].vector[0].elements.Int;			\
@@ -554,29 +554,29 @@
 
   switch (op[0]) { 
-    case '+': VS_FUNC(ST_SCALAR_INT, *M1 + M2);
-    case '-': VS_FUNC(ST_SCALAR_INT, *M1 - M2);
-    case '*': VS_FUNC(ST_SCALAR_INT, *M1 * M2);
-    case '/': VS_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) M2);
-    case '%': VS_FUNC(ST_SCALAR_INT, (long long) *M1 % (long long) M2);
-    case '^': VS_FUNC(ST_SCALAR_FLT, pow (*M1, M2));
-    case '@': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2));
-    case 'a': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2));
-    case 'D': VS_FUNC(ST_SCALAR_INT, MIN (*M1, M2));
-    case 'U': VS_FUNC(ST_SCALAR_INT, MAX (*M1, M2));
-    case '<': VS_FUNC(ST_SCALAR_INT, (*M1 < M2) ? 1 : 0);
-    case '>': VS_FUNC(ST_SCALAR_INT, (*M1 > M2) ? 1 : 0);
-    case '&': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)M2));
-    case '|': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)M2));
-    case 'E': VS_FUNC(ST_SCALAR_INT, (*M1 == M2) ? 1 : 0);
-    case 'N': VS_FUNC(ST_SCALAR_INT, (*M1 != M2) ? 1 : 0);
-    case 'L': VS_FUNC(ST_SCALAR_INT, (*M1 <= M2) ? 1 : 0);
-    case 'G': VS_FUNC(ST_SCALAR_INT, (*M1 >= M2) ? 1 : 0);
-    case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0);
-    case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0);
-    default:
-      snprintf (line, 512, "error: op %c not defined!", op[0]);
-      push_error (line);
-      return (FALSE);
-  }
+  case '+': VS_FUNC(ST_SCALAR_INT, *M1 + M2);
+  case '-': VS_FUNC(ST_SCALAR_INT, *M1 - M2);
+  case '*': VS_FUNC(ST_SCALAR_INT, *M1 * M2);
+  case '/': VS_FUNC(ST_SCALAR_FLT, *M1 / (opihi_flt) M2);
+  case '%': VS_FUNC(ST_SCALAR_INT, (long long) *M1 % (long long) M2);
+  case '^': VS_FUNC(ST_SCALAR_FLT, pow (*M1, M2));
+  case '@': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2));
+  case 'a': VS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (*M1, M2));
+  case 'D': VS_FUNC(ST_SCALAR_INT, MIN (*M1, M2));
+  case 'U': VS_FUNC(ST_SCALAR_INT, MAX (*M1, M2));
+  case '<': VS_FUNC(ST_SCALAR_INT, (*M1 < M2) ? 1 : 0);
+  case '>': VS_FUNC(ST_SCALAR_INT, (*M1 > M2) ? 1 : 0);
+  case '&': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 & (long long)M2));
+  case '|': VS_FUNC(ST_SCALAR_INT, ((long long)*M1 | (long long)M2));
+  case 'E': VS_FUNC(ST_SCALAR_INT, (*M1 == M2) ? 1 : 0);
+  case 'N': VS_FUNC(ST_SCALAR_INT, (*M1 != M2) ? 1 : 0);
+  case 'L': VS_FUNC(ST_SCALAR_INT, (*M1 <= M2) ? 1 : 0);
+  case 'G': VS_FUNC(ST_SCALAR_INT, (*M1 >= M2) ? 1 : 0);
+  case 'A': VS_FUNC(ST_SCALAR_INT, (*M1 && M2) ? 1 : 0);
+  case 'O': VS_FUNC(ST_SCALAR_INT, (*M1 || M2) ? 1 : 0);
+  default:
+    snprintf (line, 512, "error: op %c not defined!", op[0]);
+    push_error (line);
+    return (FALSE);
+}
 # undef VS_FUNC
 
@@ -584,7 +584,7 @@
 
   if (V1[0].type == ST_VECTOR_TMP) {
-    free (V1[0].vector[0].elements.Ptr);
-    free (V1[0].vector);
-  }
+  free (V1[0].vector[0].elements.Ptr);
+  free (V1[0].vector);
+}
 
   clear_stack (V1);
@@ -885,19 +885,19 @@
   float *out   = (float *)OUT[0].buffer[0].matrix.buffer;
 
-# define MS_FUNC(OP) {					\
-    if (V2->type == ST_SCALAR_FLT)  {				\
-      opihi_flt M2 = V2[0].FltValue;			\
+# define MS_FUNC(OP) {				\
+    if (V2->type == ST_SCALAR_FLT)  {		\
+      opihi_flt M2 = V2[0].FltValue;		\
       for (i = 0; i < Npix; i++, out++, M1++) {	\
-	*out = OP;					\
-      }							\
-      break;						\
-    }							\
-    if (V2->type == ST_SCALAR_INT)  {				\
-      opihi_int M2 = V2[0].IntValue;			\
+	*out = OP;				\
+      }						\
+      break;					\
+    }						\
+    if (V2->type == ST_SCALAR_INT)  {		\
+      opihi_int M2 = V2[0].IntValue;		\
       for (i = 0; i < Npix; i++, out++, M1++) {	\
-	*out = OP;					\
-      }							\
-      break;						\
-    }							\
+	*out = OP;				\
+      }						\
+      break;					\
+    }						\
   }
 
@@ -961,19 +961,19 @@
   float *out   = (float *)OUT[0].buffer[0].matrix.buffer;
 
-# define SM_FUNC(OP) {					\
-    if (V1->type == ST_SCALAR_FLT)  {				\
-      opihi_flt M1 = V1[0].FltValue;			\
+# define SM_FUNC(OP) {				\
+    if (V1->type == ST_SCALAR_FLT)  {		\
+      opihi_flt M1 = V1[0].FltValue;		\
       for (i = 0; i < Npix; i++, out++, M2++) {	\
-	*out = OP;					\
-      }							\
-      break;						\
-    }							\
-    if (V1->type == ST_SCALAR_INT)  {				\
-      opihi_int M1 = V1[0].IntValue;			\
+	*out = OP;				\
+      }						\
+      break;					\
+    }						\
+    if (V1->type == ST_SCALAR_INT)  {		\
+      opihi_int M1 = V1[0].IntValue;		\
       for (i = 0; i < Npix; i++, out++, M2++) {	\
-	*out = OP;					\
-      }							\
-      break;						\
-    }							\
+	*out = OP;				\
+      }						\
+      break;					\
+    }						\
   }
 
@@ -1023,36 +1023,36 @@
 
 # define SS_FUNC(FTYPE,OP) {						\
-    if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT)) {			\
+    if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_FLT)) {	\
       opihi_flt M1 = V1[0].FltValue;					\
       opihi_flt M2 = V2[0].FltValue;					\
-      OUT[0].type = ST_SCALAR_FLT;						\
+      OUT[0].type = ST_SCALAR_FLT;					\
       OUT[0].FltValue = OP;						\
       break;								\
     }									\
-    if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT)) {			\
+    if ((V1->type == ST_SCALAR_FLT) && (V2->type == ST_SCALAR_INT)) {	\
       opihi_flt M1 = V1[0].FltValue;					\
       opihi_int M2 = V2[0].IntValue;					\
-      OUT[0].type = ST_SCALAR_FLT;						\
+      OUT[0].type = ST_SCALAR_FLT;					\
       OUT[0].FltValue = OP;						\
       break;								\
     }									\
-    if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_FLT)) {			\
+    if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_FLT)) {	\
       opihi_int M1 = V1[0].IntValue;					\
       opihi_flt M2 = V2[0].FltValue;					\
-      OUT[0].type = ST_SCALAR_FLT;						\
+      OUT[0].type = ST_SCALAR_FLT;					\
       OUT[0].FltValue = OP;						\
       break;								\
     }									\
-    if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) {	\
+    if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) { \
       opihi_int M1 = V1[0].IntValue;					\
       opihi_int M2 = V2[0].IntValue;					\
-      OUT[0].type = ST_SCALAR_FLT;						\
+      OUT[0].type = ST_SCALAR_FLT;					\
       OUT[0].FltValue = OP;						\
       break;								\
     }									\
-    if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) {			\
+    if ((V1->type == ST_SCALAR_INT) && (V2->type == ST_SCALAR_INT)) {	\
       opihi_int M1 = V1[0].IntValue;					\
       opihi_int M2 = V2[0].IntValue;					\
-      OUT[0].type = ST_SCALAR_INT;						\
+      OUT[0].type = ST_SCALAR_INT;					\
       OUT[0].IntValue = OP;						\
       break;								\
@@ -1061,29 +1061,29 @@
 
   switch (op[0]) { 
-    case '+': SS_FUNC(ST_SCALAR_INT, M1 + M2);
-    case '-': SS_FUNC(ST_SCALAR_INT, M1 - M2);
-    case '*': SS_FUNC(ST_SCALAR_INT, M1 * M2);
-    case '/': SS_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) M2);
-    case '%': SS_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) M2);
-    case '^': SS_FUNC(ST_SCALAR_FLT, pow (M1, M2));
-    case '@': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2));
-    case 'a': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2));
-    case 'D': SS_FUNC(ST_SCALAR_INT, MIN (M1, M2));
-    case 'U': SS_FUNC(ST_SCALAR_INT, MAX (M1, M2));
-    case '<': SS_FUNC(ST_SCALAR_INT, (M1 < M2) ? 1 : 0);
-    case '>': SS_FUNC(ST_SCALAR_INT, (M1 > M2) ? 1 : 0);
-    case '&': SS_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)M2));
-    case '|': SS_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)M2));
-    case 'E': SS_FUNC(ST_SCALAR_INT, (M1 == M2) ? 1 : 0);
-    case 'N': SS_FUNC(ST_SCALAR_INT, (M1 != M2) ? 1 : 0);
-    case 'L': SS_FUNC(ST_SCALAR_INT, (M1 <= M2) ? 1 : 0);
-    case 'G': SS_FUNC(ST_SCALAR_INT, (M1 >= M2) ? 1 : 0);
-    case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0);
-    case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0);
-    default:
-      snprintf (line, 512, "error: op %c not defined!", op[0]);
-      push_error (line);
-      return (FALSE);
-  }
+  case '+': SS_FUNC(ST_SCALAR_INT, M1 + M2);
+  case '-': SS_FUNC(ST_SCALAR_INT, M1 - M2);
+  case '*': SS_FUNC(ST_SCALAR_INT, M1 * M2);
+  case '/': SS_FUNC(ST_SCALAR_FLT, M1 / (opihi_flt) M2);
+  case '%': SS_FUNC(ST_SCALAR_INT, (long long) M1 % (long long) M2);
+  case '^': SS_FUNC(ST_SCALAR_FLT, pow (M1, M2));
+  case '@': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2));
+  case 'a': SS_FUNC(ST_SCALAR_FLT, DEG_RAD*atan2 (M1, M2));
+  case 'D': SS_FUNC(ST_SCALAR_INT, MIN (M1, M2));
+  case 'U': SS_FUNC(ST_SCALAR_INT, MAX (M1, M2));
+  case '<': SS_FUNC(ST_SCALAR_INT, (M1 < M2) ? 1 : 0);
+  case '>': SS_FUNC(ST_SCALAR_INT, (M1 > M2) ? 1 : 0);
+  case '&': SS_FUNC(ST_SCALAR_INT, ((long long)M1 & (long long)M2));
+  case '|': SS_FUNC(ST_SCALAR_INT, ((long long)M1 | (long long)M2));
+  case 'E': SS_FUNC(ST_SCALAR_INT, (M1 == M2) ? 1 : 0);
+  case 'N': SS_FUNC(ST_SCALAR_INT, (M1 != M2) ? 1 : 0);
+  case 'L': SS_FUNC(ST_SCALAR_INT, (M1 <= M2) ? 1 : 0);
+  case 'G': SS_FUNC(ST_SCALAR_INT, (M1 >= M2) ? 1 : 0);
+  case 'A': SS_FUNC(ST_SCALAR_INT, (M1 && M2) ? 1 : 0);
+  case 'O': SS_FUNC(ST_SCALAR_INT, (M1 || M2) ? 1 : 0);
+  default:
+    snprintf (line, 512, "error: op %c not defined!", op[0]);
+    push_error (line);
+    return (FALSE);
+}
 # undef SS_FUNC
 
@@ -1153,31 +1153,30 @@
 }
 
-
 int S_unary (StackVar *OUT, StackVar *V1, char *op) {
 
   char line[512]; // this is only used to report an error 
   
-# define S_FUNC(OP,FTYPE) {			\
-    if (V1->type == ST_SCALAR_FLT) {			\
-      opihi_flt M1  = V1[0].FltValue;		\
-      OUT[0].type = ST_SCALAR_FLT;			\
-      OUT[0].FltValue = OP;			\
-      clear_stack (V1);				\
-      return (TRUE);				\
-    }						\
+# define S_FUNC(OP,FTYPE) {						\
+    if (V1->type == ST_SCALAR_FLT) {					\
+      opihi_flt M1  = V1[0].FltValue;					\
+      OUT[0].type = ST_SCALAR_FLT;					\
+      OUT[0].FltValue = OP;						\
+      clear_stack (V1);							\
+      return (TRUE);							\
+    }									\
     if ((FTYPE == ST_SCALAR_FLT) && (V1->type == ST_SCALAR_INT)) {	\
-      opihi_int M1  = V1[0].IntValue;		\
-      OUT[0].type = ST_SCALAR_FLT;			\
-      OUT[0].FltValue = OP;			\
-      clear_stack (V1);				\
-      return (TRUE);				\
-    }						\
+      opihi_int M1  = V1[0].IntValue;					\
+      OUT[0].type = ST_SCALAR_FLT;					\
+      OUT[0].FltValue = OP;						\
+      clear_stack (V1);							\
+      return (TRUE);							\
+    }									\
     if ((FTYPE == ST_SCALAR_INT) && (V1->type == ST_SCALAR_INT)) {	\
-      opihi_int M1  = V1[0].IntValue;		\
-      OUT[0].type = ST_SCALAR_INT;			\
-      OUT[0].IntValue = OP;			\
-      clear_stack (V1);				\
-      return (TRUE);				\
-    }						\
+      opihi_int M1  = V1[0].IntValue;					\
+      OUT[0].type = ST_SCALAR_INT;					\
+      OUT[0].IntValue = OP;						\
+      clear_stack (V1);							\
+      return (TRUE);							\
+    }									\
   }
 
@@ -1211,5 +1210,8 @@
   if (!strcmp (op, "dacos"))  S_FUNC(acos (M1)*DEG_RAD, ST_SCALAR_FLT);
   if (!strcmp (op, "datan"))  S_FUNC(atan (M1)*DEG_RAD, ST_SCALAR_FLT);
-  if (!strcmp (op, "rnd"))    S_FUNC(M1*0.0 + drand48(), ST_SCALAR_FLT);
+  if (!strcmp (op, "rnd"))    S_FUNC(0.0*M1 + drand48(), ST_SCALAR_FLT);
+  if (!strcmp (op, "drnd"))   S_FUNC(0.0*M1 + drand48(), ST_SCALAR_FLT);
+  if (!strcmp (op, "lrnd"))   S_FUNC(0*M1 + lrand48(), ST_SCALAR_INT);
+  if (!strcmp (op, "mrnd"))   S_FUNC(0*M1 + mrand48(), ST_SCALAR_INT);
   if (!strcmp (op, "not"))    S_FUNC(!(M1), ST_SCALAR_INT);
   if (!strcmp (op, "--"))     S_FUNC(-1*M1, ST_SCALAR_INT); // NOTE: opihi_int is signed, 
@@ -1235,31 +1237,31 @@
   OUT[0].type = ST_VECTOR_TMP; /*** <<--- says this is a temporary matrix ***/
 
-# define V_FUNC(OP,FTYPE) {					\
-    if (V1->vector->type == OPIHI_FLT) {			\
-      CopyVector (OUT[0].vector, V1[0].vector);			\
-      opihi_flt *M1  = V1[0].vector[0].elements.Flt;		\
-      opihi_flt *out = OUT[0].vector[0].elements.Flt;		\
-      for (i = 0; i < Nx; i++, out++, M1++) {			\
-	*out = OP;						\
-      }								\
-      goto escape;						\
-    }								\
+# define V_FUNC(OP,FTYPE) {						\
+    if (V1->vector->type == OPIHI_FLT) {				\
+      CopyVector (OUT[0].vector, V1[0].vector);				\
+      opihi_flt *M1  = V1[0].vector[0].elements.Flt;			\
+      opihi_flt *out = OUT[0].vector[0].elements.Flt;			\
+      for (i = 0; i < Nx; i++, out++, M1++) {				\
+	*out = OP;							\
+      }									\
+      goto escape;							\
+    }									\
     if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_FLT)) {	\
-      MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT);	\
-      opihi_int *M1  = V1[0].vector[0].elements.Int;		\
-      opihi_flt *out = OUT[0].vector[0].elements.Flt;		\
-      for (i = 0; i < Nx; i++, out++, M1++) {			\
-	*out = OP;						\
-      }								\
-      goto escape;						\
-    }								\
+      MatchVector (OUT[0].vector, V1[0].vector, OPIHI_FLT);		\
+      opihi_int *M1  = V1[0].vector[0].elements.Int;			\
+      opihi_flt *out = OUT[0].vector[0].elements.Flt;			\
+      for (i = 0; i < Nx; i++, out++, M1++) {				\
+	*out = OP;							\
+      }									\
+      goto escape;							\
+    }									\
     if ((V1->vector->type == OPIHI_INT) && (FTYPE == ST_SCALAR_INT)) {	\
-      CopyVector (OUT[0].vector, V1[0].vector);			\
-      opihi_int *M1  = V1[0].vector[0].elements.Int;		\
-      opihi_int *out = OUT[0].vector[0].elements.Int;		\
-      for (i = 0; i < Nx; i++, out++, M1++) {			\
-	*out = OP;						\
-      }								\
-      goto escape;						\
+      CopyVector (OUT[0].vector, V1[0].vector);				\
+      opihi_int *M1  = V1[0].vector[0].elements.Int;			\
+      opihi_int *out = OUT[0].vector[0].elements.Int;			\
+      for (i = 0; i < Nx; i++, out++, M1++) {				\
+	*out = OP;							\
+      }									\
+      goto escape;							\
     } }							
 
@@ -1294,4 +1296,7 @@
   if (!strcmp (op, "datan"))  V_FUNC(atan(*M1)*DEG_RAD, ST_SCALAR_FLT);
   if (!strcmp (op, "rnd"))    V_FUNC(drand48(), ST_SCALAR_FLT);
+  if (!strcmp (op, "drnd"))   V_FUNC(drand48(), ST_SCALAR_FLT);
+  if (!strcmp (op, "lrnd"))   V_FUNC(lrand48(), ST_SCALAR_INT);
+  if (!strcmp (op, "mrnd"))   V_FUNC(mrand48(), ST_SCALAR_INT);
   if (!strcmp (op, "ramp"))   V_FUNC(i, ST_SCALAR_INT);
   if (!strcmp (op, "zero"))   V_FUNC(0, ST_SCALAR_INT);
@@ -1320,4 +1325,6 @@
 }
 
+# define M_FUNC(OP) { for (i = 0; i < Npix; i++, out++, M1++) { *out = (OP); }}
+
 int M_unary (StackVar *OUT, StackVar *V1, char *op) {
 
@@ -1337,45 +1344,45 @@
   M1  = (float *) V1[0].buffer[0].matrix.buffer;
   out = (float *)OUT[0].buffer[0].matrix.buffer;
-
+ 
+// if (!strcmp (op, "rint"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = nearbyint (*M1); }}
+  
   if (!strcmp (op, "="))     { }
-  if (!strcmp (op, "abs"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = fabs(*M1);         }}
-  if (!strcmp (op, "int"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = (opihi_flt)(long long)(*M1); }}
-
-  if (!strcmp (op, "floor")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = floor (*M1); }}
-  if (!strcmp (op, "ceil"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = ceil (*M1); }}
-  // if (!strcmp (op, "rint"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = nearbyint (*M1); }}
-
-  if (!strcmp (op, "exp"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = exp(*M1);          }}
-  if (!strcmp (op, "ten"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = pow(10.0,*M1);     }}
-  if (!strcmp (op, "log"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = log10(*M1);        }}
-  if (!strcmp (op, "ln"))    { for (i = 0; i < Npix; i++, out++, M1++) { *out = log(*M1);          }}
-  if (!strcmp (op, "sqrt"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = sqrt(*M1);         }}
-  if (!strcmp (op, "erf"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = erf(*M1);          }}
-
-  if (!strcmp (op, "sinh"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = sinh(*M1);         }}
-  if (!strcmp (op, "cosh"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = cosh(*M1);         }}
-  if (!strcmp (op, "asinh")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = asinh(*M1);        }}
-  if (!strcmp (op, "acosh")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = acosh(*M1);        }}
-  if (!strcmp (op, "lgamma")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = lgamma(*M1);      }}
-
-  if (!strcmp (op, "sin"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = sin(*M1);          }}
-  if (!strcmp (op, "cos"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = cos(*M1);          }}
-  if (!strcmp (op, "tan"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = tan(*M1);          }}
-  if (!strcmp (op, "dsin"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = sin(*M1*RAD_DEG);  }}
-  if (!strcmp (op, "dcos"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = cos(*M1*RAD_DEG);  }}
-  if (!strcmp (op, "dtan"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = tan(*M1*RAD_DEG);  }}
-  if (!strcmp (op, "asin"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = asin(*M1);         }}
-  if (!strcmp (op, "acos"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = acos(*M1);         }}
-  if (!strcmp (op, "atan"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = atan(*M1);         }}
-  if (!strcmp (op, "dasin")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = asin(*M1)*DEG_RAD; }}
-  if (!strcmp (op, "dacos")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = acos(*M1)*DEG_RAD; }}
-  if (!strcmp (op, "datan")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = atan(*M1)*DEG_RAD; }}
-  if (!strcmp (op, "not"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = !(*M1);            }}
-  if (!strcmp (op, "--"))    { for (i = 0; i < Npix; i++, out++, M1++) { *out = -(*M1);            }}
-  if (!strcmp (op, "rnd"))   { for (i = 0; i < Npix; i++, out++, M1++) { *out = drand48();         }}
-  if (!strcmp (op, "ramp"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = i;                 }}
-  if (!strcmp (op, "zero"))  { for (i = 0; i < Npix; i++, out++, M1++) { *out = 0;                 }}
-  if (!strcmp (op, "isinf")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = !finite(*M1);      }}
-  if (!strcmp (op, "isnan")) { for (i = 0; i < Npix; i++, out++, M1++) { *out = isnan(*M1);        }}
+  if (!strcmp (op, "abs"))    M_FUNC(fabs(*M1));
+  if (!strcmp (op, "int"))    M_FUNC((opihi_flt)(long long)(*M1));
+  if (!strcmp (op, "floor"))  M_FUNC(floor (*M1));
+  if (!strcmp (op, "ceil"))   M_FUNC(ceil (*M1));
+  if (!strcmp (op, "exp"))    M_FUNC(exp(*M1));
+  if (!strcmp (op, "ten"))    M_FUNC(pow(10.0,*M1));
+  if (!strcmp (op, "log"))    M_FUNC(log10(*M1));
+  if (!strcmp (op, "ln"))     M_FUNC(log(*M1));
+  if (!strcmp (op, "sqrt"))   M_FUNC(sqrt(*M1));
+  if (!strcmp (op, "erf"))    M_FUNC(erf(*M1));
+  if (!strcmp (op, "sinh"))   M_FUNC(sinh(*M1));
+  if (!strcmp (op, "cosh"))   M_FUNC(cosh(*M1));
+  if (!strcmp (op, "asinh"))  M_FUNC(asinh(*M1));
+  if (!strcmp (op, "acosh"))  M_FUNC(acosh(*M1));
+  if (!strcmp (op, "lgamma")) M_FUNC(lgamma(*M1));
+  if (!strcmp (op, "sin"))    M_FUNC(sin(*M1));
+  if (!strcmp (op, "cos"))    M_FUNC(cos(*M1));
+  if (!strcmp (op, "tan"))    M_FUNC(tan(*M1));
+  if (!strcmp (op, "dsin"))   M_FUNC(sin(*M1*RAD_DEG));
+  if (!strcmp (op, "dcos"))   M_FUNC(cos(*M1*RAD_DEG));
+  if (!strcmp (op, "dtan"))   M_FUNC(tan(*M1*RAD_DEG));
+  if (!strcmp (op, "asin"))   M_FUNC(asin(*M1));
+  if (!strcmp (op, "acos"))   M_FUNC(acos(*M1));
+  if (!strcmp (op, "atan"))   M_FUNC(atan(*M1));
+  if (!strcmp (op, "dasin"))  M_FUNC(asin(*M1)*DEG_RAD);
+  if (!strcmp (op, "dacos"))  M_FUNC(acos(*M1)*DEG_RAD);
+  if (!strcmp (op, "datan"))  M_FUNC(atan(*M1)*DEG_RAD);
+  if (!strcmp (op, "not"))    M_FUNC(!(*M1));
+  if (!strcmp (op, "--"))     M_FUNC(-(*M1));
+  if (!strcmp (op, "rnd"))    M_FUNC(drand48());
+  if (!strcmp (op, "drnd"))   M_FUNC(drand48());
+  if (!strcmp (op, "lrnd"))   M_FUNC(lrand48());
+  if (!strcmp (op, "mrnd"))   M_FUNC(mrand48());
+  if (!strcmp (op, "ramp"))   M_FUNC(i);
+  if (!strcmp (op, "zero"))   M_FUNC(0);
+  if (!strcmp (op, "isinf"))  M_FUNC(!finite(*M1));
+  if (!strcmp (op, "isnan"))  M_FUNC(isnan(*M1));
 
   /* xrm and yrm only make sense for 2D matrices. see special meaning for vectors */
