Index: soft/giet_vm/applications/rosenfeld/nrc2/src/nrset2.c
===================================================================
--- soft/giet_vm/applications/rosenfeld/nrc2/src/nrset2.c	(revision 772)
+++ soft/giet_vm/applications/rosenfeld/nrc2/src/nrset2.c	(revision 826)
@@ -16,5 +16,4 @@
 #include <stddef.h>
 #include <stdlib.h>
-#include <math.h> // fabs
 
 #include "mypredef.h"
@@ -33,112 +32,27 @@
  */
 
-/* ---------------------------------------------------------------------- */
-IMAGE_EXPORT(void) zero_si8matrix(sint8 **m, int i0, int i1, int j0, int j1)
-/* ---------------------------------------------------------------------- */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_si8vector(m[i], j0, j1);
-    }
-}
-/* ---------------------------------------------------------------------- */
-IMAGE_EXPORT(void) zero_ui8matrix(uint8 **m, int i0, int i1, int j0, int j1)
-/* ---------------------------------------------------------------------- */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_ui8vector(m[i], j0, j1);
-    }
-}
-/* ------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) zero_si16matrix(sint16 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------ */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_si16vector(m[i], j0, j1);
-    }
-}
-/* ------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) zero_ui16matrix(uint16 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------ */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_ui16vector(m[i], j0, j1);
-    }
-}
-/* ------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) zero_si32matrix(sint32 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------ */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_si32vector(m[i], j0, j1);
-    }
-}
-/* ------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) zero_ui32matrix(uint32 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------ */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_ui32vector(m[i], j0, j1);
-    }
-}
-/* ------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) zero_si64matrix(sint64 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------ */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_si64vector(m[i], j0, j1);
-    }
-}
-/* ------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) zero_ui64matrix(uint64 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------ */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_ui64vector(m[i], j0, j1);
-    }
-}
-/* ------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) zero_f32matrix(float32 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------ */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_f32vector(m[i], j0, j1);
-    }
-}
-/* ------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) zero_f64matrix(float64 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------ */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_f64vector(m[i], j0, j1);
-    }
-}
-/* ---------------------------------------------------------------------- */
-IMAGE_EXPORT(void) zero_rgb8matrix(rgb8 **m, int i0, int i1, int j0, int j1)
-/* ---------------------------------------------------------------------- */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_rgb8vector(m[i], j0, j1);
-    }
-}
-/* ------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) zero_rgbx8matrix(rgbx8 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------ */
-{
-	int i;
-    for(i=i0; i<=i1; i++) {
-        zero_rgbx8vector(m[i], j0, j1);
-    }
-}
+
+#undef zero_type_matrix
+#define zero_type_matrix(t) \
+void short_name(t,zero_,matrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1) \
+{                                                 \
+    for (int32_t i = i0; i <= i1; i++) {          \
+        short_name(t,zero_,vector)(m[i], j0, j1); \
+    }                                             \
+}
+
+zero_type_matrix(int8_t);
+zero_type_matrix(uint8_t);
+zero_type_matrix(int16_t);
+zero_type_matrix(uint16_t);
+zero_type_matrix(int32_t);
+zero_type_matrix(uint32_t);
+zero_type_matrix(int64_t);
+zero_type_matrix(uint64_t);
+zero_type_matrix(float);
+zero_type_matrix(double);
+zero_type_matrix(rgb8);
+zero_type_matrix(rgbx8);
+
 /*
  * ------------------
@@ -147,84 +61,28 @@
  */
 
