Index: trunk/Ohana/src/libfits/include/gfitsio.h
===================================================================
--- trunk/Ohana/src/libfits/include/gfitsio.h	(revision 41176)
+++ trunk/Ohana/src/libfits/include/gfitsio.h	(revision 41340)
@@ -259,5 +259,5 @@
 int     gfits_read_table               PROTO((char *filename, FTable *ftable)); 
 int     gfits_set_bintable_column      PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow));
-int     gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, int element, char nativeOrder));
+int     gfits_set_bintable_column_reformat PROTO((Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder));
 int     gfits_set_table_column         PROTO((Header *header, FTable *table, char *label, void *data, off_t Nrow));
 int     gfits_table_column             PROTO((FTable *ftable, char *field, char *mode,...)) OHANA_FORMAT(printf, 3, 4);
Index: trunk/Ohana/src/libfits/table/F_define_column.c
===================================================================
--- trunk/Ohana/src/libfits/table/F_define_column.c	(revision 41176)
+++ trunk/Ohana/src/libfits/table/F_define_column.c	(revision 41340)
@@ -56,5 +56,4 @@
   char type[64], field[64];
   
-  // this call supported multiple columns per named field
   if (!gfits_bintable_format (format, type, &Nval, &Nbytes)) return (FALSE);
   
Index: trunk/Ohana/src/libfits/table/F_set_column.c
===================================================================
--- trunk/Ohana/src/libfits/table/F_set_column.c	(revision 41176)
+++ trunk/Ohana/src/libfits/table/F_set_column.c	(revision 41340)
@@ -253,5 +253,5 @@
 /***********************/
 // convert the input data array (of the specified intype) to the desired table data type. swap unless nativeOrder is requested
