Index: soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c
===================================================================
--- soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c	(revision 821)
+++ soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c	(revision 822)
@@ -49,370 +49,65 @@
  */
 
+
+#undef display_type_matrix
+#define display_type_matrix(t) \
+void short_name(t,display_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \
+{                                              \
+    if (name != NULL) {                        \
+        printf("%s\n", name);                  \
+    }                                          \
+                                               \
+    for (int32_t i = nrl; i <= nrh; i++) {     \
+        for (int32_t j = ncl; j <= nch; j++) { \
+            printf(format, m[i][j]);           \
+        }                                      \
+        printf("\n");                          \
+    }                                          \
+}
+
+display_type_matrix(int8_t);
+display_type_matrix(uint8_t);
+display_type_matrix(int16_t);
+display_type_matrix(uint16_t);
+display_type_matrix(int32_t);
+display_type_matrix(uint32_t);
+display_type_matrix(int64_t);
+display_type_matrix(uint64_t);
+display_type_matrix(float);
+display_type_matrix(double);
+
+
 /* -------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_ui8matrix(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
+void display_rgb8matrix(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
 /* -------------------------------------------------------------------------------------------------------- */
 {
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
+    if (name != NULL) {
+        printf(name);
+    }
+    
+    for (int32_t i = nrl; i <= nrh; i++) {
+        for (int32_t j = ncl; j <= nch; j++) {
+            printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
         }
         printf("\n");
     }
 }
-/* -------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_si8matrix(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* -------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
+
+/* ---------------------------------------------------------------------------------------------------------- */
+void display_rgbx8matrix(rgbx8 ** m,int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
+/* ---------------------------------------------------------------------------------------------------------- */
+{
+    if (name != NULL) {
+        printf(name);
+    }
+    
+    for (int32_t i = nrl; i <= nrh; i++) {
+        for (int32_t j = ncl; j <= nch; j++) {
+            printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
         }
         printf("\n");
     }
 }
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_si16matrix(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_ui16matrix(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_si32matrix(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_ui32matrix(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_si64matrix(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* --------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_i64matrix(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* --------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_f32matrix(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_f64matrix(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* -------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_rgb8matrix(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* -------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(i=nrl; i<=nrh; i++) {
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
-        }
-        printf("\n");
-    }
-}
-/*
- * ----------------------
- * --- display_matrix ---
- * ----------------------
- */
-
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_si8matrix_T(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_ui8matrix_T(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ------------------------------------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) display_si16matrix_T(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ------------------------------------------------------------------------------------------------------------ */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ------------------------------------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) display_ui16matrix_T(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ------------------------------------------------------------------------------------------------------------ */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ------------------------------------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) display_si32matrix_T(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ------------------------------------------------------------------------------------------------------------ */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_ui32matrix_T(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ------------------------------------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) display_si64matrix_T(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ------------------------------------------------------------------------------------------------------------ */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ------------------------------------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) display_ui64matrix_T(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ------------------------------------------------------------------------------------------------------------ */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ------------------------------------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) display_f32matrix_T(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ------------------------------------------------------------------------------------------------------------ */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ------------------------------------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) display_f64matrix_T(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ------------------------------------------------------------------------------------------------------------ */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-}
-/* ---------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_rgb8matrix_T(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ---------------------------------------------------------------------------------------------------------- */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
-        }
-        printf("\n");
-    }
-}
-/* ------------------------------------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) display_rgbx8matrix_T(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ------------------------------------------------------------------------------------------------------------ */
-{
-    long i,j;
-    
-    if(name != NULL) printf(name);
-    
-    for(j=ncl; j<=nch; j++) {
-        for(i=nrl; i<=nrh; i++) {           
-            printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
-        }
-        printf("\n");
-    }
-}
+
 
 /*
@@ -422,22 +117,123 @@
  */
 
+#undef display_type_matrix_T
+#define display_type_matrix_T(t) \
+void short_name(t,display_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \
+{                                              \
+    if (name != NULL) {                        \
+        printf("%s\n", name);                  \
+    }                                          \
+                                               \
+    for (int32_t j = ncl; j <= nch; j++) {     \
+        for (int32_t i = nrl; i <= nrh; i++) { \
+            printf(format, m[i][j]);           \
+        }                                      \
+        printf("\n");                          \
+    }                                          \
+}
+
+display_type_matrix_T(int8_t);
+display_type_matrix_T(uint8_t);
+display_type_matrix_T(int16_t);
+display_type_matrix_T(uint16_t);
+display_type_matrix_T(int32_t);
+display_type_matrix_T(uint32_t);
+display_type_matrix_T(int64_t);
+display_type_matrix_T(uint64_t);
+display_type_matrix_T(float);
+display_type_matrix_T(double);
+
+
+/* -------------------------------------------------------------------------------------------------------- */
+void display_rgb8matrix_T(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
+/* -------------------------------------------------------------------------------------------------------- */
+{
+    if (name != NULL) {
+        printf(name);
+    }
+    
+    for (int32_t j = ncl; j <= nch; j++) {
+        for (int32_t i = nrl; i <= nrh; i++) {
+            printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
+        }
+        printf("\n");
+    }
+}
+
+/* ---------------------------------------------------------------------------------------------------------- */
+void display_rgbx8matrix_T(rgbx8 ** m,int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
+/* ---------------------------------------------------------------------------------------------------------- */
+{
+    if (name != NULL) {
+        printf(name);
+    }
+    
+    for (int32_t j = ncl; j <= nch; j++) {
+        for (int32_t i = nrl; i <= nrh; i++) {
+            printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
+        }
+        printf("\n");
+    }
+}
+
+
+
+/*
+ * -----------------------------
+ * --- display_matrix_number ---
+ * -----------------------------
+ */
+
+#undef display_type_matrix_number
+#define display_type_matrix_number(t) \
+void short_name(t,display_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \
+{                                              \
+    if (name != NULL) {                        \
+        printf("%s\n", name);                  \
+    }                                          \
+    printf("%5c", '#');                        \
+    for (int32_t j = ncl; j <= nch; j++) {     \
+        printf(format, j);                     \
+    }                                          \
+    printf("\n");                              \
+    for (int32_t i = nrl; i <= nrh; i++) {     \
+        printf("[%3d]", i);                    \
+        for (int32_t j = ncl; j <= nch; j++) { \
+            printf(format, m[i][j]);           \
+        }                                      \
+        printf("\n");                          \
+    }                                          \
+    printf("\n");                              \
+}
+
+display_type_matrix_number(int8_t);
+display_type_matrix_number(uint8_t);
+display_type_matrix_number(int16_t);
+display_type_matrix_number(uint16_t);
+display_type_matrix_number(int32_t);
+display_type_matrix_number(uint32_t);
+display_type_matrix_number(int64_t);
+display_type_matrix_number(uint64_t);
+display_type_matrix_number(float);
+display_type_matrix_number(double);
+
+
 /* --------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_si8matrix_number(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
+void display_rgb8matrix_number(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
 /* --------------------------------------------------------------------------------------------------------------- */
 {
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
+    if (name != NULL) {
+        printf(name);
+    }
     // 1ere ligne
     printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
+    for (int32_t j = ncl; j <= nch; j++) {
         printf(format, j);
     }
     printf("\n");
-    for(i=nrl; i<=nrh; i++) {
+    for (int32_t i = nrl; i <= nrh; i++) {
         printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
+        for (int32_t j = ncl; j <= nch; j++) {
+            printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
         }
         printf("\n");
@@ -445,22 +241,22 @@
     printf("\n");
 }
-/* --------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_ui8matrix_number(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* --------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
+
+/* ----------------------------------------------------------------------------------------------------------------- */
+void display_rgbx8matrix_number(rgbx8 **m,int32_t nrl,int32_t nrh,int32_t ncl, int32_t nch, char *format, char *name)
+/* ----------------------------------------------------------------------------------------------------------------- */
+{
+    if (name != NULL) {
+        printf(name);
+    }
     // 1ere ligne
     printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
+    for (int32_t j = ncl; j <= nch; j++) {
         printf(format, j);
     }
     printf("\n");
-    for(i=nrl; i<=nrh; i++) {
+    for (int32_t i = nrl; i <= nrh; i++) {
         printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
+        for (int32_t j = ncl; j <= nch; j++) {
+            printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
         }
         printf("\n");
@@ -468,234 +264,6 @@
     printf("\n");
 }
-/* ----------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_si16matrix_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ----------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
-/* ----------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_ui16matrix_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ----------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
-/* ----------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_si32matrix_number(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ----------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
-/* ----------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_ui32matrix_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ----------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
-/* ----------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_si64matrix_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ----------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
-/* ----------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_ui64matrix_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ----------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
-/* ----------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_f32matrix_number(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ----------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
-/* ----------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_f64matrix_number(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ----------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j]);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
-/* --------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_rgb8matrix_number(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* --------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
-/* ----------------------------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) display_rgbx8matrix_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
-/* ----------------------------------------------------------------------------------------------------------------- */
-{
-    int i,j;
-    
-    if(name != NULL) printf(name);
-    
-    // 1ere ligne
-    printf("%5c", '#');
-    for(j=ncl; j<=nch; j++) {
-        printf(format, j);
-    }
-    printf("\n");
-    for(i=nrl; i<=nrh; i++) {
-        printf("[%3d]", i);
-        for(j=ncl; j<=nch; j++) {
-            printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
-        }
-        printf("\n");
-    }
-    printf("\n");
-}
+
+
 
 /*
@@ -705,226 +273,83 @@
  */
 
-// ------------------------------------------------------------------------------------------------
-void display_si8matrix_positive(sint8 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
-// ------------------------------------------------------------------------------------------------
-{
-    int i, j;
-    
-    char *format, *str;
-    
-    select_display_positive_parameters(iformat, &format, &str);
-    
-    if(name != NULL) printf(name);
-    
-    for(i=i0; i<=i1; i++) {
-        for(j=j0; j<=j1; j++) {
-            if(m[i][j]) {
-                printf(format, m[i][j]);
-            } else {
-                printf("%s", str);
-            }
-        }
-        printf("\n");
-    }    
-}
-// ------------------------------------------------------------------------------------------------
-void display_ui8matrix_positive(uint8 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
-// ------------------------------------------------------------------------------------------------
-{
-    int i, j;
-    
-    char * format;
-    char * str;
-    
-    select_display_positive_parameters(iformat, &format, &str);
-    
-    if (name != NULL) {
-        printf("%s\n", name);
-    }
-    
-    // @QM have to hack this function for the giet
-    for (i = i0; i <= i1; i++) {
-        for (j = j0; j <= j1; j++) {
-            if (m[i][j]) {
-                // For the giet
-                int a = m[i][j];
-                int len = 0;
-                if (a == 0) {
-                    len = 1;
-                }
-                else {
-                    while (a != 0) {
-                        a = a / 10;
-                        len++;
-                    }
-                }
-                for (int k = len; k < iformat; k++) {
-                    printf(" ");
-                }
-                printf("%d", m[i][j]);
-            }
-            else {
-                printf("%s", str);
-            }
-        }
-        printf("\n");
-    }    
-}
-
-
-// --------------------------------------------------------------------------------------------------
-void display_si16matrix_positive(sint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
-// --------------------------------------------------------------------------------------------------
-{
-    int i, j;
-    
-    char *format, *str;
-    
-    select_display_positive_parameters(iformat, &format, &str);
-    
-    if(name != NULL) printf(name);
-    
-    for(i=i0; i<=i1; i++) {
-        for(j=j0; j<=j1; j++) {
-            if(m[i][j]) {
-                printf(format, m[i][j]);
-            } else {
-                printf("%s", str);
-            }
-        }
-        printf("\n");
-    }    
-}
-// --------------------------------------------------------------------------------------------------
-void display_ui16matrix_positive(uint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
-// --------------------------------------------------------------------------------------------------
-{
-    int i, j;
-    char *format, *str;
-    
-    select_display_positive_parameters(iformat, &format, &str);
-    
-    if(name != NULL) printf(name);
-    
-    for(i=i0; i<=i1; i++) {
-        for(j=j0; j<=j1; j++) {
-            if(m[i][j]) {
-                printf(format, m[i][j]);
-            } else {
-                printf("%s", str);
-            }
-        }
-        printf("\n");
-    }    
-}
-// --------------------------------------------------------------------------------------------------
-void display_si32matrix_positive(sint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
-// --------------------------------------------------------------------------------------------------
-{
-    int i, j;
-    char *format, *str;
-    
-    select_display_positive_parameters(iformat, &format, &str);
-    
-    if(name != NULL) printf(name);
-    
-    for(i=i0; i<=i1; i++) {
-        for(j=j0; j<=j1; j++) {
-            if(m[i][j]) {
-                printf(format, m[i][j]);
-            } else {
-                printf("%s", str);
-            }
-        }
-        printf("\n");
-    }    
-}
-// --------------------------------------------------------------------------------------------------
-void display_ui32matrix_positive(uint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
-// --------------------------------------------------------------------------------------------------
-{
-    int i, j;
-    char * format;
-    char * str;
-    
-    select_display_positive_parameters(iformat, &format, &str);
-    
-    if (name != NULL) {
-        printf("%s\n", name);
-    }
-    
-    // @QM have to hack this function for the giet
-    for (i = i0; i <= i1; i++) {
-        for (j = j0; j <= j1; j++) {
-            if (m[i][j] != 0) {
-                int a = m[i][j];
-                int len = 0;
-                if (a == 0) {
-                    len = 1;
-                }
-                else {
-                    while (a != 0) {
-                        a = a / 10;
-                        len++;
-                    }
-                }
-                for (int k = len; k < iformat; k++) {
-                    printf(" ");
-                }
-                printf("%d", m[i][j]);
-            }
-            else {
-                printf("%s", str);
-            }
-        }
-        printf("\n");
-    }    
-
-}
-// --------------------------------------------------------------------------------------------------
-void display_si64matrix_positive(sint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
-// --------------------------------------------------------------------------------------------------
-{
-    int i, j;
-    char *format, *str;
-    
-    select_display_positive_parameters(iformat, &format, &str);
-    
-    if(name != NULL) printf(name);
-    
-    for(i=i0; i<=i1; i++) {
-        for(j=j0; j<=j1; j++) {
-            if(m[i][j]) {
-                printf(format, m[i][j]);
-            } else {
-                printf("%s", str);
-            }
-        }
-        printf("\n");
-    }    
-}
-// --------------------------------------------------------------------------------------------------
-void display_ui64matrix_positive(uint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
-// --------------------------------------------------------------------------------------------------
-{
-    int i, j;
-    char *format, *str;
-    
-    select_display_positive_parameters(iformat, &format, &str);
-    
-    if(name != NULL) printf(name);
-    
-    for(i=i0; i<=i1; i++) {
-        for(j=j0; j<=j1; j++) {
-            if(m[i][j]) {
-                printf(format, m[i][j]);
-            } else {
-                printf("%s", str);
-            }
-        }
-        printf("\n");
-    }    
-}
-
+#if TARGET_OS != GIETVM
+
+#undef display_type_matrix_positive
+#define display_type_matrix_positive(t) \
+void short_name(t,display_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * name) \
+{                                                               \
+    char * format;                                              \
+    char * str;                                                 \
+    select_display_positive_parameters(iformat, &format, &str); \
+    if (name != NULL) {                                         \
+        printf("%s\n", name);                                   \
+    }                                                           \
+    for (int32_t i = i0; i <= i1; i++) {                        \
+        for (int32_t j = j0; j <= j1; j++) {                    \
+            if (m[i][j] != 0) {                                 \
+                printf(format, m[i][j]);                        \
+            }                                                   \
+            else {                                              \
+                printf("%s", str);                              \
+            }                                                   \
+        }                                                       \
+        printf("\n");                                           \
+    }                                                           \
+    printf("\n");                                               \
+}
+
+#else
+
+#undef display_type_matrix_positive
+#define display_type_matrix_positive(t) \
+void short_name(t,display_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * name) \
+{                                                               \
+    char * format;                                              \
+    char * str;                                                 \
+    select_display_positive_parameters(iformat, &format, &str); \
+    if (name != NULL) {                                         \
+        printf("%s\n", name);                                   \
+    }                                                           \
+    for (int32_t i = i0; i <= i1; i++) {                        \
+        for (int32_t j = j0; j <= j1; j++) {                    \
+            if (m[i][j] != 0) {                                 \
+                int32_t a = m[i][j];                            \
+                int32_t len = 0;                                \
+                if (a == 0) {                                   \
+                    len = 1;                                    \
+                }                                               \
+                else {                                          \
+                    while (a != 0) {                            \
+                        a = a / 10;                             \
+                        len++;                                  \
+                    }                                           \
+                }                                               \
+                for (int32_t k = len; k < iformat; k++) {       \
+                    printf(" ");                                \
+                }                                               \
+                printf(format, m[i][j]);                        \
+            }                                                   \
+            else {                                              \
+                printf("%s", str);                              \
+            }                                                   \
+        }                                                       \
+        printf("\n");                                           \
+    }                                                           \
+    printf("\n");                                               \
+}
+
+#endif
+
+
+display_type_matrix_positive(int8_t);
+display_type_matrix_positive(uint8_t);
+display_type_matrix_positive(int16_t);
+display_type_matrix_positive(uint16_t);
+display_type_matrix_positive(int32_t);
+display_type_matrix_positive(uint32_t);
+display_type_matrix_positive(int64_t);
+display_type_matrix_positive(uint64_t);
+display_type_matrix_positive(float);
+display_type_matrix_positive(double);
 
 
@@ -974,31 +399,30 @@
 
 /* ------------------------------------------------- */
-static void ReadPGMrow(int fd, int width, uint8 * line)
+static void ReadPGMrow(int32_t fd, int32_t width, uint8 * line)
 /* ------------------------------------------------- */
 {
-    read(fd, &line[0], sizeof(uint8) * width);
+    read(fd, &line[0], sizeof(uint8_t) * width);
 }
 
 
 /* -------------------------------------------------- */
-static void WritePGMrow(uint8 * line, int width, int fd)
+static void WritePGMrow(uint8_t * line, int32_t width, int32_t fd)
 /* -------------------------------------------------- */
 {
-    write(fd, &line[0], sizeof(uint8) * width);
+    write(fd, &line[0], sizeof(uint8_t) * width);
 }
 
 
 /* ----------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch)
+uint8_t ** LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch)
 /* ----------------------------------------------------------------------------------------------- */
 {
     // only for P5 binary type, not for text type
     
-    int height, width, gris;
-    uint8 ** m;
-    int fd;
+    int32_t height, width, gris;
+    uint8_t ** m;
+    int32_t fd;
     
     char buffer[80];
-    int i;
     (void) gris;
     
@@ -1026,5 +450,5 @@
     m = ui8matrix(*nrl, *nrh, *ncl, *nch);
     
-    for (i = 0; i < height; i++) {
+    for (int32_t i = 0; i < height; i++) {
         ReadPGMrow(fd, width, m[i]);
     }
@@ -1037,14 +461,13 @@
 
 /* ----------------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename)
+void SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename)
 /* ----------------------------------------------------------------------------------------------- */
 {
-    int nrow = nrh - nrl + 1;
-    int ncol = nch - ncl + 1;
+    int32_t nrow = nrh - nrl + 1;
+    int32_t ncol = nch - ncl + 1;
     
     char buffer[80];
     
-    int fd;
-    int i;
+    int32_t fd;
     
     //fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT);
@@ -1058,5 +481,5 @@
     snprintf(buffer, 80, "P5\n%d %d\n255\n", ncol, nrow);
     write(fd, buffer, strlen(buffer));
-    for (i = nrl; i <= nrh; i++) {
+    for (int32_t i = nrl; i <= nrh; i++) {
         WritePGMrow(m[i], ncol, fd);
     }
@@ -1068,2 +491,11 @@
 
 
+// Local Variables:
+// tab-width: 4
+// c-basic-offset: 4
+// c-file-offsets:((innamespace . 0)(inline-open . 0))
+// indent-tabs-mode: nil
+// End:
+
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
+