-/* ------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) set_si8matrix(sint8 **m, int i0, int i1, int j0, int j1, sint8 x)
-/* ------------------------------------------------------------------------------ */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_si8vector(m[i], j0, j1, x);
-}
-/* ------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) set_ui8matrix(uint8 **m, int i0, int i1, int j0, int j1, uint8 x)
-/* ------------------------------------------------------------------------------ */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_ui8vector(m[i], j0, j1, x);
-}
-/* --------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si16matrix(sint16 **m, int i0, int i1, int j0, int j1, sint16 x)
-/* --------------------------------------------------------------------------------- */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_si16vector(m[i], j0, j1, x);
-}
-/* --------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui16matrix(uint16 **m, int i0, int i1, int j0, int j1, uint16 x)
-/* --------------------------------------------------------------------------------- */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_ui16vector(m[i], j0, j1, x);
-}
-/* --------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si32matrix(sint32 **m, int i0, int i1, int j0, int j1, sint32 x)
-/* --------------------------------------------------------------------------------- */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_si32vector(m[i], j0, j1, x);
-}
-/* --------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui32matrix(uint32 **m, int i0, int i1, int j0, int j1, uint32 x)
-/* --------------------------------------------------------------------------------- */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_ui32vector(m[i], j0, j1, x);
-}
-/* --------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_f32matrix(float32 **m, int i0, int i1,int j0, int j1, float32 x)
-/* --------------------------------------------------------------------------------- */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_f32vector(m[i], j0, j1, x);
-}
-/* --------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_f64matrix(float64 **m,int i0, int i1, int j0, int j1, float64 x)
-/* --------------------------------------------------------------------------------- */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_f64vector(m[i], j0, j1, x);
-}
-/* ---------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_rgb8matrix(rgb8 **m,int i0, int i1, int j0, int j1, rgb8 x)
-/* ---------------------------------------------------------------------------- */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_rgb8vector(m[i], j0, j1, x);
-}
-/* ----------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_rgbx8matrix(rgbx8 **m,int i0,int i1,int j0, int j1, rgbx8 x)
-/* ----------------------------------------------------------------------------- */
-{
-	int i;
-	for(i=i0; i<=i1; i++)
-		set_rgbx8vector(m[i], j0, j1, x);
-}
+#undef set_type_matrix
+#define set_type_matrix(t) \
+void short_name(t,set_,matrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, t x) \
+{                                                    \
+    for (int32_t i = i0; i <= i1; i++) {             \
+        short_name(t,set_,vector)(m[i], j0, j1, x);  \
+    }                                                \
+}
+
+set_type_matrix(int8_t);
+set_type_matrix(uint8_t);
+set_type_matrix(int16_t);
+set_type_matrix(uint16_t);
+set_type_matrix(int32_t);
+set_type_matrix(uint32_t);
+set_type_matrix(int64_t);
+set_type_matrix(uint64_t);
+set_type_matrix(float);
+set_type_matrix(double);
+set_type_matrix(rgb8);
+set_type_matrix(rgbx8);
+
+
+
 /*
  * ----------------
@@ -232,110 +90,30 @@
  * ----------------
  */