-int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, int element, char nativeOrder) {
+int gfits_set_bintable_column_reformat (Header *header, FTable *table, char *label, char *intype, void *data, off_t Nrow, char nativeOrder) {
 
   off_t Nx, Ny;
@@ -288,8 +288,4 @@
 
   if (!gfits_bintable_format (format, outtype, &Nval, &NbytesOut)) return (FALSE);
-  if (element >= Nval) {
-    fprintf (stderr, "programming error: element >= Nval for field %s, format %s\n", label, format);
-    return FALSE;
-  }
   
   /* check existing table dimensions */
@@ -311,13 +307,9 @@
   }
 
-  // NOTE: we are inserting a single column into the output
-  // table.  If the output field is multi-value, the resulting
-  // array is inserted into the appropriate bytes in that output field
-
   /* make duplicate of data with correct type
      byte swap and Bzero/Bscale */
-  ALLOCATE (array, char, NbytesOut*Nrow);
+  ALLOCATE (array, char, NbytesOut*Nval*Nrow);
   Pin = data;
-  Pout = array; // 
+  Pout = array;
 
   // # define ASSIGN_DATA(ITYPE,INAME,ISIZE,OTYPE,ONAME)
@@ -329,5 +321,5 @@
   if (!strcmp (outtype, OUTNAME) && !strcmp (intype, INNAME)) {		\
     int NbytesIn = NBYTES_IN;						\
-    for (i = 0; i < Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { \
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) { \
       if (directCopy) {							\
 	*(OUTTYPE *)Pout = *(INTYPE *)Pin;				\
@@ -393,4 +385,425 @@
   SET_VALUES("double",   double, "double", double, SWAP_DBLE, 8);
 
+# if (0)
+  /** input == char **/
+  if (!strcmp (outtype, "char") && !strcmp (intype, "char")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {
+      if (directCopy) { *(char *)Pout = *(char *)Pin; } else {
+	*(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
+      }
+    }
+  }
+  if (!strcmp (outtype, "byte") && !strcmp (intype, "char")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {
+      if (directCopy) { *(char *)Pout = *(char *)Pin; } else {
+	*(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
+      }
+    }
+  }
+  if (!strcmp (outtype, "short") && !strcmp (intype, "char")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      if (directCopy) { *(short *)Pout = *(char *)Pin; } else {
+	*(short *)Pout = (*(char *)Pin - Bzero) / Bscale;
+      }
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_BYTE; }
+# endif
+    }  
+  }
+  if (!strcmp (outtype, "int") && !strcmp (intype, "char")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "char")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "float") && !strcmp (intype, "char")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(float *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "double") && !strcmp (intype, "char")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(double *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+
+  /** input == byte **/
+  if (!strcmp (outtype, "char") && !strcmp (intype, "byte")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {
+      *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "byte") && !strcmp (intype, "byte")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin+=NbytesIn, Pout+=NbytesOut) {
+      *(char *)Pout = (*(char *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "short") && !strcmp (intype, "byte")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(short *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_BYTE; }
+# endif
+    }  
+  }
+  if (!strcmp (outtype, "int") && !strcmp (intype, "byte")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "byte")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "float") && !strcmp (intype, "byte")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(float *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "double") && !strcmp (intype, "byte")) {
+    int NbytesIn = 1;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(double *)Pout = (*(char *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+
+  /** input == short **/
+  if (!strcmp (outtype, "char") && !strcmp (intype, "short")) {
+    int NbytesIn = 2;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(short *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "byte") && !strcmp (intype, "short")) {
+    int NbytesIn = 2;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(short *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "short") && !strcmp (intype, "short")) {
+    int NbytesIn = 2;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(short *)Pout = (*(short *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_BYTE; }
+# endif
+    }  
+  }
+  if (!strcmp (outtype, "int") && !strcmp (intype, "short")) {
+    int NbytesIn = 2;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int *)Pout = (*(short *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "short")) {
+    int NbytesIn = 2;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(short *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "float") && !strcmp (intype, "short")) {
+    int NbytesIn = 2;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(float *)Pout = (*(short *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "double") && !strcmp (intype, "short")) {
+    int NbytesIn = 2;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(double *)Pout = (*(short *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+
+  /** input == int **/
+  if (!strcmp (outtype, "char") && !strcmp (intype, "int")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(int *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "byte") && !strcmp (intype, "int")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(int *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "short") && !strcmp (intype, "int")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(short *)Pout = (*(int *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_BYTE; }
+# endif
+    }  
+  }
+  if (!strcmp (outtype, "int") && !strcmp (intype, "int")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int *)Pout = (*(int *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "int")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(int *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "float") && !strcmp (intype, "int")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(float *)Pout = (*(int *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "double") && !strcmp (intype, "int")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(double *)Pout = (*(int *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+
+  /** input == int64_t **/
+  if (!strcmp (outtype, "char") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "byte") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "short") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(short *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_BYTE; }
+# endif
+    }  
+  }
+  if (!strcmp (outtype, "int") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "float") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(float *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "double") && !strcmp (intype, "int64_t")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(double *)Pout = (*(int64_t *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+
+  /** input == float **/
+  if (!strcmp (outtype, "char") && !strcmp (intype, "float")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(float *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "byte") && !strcmp (intype, "float")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(float *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "short") && !strcmp (intype, "float")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(short *)Pout = (*(float *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_BYTE; }
+# endif
+    }  
+  }
+  if (!strcmp (outtype, "int") && !strcmp (intype, "float")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int *)Pout = (*(float *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "float")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(float *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "float") && !strcmp (intype, "float")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(float *)Pout = (*(float *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "double") && !strcmp (intype, "float")) {
+    int NbytesIn = 4;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(double *)Pout = (*(float *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+
+  /** input == double **/
+  if (!strcmp (outtype, "char") && !strcmp (intype, "double")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(double *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "byte") && !strcmp (intype, "double")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(char *)Pout = (*(double *)Pin - Bzero) / Bscale;
+    }
+  }
+  if (!strcmp (outtype, "short") && !strcmp (intype, "double")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(short *)Pout = (*(double *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_BYTE; }
+# endif
+    }  
+  }
+  if (!strcmp (outtype, "int") && !strcmp (intype, "double")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int *)Pout = (*(double *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "int64_t") && !strcmp (intype, "double")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(int64_t *)Pout = (*(double *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "float") && !strcmp (intype, "double")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(float *)Pout = (*(double *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_WORD; }
+# endif
+    }
+  }
+  if (!strcmp (outtype, "double") && !strcmp (intype, "double")) {
+    int NbytesIn = 8;
+    for (i = 0; i < Nval*Nrow; i++, Pin += NbytesIn, Pout += NbytesOut) {
+      *(double *)Pout = (*(double *)Pin - Bzero) / Bscale;
+# ifdef BYTE_SWAP
+      if (!nativeOrder) { SWAP_DBLE; }
+# endif
+    }
+  }
+# endif
+
   /* check array space */
   if (Nx*Ny < Nx*(Nrow - 1) + Nstart + Nval*NbytesOut) {
@@ -400,8 +813,8 @@
 
   /* insert bytes from array into appropriate section of buffer */
-  Pout = table[0].buffer + Nstart + element*NbytesOut;
+  Pout = table[0].buffer + Nstart;
   Pin  = array;
-  for (i = 0; i < Nrow; i++, Pout += Nx, Pin += NbytesOut) {
-    memcpy (Pout, Pin, NbytesOut);
+  for (i = 0; i < Nrow; i++, Pout += Nx, Pin += Nval*NbytesOut) {
+    memcpy (Pout, Pin, Nval*NbytesOut);
   }
 