-/* ------------------------------------------------------------------------------------------------ */
-void set_ui8matrix_param(uint8 **m, int i0, int i1, int j0, int j1, uint8 x, uint8 xstep, uint8 ystep)
-/* ------------------------------------------------------------------------------------------------ */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_ui8vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* -------------------------------------------------------------------------------------------------- */
-void set_si8matrix_param(sint8 **m, int i0, int i1, int j0, int j1, sint8 x, sint8 xstep, sint8 ystep)
-/* -------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_si8vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* ----------------------------------------------------------------------------------------------------- */
-void set_ui16matrix_param(uint16 **m, int i0, int i1, int j0, int j1, uint16 x, uint16 xstep, uint16 ystep)
-/* ----------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_ui16vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* ----------------------------------------------------------------------------------------------------- */
-void set_si16matrix_param(sint16 **m, int i0, int i1, int j0, int j1, sint16 x, sint16 xstep, sint16 ystep)
-/* ----------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_si16vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* ----------------------------------------------------------------------------------------------------- */
-void set_ui32matrix_param(uint32 **m, int i0, int i1, int j0, int j1, uint32 x, uint32 xstep, uint32 ystep)
-/* ----------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_ui32vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* ----------------------------------------------------------------------------------------------------- */
-void set_si32matrix_param(sint32 **m, int i0, int i1, int j0, int j1, sint32 x, sint32 xstep, sint32 ystep)
-/* ----------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_si32vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* ----------------------------------------------------------------------------------------------------- */
-void set_ui64matrix_param(uint64 **m, int i0, int i1, int j0, int j1, uint64 x, uint64 xstep, uint64 ystep)
-/* ----------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_ui64vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* ----------------------------------------------------------------------------------------------------- */
-void set_si64matrix_param(sint64 **m, int i0, int i1, int j0, int j1, sint64 x, sint64 xstep, sint64 ystep)
-/* ----------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_si64vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* -------------------------------------------------------------------------------------------------------- */
-void set_f32matrix_param(float32 **m, int i0, int i1, int j0, int j1, float32 x, float32 xstep, float32 ystep)
-/* -------------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_f32vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* -------------------------------------------------------------------------------------------------------- */
-void set_f64matrix_param(float64 **m, int i0, int i1, int j0, int j1, float64 x, float64 xstep, float64 ystep)
-/* -------------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
-        set_f64vector_param(m[i], j0, j1, x, xstep);
-        x += ystep;
-    }
-}
-/* --------------------------------------------------------------------------------------------- */
-void set_rgb8matrix_param(rgb8 **m, int i0, int i1, int j0, int j1, rgb8 x, rgb8 xstep, rgb8 ystep)
-/* --------------------------------------------------------------------------------------------- */
-{
-    int i;
-    for(i=i0; i<=i1; i++) {
+
+#undef set_type_matrix_param
+#define set_type_matrix_param(t) \
+void short_name(t,set_,matrix_param)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, t x, t xstep, t ystep) \
+{                                                                \
+    for (int32_t i = i0; i <= i1; i++) {                         \
+        short_name(t,set_,vector_param)(m[i], j0, j1, x, xstep); \
+        x += ystep;                                              \
+    }                                                            \
+}
+
+set_type_matrix_param(int8_t);
+set_type_matrix_param(uint8_t);
+set_type_matrix_param(int16_t);
+set_type_matrix_param(uint16_t);
+set_type_matrix_param(int32_t);
+set_type_matrix_param(uint32_t);
+set_type_matrix_param(int64_t);
+set_type_matrix_param(uint64_t);
+set_type_matrix_param(float);
+set_type_matrix_param(double);
+
+
+void set_rgb8matrix_param(rgb8 ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, rgb8 x, rgb8 xstep, rgb8 ystep)
+{
+    for (int32_t i = i0; i <= i1; i++) {
         set_rgb8vector_param(m[i], j0, j1, x, xstep);
         x.r += ystep.r;
@@ -344,19 +122,18 @@
     }
 }
-/* -------------------------------------------------------------------------------------------------- */
-void set_rgbx8matrix_param(rgbx8 **m, int i0, int i1, int j0, int j1, rgbx8 x, rgbx8 xstep, rgbx8 ystep)
-/* -------------------------------------------------------------------------------------------------- */
-{
-    int i;
-    
+
+void set_rgbx8matrix_param(rgbx8 ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, rgbx8 x, rgbx8 xstep, rgbx8 ystep)
+{
     x.x = 0;
-    for(i=i0; i<=i1; i++) {
+    for (int32_t i = i0; i <= i1; i++) {
         set_rgbx8vector_param(m[i], j0, j1, x, xstep);
         x.r += ystep.r;
         x.g += ystep.g;
         x.b += ystep.b;
-		x.x += ystep.x;
+        x.x += ystep.x;
     }
 }
+
+
 /*
  * --------------------
@@ -364,69 +141,29 @@
  * --------------------
  */
-/* ----------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si8matrix_i(sint8 **m, int i0, int i1, int j0, int j1)
-/* ----------------------------------------------------------------------- */
-{
-    set_si8matrix_param(m, i0, i1, j0, j1, i0,0, 1);
-}
-/* ----------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui8matrix_i(uint8 **m, int i0, int i1, int j0, int j1)
-/* ----------------------------------------------------------------------- */
-{
-    set_ui8matrix_param(m, i0, i1, j0, j1, i0,0, 1);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si16matrix_i(sint16 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_si16matrix_param(m, i0, i1, j0, j1, i0,0, 1);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui16matrix_i(uint16 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_ui16matrix_param(m, i0, i1, j0, j1, i0,0, 1);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si32matrix_i(sint32 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_si32matrix_param(m, i0, i1, j0, j1, i0,0, 1);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui32matrix_i(uint32 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_ui32matrix_param(m, i0, i1, j0, j1, i0,0, 1);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si64matrix_i(sint64 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_si64matrix_param(m, i0, i1, j0, j1, i0,0, 1);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui64matrix_i(uint64 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_ui64matrix_param(m, i0, i1, j0, j1, i0,0, 1);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_f32matrix_i(float32 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_f32matrix_param(m, i0, i1, j0, j1, (float32) i0, (float32)0, (float32)1);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_f64matrix_i(float64 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_f64matrix_param(m, i0, i1, j0, j1, i0,(float64)0, (float64)1);
-}
-/* ----------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_rgb8matrix_i(rgb8 **m, int i0, int i1, int j0, int j1)
-/* ----------------------------------------------------------------------- */
-{
-    rgb8 x0, xstep, ystep;
+
+#undef set_type_matrix_i
+#define set_type_matrix_i(t) \
+void short_name(t,set_,matrix_i)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1) \
+{                                                                 \
+    short_name(t,set_,matrix_param)(m, i0, i1, j0, j1, i0, 0, 1); \
+}
+
+set_type_matrix_i(int8_t);
+set_type_matrix_i(uint8_t);
+set_type_matrix_i(int16_t);
+set_type_matrix_i(uint16_t);
+set_type_matrix_i(int32_t);
+set_type_matrix_i(uint32_t);
+set_type_matrix_i(int64_t);
+set_type_matrix_i(uint64_t);
+set_type_matrix_i(float);
+set_type_matrix_i(double);
+
+
+void set_rgb8matrix_i(rgb8 ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1)
+{
+    rgb8 x0;
+    rgb8 xstep;
+    rgb8 ystep;
 
     x0.r    = x0.g    = x0.b    = i0;
@@ -436,16 +173,23 @@
     set_rgb8matrix_param(m, i0, i1, j0, j1, x0, xstep, ystep);
 }
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_rgbx8matrix_i(rgbx8 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    rgbx8 x, xstep, ystep;
-
-    x.r     = x.g     = x.b     = i0; x.x     = 255;
-    xstep.r = xstep.g = xstep.b = 0;  xstep.x = 255;
-    ystep.r = ystep.g = ystep.b = 1;  ystep.x = 255;
+
+
+void set_rgbx8matrix_i(rgbx8 ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1)
+{
+    rgbx8 x;
+    rgbx8 xstep;
+    rgbx8 ystep;
+
+    x.r     = x.g     = x.b     = i0;
+    x.x     = 255;
+    xstep.r = xstep.g = xstep.b = 0;
+    xstep.x = 255;
+    ystep.r = ystep.g = ystep.b = 1;
+    ystep.x = 255;
 
     set_rgbx8matrix_param(m, i0, i1, j0, j1, x, xstep, ystep);
 }
+
+
 /*
  * --------------------
@@ -453,71 +197,32 @@
  * --------------------
  */
-/* ----------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si8matrix_j(sint8 **m, int i0, int i1, int j0, int j1)
-/* ----------------------------------------------------------------------- */
-{
-    set_si8matrix_param(m, i0, i1, j0, j1, j0, 1, 0);
-}
-/* ----------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui8matrix_j(uint8 **m, int i0, int i1, int j0, int j1)
-/* ----------------------------------------------------------------------- */
-{
-    set_ui8matrix_param(m, i0, i1, j0, j1, j0, 1, 0);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si16matrix_j(sint16 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_si16matrix_param(m, i0, i1, j0, j1, j0, 1, 0);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui16matrix_j(uint16 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_ui16matrix_param(m, i0, i1, j0, j1, j0, 1, 0);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si32matrix_j(sint32 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_si32matrix_param(m, i0, i1, j0, j1, j0, 1, 0);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui32matrix_j(uint32 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_ui32matrix_param(m, i0, i1, j0, j1, j0, 1, 0);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_si64matrix_j(sint64 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_si64matrix_param(m, i0, i1, j0, j1, j0, 1, 0);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui64matrix_j(uint64 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_ui64matrix_param(m, i0, i1, j0, j1, j0, 1, 0);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_f32matrix_j(float32 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_f32matrix_param(m, i0, i1, j0, j1, (float32)j0,(float32)1, (float32)0);
-}
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_f64matrix_j(float64 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
-{
-    set_f64matrix_param(m, i0, i1, j0, j1, j0,(float64)1, (float64)0);
-}
-/* ----------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_rgb8matrix_j(rgb8 **m, int i0, int i1, int j0, int j1)
-/* ----------------------------------------------------------------------- */
-{
-    rgb8 x, xstep, ystep;
-
-    x.r     = x.g     = x.b    = j0;
+
+#undef set_type_matrix_j
+#define set_type_matrix_j(t) \
+void short_name(t,set_,matrix_j)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1) \
+{                                                                 \
+    short_name(t,set_,matrix_param)(m, i0, i1, j0, j1, j0, 1, 0); \
+}
+
+set_type_matrix_j(int8_t);
+set_type_matrix_j(uint8_t);
+set_type_matrix_j(int16_t);
+set_type_matrix_j(uint16_t);
+set_type_matrix_j(int32_t);
+set_type_matrix_j(uint32_t);
+set_type_matrix_j(int64_t);
+set_type_matrix_j(uint64_t);
+set_type_matrix_j(float);
+set_type_matrix_j(double);
+
+
+
+void set_rgb8matrix_j(rgb8 ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1)
+{
+    rgb8 x;
+    rgb8 xstep;
+    rgb8 ystep;
+
+    x.r     = x.g     = x.b     = j0;
     xstep.r = xstep.g = xstep.b = 1;
     ystep.r = ystep.g = ystep.b = 0;
@@ -525,62 +230,96 @@
     set_rgb8matrix_param(m, i0, i1, j0, j1, x, xstep, ystep);
 }
-/* ------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_rgbx8matrix_j(rgbx8 **m, int i0, int i1, int j0, int j1)
-/* ------------------------------------------------------------------------- */
+
+void set_rgbx8matrix_j(rgbx8 ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1)
 {
     rgbx8 x, xstep, ystep;
 
-    x.r     = x.g     = x.b     = j0; x.x     = 255;
-    xstep.r = xstep.g = xstep.b = 1;  xstep.x = 255;
-    ystep.r = ystep.g = ystep.b = 0;  ystep.x = 255;
+    x.r     = x.g     = x.b     = j0;
+    x.x     = 255;
+    xstep.r = xstep.g = xstep.b = 1;
+    xstep.x = 255;
+    ystep.r = ystep.g = ystep.b = 0;
+    ystep.x = 255;
 
     set_rgbx8matrix_param(m, i0, i1, j0, j1, x, xstep, ystep);
-}/*
+}
+
+/*
  * --------------
  * --- autres ---
  * --------------
  */
-/* ------------------------------------------------------------------------------------ */
-IMAGE_EXPORT(void) set_ui8matrix_border1(uint8 **m,int i0, int i1, int j0, int j1, uint8 x)
-/* ------------------------------------------------------------------------------------- */
-{
-	int i;
-	
-	set_ui8vector(m[i0], j0, j1, x);
-	
-	for(i=i0+1; i<=i1-1; i++) {
-		m[i][j0] = x;
-		m[i][j1] = x;
-	}
-	
-	set_ui8vector(m[i0], j0, j1, x);
-}
-/* --------------------------------------------------------------------------------------- */
-IMAGE_EXPORT(void) set_ui8matrix_border(uint8 **m,int i0,int i1,int j0, int j1, int n, uint8 x)
-/* --------------------------------------------------------------------------------------- */
-{
-	int i, j;
-	uint8 *Xi=NULL;
-	
-	for(i=i0; i<i0+n; i++) {
-		Xi = m[i];
-		for(j=j0; j<=j1; j++) {
-			Xi[j] = x;
-		}
-	}
-	
-	for(i=i0+n; i<i1; i++) {
-		Xi = m[i];
-		for(j=0; j<n; j++) {
-			Xi[j0+j] = x;
-			Xi[j1-j] = x;
-		}
-	}
-	
-	for(i=i1-n+1; i<=i1; i++) {
-		Xi = m[i];
-		for(j=j0; j<=j1; j++) {
-			Xi[j] = x;
-		}
-	}
-}
+
+#undef set_type_matrix_border1
+#define set_type_matrix_border1(t) \
+void short_name(t,set_,matrix_border1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, t x) \
+{                                                \
+    short_name(t,set_,vector)(m[i0], j0, j1, x); \
+    for (int32_t i = i0 + 1; i <= i1 - 1; i++) { \
+        m[i][j0] = x;                            \
+        m[i][j1] = x;                            \
+    }                                            \
+    short_name(t,set_,vector)(m[i0], j0, j1, x); \
+}
+
+
+set_type_matrix_border1(int8_t);
+set_type_matrix_border1(uint8_t);
+set_type_matrix_border1(int16_t);
+set_type_matrix_border1(uint16_t);
+set_type_matrix_border1(int32_t);
+set_type_matrix_border1(uint32_t);
+set_type_matrix_border1(int64_t);
+set_type_matrix_border1(uint64_t);
+set_type_matrix_border1(float);
+set_type_matrix_border1(double);
+
+
+#undef set_type_matrix_border
+#define set_type_matrix_border(t) \
+void short_name(t,set_,matrix_border)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t n, t x) \
+{                                                \
+    t * Xi = NULL;                               \
+    for (int32_t i = i0; i < i0 + n; i++) {      \
+        Xi = m[i];                               \
+        for (int32_t j = j0; j <= j1; j++) {     \
+            Xi[j] = x;                           \
+        }                                        \
+    }                                            \
+    for (int32_t i = i0 + n; i < i1; i++) {      \
+        Xi = m[i];                               \
+        for (int32_t j = 0; j < n; j++) {        \
+            Xi[j0 + j] = x;                      \
+            Xi[j1 - j] = x;                      \
+        }                                        \
+    }                                            \
+    for (int32_t i = i1 - n + 1; i <= i1; i++) { \
+        Xi = m[i];                               \
+        for (int32_t j = j0; j <= j1; j++) {     \
+            Xi[j] = x;                           \
+        }                                        \
+    }                                            \
+}
+
+
+set_type_matrix_border(int8_t);
+set_type_matrix_border(uint8_t);
+set_type_matrix_border(int16_t);
+set_type_matrix_border(uint16_t);
+set_type_matrix_border(int32_t);
+set_type_matrix_border(uint32_t);
+set_type_matrix_border(int64_t);
+set_type_matrix_border(uint64_t);
+set_type_matrix_border(float);
+set_type_matrix_border(double);
+
+
+// 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
+
