Ignore:
Timestamp:
Jun 1, 2016, 10:25:43 AM (9 years ago)
Author:
meunier
Message:

In rosenfeld:

  • Updated nrio0, nrio1, nrio2, nrio1f, nrio2f, nrio1x, nrbool1, nrbool2 and nralloc1 in the nrc2 lib in order to use macro-typed functions
  • Updated the simulation script to include performance evaluation with random images, and a script to generate graphs
  • Updated the clock.h to use 64-bit integers, which potentially breaks the printing on the giet
Location:
soft/giet_vm/applications/rosenfeld/nrc2
Files:
2 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/rosenfeld/nrc2/Makefile

    r821 r822  
    77
    88# -- File list ----------
    9 FILE = nralloc1.c, nralloc2.c, nralloc2x.c, nrarith0.c, nrarith1.c, nrarith2.c, nrarith2x.c, nrbool1.c, nrbool2.c, nrhisto.c, nrio0.c, nrio1.c, nrio2.c, nrlinalg.c, nrlut.c, nrmem1.c, nrmem1x.c, nrmem2.c, nrmem2x.c, nrset1.c, nrset2.c, nrset2x.c, nrsort1.c, nrsort2.c, nrwrap1.c, nrwrap2.c
     9FILE = nralloc1.c, nralloc2.c, nralloc2x.c, nrarith0.c, nrarith1.c, nrarith2.c, nrarith2x.c, nrbool1.c, nrbool2.c, nrio0.c, nrio1.c, nrio1x.c, nrio2.c, nrlinalg.c, nrlut.c, nrmem1.c, nrmem1x.c, nrmem2.c, nrmem2x.c, nrset1.c, nrset2.c, nrset2x.c, nrsort1.c, nrsort2.c, nrwrap1.c, nrwrap2.c
     10FILE := $(FILE), nrio1f.c, nrio1xf.c, nrio2f.c # comment if giet
    1011
    1112
     
    1617OBJ_PATH = obj
    1718INC_PATH = include
     19PRODUCT = libnrc2x.a
     20
     21all: checktarget $(PRODUCT)
    1822
    1923ifeq ($(TARGET),giet-vm)
     
    3640CFLAGSCPU := -mips32 -EL -G0 -mhard-float
    3741
     42checktarget:
     43        @if [ -f $(PRODUCT) ] && objdump -f $(PRODUCT) | grep "little" > /dev/null ; then \
     44                echo -ne "" ; \
     45        else \
     46                rm -f $(OBJS) $(PRODUCT) ;\
     47        fi
    3848endif
    3949
     
    5060C_CONFIG_FLAGS = -DCLI
    5161C_INC_FLAGS = -I$(INC_PATH)
     62
     63checktarget:
     64        @if [ -f $(PRODUCT) ] && objdump -f  $(PRODUCT) | grep "86" > /dev/null ; then \
     65                echo -ne "" ; \
     66        else \
     67                rm -f $(OBJS) $(PRODUCT) ;\
     68        fi
    5269
    5370endif
     
    6683
    6784
    68 PRODUCT = libnrc2x.a
    6985
    7086OBJS = $(addprefix $(OBJ_PATH)/, $(addsuffix .o, $(basename $(FILE))))
    7187
    72 all: $(PRODUCT)
    7388
    74 $(OBJ_PATH)/%.o: $(SRC_PATH)/%.c
     89$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c $(INC_PATH)/*.h
    7590        $(CC) -c $(CFLAGS) -o $@ $<
    7691
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrbool1.h

    r772 r822  
    1111#define _NR_BOOL1_H_
    1212
    13 #ifdef __cplusplus
    14 #ifdef PRAGMA_VERBOSE
    15 #pragma message ("C++")
    16 #endif
    17 extern "C" {
    18 #endif
    1913
    20 #ifdef PRAGMA_VERBOSE
    21 //#pragma message("- include nrbool1.h")
    22 #endif
    23 
    24 /* ========================= */
    25 /* === Logical operation === */
    26 /* ========================= */
     14/* ========================== */
     15/* === Logical operations === */
     16/* ========================== */
    2717
    2818/* ----------- */
     
    3020/* ----------- */
    3121/* Y = ! Y */
    32 IMAGE_EXPORT(void) not_bvector    (byte   *X, long ncl, long nch, byte   *Y);
    33 IMAGE_EXPORT(void) not_si8vector  (sint8  *X, long ncl, long nch, sint8  *Y);
    34 IMAGE_EXPORT(void) not_ui8vector  (uint8  *X, long ncl, long nch, uint8  *Y);
    35 IMAGE_EXPORT(void) not_si16vector (sint16 *X, long ncl, long nch, sint16 *Y);
    36 IMAGE_EXPORT(void) not_ui16vector (uint16 *X, long ncl, long nch, uint16 *Y);
    37 IMAGE_EXPORT(void) not_si32vector (sint32 *X, long ncl, long nch, sint32 *Y);
    38 IMAGE_EXPORT(void) not_ui32vector (uint32 *X, long ncl, long nch, uint32 *Y);
    39 IMAGE_EXPORT(void) not_si64vector (sint64 *X, long ncl, long nch, sint64 *Y);
    40 IMAGE_EXPORT(void) not_ui64vector (uint64 *X, long ncl, long nch, uint64 *Y);
    41 IMAGE_EXPORT(void) not_rgb8vector (rgb8   *X, long ncl, long nch, rgb8   *Y);
    42 IMAGE_EXPORT(void) not_rgbx8vector(rgbx8  *X, long ncl, long nch, rgbx8  *Y);
     22
     23#define not_type_vector(t) \
     24void short_name(t,not_,vector)(t * X, int32_t ncl, int32_t nch, t * Y)
     25
     26not_type_vector(int8_t);
     27not_type_vector(uint8_t);
     28not_type_vector(int16_t);
     29not_type_vector(uint16_t);
     30not_type_vector(int32_t);
     31not_type_vector(uint32_t);
     32not_type_vector(int64_t);
     33not_type_vector(uint64_t);
     34not_type_vector(rgb8);
     35not_type_vector(rgbx8);
     36
    4337
    4438/* ---------- */
     
    4741/* Z = X | Y */
    4842
    49 IMAGE_EXPORT(void) or_bvector    (byte   *X, long ncl, long nch, byte   *Y, byte    *Z);
    50 IMAGE_EXPORT(void) or_si8vector  (sint8  *X, long ncl, long nch, sint8  *Y, sint8   *Z);
    51 IMAGE_EXPORT(void) or_ui8vector  (uint8  *X, long ncl, long nch, uint8  *Y, uint8   *Z);
    52 IMAGE_EXPORT(void) or_si16vector (sint16 *X, long ncl, long nch, sint16 *Y, sint16  *Z);
    53 IMAGE_EXPORT(void) or_ui16vector (uint16 *X, long ncl, long nch, uint16 *Y, uint16  *Z);
    54 IMAGE_EXPORT(void) or_si32vector (sint32 *X, long ncl, long nch, sint32 *Y, sint32  *Z);
    55 IMAGE_EXPORT(void) or_ui32vector (uint32 *X, long ncl, long nch, uint32 *Y, uint32  *Z);
    56 IMAGE_EXPORT(void) or_si64vector (sint64 *X, long ncl, long nch, sint64 *Y, sint64  *Z);
    57 IMAGE_EXPORT(void) or_ui64vector (uint64 *X, long ncl, long nch, uint64 *Y, uint64  *Z);
    58 IMAGE_EXPORT(void) or_rgb8vector (rgb8   *X, long ncl, long nch, rgb8   *Y, rgb8    *Z);
    59 IMAGE_EXPORT(void) or_rgbx8vector(rgbx8  *X, long ncl, long nch, rgbx8  *Y, rgbx8   *Z);
     43#define or_type_vector(t) \
     44void short_name(t,or_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z); \
     45void short_name(t,orc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z)
    6046
    61 IMAGE_EXPORT(void) orc_bvector    (byte   *X, long ncl, long nch, byte   y, byte    *Z);
    62 IMAGE_EXPORT(void) orc_si8vector  (sint8  *X, long ncl, long nch, sint8  y, sint8   *Z);
    63 IMAGE_EXPORT(void) orc_ui8vector  (uint8  *X, long ncl, long nch, uint8  y, uint8   *Z);
    64 IMAGE_EXPORT(void) orc_si16vector (sint16 *X, long ncl, long nch, sint16 y, sint16  *Z);
    65 IMAGE_EXPORT(void) orc_ui16vector (uint16 *X, long ncl, long nch, uint16 y, uint16  *Z);
    66 IMAGE_EXPORT(void) orc_si32vector (sint32 *X, long ncl, long nch, sint32 y, sint32  *Z);
    67 IMAGE_EXPORT(void) orc_ui32vector (uint32 *X, long ncl, long nch, uint32 y, uint32  *Z);
    68 IMAGE_EXPORT(void) orc_si64vector (sint64 *X, long ncl, long nch, sint64 y, sint64  *Z);
    69 IMAGE_EXPORT(void) orc_ui64vector (uint64 *X, long ncl, long nch, uint64 y, uint64  *Z);
    70 IMAGE_EXPORT(void) orc_rgb8vector (rgb8   *X, long ncl, long nch, rgb8   y, rgb8    *Z);
    71 IMAGE_EXPORT(void) orc_rgbx8vector(rgbx8  *X, long ncl, long nch, rgbx8  y, rgbx8   *Z);
     47or_type_vector(int8_t);
     48or_type_vector(uint8_t);
     49or_type_vector(int16_t);
     50or_type_vector(uint16_t);
     51or_type_vector(int32_t);
     52or_type_vector(uint32_t);
     53or_type_vector(int64_t);
     54or_type_vector(uint64_t);
     55or_type_vector(rgb8);
     56or_type_vector(rgbx8);
     57
    7258
    7359/* ----------- */
     
    7662/* Z = X ^ Y */
    7763
    78 IMAGE_EXPORT(void) xor_bvector    (byte   *X, long ncl, long nch, byte   *Y, byte    *Z);
    79 IMAGE_EXPORT(void) xor_si8vector  (sint8  *X, long ncl, long nch, sint8  *Y, sint8   *Z);
    80 IMAGE_EXPORT(void) xor_ui8vector  (uint8  *X, long ncl, long nch, uint8  *Y, uint8   *Z);
    81 IMAGE_EXPORT(void) xor_si16vector (sint16 *X, long ncl, long nch, sint16 *Y, sint16  *Z);
    82 IMAGE_EXPORT(void) xor_ui16vector (uint16 *X, long ncl, long nch, uint16 *Y, uint16  *Z);
    83 IMAGE_EXPORT(void) xor_si32vector (sint32 *X, long ncl, long nch, sint32 *Y, sint32  *Z);
    84 IMAGE_EXPORT(void) xor_ui32vector (uint32 *X, long ncl, long nch, uint32 *Y, uint32  *Z);
    85 IMAGE_EXPORT(void) xor_si64vector (sint64 *X, long ncl, long nch, sint64 *Y, sint64  *Z);
    86 IMAGE_EXPORT(void) xor_ui64vector (uint64 *X, long ncl, long nch, uint64 *Y, uint64  *Z);
    87 IMAGE_EXPORT(void) xor_rgb8vector (rgb8   *X, long ncl, long nch, rgb8   *Y, rgb8    *Z);
    88 IMAGE_EXPORT(void) xor_rgbx8vector(rgbx8  *X, long ncl, long nch, rgbx8  *Y, rgbx8   *Z);
     64#define xor_type_vector(t) \
     65void short_name(t,xor_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z); \
     66void short_name(t,xorc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z)
    8967
    90 IMAGE_EXPORT(void) xorc_bvector    (byte   *X, long ncl, long nch, byte   y, byte    *Z);
    91 IMAGE_EXPORT(void) xorc_si8vector  (sint8  *X, long ncl, long nch, sint8  y, sint8   *Z);
    92 IMAGE_EXPORT(void) xorc_ui8vector  (uint8  *X, long ncl, long nch, uint8  y, uint8   *Z);
    93 IMAGE_EXPORT(void) xorc_si16vector (sint16 *X, long ncl, long nch, sint16 y, sint16  *Z);
    94 IMAGE_EXPORT(void) xorc_ui16vector (uint16 *X, long ncl, long nch, uint16 y, uint16  *Z);
    95 IMAGE_EXPORT(void) xorc_si32vector (sint32 *X, long ncl, long nch, sint32 y, sint32  *Z);
    96 IMAGE_EXPORT(void) xorc_ui32vector (uint32 *X, long ncl, long nch, uint32 y, uint32  *Z);
    97 IMAGE_EXPORT(void) xorc_si64vector (sint64 *X, long ncl, long nch, sint64 y, sint64  *Z);
    98 IMAGE_EXPORT(void) xorc_ui64vector (uint64 *X, long ncl, long nch, uint64 y, uint64  *Z);
    99 IMAGE_EXPORT(void) xorc_rgb8vector (rgb8   *X, long ncl, long nch, rgb8   y, rgb8    *Z);
    100 IMAGE_EXPORT(void) xorc_rgbx8vector(rgbx8  *X, long ncl, long nch, rgbx8  y, rgbx8   *Z);
     68xor_type_vector(int8_t);
     69xor_type_vector(uint8_t);
     70xor_type_vector(int16_t);
     71xor_type_vector(uint16_t);
     72xor_type_vector(int32_t);
     73xor_type_vector(uint32_t);
     74xor_type_vector(int64_t);
     75xor_type_vector(uint64_t);
     76xor_type_vector(rgb8);
     77xor_type_vector(rgbx8);
     78
    10179
    10280/* ----------- */
     
    10583/* Z = X & Y */
    10684
    107 IMAGE_EXPORT(void) and_bvector    (byte   *X, long ncl, long nch, byte   *Y, byte    *Z);
    108 IMAGE_EXPORT(void) and_si8vector  (sint8  *X, long ncl, long nch, sint8  *Y, sint8   *Z);
    109 IMAGE_EXPORT(void) and_ui8vector  (uint8  *X, long ncl, long nch, uint8  *Y, uint8   *Z);
    110 IMAGE_EXPORT(void) and_si16vector (sint16 *X, long ncl, long nch, sint16 *Y, sint16  *Z);
    111 IMAGE_EXPORT(void) and_ui16vector (uint16 *X, long ncl, long nch, uint16 *Y, uint16  *Z);
    112 IMAGE_EXPORT(void) and_si32vector (sint32 *X, long ncl, long nch, sint32 *Y, sint32  *Z);
    113 IMAGE_EXPORT(void) and_ui32vector (uint32 *X, long ncl, long nch, uint32 *Y, uint32  *Z);
    114 IMAGE_EXPORT(void) and_si64vector (sint64 *X, long ncl, long nch, sint64 *Y, sint64  *Z);
    115 IMAGE_EXPORT(void) and_ui64vector (uint64 *X, long ncl, long nch, uint64 *Y, uint64  *Z);
    116 IMAGE_EXPORT(void) and_rgb8vector (rgb8   *X, long ncl, long nch, rgb8   *Y, rgb8    *Z);
    117 IMAGE_EXPORT(void) and_rgbx8vector(rgbx8  *X, long ncl, long nch, rgbx8  *Y, rgbx8   *Z);
     85#define and_type_vector(t) \
     86void short_name(t,and_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z); \
     87void short_name(t,andc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z)
    11888
    119 IMAGE_EXPORT(void) andc_bvector    (byte   *X, long ncl, long nch, byte   y, byte    *Z);
    120 IMAGE_EXPORT(void) andc_si8vector  (sint8  *X, long ncl, long nch, sint8  y, sint8   *Z);
    121 IMAGE_EXPORT(void) andc_ui8vector  (uint8  *X, long ncl, long nch, uint8  y, uint8   *Z);
    122 IMAGE_EXPORT(void) andc_si16vector (sint16 *X, long ncl, long nch, sint16 y, sint16  *Z);
    123 IMAGE_EXPORT(void) andc_ui16vector (uint16 *X, long ncl, long nch, uint16 y, uint16  *Z);
    124 IMAGE_EXPORT(void) andc_si32vector (sint32 *X, long ncl, long nch, sint32 y, sint32  *Z);
    125 IMAGE_EXPORT(void) andc_ui32vector (uint32 *X, long ncl, long nch, uint32 y, uint32  *Z);
    126 IMAGE_EXPORT(void) andc_si64vector (sint64 *X, long ncl, long nch, sint64 y, sint64  *Z);
    127 IMAGE_EXPORT(void) andc_ui64vector (uint64 *X, long ncl, long nch, uint64 y, uint64  *Z);
    128 IMAGE_EXPORT(void) andc_rgb8vector (rgb8   *X, long ncl, long nch, rgb8   y, rgb8    *Z);
    129 IMAGE_EXPORT(void) andc_rgbx8vector(rgbx8  *X, long ncl, long nch, rgbx8  y, rgbx8   *Z);
     89and_type_vector(int8_t);
     90and_type_vector(uint8_t);
     91and_type_vector(int16_t);
     92and_type_vector(uint16_t);
     93and_type_vector(int32_t);
     94and_type_vector(uint32_t);
     95and_type_vector(int64_t);
     96and_type_vector(uint64_t);
     97and_type_vector(rgb8);
     98and_type_vector(rgbx8);
    13099
    131100
    132 #ifdef __cplusplus
    133 }
    134 #endif
     101#endif // _NR_BOOL1_H_
    135102
    136 #endif // _NR_BOOL1_H_
     103// Local Variables:
     104// tab-width: 4
     105// c-basic-offset: 4
     106// c-file-offsets:((innamespace . 0)(inline-open . 0))
     107// indent-tabs-mode: nil
     108// End:
     109
     110// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     111
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrbool2.h

    r772 r822  
    1111#define _NR_BOOL2_H_
    1212
    13 #ifdef __cplusplus
    14 #ifdef PRAGMA_VERBOSE
    15 #pragma message ("C++")
    16 #endif
    17 extern "C" {
    18 #endif
     13#include "nrc_os_config.h"
    1914
    20 #ifdef PRAGMA_VERBOSE
    21 //#pragma message("- include nrbool2.h")
    22 #endif
    2315
    24 IMAGE_EXPORT(int) cmpeq_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y);
    25 IMAGE_EXPORT(int) cmpeq_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y);
    26 IMAGE_EXPORT(int) cmpeq_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y);
    27 IMAGE_EXPORT(int) cmpeq_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y);
    28 IMAGE_EXPORT(int) cmpeq_ui16matrix(uint16 **X, long nrl, long nrh, long ncl, long nch, uint16 **Y);
    29 IMAGE_EXPORT(int) cmpeq_si32matrix(sint32 **X, long nrl, long nrh, long ncl, long nch, sint32 **Y);
    30 IMAGE_EXPORT(int) cmpeq_ui32matrix(uint32 **X, long nrl, long nrh, long ncl, long nch, uint32 **Y);
     16#define cmpeq_type_matrix(t) \
     17int32_t short_name(t,cmpeq_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y)
     18
     19cmpeq_type_matrix(int8_t);
     20cmpeq_type_matrix(uint8_t);
     21cmpeq_type_matrix(int16_t);
     22cmpeq_type_matrix(uint16_t);
     23cmpeq_type_matrix(int32_t);
     24cmpeq_type_matrix(uint32_t);
     25cmpeq_type_matrix(int64_t);
     26cmpeq_type_matrix(uint64_t);
    3127
    3228
     
    3733 */
    3834
    39 IMAGE_EXPORT(void) not_bmatrix    (byte   **X, long nrl,long nrh,long ncl, long nch, byte   **Y);
    40 IMAGE_EXPORT(void) not_si8matrix  (sint8  **X, long nrl,long nrh,long ncl, long nch, sint8  **Y);
    41 IMAGE_EXPORT(void) not_ui8matrix  (uint8  **X, long nrl,long nrh,long ncl, long nch, uint8  **Y);
    42 IMAGE_EXPORT(void) not_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y);
    43 IMAGE_EXPORT(void) not_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y);
    44 IMAGE_EXPORT(void) not_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y);
    45 IMAGE_EXPORT(void) not_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y);
    46 IMAGE_EXPORT(void) not_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y);
    47 IMAGE_EXPORT(void) not_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y);
    48 IMAGE_EXPORT(void) not_rgb8matrix (rgb8   **X, long nrl,long nrh,long ncl, long nch, rgb8   **Y);
    49 IMAGE_EXPORT(void) not_rgbx8matrix(rgbx8  **X, long nrl,long nrh,long ncl, long nch, rgbx8  **Y);
     35#define not_type_matrix(t) \
     36void short_name(t,not_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y)
     37
     38not_type_matrix(int8_t);
     39not_type_matrix(uint8_t);
     40not_type_matrix(int16_t);
     41not_type_matrix(uint16_t);
     42not_type_matrix(int32_t);
     43not_type_matrix(uint32_t);
     44not_type_matrix(int64_t);
     45not_type_matrix(uint64_t);
     46not_type_matrix(rgb8);
     47not_type_matrix(rgbx8);
     48
    5049
    5150/*
     
    5554 */
    5655
    57 IMAGE_EXPORT(void) or_bmatrix    (byte   **X, long nrl,long nrh,long ncl, long nch, byte   **Y, byte    **Z);
    58 IMAGE_EXPORT(void) or_si8matrix  (sint8  **X, long nrl,long nrh,long ncl, long nch, sint8  **Y, sint8   **Z);
    59 IMAGE_EXPORT(void) or_ui8matrix  (uint8  **X, long nrl,long nrh,long ncl, long nch, uint8  **Y, uint8   **Z);
    60 IMAGE_EXPORT(void) or_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16  **Z);
    61 IMAGE_EXPORT(void) or_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16  **Z);
    62 IMAGE_EXPORT(void) or_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32  **Z);
    63 IMAGE_EXPORT(void) or_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32  **Z);
    64 IMAGE_EXPORT(void) or_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64  **Z);
    65 IMAGE_EXPORT(void) or_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64  **Z);
    66 IMAGE_EXPORT(void) or_rgb8matrix (rgb8   **X, long nrl,long nrh,long ncl, long nch, rgb8   **Y, rgb8    **Z);
    67 IMAGE_EXPORT(void) or_rgbx8matrix(rgbx8  **X, long nrl,long nrh,long ncl, long nch, rgbx8  **Y, rgbx8   **Z);
     56#define or_type_matrix(t) \
     57void short_name(t,or_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z); \
     58void short_name(t,orc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z)
    6859
    69 IMAGE_EXPORT(void) orc_bmatrix    (byte   **X, long nrl,long nrh,long ncl, long nch, byte   y, byte    **Z);
    70 IMAGE_EXPORT(void) orc_si8matrix  (sint8  **X, long nrl,long nrh,long ncl, long nch, sint8  y, sint8   **Z);
    71 IMAGE_EXPORT(void) orc_ui8matrix  (uint8  **X, long nrl,long nrh,long ncl, long nch, uint8  y, uint8   **Z);
    72 IMAGE_EXPORT(void) orc_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16  **Z);
    73 IMAGE_EXPORT(void) orc_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16  **Z);
    74 IMAGE_EXPORT(void) orc_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32  **Z);
    75 IMAGE_EXPORT(void) orc_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32  **Z);
    76 IMAGE_EXPORT(void) orc_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64  **Z);
    77 IMAGE_EXPORT(void) orc_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64  **Z);
    78 IMAGE_EXPORT(void) orc_rgb8matrix (rgb8   **X, long nrl,long nrh,long ncl, long nch, rgb8   y, rgb8    **Z);
    79 IMAGE_EXPORT(void) orc_rgbx8matrix(rgbx8  **X, long nrl,long nrh,long ncl, long nch, rgbx8  y, rgbx8   **Z);
     60or_type_matrix(int8_t);
     61or_type_matrix(uint8_t);
     62or_type_matrix(int16_t);
     63or_type_matrix(uint16_t);
     64or_type_matrix(int32_t);
     65or_type_matrix(uint32_t);
     66or_type_matrix(int64_t);
     67or_type_matrix(uint64_t);
     68or_type_matrix(rgb8);
     69or_type_matrix(rgbx8);
     70
    8071
    8172/*
     
    8576 */
    8677
    87 IMAGE_EXPORT(void) xor_bmatrix    (byte   **X, long nrl,long nrh,long ncl, long nch, byte   **Y, byte    **Z);
    88 IMAGE_EXPORT(void) xor_si8matrix  (sint8  **X, long nrl,long nrh,long ncl, long nch, sint8  **Y, sint8   **Z);
    89 IMAGE_EXPORT(void) xor_ui8matrix  (uint8  **X, long nrl,long nrh,long ncl, long nch, uint8  **Y, uint8   **Z);
    90 IMAGE_EXPORT(void) xor_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16  **Z);
    91 IMAGE_EXPORT(void) xor_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16  **Z);
    92 IMAGE_EXPORT(void) xor_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32  **Z);
    93 IMAGE_EXPORT(void) xor_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32  **Z);
    94 IMAGE_EXPORT(void) xor_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64  **Z);
    95 IMAGE_EXPORT(void) xor_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64  **Z);
    96 IMAGE_EXPORT(void) xor_rgb8matrix (rgb8   **X, long nrl,long nrh,long ncl, long nch, rgb8   **Y, rgb8    **Z);
    97 IMAGE_EXPORT(void) xor_rgbx8matrix(rgbx8  **X, long nrl,long nrh,long ncl, long nch, rgbx8  **Y, rgbx8   **Z);
     78#define xor_type_matrix(t) \
     79void short_name(t,xor_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z); \
     80void short_name(t,xorc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z)
    9881
    99 IMAGE_EXPORT(void) xorc_bmatrix    (byte   **X, long nrl,long nrh,long ncl, long nch, byte   y, byte    **Z);
    100 IMAGE_EXPORT(void) xorc_si8matrix  (sint8  **X, long nrl,long nrh,long ncl, long nch, sint8  y, sint8   **Z);
    101 IMAGE_EXPORT(void) xorc_ui8matrix  (uint8  **X, long nrl,long nrh,long ncl, long nch, uint8  y, uint8   **Z);
    102 IMAGE_EXPORT(void) xorc_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16  **Z);
    103 IMAGE_EXPORT(void) xorc_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16  **Z);
    104 IMAGE_EXPORT(void) xorc_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32  **Z);
    105 IMAGE_EXPORT(void) xorc_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32  **Z);
    106 IMAGE_EXPORT(void) xorc_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64  **Z);
    107 IMAGE_EXPORT(void) xorc_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64  **Z);
    108 IMAGE_EXPORT(void) xorc_rgb8matrix (rgb8   **X, long nrl,long nrh,long ncl, long nch, rgb8   y, rgb8    **Z);
    109 IMAGE_EXPORT(void) xorc_rgbx8matrix(rgbx8  **X, long nrl,long nrh,long ncl, long nch, rgbx8  y, rgbx8   **Z);
     82xor_type_matrix(int8_t);
     83xor_type_matrix(uint8_t);
     84xor_type_matrix(int16_t);
     85xor_type_matrix(uint16_t);
     86xor_type_matrix(int32_t);
     87xor_type_matrix(uint32_t);
     88xor_type_matrix(int64_t);
     89xor_type_matrix(uint64_t);
     90xor_type_matrix(rgb8);
     91xor_type_matrix(rgbx8);
     92
    11093
    11194/*
    112  * -----------
     95 * ----------
    11396 * --- And ---
    114  * -----------
     97 * ----------
    11598 */
    11699
    117 IMAGE_EXPORT(void) and_bmatrix    (byte   **X, long nrl,long nrh,long ncl, long nch, byte   **Y, byte    **Z);
    118 IMAGE_EXPORT(void) and_si8matrix  (sint8  **X, long nrl,long nrh,long ncl, long nch, sint8  **Y, sint8   **Z);
    119 IMAGE_EXPORT(void) and_ui8matrix  (uint8  **X, long nrl,long nrh,long ncl, long nch, uint8  **Y, uint8   **Z);
    120 IMAGE_EXPORT(void) and_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16  **Z);
    121 IMAGE_EXPORT(void) and_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16  **Z);
    122 IMAGE_EXPORT(void) and_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32  **Z);
    123 IMAGE_EXPORT(void) and_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32  **Z);
    124 IMAGE_EXPORT(void) and_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64  **Z);
    125 IMAGE_EXPORT(void) and_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64  **Z);
    126 IMAGE_EXPORT(void) and_rgb8matrix (rgb8   **X, long nrl,long nrh,long ncl, long nch, rgb8   **Y, rgb8    **Z);
    127 IMAGE_EXPORT(void) and_rgbx8matrix(rgbx8  **X, long nrl,long nrh,long ncl, long nch, rgbx8  **Y, rgbx8   **Z);
     100#define and_type_matrix(t) \
     101void short_name(t,and_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z); \
     102void short_name(t,andc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z)
    128103
    129 IMAGE_EXPORT(void) andc_bmatrix    (byte   **X, long nrl,long nrh,long ncl, long nch, byte   y, byte    **Z);
    130 IMAGE_EXPORT(void) andc_si8matrix  (sint8  **X, long nrl,long nrh,long ncl, long nch, sint8  y, sint8   **Z);
    131 IMAGE_EXPORT(void) andc_ui8matrix  (uint8  **X, long nrl,long nrh,long ncl, long nch, uint8  y, uint8   **Z);
    132 IMAGE_EXPORT(void) andc_si16matrix (sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16  **Z);
    133 IMAGE_EXPORT(void) andc_ui16matrix (uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16  **Z);
    134 IMAGE_EXPORT(void) andc_si32matrix (sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32  **Z);
    135 IMAGE_EXPORT(void) andc_ui32matrix (uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32  **Z);
    136 IMAGE_EXPORT(void) andc_si64matrix (sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64  **Z);
    137 IMAGE_EXPORT(void) andc_ui64matrix (uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64  **Z);
    138 IMAGE_EXPORT(void) andc_rgb8matrix (rgb8   **X, long nrl,long nrh,long ncl, long nch, rgb8   y, rgb8    **Z);
    139 IMAGE_EXPORT(void) andc_rgbx8matrix(rgbx8  **X, long nrl,long nrh,long ncl, long nch, rgbx8  y, rgbx8   **Z);
     104and_type_matrix(int8_t);
     105and_type_matrix(uint8_t);
     106and_type_matrix(int16_t);
     107and_type_matrix(uint16_t);
     108and_type_matrix(int32_t);
     109and_type_matrix(uint32_t);
     110and_type_matrix(int64_t);
     111and_type_matrix(uint64_t);
     112and_type_matrix(rgb8);
     113and_type_matrix(rgbx8);
    140114
    141 #ifdef __cplusplus
    142 }
    143 #endif
    144115
    145116#endif // _NR_BOOL2_H_
     117
     118// Local Variables:
     119// tab-width: 4
     120// c-basic-offset: 4
     121// c-file-offsets:((innamespace . 0)(inline-open . 0))
     122// indent-tabs-mode: nil
     123// End:
     124
     125// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     126
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio.h

    r772 r822  
    1111#define __NRIO_H__
    1212
    13 #ifdef __cplusplus
    14 #pragma message ("C++")
    15 extern "C" {
    16 #endif
    17    
    18 #ifdef VERBOSE_PRAGMA
    19 //#pragma message ("- *** include nrio.h ***")
    20 #endif
    21 
    2213#include "nrio0.h"
    2314#include "nrio1.h"
     
    2516#include "nrio3.h"
    2617
    27 #ifdef __cplusplus
    28 }
    29 #endif
    30 
    3118#endif // __NRIO_H__
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio0.h

    r777 r822  
    1111#define _NR_IO0_H_
    1212
    13 #ifdef __cplusplus
    14 #pragma message ("C++")
    15 extern "C" {
    16 #endif
    17    
    18 #ifdef VERBOSE_PRAGMA
    19 //#pragma message ("- *** include nrio0.h ***")
    20 #endif
     13void generate_filename_k_ndigit          (char * filename, int k, int ndigit,                   char * complete_filename, int maxlen);
     14void generate_filename_k_ndigit_extension(char * filename, int k, int ndigit, char * extension, char * complete_filename, int maxlen);
    2115
    22 IMAGE_EXPORT(void) generate_filename_k_ndigit          (char *filename, int k, int ndigit,                  char *complete_filename, int maxlen);
    23 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen);
     16void generate_path_filename                     (char * path, char * filename,                                             char * complete_filename, int maxlen);
     17void generate_path_filename_extension           (char * path, char * filename,                           char * extension, char * complete_filename, int maxlen);
     18void generate_path_filename_suffix_extension    (char * path, char * filename, char * suffix,            char * extension, char * complete_filename, int maxlen);
     19void generate_path_filename_k_ndigit_extension  (char * path, char * filename, int k, int ndigit,        char * extension, char * complete_filename, int maxlen);
     20void generate_path_filename_k_ndigit_l_extension(char * path, char * filename, int k, int ndigit, int l, char * extension, char * complete_filename, int maxlen);
    2421
    25 IMAGE_EXPORT(void) generate_path_filename                     (char *path, char *filename,                                            char *complete_filename, int maxlen);
    26 IMAGE_EXPORT(void) generate_path_filename_extension           (char *path, char *filename,                           char *extension, char *complete_filename, int maxlen);
    27 IMAGE_EXPORT(void) generate_path_filename_suffix_extension    (char *path, char *filename, char *suffix,             char *extension, char *complete_filename, int maxlen);
    28 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension  (char *path, char *filename, int k, int ndigit,        char *extension, char *complete_filename, int maxlen);
    29 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename, int maxlen);
     22void select_display_positive_parameters(int iformat, char ** format, char ** str);
    3023
    31 void select_display_positive_parameters(int iformat, char **format, char **str);
    32 
    33 #ifdef __cplusplus
    34 }
    35 #endif
    3624
    3725#endif // _NR_IO0_H_
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio1.h

    r772 r822  
    1111#define _NR_IO1_H_
    1212
    13 #ifdef __cplusplus
    14 #pragma message ("C++")
    15 extern "C" {
    16 #endif
    17    
    18 #ifdef VERBOSE_PRAGMA
    19 //#pragma message ("- *** include nrio1.h ***")
    20 #endif
    21 
    2213/*
    23  * ----------------------
    24  * --- display_vector ---
    25  * ----------------------
     14 * -----------------------------------------------------------------------------------
     15 * --- display_vector + display_vector_number + display_vector_T + vector_number_T ---
     16 * -----------------------------------------------------------------------------------
    2617 */
    2718
    28 IMAGE_EXPORT(void) display_bvector    (byte    *v, long nl,long nh, char *format, char *name);
    29 IMAGE_EXPORT(void) display_si8vector  (sint8   *v, long nl,long nh, char *format, char *name);
    30 IMAGE_EXPORT(void) display_ui8vector  (uint8   *v, long nl,long nh, char *format, char *name);
    31 IMAGE_EXPORT(void) display_si16vector (sint16  *v, long nl,long nh, char *format, char *name);
    32 IMAGE_EXPORT(void) display_ui16vector (uint16  *v, long nl,long nh, char *format, char *name);
    33 IMAGE_EXPORT(void) display_si32vector (sint32  *v, long nl,long nh, char *format, char *name);
    34 IMAGE_EXPORT(void) display_ui32vector (uint32  *v, long nl,long nh, char *format, char *name);
    35 IMAGE_EXPORT(void) display_si64vector (sint64  *v, long nl,long nh, char *format, char *name);
    36 IMAGE_EXPORT(void) display_ui64vector (uint64  *v, long nl,long nh, char *format, char *name);
     19#define display_type_vector(t) \
     20void short_name(t,display_,vector)(t * v, int32_t nl, int32_t nh, char * format, char * name); \
     21void short_name(t,display_,vector_number)(t * v, int32_t nl, int32_t nh, char * format, char * name); \
     22void short_name(t,display_,vector_T)(t * v, int32_t i0, int32_t i1, char * format, char * name); \
     23void short_name(t,display_,vector_number_T)(t * v, int32_t i0, int32_t i1, char * format, char * name)
    3724
    38 IMAGE_EXPORT(void) display_f32vector  (float32 *v, long nl,long nh, char *format, char *name);
    39 IMAGE_EXPORT(void) display_f64vector  (float64 *v, long nl,long nh, char *format, char *name);
     25display_type_vector(int8_t);
     26display_type_vector(uint8_t);
     27display_type_vector(int16_t);
     28display_type_vector(uint16_t);
     29display_type_vector(int32_t);
     30display_type_vector(uint32_t);
     31display_type_vector(int64_t);
     32display_type_vector(uint64_t);
     33display_type_vector(float);
     34display_type_vector(double);
     35display_type_vector(rgb8);
     36display_type_vector(rgbx8);
    4037
    41 IMAGE_EXPORT(void) display_rgb8vector (rgb8    *v, long nl,long nh, char *format, char *name);
    42 IMAGE_EXPORT(void) display_rgbx8vector(rgbx8   *v, long nl,long nh, char *format, char *name);
    43 
    44 /*
    45  * -----------------------------
    46  * --- display_vector_number ---
    47  * -----------------------------
    48  */
    49 
    50 IMAGE_EXPORT(void) display_bvector_number    (byte    *v, long nl,long nh, char *format, char *name);
    51 IMAGE_EXPORT(void) display_si8vector_number  (sint8   *v, long nl,long nh, char *format, char *name);
    52 IMAGE_EXPORT(void) display_ui8vector_number  (uint8   *v, long nl,long nh, char *format, char *name);
    53 IMAGE_EXPORT(void) display_si16vector_number (sint16  *v, long nl,long nh, char *format, char *name);
    54 IMAGE_EXPORT(void) display_ui16vector_number (uint16  *v, long nl,long nh, char *format, char *name);
    55 IMAGE_EXPORT(void) display_si32vector_number (sint32  *v, long nl,long nh, char *format, char *name);
    56 IMAGE_EXPORT(void) display_ui32vector_number (uint32  *v, long nl,long nh, char *format, char *name);
    57 IMAGE_EXPORT(void) display_si64vector_number (sint64  *v, long nl,long nh, char *format, char *name);
    58 IMAGE_EXPORT(void) display_ui64vector_number (uint64  *v, long nl,long nh, char *format, char *name);
    59 
    60 IMAGE_EXPORT(void) display_f32vector_number  (float32 *v, long nl,long nh, char *format, char *name);
    61 IMAGE_EXPORT(void) display_f64vector_number  (float64 *v, long nl,long nh, char *format, char *name);
    62 
    63 IMAGE_EXPORT(void) display_rgb8vector_number (rgb8    *v, long nl,long nh, char *format, char *name);
    64 IMAGE_EXPORT(void) display_rgbx8vector_number(rgbx8   *v, long nl,long nh, char *format, char *name);
    65 
    66 /*
    67  * ------------------------
    68  * --- display_vector_T ---
    69  * ------------------------
    70  */
    71 
    72 IMAGE_EXPORT(void) display_si8vector_T  (sint8   *v,int i0, int i1, char *format, char *name);
    73 IMAGE_EXPORT(void) display_ui8vector_T  (uint8   *v,int i0, int i1, char *format, char *name);
    74 IMAGE_EXPORT(void) display_si16vector_T (sint16  *v,int i0, int i1, char *format, char *name);
    75 IMAGE_EXPORT(void) display_ui16vector_T (uint16  *v,int i0, int i1, char *format, char *name);
    76 IMAGE_EXPORT(void) display_si32vector_T (sint32  *v,int i0, int i1, char *format, char *name);
    77 IMAGE_EXPORT(void) display_ui32vector_T (uint32  *v,int i0, int i1, char *format, char *name);
    78 IMAGE_EXPORT(void) display_si64vector_T (sint64  *v,int i0, int i1, char *format, char *name);
    79 IMAGE_EXPORT(void) display_ui64vector_T (uint64  *v,int i0, int i1, char *format, char *name);
    80 
    81 IMAGE_EXPORT(void) display_f32vector_T  (float32 *v,int i0, int i1, char *format, char *name);
    82 IMAGE_EXPORT(void) display_f64vector_T  (float64 *v,int i0, int i1, char *format, char *name);
    83 
    84 IMAGE_EXPORT(void) display_rgb8vector_T (rgb8    *v, int i0, int i1, char *format, char *name);
    85 IMAGE_EXPORT(void) display_rgbx8vector_T(rgbx8   *v, int i0, int i1, char *format, char *name);
    86 
    87 /*
    88  * -------------------------------
    89  * --- display_vector_number_T ---
    90  * -------------------------------
    91  */
    92 
    93 IMAGE_EXPORT(void) display_si8vector_number_T (sint8   *v,int i0, int i1, char *format, char *name);
    94 IMAGE_EXPORT(void) display_ui8vector_number_T (uint8   *v,int i0, int i1, char *format, char *name);
    95 IMAGE_EXPORT(void) display_si16vector_number_T(sint16  *v,int i0, int i1, char *format, char *name);
    96 IMAGE_EXPORT(void) display_ui16vector_number_T(uint16  *v,int i0, int i1, char *format, char *name);
    97 IMAGE_EXPORT(void) display_si32vector_number_T(sint32  *v,int i0, int i1, char *format, char *name);
    98 IMAGE_EXPORT(void) display_ui32vector_number_T(uint32  *v,int i0, int i1, char *format, char *name);
    99 IMAGE_EXPORT(void) display_si64vector_number_T(sint64  *v,int i0, int i1, char *format, char *name);
    100 IMAGE_EXPORT(void) display_ui64vector_number_T(uint64  *v,int i0, int i1, char *format, char *name);
    101 
    102 IMAGE_EXPORT(void) display_f32vector_number_T (float32 *v,int i0, int i1, char *format, char *name);
    103 IMAGE_EXPORT(void) display_f64vector_number_T (float64 *v,int i0, int i1, char *format, char *name);
    104 
    105 IMAGE_EXPORT(void) display_rgb8vector_number_T (rgb8  *v,int i0, int i1, char *format, char *name);
    106 IMAGE_EXPORT(void) display_rgbx8vector_number_T(rgbx8 *v,int i0, int i1, char *format, char *name);
    10738
    10839/*
     
    11142 * -------------------------------
    11243 */
    113    
    114 void display_ui8vector_positive (uint8  *v, int j0, int j1, int iformat, char *name);
    115 void display_ui16vector_positive(uint16 *v, int j0, int j1, int iformat, char *name);
    116 void display_ui32vector_positive(uint32 *v, int j0, int j1, int iformat, char *name);
    117    
     44
     45#undef display_type_vector_positive
     46#define display_type_vector_positive(t) \
     47void short_name(t,display_,vector_positive)(t * v, int32_t j0, int32_t j1, int32_t iformat, char * name)
     48
     49display_type_vector_positive(int8_t);
     50display_type_vector_positive(uint8_t);
     51display_type_vector_positive(int16_t);
     52display_type_vector_positive(uint16_t);
     53display_type_vector_positive(int32_t);
     54display_type_vector_positive(uint32_t);
     55display_type_vector_positive(int64_t);
     56display_type_vector_positive(uint64_t);
     57display_type_vector_positive(float);
     58display_type_vector_positive(double);
     59
     60 
    11861/*
    11962 * --------------------
    12063 * --- write_vector ---
     64 * --- write_vector_T ---
     65 * --- write_vector_number ---
     66 * --- write_vector_T_number ---
     67 * --- fread_vector ---
     68 * --- fwrite_vector ---
    12169 * --------------------
    12270 */
    12371
    124 IMAGE_EXPORT(void) write_si8vector  (sint8   *v,long nl,long nh, char *format, char *filename);
    125 IMAGE_EXPORT(void) write_ui8vector  (uint8   *v,long nl,long nh, char *format, char *filename);
    126 IMAGE_EXPORT(void) write_si16vector (sint16  *v,long nl,long nh, char *format, char *filename);
    127 IMAGE_EXPORT(void) write_ui16vector (uint16  *v,long nl,long nh, char *format, char *filename);
    128 IMAGE_EXPORT(void) write_si32vector (sint32  *v,long nl,long nh, char *format, char *filename);
    129 IMAGE_EXPORT(void) write_ui32vector (uint32  *v,long nl,long nh, char *format, char *filename);
    130 IMAGE_EXPORT(void) write_si64vector (sint64  *v,long nl,long nh, char *format, char *filename);
    131 IMAGE_EXPORT(void) write_ui64vector (uint64  *v,long nl,long nh, char *format, char *filename);
     72#define write_type_vector(t) \
     73void short_name(t,write_,vector)(t * v, int32_t nl, int32_t nh, char * format, char * filename); \
     74void short_name(t,write_,vector_T)(t * v, int32_t nl, int32_t nh, char * format, char * filename); \
     75void short_name(t,write_,vector_number)(t * v, int32_t nl, int32_t nh, char * format, char * filename); \
     76void short_name(t,write_,vector_T_number)(t * v, int32_t nl, int32_t nh, char * format, char * filename); \
     77void short_name(t,fread_,vector)(char * filename, t * v, int32_t nl, int32_t nh); \
     78void short_name(t,fwrite_,vector)(t * v, int32_t nl, int32_t nh, char * filename) \
    13279
    133 IMAGE_EXPORT(void) write_f32vector  (float32 *v,long nl,long nh, char *format, char *filename);
    134 IMAGE_EXPORT(void) write_f64vector  (float64 *v,long nl,long nh, char *format, char *filename);
     80write_type_vector(int8_t);
     81write_type_vector(uint8_t);
     82write_type_vector(int16_t);
     83write_type_vector(uint16_t);
     84write_type_vector(int32_t);
     85write_type_vector(uint32_t);
     86write_type_vector(int64_t);
     87write_type_vector(uint64_t);
     88write_type_vector(float);
     89write_type_vector(double);
     90write_type_vector(rgb8);
     91write_type_vector(rgbx8);
    13592
    136 IMAGE_EXPORT(void) write_rgb8vector (rgb8    *v,long nl,long nh, char *format, char *filename);
    137 IMAGE_EXPORT(void) write_rgbx8vector(rgbx8   *v,long nl,long nh, char *format, char *filename);
    138 
    139 /*
    140  * ----------------------
    141  * --- write_vector_T ---
    142  * ----------------------
    143  */
    144 
    145 IMAGE_EXPORT(void) write_si8vector_T  (sint8   *v,long nl,long nh, char *format, char *filename);
    146 IMAGE_EXPORT(void) write_ui8vector_T  (uint8   *v,long nl,long nh, char *format, char *filename);
    147 IMAGE_EXPORT(void) write_si16vector_T (sint16  *v,long nl,long nh, char *format, char *filename);
    148 IMAGE_EXPORT(void) write_ui16vector_T (uint16  *v,long nl,long nh, char *format, char *filename);
    149 IMAGE_EXPORT(void) write_si32vector_T (sint32  *v,long nl,long nh, char *format, char *filename);
    150 IMAGE_EXPORT(void) write_ui32vector_T (uint32  *v,long nl,long nh, char *format, char *filename);
    151 IMAGE_EXPORT(void) write_si64vector_T (sint64  *v,long nl,long nh, char *format, char *filename);
    152 IMAGE_EXPORT(void) write_ui64vector_T (uint64  *v,long nl,long nh, char *format, char *filename);
    153 
    154 IMAGE_EXPORT(void) write_f32vector_T  (float32 *v,long nl,long nh, char *format, char *filename);
    155 IMAGE_EXPORT(void) write_f64vector_T  (float64 *v,long nl,long nh, char *format, char *filename);
    156 
    157 IMAGE_EXPORT(void) write_rgb8vector_T (rgb8    *v,long nl,long nh, char *format, char *filename);
    158 IMAGE_EXPORT(void) write_rgbx8vector_T(rgbx8   *v,long nl,long nh, char *format, char *filename);
    159 
    160 /*
    161  * ---------------------------
    162  * --- write_vector_number ---
    163  * ---------------------------
    164  */
    165 
    166 IMAGE_EXPORT(void) write_si8vector_number  (sint8   *v,long nl,long nh, char *format, char *filename);
    167 IMAGE_EXPORT(void) write_ui8vector_number  (uint8   *v,long nl,long nh, char *format, char *filename);
    168 IMAGE_EXPORT(void) write_si16vector_number (sint16  *v,long nl,long nh, char *format, char *filename);
    169 IMAGE_EXPORT(void) write_ui16vector_number (uint16  *v,long nl,long nh, char *format, char *filename);
    170 IMAGE_EXPORT(void) write_si32vector_number (sint32  *v,long nl,long nh, char *format, char *filename);
    171 IMAGE_EXPORT(void) write_ui32vector_number (uint32  *v,long nl,long nh, char *format, char *filename);
    172 IMAGE_EXPORT(void) write_si64vector_number (sint64  *v,long nl,long nh, char *format, char *filename);
    173 IMAGE_EXPORT(void) write_ui64vector_number (uint64  *v,long nl,long nh, char *format, char *filename);
    174 
    175 IMAGE_EXPORT(void) write_f32vector_number  (float32 *v,long nl,long nh, char *format, char *filename);
    176 IMAGE_EXPORT(void) write_f64vector_number  (float64 *v,long nl,long nh, char *format, char *filename);
    177 
    178 IMAGE_EXPORT(void) write_rgb8vector_number (rgb8    *v,long nl,long nh, char *format, char *filename);
    179 IMAGE_EXPORT(void) write_rgbx8vector_number(rgbx8   *v,long nl,long nh, char *format, char *filename);
    180 
    181 /*
    182  * -----------------------------
    183  * --- write_vector_T_number ---
    184  * -----------------------------
    185  */
    186 
    187 IMAGE_EXPORT(void) write_si8vector_T_number  (sint8   *v,long nl,long nh, char *format, char *filename);
    188 IMAGE_EXPORT(void) write_ui8vector_T_number  (uint8   *v,long nl,long nh, char *format, char *filename);
    189 IMAGE_EXPORT(void) write_si16vector_T_number (sint16  *v,long nl,long nh, char *format, char *filename);
    190 IMAGE_EXPORT(void) write_ui16vector_T_number (uint16  *v,long nl,long nh, char *format, char *filename);
    191 IMAGE_EXPORT(void) write_si32vector_T_number (sint32  *v,long nl,long nh, char *format, char *filename);
    192 IMAGE_EXPORT(void) write_ui32vector_T_number (uint32  *v,long nl,long nh, char *format, char *filename);
    193 IMAGE_EXPORT(void) write_si64vector_T_number (sint64  *v,long nl,long nh, char *format, char *filename);
    194 IMAGE_EXPORT(void) write_ui64vector_T_number (uint64  *v,long nl,long nh, char *format, char *filename);
    195 
    196 IMAGE_EXPORT(void) write_f32vector_T_number  (float32 *v,long nl,long nh, char *format, char *filename);
    197 IMAGE_EXPORT(void) write_f64vector_T_number  (float64 *v,long nl,long nh, char *format, char *filename);
    198 
    199 IMAGE_EXPORT(void) write_rgb8vector_T_number (rgb8    *v,long nl,long nh, char *format, char *filename);
    200 IMAGE_EXPORT(void) write_rgbx8vector_T_number(rgbx8   *v,long nl,long nh, char *format, char *filename);
    201 
    202 /*
    203  * --------------------
    204  * --- fread_vector ---
    205  * --------------------
    206  */
    207 IMAGE_EXPORT(void) fread_si8vector  (char *filename, sint8   *v,long nl,long nh);
    208 IMAGE_EXPORT(void) fread_ui8vector  (char *filename, uint8   *v,long nl,long nh);
    209 IMAGE_EXPORT(void) fread_si16vector (char *filename, sint16  *v,long nl,long nh);
    210 IMAGE_EXPORT(void) fread_ui16vector (char *filename, uint16  *v,long nl,long nh);
    211 IMAGE_EXPORT(void) fread_si32vector (char *filename, sint32  *v,long nl,long nh);
    212 IMAGE_EXPORT(void) fread_ui32vector (char *filename, uint32  *v,long nl,long nh);
    213 IMAGE_EXPORT(void) fread_si64vector (char *filename, sint64  *v,long nl,long nh);
    214 IMAGE_EXPORT(void) fread_ui64vector (char *filename, uint64  *v,long nl,long nh);
    215 
    216 IMAGE_EXPORT(void) fread_f32vector  (char *filename, float32 *v,long nl,long nh);
    217 IMAGE_EXPORT(void) fread_f64vector  (char *filename, float64 *v,long nl,long nh);
    218 
    219 IMAGE_EXPORT(void) fread_rgb8vector (char *filename, rgb8    *v,long nl,long nh);
    220 IMAGE_EXPORT(void) fread_rgbx8vector(char *filename, rgbx8   *v,long nl,long nh);
    221 
    222 /*
    223  * ---------------------
    224  * --- fwrite_vector ---
    225  * ---------------------
    226  */
    227 IMAGE_EXPORT(void) fwrite_si8vector  (sint8   *v,long nl,long nh,char *filename);
    228 IMAGE_EXPORT(void) fwrite_ui8vector  (uint8   *v,long nl,long nh,char *filename);
    229 IMAGE_EXPORT(void) fwrite_si16vector (sint16  *v,long nl,long nh,char *filename);
    230 IMAGE_EXPORT(void) fwrite_ui16vector (uint16  *v,long nl,long nh,char *filename);
    231 IMAGE_EXPORT(void) fwrite_si32vector (sint32  *v,long nl,long nh,char *filename);
    232 IMAGE_EXPORT(void) fwrite_ui32vector (uint32  *v,long nl,long nh,char *filename);
    233 IMAGE_EXPORT(void) fwrite_si64vector (sint64  *v,long nl,long nh,char *filename);
    234 IMAGE_EXPORT(void) fwrite_ui64vector (uint64  *v,long nl,long nh,char *filename);
    235 
    236 IMAGE_EXPORT(void) fwrite_f32vector  (float32 *v,long nl,long nh,char *filename);
    237 IMAGE_EXPORT(void) fwrite_f64vector  (float64 *v,long nl,long nh,char *filename);
    238 
    239 IMAGE_EXPORT(void) fwrite_rgb8vector (rgb8    *v,long nl,long nh,char *filename);
    240 IMAGE_EXPORT(void) fwrite_rgbx8vector(rgbx8   *v,long nl,long nh,char *filename);
    241 
    242 #ifdef __cplusplus
    243 }
    244 #endif
    24593
    24694#endif // _NR_IO1_H_
     95
     96// Local Variables:
     97// tab-width: 4
     98// c-basic-offset: 4
     99// c-file-offsets:((innamespace . 0)(inline-open . 0))
     100// indent-tabs-mode: nil
     101// End:
     102
     103// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     104
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio1x.h

    r772 r822  
    1111#define _NR_IO1X_H_
    1212
    13 #ifdef __cplusplus
    14 #pragma message ("C++")
    15 extern "C" {
    16 #endif
    17    
    18 IMAGE_EXPORT(void) display_bvector_circular    (byte     *v,long nl,long nh, long c0, long c1, char *format, char *name);
    19 IMAGE_EXPORT(void) display_si16vector_circular (sint16   *v,long nl,long nh, long c0, long c1, char *format, char *name);
    20 IMAGE_EXPORT(void) display_ui16vector_circular (uint16   *v,long nl,long nh, long c0, long c1, char *format, char *name);
    21 IMAGE_EXPORT(void) display_f32vector_circular     (float32  *v,long nl,long nh, long c0, long c1, char *format, char *name);
    22 IMAGE_EXPORT(void) display_f64vector_circular    (float64  *v,long nl,long nh, long c0, long c1, char *format, char *name);
     13#define display_type_vector_circular(t) \
     14void short_name(t,display_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name); \
     15void short_name(t,display_,vector_circular_number)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name); \
     16void short_name(t,display_,vector_cycle)(t * v, int32_t nl, int32_t nh, char * format, char * name); \
     17void short_name(t,write_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * filename)
    2318
    24 IMAGE_EXPORT(void) display_bvector_circular_number   (byte    *v,long nl,long nh, long c0, long c1, char *format, char *name);
    25 IMAGE_EXPORT(void) display_si16vector_circular_number(sint16  *v,long nl,long nh, long c0, long c1, char *format, char *name);
    26 IMAGE_EXPORT(void) display_ui16vector_circular_number(uint16  *v,long nl,long nh, long c0, long c1, char *format, char *name);
    27 IMAGE_EXPORT(void) display_f32vector_circular_number (float32 *v,long nl,long nh, long c0, long c1, char *format, char *name);
    28 IMAGE_EXPORT(void) display_f64vector_circular_number (float64 *v,long nl,long nh, long c0, long c1, char *format, char *name);
     19display_type_vector_circular(int8_t);
     20display_type_vector_circular(uint8_t);
     21display_type_vector_circular(int16_t);
     22display_type_vector_circular(uint16_t);
     23display_type_vector_circular(int32_t);
     24display_type_vector_circular(uint32_t);
     25display_type_vector_circular(int64_t);
     26display_type_vector_circular(uint64_t);
     27display_type_vector_circular(float);
     28display_type_vector_circular(double);
    2929
    30 IMAGE_EXPORT(void) display_bvector_cycle   (byte   *v,long nl,long nh, char *format, char *name);
    31 IMAGE_EXPORT(void) display_si16vector_cycle(sint16 *v,long nl,long nh, char *format, char *name);
    32 IMAGE_EXPORT(void) display_ui16vector_cycle(uint16 *v,long nl,long nh, char *format, char *name);
    33 
    34 IMAGE_EXPORT(void) write_bvector_circular(byte *v,long nl,long nh, long c0, long c1, char *format, char *filename);
    35 
    36    
    37 #ifdef __cplusplus
    38 }
    39 #endif
    4030
    4131#endif // _NR_IO1X_H_
     32
     33// Local Variables:
     34// tab-width: 4
     35// c-basic-offset: 4
     36// c-file-offsets:((innamespace . 0)(inline-open . 0))
     37// indent-tabs-mode: nil
     38// End:
     39
     40// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     41
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio2.h

    r798 r822  
    1111#define _NR_IO2_H_
    1212
    13 #ifdef __cplusplus
    14 #pragma message ("C++")
    15 extern "C" {
    16 #endif
    17    
    18 #ifdef VERBOSE_PRAGMA
    19 //#pragma message ("- *** include nrio2.h ***")
    20 #endif
    21 
    2213
    2314/*
    2415 * ----------------------
    2516 * --- display_matrix ---
     17 * --- display_matrix_T ---
     18 * --- display_matrix_number ---
     19 * --- display_matrix_positive ---
    2620 * ----------------------
    2721 */
    2822
    29 IMAGE_EXPORT(void) display_si8matrix  (sint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    30 IMAGE_EXPORT(void) display_ui8matrix  (uint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    31 IMAGE_EXPORT(void) display_si16matrix (sint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    32 IMAGE_EXPORT(void) display_ui16matrix (uint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    33 IMAGE_EXPORT(void) display_si32matrix (sint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    34 IMAGE_EXPORT(void) display_ui32matrix (uint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    35 IMAGE_EXPORT(void) display_si64matrix (sint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    36 IMAGE_EXPORT(void) display_ui64matrix (uint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
     23#define display_type_matrix(t) \
     24void short_name(t,display_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name); \
     25void short_name(t,display_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name); \
     26void short_name(t,display_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name); \
     27void 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)
    3728
    38 IMAGE_EXPORT(void) display_f32matrix  (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    39 IMAGE_EXPORT(void) display_f64matrix  (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    4029
    41 IMAGE_EXPORT(void) display_rgb8matrix (rgb8    **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    42 IMAGE_EXPORT(void) display_rgbx8matrix(rgbx8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
     30display_type_matrix(int8_t);
     31display_type_matrix(uint8_t);
     32display_type_matrix(int16_t);
     33display_type_matrix(uint16_t);
     34display_type_matrix(int32_t);
     35display_type_matrix(uint32_t);
     36display_type_matrix(int64_t);
     37display_type_matrix(uint64_t);
     38display_type_matrix(float);
     39display_type_matrix(double);
     40display_type_matrix(rgb8);
     41display_type_matrix(rgbx8);
    4342
    44 /*
    45  * ------------------------
    46  * --- display_matrix_T ---
    47  * ------------------------
    48  */
    49 
    50 IMAGE_EXPORT(void) display_si8matrix_T (sint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    51 IMAGE_EXPORT(void) display_ui8matrix_T (uint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    52 IMAGE_EXPORT(void) display_si16matrix_T(sint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    53 IMAGE_EXPORT(void) display_ui16matrix_T(uint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    54 IMAGE_EXPORT(void) display_si32matrix_T(sint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    55 IMAGE_EXPORT(void) display_ui32matrix_T(uint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    56 IMAGE_EXPORT(void) display_si64matrix_T(sint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    57 IMAGE_EXPORT(void) display_ui64matrix_T(uint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    58 
    59 IMAGE_EXPORT(void) display_f32matrix_T (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    60 IMAGE_EXPORT(void) display_f64matrix_T (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    61 
    62 IMAGE_EXPORT(void) display_rgb8matrix_T (rgb8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    63 IMAGE_EXPORT(void) display_rgbx8matrix_T(rgbx8  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    64 
    65 /*
    66  * -----------------------------
    67  * --- display_matrix_number ---
    68  * -----------------------------
    69  */
    70 
    71 IMAGE_EXPORT(void) display_si8matrix_number (sint8  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    72 IMAGE_EXPORT(void) display_ui8matrix_number (uint8  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    73 IMAGE_EXPORT(void) display_si16matrix_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    74 IMAGE_EXPORT(void) display_ui16matrix_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    75 IMAGE_EXPORT(void) display_i32matrix_number (sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    76 IMAGE_EXPORT(void) display_ui32matrix_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    77 IMAGE_EXPORT(void) display_si64matrix_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    78 IMAGE_EXPORT(void) display_ui64matrix_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    79 
    80 IMAGE_EXPORT(void) display_f32matrix_number (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    81 IMAGE_EXPORT(void) display_f64matrix_number (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    82 
    83 IMAGE_EXPORT(void) display_rgb8matrix_number (rgb8  **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    84 IMAGE_EXPORT(void) display_rgbx8matrix_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name);
    8543
    8644/*
    8745 * --------------------
    8846 * --- write_matrix ---
    89  * --------------------
    90  */
    91 
    92 IMAGE_EXPORT(void) write_si8matrix  (sint8  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    93 IMAGE_EXPORT(void) write_ui8matrix  (uint8  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    94 IMAGE_EXPORT(void) write_si16matrix (sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    95 IMAGE_EXPORT(void) write_ui16matrix (uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    96 IMAGE_EXPORT(void) write_si32matrix (sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    97 IMAGE_EXPORT(void) write_ui32matrix (uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    98 IMAGE_EXPORT(void) write_si64matrix (sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    99 IMAGE_EXPORT(void) write_ui64matrix (uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    100 
    101 IMAGE_EXPORT(void) write_f32matrix (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    102 IMAGE_EXPORT(void) write_f64matrix (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    103 
    104 IMAGE_EXPORT(void) write_rgb8matrix (rgb8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    105 IMAGE_EXPORT(void) write_rgbx8matrix(rgbx8  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    106 
    107 /*
    108  * ----------------------
    10947 * --- write_matrix_T ---
    110  * ----------------------
    111  */
    112 
    113 IMAGE_EXPORT(void) write_si8matrix_T  (sint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    114 IMAGE_EXPORT(void) write_ui8matrix_T  (uint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    115 IMAGE_EXPORT(void) write_si16matrix_T (sint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    116 IMAGE_EXPORT(void) write_ui16matrix_T (uint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    117 IMAGE_EXPORT(void) write_si32matrix_T (sint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    118 IMAGE_EXPORT(void) write_ui32matrix_T (uint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    119 IMAGE_EXPORT(void) write_si64matrix_T (sint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    120 IMAGE_EXPORT(void) write_ui64matrix_T (uint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    121 
    122 IMAGE_EXPORT(void) write_f32matrix_T  (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    123 IMAGE_EXPORT(void) write_f64matrix_T  (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    124 
    125 IMAGE_EXPORT(void) write_rgb8matrix_T (rgb8    **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    126 IMAGE_EXPORT(void) write_rgbx8matrix_T(rgbx8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    127 
    128 /*
    129  * ---------------------------
    13048 * --- write_matrix_number ---
    131  * ---------------------------
    132  */
    133 
    134 IMAGE_EXPORT(void) write_si8matrix_number  (sint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    135 IMAGE_EXPORT(void) write_ui8matrix_number  (uint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    136 IMAGE_EXPORT(void) write_si16matrix_number (sint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    137 IMAGE_EXPORT(void) write_ui16matrix_number (uint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    138 IMAGE_EXPORT(void) write_si32matrix_number (sint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    139 IMAGE_EXPORT(void) write_ui32matrix_number (uint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    140 IMAGE_EXPORT(void) write_si64matrix_number (sint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    141 IMAGE_EXPORT(void) write_ui64matrix_number (uint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    142 
    143 IMAGE_EXPORT(void) write_f32matrix_number  (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    144 IMAGE_EXPORT(void) write_f64matrix_number  (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    145 
    146 IMAGE_EXPORT(void) write_rgb8matrix_number (rgb8    **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    147 IMAGE_EXPORT(void) write_rgbx8matrix_number(rgbx8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    148 
    149 /*
    150  * -----------------------------
    15149 * --- write_matrix_T_number ---
    152  * -----------------------------
    153  */
    154 
    155 IMAGE_EXPORT(void) write_si8matrix_T_number  (sint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    156 IMAGE_EXPORT(void) write_ui8matrix_T_number  (uint8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    157 IMAGE_EXPORT(void) write_si16matrix_T_number (sint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    158 IMAGE_EXPORT(void) write_ui16matrix_T_number (uint16  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    159 IMAGE_EXPORT(void) write_si32matrix_T_number (sint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    160 IMAGE_EXPORT(void) write_ui32matrix_T_number (uint32  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    161 IMAGE_EXPORT(void) write_si64matrix_T_number (sint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    162 IMAGE_EXPORT(void) write_ui64matrix_T_number (uint64  **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    163 
    164 IMAGE_EXPORT(void) write_f32matrix_T_number  (float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    165 IMAGE_EXPORT(void) write_f64matrix_T_number  (float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    166 
    167 IMAGE_EXPORT(void) write_rgb8matrix_T_number (rgb8    **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    168 IMAGE_EXPORT(void) write_rgbx8matrix_T_number(rgbx8   **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename);
    169 
    170 /*
    171  * ---------------------
    17250 * --- fwrite_matrix ---
    173  * ---------------------
    174  */
    175 
    176 IMAGE_EXPORT(void) fwrite_si8matrix  (sint8  **m,long nrl,long nrh,long ncl, long nch, char *filename);
    177 IMAGE_EXPORT(void) fwrite_ui8matrix  (uint8  **m,long nrl,long nrh,long ncl, long nch, char *filename);
    178 IMAGE_EXPORT(void) fwrite_si16matrix (sint16 **m,long nrl,long nrh,long ncl, long nch, char *filename);
    179 IMAGE_EXPORT(void) fwrite_ui16matrix (uint16 **m,long nrl,long nrh,long ncl, long nch, char *filename);
    180 IMAGE_EXPORT(void) fwrite_si32matrix (sint32 **m,long nrl,long nrh,long ncl, long nch, char *filename);
    181 IMAGE_EXPORT(void) fwrite_ui32matrix (uint32 **m,long nrl,long nrh,long ncl, long nch, char *filename);
    182 IMAGE_EXPORT(void) fwrite_si64matrix (sint64 **m,long nrl,long nrh,long ncl, long nch, char *filename);
    183 IMAGE_EXPORT(void) fwrite_ui64matrix (uint64 **m,long nrl,long nrh,long ncl, long nch, char *filename);
    184 
    185 IMAGE_EXPORT(void) fwrite_f32matrix (float32 **m,long nrl,long nrh,long ncl, long nch, char *filename);
    186 IMAGE_EXPORT(void) fwrite_f64matrix (float64 **m,long nrl,long nrh,long ncl, long nch, char *filename);
    187 
    188 IMAGE_EXPORT(void) fwrite_rgb8matrix(rgb8    **m,long nrl,long nrh,long ncl, long nch, char *filename);
    189 IMAGE_EXPORT(void) fwrite_rgbx8matrix(rgbx8  **m,long nrl,long nrh,long ncl, long nch, char *filename);
    190 
    191 /*
    192  * --------------------
    19351 * --- fread_matrix ---
    19452 * --------------------
    19553 */
    19654
    197 IMAGE_EXPORT(void) fread_si8matrix  (char *filename, sint8    **m,long nrl,long nrh,long ncl, long nch);
    198 IMAGE_EXPORT(void) fread_ui8matrix  (char *filename, uint8    **m,long nrl,long nrh,long ncl, long nch);
    199 IMAGE_EXPORT(void) fread_si16matrix (char *filename, sint16   **m,long nrl,long nrh,long ncl, long nch);
    200 IMAGE_EXPORT(void) fread_ui16matrix (char *filename, uint16   **m,long nrl,long nrh,long ncl, long nch);
    201 IMAGE_EXPORT(void) fread_si32matrix (char *filename, sint32   **m,long nrl,long nrh,long ncl, long nch);
    202 IMAGE_EXPORT(void) fread_ui32matrix (char *filename, uint32   **m,long nrl,long nrh,long ncl, long nch);
    203 IMAGE_EXPORT(void) fread_si64matrix (char *filename, sint64   **m,long nrl,long nrh,long ncl, long nch);
    204 IMAGE_EXPORT(void) fread_ui64matrix (char *filename, uint64   **m,long nrl,long nrh,long ncl, long nch);
    205 IMAGE_EXPORT(void) fread_f32matrix  (char *filename, float32  **m,long nrl,long nrh,long ncl, long nch);
    206 IMAGE_EXPORT(void) fread_f64matrix  (char *filename, float64  **m,long nrl,long nrh,long ncl, long nch);
     55#define write_type_matrix(t) \
     56void short_name(t,write_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \
     57void short_name(t,write_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \
     58void short_name(t,write_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \
     59void short_name(t,write_,matrix_T_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \
     60void short_name(t,fwrite_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename); \
     61void short_name(t,fread_,matrix)(char * filename, t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch)  \
    20762
    208 IMAGE_EXPORT(void) fread_rgb8matrix (char *filename, rgb8     **m,long nrl,long nrh,long ncl, long nch);
    209 IMAGE_EXPORT(void) fread_rgbx8matrix(char *filename, rgbx8    **m,long nrl,long nrh,long ncl, long nch);
     63write_type_matrix(int8_t);
     64write_type_matrix(uint8_t);
     65write_type_matrix(int16_t);
     66write_type_matrix(uint16_t);
     67write_type_matrix(int32_t);
     68write_type_matrix(uint32_t);
     69write_type_matrix(int64_t);
     70write_type_matrix(uint64_t);
     71write_type_matrix(float);
     72write_type_matrix(double);
     73write_type_matrix(rgb8);
     74write_type_matrix(rgbx8);
    21075
    211 /*
    212  * -------------------------------
    213  * --- display_matrix_positive ---
    214  * -------------------------------
    215  */
    216 
    217 void display_si8matrix_positive (sint8 * *m, int i0, int i1, int j0, int j1, int iformat, char *name);
    218 void display_ui8matrix_positive (uint8 * *m, int i0, int i1, int j0, int j1, int iformat, char *name);
    219 void display_si16matrix_positive(sint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name);
    220 void display_ui16matrix_positive(uint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name);
    221 void display_si32matrix_positive(sint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name);
    222 void display_ui32matrix_positive(uint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name);
    223 void display_si64matrix_positive(sint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name);
    224 void display_ui64matrix_positive(uint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name);
    22576
    22677// -------------------------------
     
    22879// -------------------------------
    22980
    230 void write_ui8matrix_positive (uint8  **m,int i0, int i1, int j0, int j1, int iformat, char *filename);
    231 void write_ui16matrix_positive(uint16 **m,int i0, int i1, int j0, int j1, int iformat, char *filename);
    232 void write_ui32matrix_positive(uint32 **m,int i0, int i1, int j0, int j1, int iformat, char *filename);
     81#define write_type_matrix_positive(t) \
     82void short_name(t,write_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * filename)
     83
     84write_type_matrix_positive(uint8_t);
     85write_type_matrix_positive(uint16_t);
     86write_type_matrix_positive(uint32_t);
    23387
    23488/* ------------------------ */
     
    23690/* ------------------------ */
    23791
    238 IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch);
    239 IMAGE_EXPORT(uint8 **) LoadPGM_bmatrix  (char *filename, int *nrl, int *nrh, int *ncl, int *nch);
    240 IMAGE_EXPORT(void)     LoadPGM_bmatrix2 (char *filename, int *nrl, int *nrh, int *ncl, int *nch, uint8 **m);
    241 IMAGE_EXPORT(void)     MLoadPGM_bmatrix (char *filename, int nrl, int nrh, int ncl, int nch, uint8 **m);
     92uint8_t ** LoadPGM_ui8matrix  (char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch);
     93void       LoadPGM_ui8matrix2 (char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch, uint8_t ** m);
     94rgb8 **    LoadPPM_rgb8matrix (char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch);
     95void       LoadPPM_rgb8matrix2(char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch, rgb8 ** m);
    24296
    243 IMAGE_EXPORT(void)     SavePGM_bmatrix  (uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename);
    244 IMAGE_EXPORT(void)     SavePGM_ui8matrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename);
    245 
    246 IMAGE_EXPORT(rgb8 **)  LoadPPM_rgb8matrix (char *filename, int *nrl, int *nrh, int *ncl, int *nch);
    247 IMAGE_EXPORT(void)     LoadPPM_rgb8matrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, rgb8 **m);
    248 
    249 IMAGE_EXPORT(void)     SavePPM_rgb8matrix(rgb8 **m, int nrl, int nrh, int ncl, int nch, char *filename);
     97void MLoadPGM_ui8matrix(char * filename, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8 ** m);
     98void SavePGM_ui8matrix    (uint8_t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename);
     99void SavePPM_rgb8matrix      (rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename);
    250100
    251101
    252102
    253 #ifdef __cplusplus
    254 }
    255 #endif
    256 
    257103#endif // _NR_IO2_H_
    258104
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrtype.h

    r821 r822  
    1717
    1818#include <stdint.h>
    19 
    20 // ---------------------------------- //
    21 // -- don not write under the line -- //
    22 // ---------------------------------- //
    2319
    2420
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nralloc1.c

    r821 r822  
    157157#undef remote_type_vector
    158158#define remote_type_vector(t)                                                   \
    159 t * short_name(t,remote_,vector)(int32_t nl, int32_t nh, int32_t x, int32_t y) \
     159t * short_name(t,remote_,vector)(int32_t nl, int32_t nh, int32_t x, int32_t y)  \
    160160{                                                                               \
    161161    t * v;                                                                      \
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrbool1.c

    r772 r822  
    1717#include <math.h> // fabs
    1818
     19#include "nrc_os_config.h"
    1920#include "mypredef.h"
    2021#include "nrtype.h"
     
    3132 */
    3233
    33 /* -------------------------------------------------------------- */
    34 IMAGE_EXPORT(void) not_bvector(byte *X, long ncl, long nch, byte *Y)
    35 /* -------------------------------------------------------------- */
    36 {
    37         long j;
    38        
    39         for(j=ncl; j<=nch; j++) {
    40                 Y[j] = ~X[j];
    41         }
    42 }
    43 /* ------------------------------------------------------------------ */
    44 IMAGE_EXPORT(void) not_si8vector(sint8 *X, long ncl, long nch, sint8 *Y)
    45 /* ------------------------------------------------------------------ */
    46 {
    47         long j;
    48        
    49         for(j=ncl; j<=nch; j++) {
    50                 Y[j] = ~X[j];
    51         }
    52 }
    53 /* ------------------------------------------------------------------ */
    54 IMAGE_EXPORT(void) not_ui8vector(uint8 *X, long ncl, long nch, uint8 *Y)
    55 /* ------------------------------------------------------------------ */
    56 {
    57         long j;
    58        
    59         for(j=ncl; j<=nch; j++) {
    60                 Y[j] = ~X[j];
    61         }
    62 }
    63 /* --------------------------------------------------------------------- */
    64 IMAGE_EXPORT(void) not_si16vector(sint16 *X, long ncl, long nch, sint16 *Y)
    65 /* --------------------------------------------------------------------- */
    66 {
    67         long j;
    68        
    69         for(j=ncl; j<=nch; j++) {
    70                 Y[j] = ~X[j];
    71         }
    72 }
    73 /* --------------------------------------------------------------------- */
    74 IMAGE_EXPORT(void) not_ui16vector(uint16 *X, long ncl, long nch, uint16 *Y)
    75 /* --------------------------------------------------------------------- */
    76 {
    77         long j;
    78        
    79         for(j=ncl; j<=nch; j++) {
    80                 Y[j] = ~X[j];
    81         }
    82 }
    83 /* --------------------------------------------------------------------- */
    84 IMAGE_EXPORT(void) not_si32vector(sint32 *X, long ncl, long nch, sint32 *Y)
    85 /* --------------------------------------------------------------------- */
    86 {
    87         long j;
    88        
    89         for(j=ncl; j<=nch; j++) {
    90                 Y[j] = ~X[j];
    91         }
    92 }
    93 /* --------------------------------------------------------------------- */
    94 IMAGE_EXPORT(void) not_ui32vector(uint32 *X, long ncl, long nch, uint32 *Y)
    95 /* --------------------------------------------------------------------- */
    96 {
    97         long j;
    98        
    99         for(j=ncl; j<=nch; j++) {
    100                 Y[j] = ~X[j];
    101         }
    102 }
    103 /* --------------------------------------------------------------------- */
    104 IMAGE_EXPORT(void) not_si64vector(sint64 *X, long ncl, long nch, sint64 *Y)
    105 /* --------------------------------------------------------------------- */
    106 {
    107         long j;
    108        
    109         for(j=ncl; j<=nch; j++) {
    110                 Y[j] = ~X[j];
    111         }
    112 }
    113 /* --------------------------------------------------------------------- */
    114 IMAGE_EXPORT(void) not_ui64vector(uint64 *X, long ncl, long nch, uint64 *Y)
    115 /* --------------------------------------------------------------------- */
    116 {
    117         long j;
    118        
    119         for(j=ncl; j<=nch; j++) {
    120                 Y[j] = ~X[j];
    121         }
    122 }
     34#undef not_type_vector
     35#define not_type_vector(t) \
     36void short_name(t,not_,vector)(t * X, int32_t ncl, int32_t nch, t * Y) \
     37{                                          \
     38        for (int32_t j = ncl; j <= nch; j++) { \
     39                Y[j] = ~X[j];                      \
     40        }                                      \
     41}
     42
     43not_type_vector(int8_t);
     44not_type_vector(uint8_t);
     45not_type_vector(int16_t);
     46not_type_vector(uint16_t);
     47not_type_vector(int32_t);
     48not_type_vector(uint32_t);
     49not_type_vector(int64_t);
     50not_type_vector(uint64_t);
     51
     52
    12353/* ----------------------------------------------------------------- */
    124 IMAGE_EXPORT(void) not_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 *Y)
     54void not_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y)
    12555/* ----------------------------------------------------------------- */
    12656{
    127         long j;
    128     rgb8 x, y;
    129        
    130         for(j=ncl; j<=nch; j++) {
    131         x = X[j];
    132         RGB8_NOT(x,y);
    133                 Y[j] = y;
    134         }
    135 }
     57        for (int32_t j = ncl; j <= nch; j++) {
     58        RGB8_NOT(X[j], Y[j]);
     59        }
     60}
     61
    13662/* -------------------------------------------------------------------- */
    137 IMAGE_EXPORT(void) not_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y)
     63void not_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y)
    13864/* -------------------------------------------------------------------- */
    13965{
    140         long j;
    141     rgbx8 x, y;
    142        
    143         for(j=ncl; j<=nch; j++) {
    144         x = X[j];
    145         RGBX8_NOT(x,y);
    146                 Y[j] = y;
    147         }
    148 }
     66        for (int32_t j = ncl; j <= nch; j++) {
     67        RGBX8_NOT(X[j], Y[j]);
     68        }
     69}
     70
    14971/*
    15072 * -----------
     
    15375 */
    15476
    155 /* ---------------------------------------------------------------------- */
    156 IMAGE_EXPORT(void) or_bvector(byte *X, long ncl, long nch, byte *Y, byte *Z)
    157 /* ---------------------------------------------------------------------- */
    158 {
    159         long j;
    160        
    161         for(j=ncl; j<=nch; j++) {
    162                 Z[j] = X[j] | Y[j];
    163         }
    164 }
    165 /* --------------------------------------------------------------------------- */
    166 IMAGE_EXPORT(void) or_si8vector(sint8 *X, long ncl, long nch, sint8 *Y, sint8 *Z)
    167 /* --------------------------------------------------------------------------- */
    168 {
    169         long j;
    170        
    171         for(j=ncl; j<=nch; j++) {
    172                 Z[j] = X[j] | Y[j];
    173         }
    174 }
    175 /* --------------------------------------------------------------------------- */
    176 IMAGE_EXPORT(void) or_ui8vector(uint8 *X, long ncl, long nch, uint8 *Y, uint8 *Z)
    177 /* --------------------------------------------------------------------------- */
    178 {
    179         long j;
    180        
    181         for(j=ncl; j<=nch; j++) {
    182                 Z[j] = X[j] | Y[j];
    183         }
    184 }
    185 /* ------------------------------------------------------------------------------- */
    186 IMAGE_EXPORT(void) or_si16vector(sint16 *X, long ncl, long nch, sint16 *Y, sint16 *Z)
    187 /* ------------------------------------------------------------------------------- */
    188 {
    189         long j;
    190        
    191         for(j=ncl; j<=nch; j++) {
    192                 Z[j] = X[j] | Y[j];
    193         }
    194 }
    195 /* ------------------------------------------------------------------------------- */
    196 IMAGE_EXPORT(void) or_ui16vector(uint16 *X, long ncl, long nch, uint16 *Y, uint16 *Z)
    197 /* ------------------------------------------------------------------------------- */
    198 {
    199         long j;
    200        
    201         for(j=ncl; j<=nch; j++) {
    202                 Z[j] = X[j] | Y[j];
    203         }
    204 }
    205 /* ------------------------------------------------------------------------------- */
    206 IMAGE_EXPORT(void) or_si32vector(sint32 *X, long ncl, long nch, sint32 *Y, sint32 *Z)
    207 /* ------------------------------------------------------------------------------- */
    208 {
    209         long j;
    210        
    211         for(j=ncl; j<=nch; j++) {
    212                 Z[j] = X[j] | Y[j];
    213         }
    214 }
    215 /* ------------------------------------------------------------------------------- */
    216 IMAGE_EXPORT(void) or_ui32vector(uint32 *X, long ncl, long nch, uint32 *Y, uint32 *Z)
    217 /* ------------------------------------------------------------------------------- */
    218 {
    219         long j;
    220        
    221         for(j=ncl; j<=nch; j++) {
    222                 Z[j] = X[j] | Y[j];
    223         }
    224 }
    225 /* ------------------------------------------------------------------------------- */
    226 IMAGE_EXPORT(void) or_si64vector(sint64 *X, long ncl, long nch, sint64 *Y, sint64 *Z)
    227 /* ------------------------------------------------------------------------------- */
    228 {
    229         long j;
    230        
    231         for(j=ncl; j<=nch; j++) {
    232                 Z[j] = X[j] | Y[j];
    233         }
    234 }
    235 /* ------------------------------------------------------------------------------- */
    236 IMAGE_EXPORT(void) or_ui64vector(uint64 *X, long ncl, long nch, uint64 *Y, uint64 *Z)
    237 /* ------------------------------------------------------------------------------- */
    238 {
    239         long j;
    240        
    241         for(j=ncl; j<=nch; j++) {
    242                 Z[j] = X[j] | Y[j];
    243         }
    244 }
     77#undef or_type_vector
     78#define or_type_vector(t) \
     79void short_name(t,or_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \
     80{                                          \
     81        for (int32_t j = ncl; j <= nch; j++) { \
     82                Z[j] = X[j] | Y[j];                \
     83        }                                      \
     84}
     85
     86or_type_vector(int8_t);
     87or_type_vector(uint8_t);
     88or_type_vector(int16_t);
     89or_type_vector(uint16_t);
     90or_type_vector(int32_t);
     91or_type_vector(uint32_t);
     92or_type_vector(int64_t);
     93or_type_vector(uint64_t);
     94
     95
    24596/* ------------------------------------------------------------------------- */
    246 IMAGE_EXPORT(void) or_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 *Y, rgb8 *Z)
     97void or_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z)
    24798/* ------------------------------------------------------------------------- */
    24899{
    249         long j;
    250     rgb8 x, y, z;
    251        
    252         for(j=ncl; j<=nch; j++) {
    253         x = X[j];
    254         y = Y[j];
    255         RGB8_OR(x,y,z);
    256                 Z[j] = z;
     100        for (int32_t j = ncl; j <= nch; j++) {
     101        RGB8_OR(X[j], Y[j], Z[j]);
    257102        }
    258103}
    259104/* ----------------------------------------------------------------------------- */
    260 IMAGE_EXPORT(void) or_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y, rgbx8 *Z)
     105void or_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z)
    261106/* ----------------------------------------------------------------------------- */
    262107{
    263         long j;
    264     rgbx8 x, y, z;
    265        
    266         for(j=ncl; j<=nch; j++) {
    267         x = X[j];
    268         y = Y[j];
    269         RGBX8_OR(x,y,z);
    270                 Z[j] = z;
    271         }
    272 }
    273 /* ---------------------------------------------------------------------- */
    274 IMAGE_EXPORT(void) orc_bvector(byte *X, long ncl, long nch, byte y, byte *Z)
    275 /* ---------------------------------------------------------------------- */
    276 {
    277         long j;
    278        
    279         for(j=ncl; j<=nch; j++) {
    280                 Z[j] = X[j] | y;
    281         }
    282 }
    283 /* --------------------------------------------------------------------------- */
    284 IMAGE_EXPORT(void) orc_si8vector(sint8 *X, long ncl, long nch, sint8 y, sint8 *Z)
    285 /* --------------------------------------------------------------------------- */
    286 {
    287         long j;
    288        
    289         for(j=ncl; j<=nch; j++) {
    290                 Z[j] = X[j] | y;
    291         }
    292 }
    293 /* --------------------------------------------------------------------------- */
    294 IMAGE_EXPORT(void) orc_ui8vector(uint8 *X, long ncl, long nch, uint8 y, uint8 *Z)
    295 /* --------------------------------------------------------------------------- */
    296 {
    297         long j;
    298        
    299         for(j=ncl; j<=nch; j++) {
    300                 Z[j] = X[j] | y;
    301         }
    302 }
    303 /* ------------------------------------------------------------------------------- */
    304 IMAGE_EXPORT(void) orc_si16vector(sint16 *X, long ncl, long nch, sint16 y, sint16 *Z)
    305 /* ------------------------------------------------------------------------------- */
    306 {
    307         long j;
    308        
    309         for(j=ncl; j<=nch; j++) {
    310                 Z[j] = X[j] | y;
    311         }
    312 }
    313 /* ------------------------------------------------------------------------------- */
    314 IMAGE_EXPORT(void) orc_ui16vector(uint16 *X, long ncl, long nch, uint16 y, uint16 *Z)
    315 /* ------------------------------------------------------------------------------- */
    316 {
    317         long j;
    318        
    319         for(j=ncl; j<=nch; j++) {
    320                 Z[j] = X[j] | y;
    321         }
    322 }
    323 /* ------------------------------------------------------------------------------- */
    324 IMAGE_EXPORT(void) orc_si32vector(sint32 *X, long ncl, long nch, sint32 y, sint32 *Z)
    325 /* ------------------------------------------------------------------------------- */
    326 {
    327         long j;
    328        
    329         for(j=ncl; j<=nch; j++) {
    330                 Z[j] = X[j] | y;
    331         }
    332 }
    333 /* ------------------------------------------------------------------------------- */
    334 IMAGE_EXPORT(void) orc_ui32vector(uint32 *X, long ncl, long nch, uint32 y, uint32 *Z)
    335 /* ------------------------------------------------------------------------------- */
    336 {
    337         long j;
    338        
    339         for(j=ncl; j<=nch; j++) {
    340                 Z[j] = X[j] | y;
    341         }
    342 }
    343 /* ------------------------------------------------------------------------------- */
    344 IMAGE_EXPORT(void) orc_si64vector(sint64 *X, long ncl, long nch, sint64 y, sint64 *Z)
    345 /* ------------------------------------------------------------------------------- */
    346 {
    347         long j;
    348        
    349         for(j=ncl; j<=nch; j++) {
    350                 Z[j] = X[j] | y;
    351         }
    352 }
    353 /* ------------------------------------------------------------------------------- */
    354 IMAGE_EXPORT(void) orc_ui64vector(uint64 *X, long ncl, long nch, uint64 y, uint64 *Z)
    355 /* ------------------------------------------------------------------------------- */
    356 {
    357         long j;
    358        
    359         for(j=ncl; j<=nch; j++) {
    360                 Z[j] = X[j] | y;
    361         }
    362 }
     108        for (int32_t j = ncl; j <= nch; j++) {
     109        RGBX8_OR(X[j], Y[j], Z[j]);
     110        }
     111}
     112
     113
     114#undef orc_type_vector
     115#define orc_type_vector(t) \
     116void short_name(t,orc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \
     117{                                          \
     118        for (int32_t j = ncl; j <= nch; j++) { \
     119                Z[j] = X[j] | y;                   \
     120        }                                      \
     121}
     122
     123orc_type_vector(int8_t);
     124orc_type_vector(uint8_t);
     125orc_type_vector(int16_t);
     126orc_type_vector(uint16_t);
     127orc_type_vector(int32_t);
     128orc_type_vector(uint32_t);
     129orc_type_vector(int64_t);
     130orc_type_vector(uint64_t);
     131
     132
    363133/* ------------------------------------------------------------------------- */
    364 IMAGE_EXPORT(void) orc_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 y, rgb8 *Z)
     134void orc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z)
    365135/* ------------------------------------------------------------------------- */
    366136{
    367         long j;
    368     rgb8 x, z;
    369        
    370         for(j=ncl; j<=nch; j++) {
    371         x = X[j];
    372         RGB8_OR(x,y,z);
    373                 Z[j] = z;
    374         }
    375 }
     137        for (int32_t j = ncl; j <= nch; j++) {
     138        RGB8_OR(X[j], y, Z[j]);
     139        }
     140}
     141
    376142/* ----------------------------------------------------------------------------- */
    377 IMAGE_EXPORT(void) orc_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 y, rgbx8 *Z)
     143void orc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z)
    378144/* ----------------------------------------------------------------------------- */
    379145{
    380         long j;
    381     rgbx8 x, z;
    382        
    383         for(j=ncl; j<=nch; j++) {
    384         x = X[j];
    385         RGBX8_OR(x,y,z);
    386                 Z[j] = z;
    387         }
    388 }
     146        for (int32_t j = ncl; j <= nch; j++) {
     147        RGBX8_OR(X[j], y, Z[j]);
     148        }
     149}
     150
     151
    389152/*
    390153 * -----------
     
    392155 * -----------
    393156 */
    394 /* ----------------------------------------------------------------------- */
    395 IMAGE_EXPORT(void) xor_bvector(byte *X, long ncl, long nch, byte *Y, byte *Z)
    396 /* ----------------------------------------------------------------------- */
    397 {
    398         long j;
    399        
    400         for(j=ncl; j<=nch; j++) {
    401                 Z[j] = X[j] ^ Y[j];
    402         }
    403 }
    404 /* ---------------------------------------------------------------------------- */
    405 IMAGE_EXPORT(void) xor_si8vector(sint8 *X, long ncl, long nch, sint8 *Y, sint8 *Z)
    406 /* ---------------------------------------------------------------------------- */
    407 {
    408         long j;
    409        
    410         for(j=ncl; j<=nch; j++) {
    411                 Z[j] = X[j] ^ Y[j];
    412         }
    413 }
    414 /* ---------------------------------------------------------------------------- */
    415 IMAGE_EXPORT(void) xor_ui8vector(uint8 *X, long ncl, long nch, uint8 *Y, uint8 *Z)
    416 /* ---------------------------------------------------------------------------- */
    417 {
    418         long j;
    419        
    420         for(j=ncl; j<=nch; j++) {
    421                 Z[j] = X[j] ^ Y[j];
    422         }
    423 }
    424 /* -------------------------------------------------------------------------------- */
    425 IMAGE_EXPORT(void) xor_si16vector(sint16 *X, long ncl, long nch, sint16 *Y, sint16 *Z)
    426 /* -------------------------------------------------------------------------------- */
    427 {
    428         long j;
    429        
    430         for(j=ncl; j<=nch; j++) {
    431                 Z[j] = X[j] ^ Y[j];
    432         }
    433 }
    434 /* -------------------------------------------------------------------------------- */
    435 IMAGE_EXPORT(void) xor_ui16vector(uint16 *X, long ncl, long nch, uint16 *Y, uint16 *Z)
    436 /* -------------------------------------------------------------------------------- */
    437 {
    438         long j;
    439        
    440         for(j=ncl; j<=nch; j++) {
    441                 Z[j] = X[j] ^ Y[j];
    442         }
    443 }
    444 /* -------------------------------------------------------------------------------- */
    445 IMAGE_EXPORT(void) xor_si32vector(sint32 *X, long ncl, long nch, sint32 *Y, sint32 *Z)
    446 /* -------------------------------------------------------------------------------- */
    447 {
    448         long j;
    449        
    450         for(j=ncl; j<=nch; j++) {
    451                 Z[j] = X[j] ^ Y[j];
    452         }
    453 }
    454 /* -------------------------------------------------------------------------------- */
    455 IMAGE_EXPORT(void) xor_ui32vector(uint32 *X, long ncl, long nch, uint32 *Y, uint32 *Z)
    456 /* -------------------------------------------------------------------------------- */
    457 {
    458         long j;
    459        
    460         for(j=ncl; j<=nch; j++) {
    461                 Z[j] = X[j] ^ Y[j];
    462         }
    463 }
    464 /* -------------------------------------------------------------------------------- */
    465 IMAGE_EXPORT(void) xor_si64vector(sint64 *X, long ncl, long nch, sint64 *Y, sint64 *Z)
    466 /* -------------------------------------------------------------------------------- */
    467 {
    468         long j;
    469        
    470         for(j=ncl; j<=nch; j++) {
    471                 Z[j] = X[j] ^ Y[j];
    472         }
    473 }
    474 /* -------------------------------------------------------------------------------- */
    475 IMAGE_EXPORT(void) xor_ui64vector(uint64 *X, long ncl, long nch, uint64 *Y, uint64 *Z)
    476 /* -------------------------------------------------------------------------------- */
    477 {
    478         long j;
    479        
    480         for(j=ncl; j<=nch; j++) {
    481                 Z[j] = X[j] ^ Y[j];
    482         }
    483 }
    484 /* -------------------------------------------------------------------------- */
    485 IMAGE_EXPORT(void) xor_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 *Y, rgb8 *Z)
    486 /* -------------------------------------------------------------------------- */
    487 {
    488         long j;
    489     rgb8 x, y, z;
    490        
    491         for(j=ncl; j<=nch; j++) {
    492         x = X[j];
    493         y = Y[j];
    494         RGB8_XOR(x,y,z);
    495                 Z[j] = z;
    496         }
    497 }
    498 /* ------------------------------------------------------------------------------ */
    499 IMAGE_EXPORT(void) xor_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y, rgbx8 *Z)
    500 /* ------------------------------------------------------------------------------ */
    501 {
    502         long j;
    503     rgbx8 x, y, z;
    504        
    505         for(j=ncl; j<=nch; j++) {
    506         x = X[j];
    507         y = Y[j];
    508         RGBX8_XOR(x,y,z);
    509                 Z[j] = z;
    510         }
    511 }
    512 /* ----------------------------------------------------------------------- */
    513 IMAGE_EXPORT(void) xorc_bvector(byte *X, long ncl, long nch, byte y, byte *Z)
    514 /* ----------------------------------------------------------------------- */
    515 {
    516         long j;
    517        
    518         for(j=ncl; j<=nch; j++) {
    519                 Z[j] = X[j] ^ y;
    520         }
    521 }
    522 /* ---------------------------------------------------------------------------- */
    523 IMAGE_EXPORT(void) xorc_si8vector(sint8 *X, long ncl, long nch, sint8 y, sint8 *Z)
    524 /* ---------------------------------------------------------------------------- */
    525 {
    526         long j;
    527        
    528         for(j=ncl; j<=nch; j++) {
    529                 Z[j] = X[j] ^ y;
    530         }
    531 }
    532 /* ---------------------------------------------------------------------------- */
    533 IMAGE_EXPORT(void) xorc_ui8vector(uint8 *X, long ncl, long nch, uint8 y, uint8 *Z)
    534 /* ---------------------------------------------------------------------------- */
    535 {
    536         long j;
    537        
    538         for(j=ncl; j<=nch; j++) {
    539                 Z[j] = X[j] ^ y;
    540         }
    541 }
    542 /* -------------------------------------------------------------------------------- */
    543 IMAGE_EXPORT(void) xorc_si16vector(sint16 *X, long ncl, long nch, sint16 y, sint16 *Z)
    544 /* -------------------------------------------------------------------------------- */
    545 {
    546         long j;
    547        
    548         for(j=ncl; j<=nch; j++) {
    549                 Z[j] = X[j] ^ y;
    550         }
    551 }
    552 /* -------------------------------------------------------------------------------- */
    553 IMAGE_EXPORT(void) xorc_ui16vector(uint16 *X, long ncl, long nch, uint16 y, uint16 *Z)
    554 /* -------------------------------------------------------------------------------- */
    555 {
    556         long j;
    557        
    558         for(j=ncl; j<=nch; j++) {
    559                 Z[j] = X[j] ^ y;
    560         }
    561 }
    562 /* -------------------------------------------------------------------------------- */
    563 IMAGE_EXPORT(void) xorc_si32vector(sint32 *X, long ncl, long nch, sint32 y, sint32 *Z)
    564 /* -------------------------------------------------------------------------------- */
    565 {
    566         long j;
    567        
    568         for(j=ncl; j<=nch; j++) {
    569                 Z[j] = X[j] ^ y;
    570         }
    571 }
    572 /* -------------------------------------------------------------------------------- */
    573 IMAGE_EXPORT(void) xorc_ui32vector(uint32 *X, long ncl, long nch, uint32 y, uint32 *Z)
    574 /* -------------------------------------------------------------------------------- */
    575 {
    576         long j;
    577        
    578         for(j=ncl; j<=nch; j++) {
    579                 Z[j] = X[j] ^ y;
    580         }
    581 }
    582 /* -------------------------------------------------------------------------------- */
    583 IMAGE_EXPORT(void) xorc_si64vector(sint64 *X, long ncl, long nch, sint64 y, sint64 *Z)
    584 /* -------------------------------------------------------------------------------- */
    585 {
    586         long j;
    587        
    588         for(j=ncl; j<=nch; j++) {
    589                 Z[j] = X[j] ^ y;
    590         }
    591 }
    592 /* -------------------------------------------------------------------------------- */
    593 IMAGE_EXPORT(void) xorc_ui64vector(uint64 *X, long ncl, long nch, uint64 y, uint64 *Z)
    594 /* -------------------------------------------------------------------------------- */
    595 {
    596         long j;
    597        
    598         for(j=ncl; j<=nch; j++) {
    599                 Z[j] = X[j] ^ y;
    600         }
    601 }
    602 /* -------------------------------------------------------------------------- */
    603 IMAGE_EXPORT(void) xorc_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 y, rgb8 *Z)
    604 /* -------------------------------------------------------------------------- */
    605 {
    606         long j;
    607     rgb8 x, z;
    608        
    609         for(j=ncl; j<=nch; j++) {
    610         x = X[j];
    611         RGB8_XOR(x,y,z);
    612                 Z[j] = z;
    613         }
    614 }
    615 /* ------------------------------------------------------------------------------ */
    616 IMAGE_EXPORT(void) xorc_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 y, rgbx8 *Z)
    617 /* ------------------------------------------------------------------------------ */
    618 {
    619         long j;
    620     rgbx8 x, z;
    621        
    622         for(j=ncl; j<=nch; j++) {
    623         x = X[j];
    624         RGBX8_XOR(x,y,z);
    625                 Z[j] = z;
    626         }
    627 }
     157
     158#undef xor_type_vector
     159#define xor_type_vector(t) \
     160void short_name(t,xor_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \
     161{                                          \
     162        for (int32_t j = ncl; j <= nch; j++) { \
     163                Z[j] = X[j] ^ Y[j];                \
     164        }                                      \
     165}
     166
     167xor_type_vector(int8_t);
     168xor_type_vector(uint8_t);
     169xor_type_vector(int16_t);
     170xor_type_vector(uint16_t);
     171xor_type_vector(int32_t);
     172xor_type_vector(uint32_t);
     173xor_type_vector(int64_t);
     174xor_type_vector(uint64_t);
     175
     176
     177/* -------------------------------------------------------------------------- */
     178void xor_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z)
     179/* -------------------------------------------------------------------------- */
     180{
     181        for (int32_t j = ncl; j <= nch; j++) {
     182        RGB8_XOR(X[j], Y[j], Z[j]);
     183        }
     184}
     185
     186/* ------------------------------------------------------------------------------ */
     187void xor_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z)
     188/* ------------------------------------------------------------------------------ */
     189{
     190        for (int32_t j = ncl; j <= nch; j++) {
     191        RGBX8_XOR(X[j], Y[j], Z[j]);
     192        }
     193}
     194
     195
     196#undef xorc_type_vector
     197#define xorc_type_vector(t) \
     198void short_name(t,xorc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \
     199{                                          \
     200        for (int32_t j = ncl; j <= nch; j++) { \
     201                Z[j] = X[j] ^ y;                   \
     202        }                                      \
     203}
     204
     205xorc_type_vector(int8_t);
     206xorc_type_vector(uint8_t);
     207xorc_type_vector(int16_t);
     208xorc_type_vector(uint16_t);
     209xorc_type_vector(int32_t);
     210xorc_type_vector(uint32_t);
     211xorc_type_vector(int64_t);
     212xorc_type_vector(uint64_t);
     213
     214
     215/* -------------------------------------------------------------------------- */
     216void xorc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z)
     217/* -------------------------------------------------------------------------- */
     218{
     219        for (int32_t j = ncl; j <= nch; j++) {
     220        RGB8_XOR(X[j], y, Z[j]);
     221        }
     222}
     223
     224/* ------------------------------------------------------------------------------ */
     225void xorc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z)
     226/* ------------------------------------------------------------------------------ */
     227{
     228        for (int32_t j = ncl; j <= nch; j++) {
     229        RGBX8_XOR(X[j], y, Z[j]);
     230        }
     231}
     232
     233
    628234/*
    629235 * -----------
     
    631237 * -----------
    632238 */
    633 /* ----------------------------------------------------------------------- */
    634 IMAGE_EXPORT(void) and_bvector(byte *X, long ncl, long nch, byte *Y, byte *Z)
    635 /* ----------------------------------------------------------------------- */
    636 {
    637         long j;
    638        
    639         for(j=ncl; j<=nch; j++) {
    640                 Z[j] = X[j] & Y[j];
    641         }
    642 }
    643 /* ---------------------------------------------------------------------------- */
    644 IMAGE_EXPORT(void) and_si8vector(sint8 *X, long ncl, long nch, sint8 *Y, sint8 *Z)
    645 /* ---------------------------------------------------------------------------- */
    646 {
    647         long j;
    648        
    649         for(j=ncl; j<=nch; j++) {
    650                 Z[j] = X[j] & Y[j];
    651         }
    652 }
    653 /* ---------------------------------------------------------------------------- */
    654 IMAGE_EXPORT(void) and_ui8vector(uint8 *X, long ncl, long nch, uint8 *Y, uint8 *Z)
    655 /* ---------------------------------------------------------------------------- */
    656 {
    657         long j;
    658        
    659         for(j=ncl; j<=nch; j++) {
    660                 Z[j] = X[j] & Y[j];
    661         }
    662 }
    663 /* -------------------------------------------------------------------------------- */
    664 IMAGE_EXPORT(void) and_si16vector(sint16 *X, long ncl, long nch, sint16 *Y, sint16 *Z)
    665 /* -------------------------------------------------------------------------------- */
    666 {
    667         long j;
    668        
    669         for(j=ncl; j<=nch; j++) {
    670                 Z[j] = X[j] & Y[j];
    671         }
    672 }
    673 /* -------------------------------------------------------------------------------- */
    674 IMAGE_EXPORT(void) and_ui16vector(uint16 *X, long ncl, long nch, uint16 *Y, uint16 *Z)
    675 /* -------------------------------------------------------------------------------- */
    676 {
    677         long j;
    678        
    679         for(j=ncl; j<=nch; j++) {
    680                 Z[j] = X[j] & Y[j];
    681         }
    682 }
    683 /* -------------------------------------------------------------------------------- */
    684 IMAGE_EXPORT(void) and_si32vector(sint32 *X, long ncl, long nch, sint32 *Y, sint32 *Z)
    685 /* -------------------------------------------------------------------------------- */
    686 {
    687         long j;
    688        
    689         for(j=ncl; j<=nch; j++) {
    690                 Z[j] = X[j] & Y[j];
    691         }
    692 }
    693 /* -------------------------------------------------------------------------------- */
    694 IMAGE_EXPORT(void) and_ui32vector(uint32 *X, long ncl, long nch, uint32 *Y, uint32 *Z)
    695 /* -------------------------------------------------------------------------------- */
    696 {
    697         long j;
    698        
    699         for(j=ncl; j<=nch; j++) {
    700                 Z[j] = X[j] & Y[j];
    701         }
    702 }
    703 /* -------------------------------------------------------------------------------- */
    704 IMAGE_EXPORT(void) and_si64vector(sint64 *X, long ncl, long nch, sint64 *Y, sint64 *Z)
    705 /* -------------------------------------------------------------------------------- */
    706 {
    707         long j;
    708        
    709         for(j=ncl; j<=nch; j++) {
    710                 Z[j] = X[j] & Y[j];
    711         }
    712 }
    713 /* -------------------------------------------------------------------------------- */
    714 IMAGE_EXPORT(void) and_ui64vector(uint64 *X, long ncl, long nch, uint64 *Y, uint64 *Z)
    715 /* -------------------------------------------------------------------------------- */
    716 {
    717         long j;
    718        
    719         for(j=ncl; j<=nch; j++) {
    720                 Z[j] = X[j] & Y[j];
    721         }
    722 }
    723 /* -------------------------------------------------------------------------- */
    724 IMAGE_EXPORT(void) and_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 *Y, rgb8 *Z)
    725 /* -------------------------------------------------------------------------- */
    726 {
    727         long j;
    728     rgb8 x, y, z;
    729        
    730         for(j=ncl; j<=nch; j++) {
    731         x = X[j];
    732         y = Y[j];
    733         RGB8_AND(x,y,z);
    734                 Z[j] = z;
    735         }
    736 }
    737 /* ------------------------------------------------------------------------------ */
    738 IMAGE_EXPORT(void) and_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 *Y, rgbx8 *Z)
    739 /* ------------------------------------------------------------------------------ */
    740 {
    741         long j;
    742     rgbx8 x, y, z;
    743        
    744         for(j=ncl; j<=nch; j++) {
    745         x = X[j];
    746         y = Y[j];
    747         RGBX8_AND(x,y,z);
    748                 Z[j] = z;
    749         }
    750 }
    751 /* ----------------------------------------------------------------------- */
    752 IMAGE_EXPORT(void) andc_bvector(byte *X, long ncl, long nch, byte y, byte *Z)
    753 /* ----------------------------------------------------------------------- */
    754 {
    755         long j;
    756        
    757         for(j=ncl; j<=nch; j++) {
    758                 Z[j] = X[j] & y;
    759         }
    760 }
    761 /* ---------------------------------------------------------------------------- */
    762 IMAGE_EXPORT(void) andc_si8vector(sint8 *X, long ncl, long nch, sint8 y, sint8 *Z)
    763 /* ---------------------------------------------------------------------------- */
    764 {
    765         long j;
    766        
    767         for(j=ncl; j<=nch; j++) {
    768                 Z[j] = X[j] & y;
    769         }
    770 }
    771 /* ---------------------------------------------------------------------------- */
    772 IMAGE_EXPORT(void) andc_ui8vector(uint8 *X, long ncl, long nch, uint8 y, uint8 *Z)
    773 /* ---------------------------------------------------------------------------- */
    774 {
    775         long j;
    776        
    777         for(j=ncl; j<=nch; j++) {
    778                 Z[j] = X[j] & y;
    779         }
    780 }
    781 /* -------------------------------------------------------------------------------- */
    782 IMAGE_EXPORT(void) andc_si16vector(sint16 *X, long ncl, long nch, sint16 y, sint16 *Z)
    783 /* -------------------------------------------------------------------------------- */
    784 {
    785         long j;
    786        
    787         for(j=ncl; j<=nch; j++) {
    788                 Z[j] = X[j] & y;
    789         }
    790 }
    791 /* -------------------------------------------------------------------------------- */
    792 IMAGE_EXPORT(void) andc_ui16vector(uint16 *X, long ncl, long nch, uint16 y, uint16 *Z)
    793 /* -------------------------------------------------------------------------------- */
    794 {
    795         long j;
    796        
    797         for(j=ncl; j<=nch; j++) {
    798                 Z[j] = X[j] & y;
    799         }
    800 }
    801 /* -------------------------------------------------------------------------------- */
    802 IMAGE_EXPORT(void) andc_si32vector(sint32 *X, long ncl, long nch, sint32 y, sint32 *Z)
    803 /* -------------------------------------------------------------------------------- */
    804 {
    805         long j;
    806        
    807         for(j=ncl; j<=nch; j++) {
    808                 Z[j] = X[j] & y;
    809         }
    810 }
    811 /* -------------------------------------------------------------------------------- */
    812 IMAGE_EXPORT(void) andc_ui32vector(uint32 *X, long ncl, long nch, uint32 y, uint32 *Z)
    813 /* -------------------------------------------------------------------------------- */
    814 {
    815         long j;
    816        
    817         for(j=ncl; j<=nch; j++) {
    818                 Z[j] = X[j] & y;
    819         }
    820 }
    821 /* -------------------------------------------------------------------------------- */
    822 IMAGE_EXPORT(void) andc_si64vector(sint64 *X, long ncl, long nch, sint64 y, sint64 *Z)
    823 /* -------------------------------------------------------------------------------- */
    824 {
    825         long j;
    826        
    827         for(j=ncl; j<=nch; j++) {
    828                 Z[j] = X[j] & y;
    829         }
    830 }
    831 /* -------------------------------------------------------------------------------- */
    832 IMAGE_EXPORT(void) andc_ui64vector(uint64 *X, long ncl, long nch, uint64 y, uint64 *Z)
    833 /* -------------------------------------------------------------------------------- */
    834 {
    835         long j;
    836        
    837         for(j=ncl; j<=nch; j++) {
    838                 Z[j] = X[j] & y;
    839         }
    840 }
    841 /* -------------------------------------------------------------------------- */
    842 IMAGE_EXPORT(void) andc_rgb8vector(rgb8 *X, long ncl, long nch, rgb8 y, rgb8 *Z)
    843 /* -------------------------------------------------------------------------- */
    844 {
    845         long j;
    846     rgb8 x, z;
    847        
    848         for(j=ncl; j<=nch; j++) {
    849         x = X[j];
    850         RGB8_AND(x,y,z);
    851                 Z[j] = z;
    852         }
    853 }
    854 /* ------------------------------------------------------------------------------ */
    855 IMAGE_EXPORT(void) andc_rgbx8vector(rgbx8 *X, long ncl, long nch, rgbx8 y, rgbx8 *Z)
    856 /* ------------------------------------------------------------------------------ */
    857 {
    858         long j;
    859     rgbx8 x, z;
    860        
    861         for(j=ncl; j<=nch; j++) {
    862         x = X[j];
    863         RGBX8_AND(x,y,z);
    864                 Z[j] = z;
    865         }
    866 }
     239
     240
     241#undef and_type_vector
     242#define and_type_vector(t) \
     243void short_name(t,and_,vector)(t * X, int32_t ncl, int32_t nch, t * Y, t * Z) \
     244{                                          \
     245        for (int32_t j = ncl; j <= nch; j++) { \
     246                Z[j] = X[j] & Y[j];                \
     247        }                                      \
     248}
     249
     250and_type_vector(int8_t);
     251and_type_vector(uint8_t);
     252and_type_vector(int16_t);
     253and_type_vector(uint16_t);
     254and_type_vector(int32_t);
     255and_type_vector(uint32_t);
     256and_type_vector(int64_t);
     257and_type_vector(uint64_t);
     258
     259
     260/* -------------------------------------------------------------------------- */
     261void and_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 * Y, rgb8 * Z)
     262/* -------------------------------------------------------------------------- */
     263{
     264        for (int32_t j = ncl; j <= nch; j++) {
     265        RGB8_AND(X[j], Y[j], Z[j]);
     266        }
     267}
     268
     269/* ------------------------------------------------------------------------------ */
     270void and_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 * Y, rgbx8 * Z)
     271/* ------------------------------------------------------------------------------ */
     272{
     273        for (int32_t j = ncl; j <= nch; j++) {
     274        RGBX8_AND(X[j], Y[j], Z[j]);
     275        }
     276}
     277
     278
     279#undef andc_type_vector
     280#define andc_type_vector(t) \
     281void short_name(t,andc_,vector)(t * X, int32_t ncl, int32_t nch, t y, t * Z) \
     282{                                          \
     283        for (int32_t j = ncl; j <= nch; j++) { \
     284                Z[j] = X[j] ^ y;                   \
     285        }                                      \
     286}
     287
     288andc_type_vector(int8_t);
     289andc_type_vector(uint8_t);
     290andc_type_vector(int16_t);
     291andc_type_vector(uint16_t);
     292andc_type_vector(int32_t);
     293andc_type_vector(uint32_t);
     294andc_type_vector(int64_t);
     295andc_type_vector(uint64_t);
     296
     297
     298/* -------------------------------------------------------------------------- */
     299void andc_rgb8vector(rgb8 * X, int32_t ncl, int32_t nch, rgb8 y, rgb8 * Z)
     300/* -------------------------------------------------------------------------- */
     301{
     302        for (int32_t j = ncl; j <= nch; j++) {
     303        RGB8_AND(X[j], y, Z[j]);
     304        }
     305}
     306
     307/* ------------------------------------------------------------------------------ */
     308void andc_rgbx8vector(rgbx8 * X, int32_t ncl, int32_t nch, rgbx8 y, rgbx8 * Z)
     309/* ------------------------------------------------------------------------------ */
     310{
     311        for (int32_t j = ncl; j <= nch; j++) {
     312        RGBX8_AND(X[j], y, Z[j]);
     313        }
     314}
     315
     316
     317// Local Variables:
     318// tab-width: 4
     319// c-basic-offset: 4
     320// c-file-offsets:((innamespace . 0)(inline-open . 0))
     321// indent-tabs-mode: nil
     322// End:
     323
     324// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     325
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrbool2.c

    r772 r822  
    1616#include <stddef.h>
    1717#include <stdlib.h>
    18 #include <math.h> // fabs
     18#include <math.h>
     19#include <stdbool.h>
    1920
     21#include "nrc_os_config.h"
    2022#include "mypredef.h"
    2123#include "nrtype.h"
     
    2729#include "nrbool2.h"
    2830
    29 /* ----------------------------------------------------------------------------------- */
    30 IMAGE_EXPORT(int) cmpeq_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y)
    31 /* ----------------------------------------------------------------------------------- */
    32 {
    33         int i, j;
    34        
    35         for(i=nrl; i<=nrh; i++) {
    36                 for(j=ncl; j<=nch; j++) {
    37                         if(X[i][j] != Y[i][j]) return 1;
    38                 }
    39         }
    40         return 0;
     31
     32#undef cmpeq_type_matrix
     33#define cmpeq_type_matrix(t) \
     34int32_t short_name(t,cmpeq_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y) \
     35{                                              \
     36    for (int32_t i = nrl; i <= nrh; i++) {     \
     37        for (int32_t j = ncl; j <= nch; j++) { \
     38            if (X[i][j] != Y[i][j]) {          \
     39                return 1;                      \
     40            }                                  \
     41        }                                      \
     42    }                                          \
     43    return 0;                                  \
    4144}
    42 /* --------------------------------------------------------------------------------------- */
    43 IMAGE_EXPORT(int) cmpeq_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y)
    44 /* --------------------------------------------------------------------------------------- */
    45 {
    46         int i, j;
    47        
    48         for(i=nrl; i<=nrh; i++) {
    49                 for(j=ncl; j<=nch; j++) {
    50                         if(X[i][j] != Y[i][j]) return 1;
    51                 }
    52         }
    53         return 0;
    54 }
    55 /* ----------------------------------------------------------------------------------------- */
    56 IMAGE_EXPORT(int) cmpeq_ui8matrix(uint8 **X, long nrl, long nrh, long ncl, long nch, uint8 **Y)
    57 /* ----------------------------------------------------------------------------------------- */
    58 {
    59         int i, j;
    60        
    61         for(i=nrl; i<=nrh; i++) {
    62                 for(j=ncl; j<=nch; j++) {
    63                         if(X[i][j] != Y[i][j]) return 1;
    64                 }
    65         }
    66         return 0;
    67 }
    68 /* -------------------------------------------------------------------------------------------- */
    69 IMAGE_EXPORT(int) cmpeq_si16matrix(sint16 **X, long nrl ,long nrh, long ncl, long nch, sint16 **Y)
    70 /* -------------------------------------------------------------------------------------------- */
    71 {
    72         int i, j;
    73        
    74         for(i=nrl; i<=nrh; i++) {
    75                 for(j=ncl; j<=nch; j++) {
    76                         if(X[i][j] != Y[i][j]) return 1;
    77                 }
    78         }
    79         return 0;
    80 }
    81 /* -------------------------------------------------------------------------------------------- */
    82 IMAGE_EXPORT(int) cmpeq_ui16matrix(uint16 **X, long nrl, long nrh, long ncl, long nch, uint16 **Y)
    83 /* -------------------------------------------------------------------------------------------- */
    84 {
    85         int i, j;
    86        
    87         for(i=nrl; i<=nrh; i++) {
    88                 for(j=ncl; j<=nch; j++) {
    89                         if(X[i][j] != Y[i][j]) return 1;
    90                 }
    91         }
    92         return 0;
    93 }
    94 /* -------------------------------------------------------------------------------------------- */
    95 IMAGE_EXPORT(int) cmpeq_si32matrix(sint32 **X, long nrl, long nrh, long ncl, long nch, sint32 **Y)
    96 /* -------------------------------------------------------------------------------------------- */
    97 {
    98         int i, j;
    99        
    100         for(i=nrl; i<=nrh; i++) {
    101                 for(j=ncl; j<=nch; j++) {
    102                         if(X[i][j] != Y[i][j]) return 1;
    103                 }
    104         }
    105         return 0;
    106 }
    107 /* -------------------------------------------------------------------------------------------- */
    108 IMAGE_EXPORT(int) cmpeq_ui32matrix(uint32 **X, long nrl, long nrh, long ncl, long nch, uint32 **Y)
    109 /* -------------------------------------------------------------------------------------------- */
    110 {
    111         int i, j;
    112        
    113         for(i=nrl; i<=nrh; i++) {
    114                 for(j=ncl; j<=nch; j++) {
    115                         if(X[i][j] != Y[i][j]) return 1;
    116                 }
    117         }
    118         return 0;
    119 }
     45
     46cmpeq_type_matrix(int8_t);
     47cmpeq_type_matrix(uint8_t);
     48cmpeq_type_matrix(int16_t);
     49cmpeq_type_matrix(uint16_t);
     50cmpeq_type_matrix(int32_t);
     51cmpeq_type_matrix(uint32_t);
     52cmpeq_type_matrix(int64_t);
     53cmpeq_type_matrix(uint64_t);
     54
     55
    12056
    12157/*
     
    12561 */
    12662
    127 /* ---------------------------------------------------------------------------------- */
    128 IMAGE_EXPORT(void) not_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y)
    129 /* ---------------------------------------------------------------------------------- */
    130 {
    131         long i;
    132        
    133         for(i=nrl; i<=nrh; i++) {
    134                 not_bvector(X[i], ncl, nch, Y[i]);
    135         }
     63#undef not_type_matrix
     64#define not_type_matrix(t) \
     65void short_name(t,not_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y) \
     66{                                                        \
     67    for (int32_t i = nrl; i <= nrh; i++) {               \
     68        short_name(t,not_,vector)(X[i], ncl, nch, Y[i]); \
     69    }                                                    \
    13670}
    137 /* -------------------------------------------------------------------------------------- */
    138 IMAGE_EXPORT(void) not_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y)
    139 /* -------------------------------------------------------------------------------------- */
    140 {
    141         long i;
    142    
    143     for(i=nrl; i<=nrh; i++) {
    144         not_si8vector(X[i], ncl, nch, Y[i]);
    145     }
    146 }
    147 /* -------------------------------------------------------------------------------------- */
    148 IMAGE_EXPORT(void) not_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y)
    149 /* -------------------------------------------------------------------------------------- */
    150 {
    151     long i;
    152    
    153     for(i=nrl; i<=nrh; i++) {
    154         not_ui8vector(X[i], ncl, nch, Y[i]);
    155     }
    156 }
    157 /* ----------------------------------------------------------------------------------------- */
    158 IMAGE_EXPORT(void) not_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y)
    159 /* ----------------------------------------------------------------------------------------- */
    160 {
    161     long i;
    162    
    163     for(i=nrl; i<=nrh; i++) {
    164         not_si16vector(X[i], ncl, nch, Y[i]);
    165     }
    166 }
    167 /* ----------------------------------------------------------------------------------------- */
    168 IMAGE_EXPORT(void) not_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y)
    169 /* ----------------------------------------------------------------------------------------- */
    170 {
    171     long i;
    172    
    173     for(i=nrl; i<=nrh; i++) {
    174         not_ui16vector(X[i], ncl, nch, Y[i]);
    175     }
    176 }
    177 /* ---------------------------------------------------------------------------------------- */
    178 IMAGE_EXPORT(void) not_si32matrix(int32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y)
    179 /* ---------------------------------------------------------------------------------------- */
    180 {
    181     long i;
    182    
    183     for(i=nrl; i<=nrh; i++) {
    184         not_si32vector(X[i], ncl, nch, Y[i]);
    185     }
    186 }
    187 /* ----------------------------------------------------------------------------------------- */
    188 IMAGE_EXPORT(void) not_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y)
    189 /* ----------------------------------------------------------------------------------------- */
    190 {
    191     long i;
    192    
    193     for(i=nrl; i<=nrh; i++) {
    194         not_ui32vector(X[i], ncl, nch, Y[i]);
    195     }
    196 }
    197 /* --------------------------------------------------------------------------------------- */
    198 IMAGE_EXPORT(void) not_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y)
    199 /* --------------------------------------------------------------------------------------- */
    200 {
    201     long i;
    202    
    203     for(i=nrl; i<=nrh; i++) {
    204         not_rgb8vector(X[i], ncl, nch, Y[i]);
    205     }
    206 }
    207 /* ------------------------------------------------------------------------------------------ */
    208 IMAGE_EXPORT(void) not_rgbx8matrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y)
    209 /* ------------------------------------------------------------------------------------------ */
    210 {
    211     long i;
    212    
    213     for(i=nrl; i<=nrh; i++) {
    214         not_rgbx8vector(X[i], ncl, nch, Y[i]);
    215     }
    216 }
     71
     72not_type_matrix(int8_t);
     73not_type_matrix(uint8_t);
     74not_type_matrix(int16_t);
     75not_type_matrix(uint16_t);
     76not_type_matrix(int32_t);
     77not_type_matrix(uint32_t);
     78not_type_matrix(int64_t);
     79not_type_matrix(uint64_t);
     80not_type_matrix(rgb8);
     81not_type_matrix(rgbx8);
     82
     83
    21784
    21885/*
     
    22289 */
    22390
    224 /* ------------------------------------------------------------------------------------------- */
    225 IMAGE_EXPORT(void) or_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y, byte **Z)
    226 /* ------------------------------------------------------------------------------------------- */
    227 {
    228     long i;
    229    
    230     for(i=nrl; i<=nrh; i++) {
    231         or_bvector(X[i], ncl, nch, Y[i], Z[i]);
    232     }
     91#undef or_type_matrix
     92#define or_type_matrix(t) \
     93void short_name(t,or_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \
     94{                                                             \
     95    for (int32_t i = nrl; i <= nrh; i++) {                    \
     96        short_name(t,or_,vector)(X[i], ncl, nch, Y[i], Z[i]); \
     97    }                                                         \
     98}                                                             \
     99void short_name(t,orc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \
     100{                                                             \
     101    for (int32_t i = nrl; i <= nrh; i++) {                    \
     102        short_name(t,orc_,vector)(X[i], ncl, nch, y, Z[i]);   \
     103    }                                                         \
    233104}
    234 /* ------------------------------------------------------------------------------------------------ */
    235 IMAGE_EXPORT(void) or_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z)
    236 /* ------------------------------------------------------------------------------------------------ */
    237 {
    238     long i;
    239    
    240     for(i=nrl; i<=nrh; i++) {
    241         or_si8vector(X[i], ncl, nch, Y[i], Z[i]);
    242     }
    243 }
    244 /* ------------------------------------------------------------------------------------------------ */
    245 IMAGE_EXPORT(void) or_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z)
    246 /* ------------------------------------------------------------------------------------------------ */
    247 {
    248     long i;
    249    
    250     for(i=nrl; i<=nrh; i++) {
    251         or_ui8vector(X[i], ncl, nch, Y[i], Z[i]);
    252     }
    253 }
    254 /* ---------------------------------------------------------------------------------------------------- */
    255 IMAGE_EXPORT(void) or_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z)
    256 /* ---------------------------------------------------------------------------------------------------- */
    257 {
    258     long i;
    259    
    260     for(i=nrl; i<=nrh; i++) {
    261         or_si16vector(X[i], ncl, nch, Y[i], Z[i]);
    262     }
    263 }
    264 /* ---------------------------------------------------------------------------------------------------- */
    265 IMAGE_EXPORT(void) or_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z)
    266 /* ---------------------------------------------------------------------------------------------------- */
    267 {
    268     long i;
    269    
    270     for(i=nrl; i<=nrh; i++) {
    271         or_ui16vector(X[i], ncl, nch, Y[i], Z[i]);
    272     }
    273 }
    274 /* ---------------------------------------------------------------------------------------------------- */
    275 IMAGE_EXPORT(void) or_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z)
    276 /* ---------------------------------------------------------------------------------------------------- */
    277 {
    278     long i;
    279    
    280     for(i=nrl; i<=nrh; i++) {
    281         or_si32vector(X[i], ncl, nch, Y[i], Z[i]);
    282     }
    283 }
    284 /* ---------------------------------------------------------------------------------------------------- */
    285 IMAGE_EXPORT(void) or_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z)
    286 /* ---------------------------------------------------------------------------------------------------- */
    287 {
    288     long i;
    289    
    290     for(i=nrl; i<=nrh; i++) {
    291         or_ui32vector(X[i], ncl, nch, Y[i], Z[i]);
    292     }
    293 }
    294 /* ---------------------------------------------------------------------------------------------------- */
    295 IMAGE_EXPORT(void) or_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z)
    296 /* ---------------------------------------------------------------------------------------------------- */
    297 {
    298     long i;
    299    
    300     for(i=nrl; i<=nrh; i++) {
    301         or_si64vector(X[i], ncl, nch, Y[i], Z[i]);
    302     }
    303 }
    304 /* ---------------------------------------------------------------------------------------------------- */
    305 IMAGE_EXPORT(void) or_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z)
    306 /* ---------------------------------------------------------------------------------------------------- */
    307 {
    308     long i;
    309    
    310     for(i=nrl; i<=nrh; i++) {
    311         or_ui64vector(X[i], ncl, nch, Y[i], Z[i]);
    312     }
    313 }
    314 /* ---------------------------------------------------------------------------------------------- */
    315 IMAGE_EXPORT(void) or_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z)
    316 /* ---------------------------------------------------------------------------------------------- */
    317 {
    318     long i;
    319    
    320     for(i=nrl; i<=nrh; i++) {
    321         or_rgb8vector(X[i], ncl, nch, Y[i], Z[i]);
    322     }
    323 }
    324 /* -------------------------------------------------------------------------------------------------- */
    325 IMAGE_EXPORT(void) or_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z)
    326 /* -------------------------------------------------------------------------------------------------- */
    327 {
    328     long i;
    329    
    330     for(i=nrl; i<=nrh; i++) {
    331         or_rgbx8vector(X[i], ncl, nch, Y[i], Z[i]);
    332     }
    333 }
    334 /* ------------------------------------------------------------------------------------------ */
    335 IMAGE_EXPORT(void) orc_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte y, byte **Z)
    336 /* ------------------------------------------------------------------------------------------ */
    337 {
    338     long i;
    339    
    340     for(i=nrl; i<=nrh; i++) {
    341         orc_bvector(X[i], ncl, nch, y, Z[i]);
    342     }
    343 }
    344 /* ----------------------------------------------------------------------------------------------- */
    345 IMAGE_EXPORT(void) orc_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z)
    346 /* ----------------------------------------------------------------------------------------------- */
    347 {
    348     long i;
    349    
    350     for(i=nrl; i<=nrh; i++) {
    351         orc_si8vector(X[i], ncl, nch, y, Z[i]);
    352     }
    353 }
    354 /* ----------------------------------------------------------------------------------------------- */
    355 IMAGE_EXPORT(void) orc_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z)
    356 /* ----------------------------------------------------------------------------------------------- */
    357 {
    358     long i;
    359    
    360     for(i=nrl; i<=nrh; i++) {
    361         orc_ui8vector(X[i], ncl, nch, y, Z[i]);
    362     }
    363 }
    364 /* -------------------------------------------------------------------------------------------------- */
    365 IMAGE_EXPORT(void) orc_i16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z)
    366 /* -------------------------------------------------------------------------------------------------- */
    367 {
    368     long i;
    369    
    370     for(i=nrl; i<=nrh; i++) {
    371         orc_si16vector(X[i], ncl, nch, y, Z[i]);
    372     }
    373 }
    374 /* --------------------------------------------------------------------------------------------------- */
    375 IMAGE_EXPORT(void) orc_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z)
    376 /* --------------------------------------------------------------------------------------------------- */
    377 {
    378     long i;
    379    
    380     for(i=nrl; i<=nrh; i++) {
    381         orc_ui16vector(X[i], ncl, nch, y, Z[i]);
    382     }
    383 }
    384 /* --------------------------------------------------------------------------------------------------- */
    385 IMAGE_EXPORT(void) orc_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z)
    386 /* --------------------------------------------------------------------------------------------------- */
    387 {
    388     long i;
    389    
    390     for(i=nrl; i<=nrh; i++) {
    391         orc_si32vector(X[i], ncl, nch, y, Z[i]);
    392     }
    393 }
    394 /* --------------------------------------------------------------------------------------------------- */
    395 IMAGE_EXPORT(void) orc_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z)
    396 /* --------------------------------------------------------------------------------------------------- */
    397 {
    398     long i;
    399    
    400     for(i=nrl; i<=nrh; i++) {
    401         orc_ui32vector(X[i], ncl, nch, y, Z[i]);
    402     }
    403 }
    404 /* --------------------------------------------------------------------------------------------------- */
    405 IMAGE_EXPORT(void) orc_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z)
    406 /* --------------------------------------------------------------------------------------------------- */
    407 {
    408     long i;
    409    
    410     for(i=nrl; i<=nrh; i++) {
    411         orc_si64vector(X[i], ncl, nch, y, Z[i]);
    412     }
    413 }
    414 /* --------------------------------------------------------------------------------------------------- */
    415 IMAGE_EXPORT(void) orc_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z)
    416105
    417 /* --------------------------------------------------------------------------------------------------- */
    418 {
    419     long i;
    420    
    421     for(i=nrl; i<=nrh; i++) {
    422         orc_ui64vector(X[i], ncl, nch, y, Z[i]);
    423     }
    424 }
    425 /* --------------------------------------------------------------------------------------------- */
    426 IMAGE_EXPORT(void) orc_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z)
    427 /* --------------------------------------------------------------------------------------------- */
    428 {
    429     long i;
    430    
    431     for(i=nrl; i<=nrh; i++) {
    432         orc_rgb8vector(X[i], ncl, nch, y, Z[i]);
    433     }
    434 }
    435 /* ------------------------------------------------------------------------------------------------- */
    436 IMAGE_EXPORT(void) orc_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z)
    437 /* ------------------------------------------------------------------------------------------------- */
    438 {
    439     long i;
    440    
    441     for(i=nrl; i<=nrh; i++) {
    442         orc_rgbx8vector(X[i], ncl, nch, y, Z[i]);
    443     }
    444 }
     106or_type_matrix(int8_t);
     107or_type_matrix(uint8_t);
     108or_type_matrix(int16_t);
     109or_type_matrix(uint16_t);
     110or_type_matrix(int32_t);
     111or_type_matrix(uint32_t);
     112or_type_matrix(int64_t);
     113or_type_matrix(uint64_t);
     114or_type_matrix(rgb8);
     115or_type_matrix(rgbx8);
     116
    445117
    446118/*
     
    450122 */
    451123
    452 /* -------------------------------------------------------------------------------------------- */
    453 IMAGE_EXPORT(void) xor_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y, byte **Z)
    454 /* -------------------------------------------------------------------------------------------- */
    455 {
    456     long i;
    457    
    458     for(i=nrl; i<=nrh; i++) {
    459         xor_bvector(X[i], ncl, nch, Y[i], Z[i]);
    460     }
     124#undef xor_type_matrix
     125#define xor_type_matrix(t) \
     126void short_name(t,xor_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \
     127{                                                              \
     128    for (int32_t i = nrl; i <= nrh; i++) {                     \
     129        short_name(t,xor_,vector)(X[i], ncl, nch, Y[i], Z[i]); \
     130    }                                                          \
     131}                                                              \
     132void short_name(t,xorc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \
     133{                                                              \
     134    for (int32_t i = nrl; i <= nrh; i++) {                     \
     135        short_name(t,xorc_,vector)(X[i], ncl, nch, y, Z[i]);   \
     136    }                                                          \
    461137}
    462 /* ------------------------------------------------------------------------------------------------- */
    463 IMAGE_EXPORT(void) xor_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z)
    464 /* ------------------------------------------------------------------------------------------------- */
    465 {
    466     long i;
    467    
    468     for(i=nrl; i<=nrh; i++) {
    469         xor_si8vector(X[i], ncl, nch, Y[i], Z[i]);
    470     }
    471 }
    472 /* ------------------------------------------------------------------------------------------------- */
    473 IMAGE_EXPORT(void) xor_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z)
    474 /* ------------------------------------------------------------------------------------------------- */
    475 {
    476     long i;
    477    
    478     for(i=nrl; i<=nrh; i++) {
    479         xor_ui8vector(X[i], ncl, nch, Y[i], Z[i]);
    480     }
    481 }
    482 /* ----------------------------------------------------------------------------------------------------- */
    483 IMAGE_EXPORT(void) xor_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z)
    484 /* ----------------------------------------------------------------------------------------------------- */
    485 {
    486     long i;
    487    
    488     for(i=nrl; i<=nrh; i++) {
    489         xor_si16vector(X[i], ncl, nch, Y[i], Z[i]);
    490     }
    491 }
    492 /* ----------------------------------------------------------------------------------------------------- */
    493 IMAGE_EXPORT(void) xor_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z)
    494 /* ----------------------------------------------------------------------------------------------------- */
    495 {
    496     long i;
    497    
    498     for(i=nrl; i<=nrh; i++) {
    499         xor_ui16vector(X[i], ncl, nch, Y[i], Z[i]);
    500     }
    501 }
    502 /* ----------------------------------------------------------------------------------------------------- */
    503 IMAGE_EXPORT(void) xor_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z)
    504 /* ----------------------------------------------------------------------------------------------------- */
    505 {
    506     long i;
    507    
    508     for(i=nrl; i<=nrh; i++) {
    509         xor_si32vector(X[i], ncl, nch, Y[i], Z[i]);
    510     }
    511 }
    512 /* ----------------------------------------------------------------------------------------------------- */
    513 IMAGE_EXPORT(void) xor_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z)
    514 /* ----------------------------------------------------------------------------------------------------- */
    515 {
    516     long i;
    517    
    518     for(i=nrl; i<=nrh; i++) {
    519         xor_ui32vector(X[i], ncl, nch, Y[i], Z[i]);
    520     }
    521 }
    522 /* ----------------------------------------------------------------------------------------------------- */
    523 IMAGE_EXPORT(void) xor_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z)
    524 /* ----------------------------------------------------------------------------------------------------- */
    525 {
    526     long i;
    527    
    528     for(i=nrl; i<=nrh; i++) {
    529         xor_si64vector(X[i], ncl, nch, Y[i], Z[i]);
    530     }
    531 }
    532 /* ----------------------------------------------------------------------------------------------------- */
    533 IMAGE_EXPORT(void) xor_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z)
    534 /* ----------------------------------------------------------------------------------------------------- */
    535 {
    536     long i;
    537    
    538     for(i=nrl; i<=nrh; i++) {
    539         xor_ui64vector(X[i], ncl, nch, Y[i], Z[i]);
    540     }
    541 }
    542 /* ----------------------------------------------------------------------------------------------- */
    543 IMAGE_EXPORT(void) xor_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z)
    544 /* ----------------------------------------------------------------------------------------------- */
    545 {
    546     long i;
    547    
    548     for(i=nrl; i<=nrh; i++) {
    549         xor_rgb8vector(X[i], ncl, nch, Y[i], Z[i]);
    550     }
    551 }
    552 /* --------------------------------------------------------------------------------------------------- */
    553 IMAGE_EXPORT(void) xor_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z)
    554 /* --------------------------------------------------------------------------------------------------- */
    555 {
    556     long i;
    557    
    558     for(i=nrl; i<=nrh; i++) {
    559         xor_rgbx8vector(X[i], ncl, nch, Y[i], Z[i]);
    560     }
    561 }
    562 /* ------------------------------------------------------------------------------------------- */
    563 IMAGE_EXPORT(void) xorc_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte y, byte **Z)
    564 /* ------------------------------------------------------------------------------------------- */
    565 {
    566     long i;
    567    
    568     for(i=nrl; i<=nrh; i++) {
    569         xorc_bvector(X[i], ncl, nch, y, Z[i]);
    570     }
    571 }
    572 /* ------------------------------------------------------------------------------------------------ */
    573 IMAGE_EXPORT(void) xorc_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z)
    574 /* ------------------------------------------------------------------------------------------------ */
    575 {
    576     long i;
    577    
    578     for(i=nrl; i<=nrh; i++) {
    579         xorc_si8vector(X[i], ncl, nch, y, Z[i]);
    580     }
    581 }
    582 /* ------------------------------------------------------------------------------------------------ */
    583 IMAGE_EXPORT(void) xorc_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z)
    584 /* ------------------------------------------------------------------------------------------------ */
    585 {
    586     long i;
    587    
    588     for(i=nrl; i<=nrh; i++) {
    589         xorc_ui8vector(X[i], ncl, nch, y, Z[i]);
    590     }
    591 }
    592 /* --------------------------------------------------------------------------------------------------- */
    593 IMAGE_EXPORT(void) xorc_i16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z)
    594 /* --------------------------------------------------------------------------------------------------- */
    595 {
    596     long i;
    597    
    598     for(i=nrl; i<=nrh; i++) {
    599         xorc_si16vector(X[i], ncl, nch, y, Z[i]);
    600     }
    601 }
    602 /* ---------------------------------------------------------------------------------------------------- */
    603 IMAGE_EXPORT(void) xorc_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z)
    604 /* ---------------------------------------------------------------------------------------------------- */
    605 {
    606     long i;
    607    
    608     for(i=nrl; i<=nrh; i++) {
    609         xorc_ui16vector(X[i], ncl, nch, y, Z[i]);
    610     }
    611 }
    612 /* ---------------------------------------------------------------------------------------------------- */
    613 IMAGE_EXPORT(void) xorc_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z)
    614 /* ---------------------------------------------------------------------------------------------------- */
    615 {
    616     long i;
    617    
    618     for(i=nrl; i<=nrh; i++) {
    619         xorc_si32vector(X[i], ncl, nch, y, Z[i]);
    620     }
    621 }
    622 /* ---------------------------------------------------------------------------------------------------- */
    623 IMAGE_EXPORT(void) xorc_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z)
    624 /* ---------------------------------------------------------------------------------------------------- */
    625 {
    626     long i;
    627    
    628     for(i=nrl; i<=nrh; i++) {
    629         xorc_ui32vector(X[i], ncl, nch, y, Z[i]);
    630     }
    631 }
    632 /* ---------------------------------------------------------------------------------------------------- */
    633 IMAGE_EXPORT(void) xorc_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z)
    634 /* ---------------------------------------------------------------------------------------------------- */
    635 {
    636     long i;
    637    
    638     for(i=nrl; i<=nrh; i++) {
    639         xorc_si64vector(X[i], ncl, nch, y, Z[i]);
    640     }
    641 }
    642 /* ---------------------------------------------------------------------------------------------------- */
    643 IMAGE_EXPORT(void) xorc_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z)
    644 /* ---------------------------------------------------------------------------------------------------- */
    645 {
    646     long i;
    647    
    648     for(i=nrl; i<=nrh; i++) {
    649         xorc_ui64vector(X[i], ncl, nch, y, Z[i]);
    650     }
    651 }
    652 /* ---------------------------------------------------------------------------------------------- */
    653 IMAGE_EXPORT(void) xorc_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z)
    654 /* ---------------------------------------------------------------------------------------------- */
    655 {
    656     long i;
    657    
    658     for(i=nrl; i<=nrh; i++) {
    659         xorc_rgb8vector(X[i], ncl, nch, y, Z[i]);
    660     }
    661 }
    662 /* -------------------------------------------------------------------------------------------------- */
    663 IMAGE_EXPORT(void) xorc_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z)
    664 /* -------------------------------------------------------------------------------------------------- */
    665 {
    666     long i;
    667    
    668     for(i=nrl; i<=nrh; i++) {
    669         xorc_rgbx8vector(X[i], ncl, nch, y, Z[i]);
    670     }
    671 }
     138
     139xor_type_matrix(int8_t);
     140xor_type_matrix(uint8_t);
     141xor_type_matrix(int16_t);
     142xor_type_matrix(uint16_t);
     143xor_type_matrix(int32_t);
     144xor_type_matrix(uint32_t);
     145xor_type_matrix(int64_t);
     146xor_type_matrix(uint64_t);
     147xor_type_matrix(rgb8);
     148xor_type_matrix(rgbx8);
    672149
    673150
     
    678155 */
    679156
    680 /* -------------------------------------------------------------------------------------------- */
    681 IMAGE_EXPORT(void) and_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte **Y, byte **Z)
    682 /* -------------------------------------------------------------------------------------------- */
    683 {
    684     long i;
    685    
    686     for(i=nrl; i<=nrh; i++) {
    687         and_bvector(X[i], ncl, nch, Y[i], Z[i]);
    688     }
     157#undef and_type_matrix
     158#define and_type_matrix(t) \
     159void short_name(t,and_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** Y, t ** Z) \
     160{                                                              \
     161    for (int32_t i = nrl; i <= nrh; i++) {                     \
     162        short_name(t,and_,vector)(X[i], ncl, nch, Y[i], Z[i]); \
     163    }                                                          \
     164}                                                              \
     165void short_name(t,andc_,matrix)(t ** X, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t y, t ** Z) \
     166{                                                              \
     167    for (int32_t i = nrl; i <= nrh; i++) {                     \
     168        short_name(t,andc_,vector)(X[i], ncl, nch, y, Z[i]);   \
     169    }                                                          \
    689170}
    690 /* ------------------------------------------------------------------------------------------------- */
    691 IMAGE_EXPORT(void) and_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 **Y, sint8 **Z)
    692 /* ------------------------------------------------------------------------------------------------- */
    693 {
    694     long i;
    695    
    696     for(i=nrl; i<=nrh; i++) {
    697         and_si8vector(X[i], ncl, nch, Y[i], Z[i]);
    698     }
    699 }
    700 /* ------------------------------------------------------------------------------------------------- */
    701 IMAGE_EXPORT(void) and_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 **Y, uint8 **Z)
    702 /* ------------------------------------------------------------------------------------------------- */
    703 {
    704     long i;
    705    
    706     for(i=nrl; i<=nrh; i++) {
    707         and_ui8vector(X[i], ncl, nch, Y[i], Z[i]);
    708     }
    709 }
    710 /* ----------------------------------------------------------------------------------------------------- */
    711 IMAGE_EXPORT(void) and_si16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 **Y, sint16 **Z)
    712 /* ----------------------------------------------------------------------------------------------------- */
    713 {
    714     long i;
    715    
    716     for(i=nrl; i<=nrh; i++) {
    717         and_si16vector(X[i], ncl, nch, Y[i], Z[i]);
    718     }
    719 }
    720 /* ----------------------------------------------------------------------------------------------------- */
    721 IMAGE_EXPORT(void) and_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 **Y, uint16 **Z)
    722 /* ----------------------------------------------------------------------------------------------------- */
    723 {
    724     long i;
    725    
    726     for(i=nrl; i<=nrh; i++) {
    727         and_ui16vector(X[i], ncl, nch, Y[i], Z[i]);
    728     }
    729 }
    730 /* ----------------------------------------------------------------------------------------------------- */
    731 IMAGE_EXPORT(void) and_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 **Y, sint32 **Z)
    732 /* ----------------------------------------------------------------------------------------------------- */
    733 {
    734     long i;
    735    
    736     for(i=nrl; i<=nrh; i++) {
    737         and_si32vector(X[i], ncl, nch, Y[i], Z[i]);
    738     }
    739 }
    740 /* ----------------------------------------------------------------------------------------------------- */
    741 IMAGE_EXPORT(void) and_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 **Y, uint32 **Z)
    742 /* ----------------------------------------------------------------------------------------------------- */
    743 {
    744     long i;
    745    
    746     for(i=nrl; i<=nrh; i++) {
    747         and_ui32vector(X[i], ncl, nch, Y[i], Z[i]);
    748     }
    749 }
    750 /* ----------------------------------------------------------------------------------------------------- */
    751 IMAGE_EXPORT(void) and_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 **Y, sint64 **Z)
    752 /* ----------------------------------------------------------------------------------------------------- */
    753 {
    754     long i;
    755    
    756     for(i=nrl; i<=nrh; i++) {
    757         and_si64vector(X[i], ncl, nch, Y[i], Z[i]);
    758     }
    759 }
    760 /* ----------------------------------------------------------------------------------------------------- */
    761 IMAGE_EXPORT(void) and_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 **Y, uint64 **Z)
    762 /* ----------------------------------------------------------------------------------------------------- */
    763 {
    764     long i;
    765    
    766     for(i=nrl; i<=nrh; i++) {
    767         and_ui64vector(X[i], ncl, nch, Y[i], Z[i]);
    768     }
    769 }
    770 /* ----------------------------------------------------------------------------------------------- */
    771 IMAGE_EXPORT(void) and_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 **Y, rgb8 **Z)
    772 /* ----------------------------------------------------------------------------------------------- */
    773 {
    774     long i;
    775    
    776     for(i=nrl; i<=nrh; i++) {
    777         and_rgb8vector(X[i], ncl, nch, Y[i], Z[i]);
    778     }
    779 }
    780 /* --------------------------------------------------------------------------------------------------- */
    781 IMAGE_EXPORT(void) and_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 **Y, rgbx8 **Z)
    782 /* --------------------------------------------------------------------------------------------------- */
    783 {
    784     long i;
    785    
    786     for(i=nrl; i<=nrh; i++) {
    787         and_rgbx8vector(X[i], ncl, nch, Y[i], Z[i]);
    788     }
    789 }
    790 /* ------------------------------------------------------------------------------------------- */
    791 IMAGE_EXPORT(void) andc_bmatrix(byte **X, long nrl,long nrh,long ncl, long nch, byte y, byte **Z)
    792 /* ------------------------------------------------------------------------------------------- */
    793 {
    794     long i;
    795    
    796     for(i=nrl; i<=nrh; i++) {
    797         andc_bvector(X[i], ncl, nch, y, Z[i]);
    798     }
    799 }
    800 /* ------------------------------------------------------------------------------------------------ */
    801 IMAGE_EXPORT(void) andc_si8matrix(sint8 **X, long nrl,long nrh,long ncl, long nch, sint8 y, sint8 **Z)
    802 /* ------------------------------------------------------------------------------------------------ */
    803 {
    804     long i;
    805    
    806     for(i=nrl; i<=nrh; i++) {
    807         andc_si8vector(X[i], ncl, nch, y, Z[i]);
    808     }
    809 }
    810 /* ------------------------------------------------------------------------------------------------ */
    811 IMAGE_EXPORT(void) andc_ui8matrix(uint8 **X, long nrl,long nrh,long ncl, long nch, uint8 y, uint8 **Z)
    812 /* ------------------------------------------------------------------------------------------------ */
    813 {
    814     long i;
    815    
    816     for(i=nrl; i<=nrh; i++) {
    817         andc_ui8vector(X[i], ncl, nch, y, Z[i]);
    818     }
    819 }
    820 /* --------------------------------------------------------------------------------------------------- */
    821 IMAGE_EXPORT(void) andc_i16matrix(sint16 **X, long nrl,long nrh,long ncl, long nch, sint16 y, sint16 **Z)
    822 /* --------------------------------------------------------------------------------------------------- */
    823 {
    824     long i;
    825    
    826     for(i=nrl; i<=nrh; i++) {
    827         andc_si16vector(X[i], ncl, nch, y, Z[i]);
    828     }
    829 }
    830 /* ---------------------------------------------------------------------------------------------------- */
    831 IMAGE_EXPORT(void) andc_ui16matrix(uint16 **X, long nrl,long nrh,long ncl, long nch, uint16 y, uint16 **Z)
    832 /* ---------------------------------------------------------------------------------------------------- */
    833 {
    834     long i;
    835    
    836     for(i=nrl; i<=nrh; i++) {
    837         andc_ui16vector(X[i], ncl, nch, y, Z[i]);
    838     }
    839 }
    840 /* ---------------------------------------------------------------------------------------------------- */
    841 IMAGE_EXPORT(void) andc_si32matrix(sint32 **X, long nrl,long nrh,long ncl, long nch, sint32 y, sint32 **Z)
    842 /* ---------------------------------------------------------------------------------------------------- */
    843 {
    844     long i;
    845    
    846     for(i=nrl; i<=nrh; i++) {
    847         andc_si32vector(X[i], ncl, nch, y, Z[i]);
    848     }
    849 }
    850 /* ---------------------------------------------------------------------------------------------------- */
    851 IMAGE_EXPORT(void) andc_ui32matrix(uint32 **X, long nrl,long nrh,long ncl, long nch, uint32 y, uint32 **Z)
    852 /* ---------------------------------------------------------------------------------------------------- */
    853 {
    854     long i;
    855    
    856     for(i=nrl; i<=nrh; i++) {
    857         andc_ui32vector(X[i], ncl, nch, y, Z[i]);
    858     }
    859 }
    860 /* ---------------------------------------------------------------------------------------------------- */
    861 IMAGE_EXPORT(void) andc_si64matrix(sint64 **X, long nrl,long nrh,long ncl, long nch, sint64 y, sint64 **Z)
    862 /* ---------------------------------------------------------------------------------------------------- */
    863 {
    864     long i;
    865    
    866     for(i=nrl; i<=nrh; i++) {
    867         andc_si64vector(X[i], ncl, nch, y, Z[i]);
    868     }
    869 }
    870 /* ---------------------------------------------------------------------------------------------------- */
    871 IMAGE_EXPORT(void) andc_ui64matrix(uint64 **X, long nrl,long nrh,long ncl, long nch, uint64 y, uint64 **Z)
    872 /* ---------------------------------------------------------------------------------------------------- */
    873 {
    874     long i;
    875    
    876     for(i=nrl; i<=nrh; i++) {
    877         andc_ui64vector(X[i], ncl, nch, y, Z[i]);
    878     }
    879 }
    880 /* ---------------------------------------------------------------------------------------------- */
    881 IMAGE_EXPORT(void) andc_rgb8matrix(rgb8 **X, long nrl,long nrh,long ncl, long nch, rgb8 y, rgb8 **Z)
    882 /* ---------------------------------------------------------------------------------------------- */
    883 {
    884     long i;
    885    
    886     for(i=nrl; i<=nrh; i++) {
    887         andc_rgb8vector(X[i], ncl, nch, y, Z[i]);
    888     }
    889 }
    890 /* -------------------------------------------------------------------------------------------------- */
    891 IMAGE_EXPORT(void) andc_rgb8xmatrix(rgbx8 **X, long nrl,long nrh,long ncl, long nch, rgbx8 y, rgbx8 **Z)
    892 /* -------------------------------------------------------------------------------------------------- */
    893 {
    894     long i;
    895    
    896     for(i=nrl; i<=nrh; i++) {
    897         andc_rgbx8vector(X[i], ncl, nch, y, Z[i]);
    898     }
    899 }
     171
     172and_type_matrix(int8_t);
     173and_type_matrix(uint8_t);
     174and_type_matrix(int16_t);
     175and_type_matrix(uint16_t);
     176and_type_matrix(int32_t);
     177and_type_matrix(uint32_t);
     178and_type_matrix(int64_t);
     179and_type_matrix(uint64_t);
     180and_type_matrix(rgb8);
     181and_type_matrix(rgbx8);
     182
     183
     184// Local Variables:
     185// tab-width: 4
     186// c-basic-offset: 4
     187// c-file-offsets:((innamespace . 0)(inline-open . 0))
     188// indent-tabs-mode: nil
     189// End:
     190
     191// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     192
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio0.c

    r777 r822  
    2626
    2727/* --------------------------------------------------------------------------------------------------- */
    28 IMAGE_EXPORT(void) generate_filename_k_ndigit(char *filename, int k, int ndigit, char *complete_filename, int maxlen)
     28void generate_filename_k_ndigit(char * filename, int k, int ndigit, char * complete_filename, int maxlen)
    2929/* --------------------------------------------------------------------------------------------------- */
    3030{
    31   char *format = "%s%d.txt";
     31    char * format = "%s%d.txt";
    3232
    33   switch(ndigit) {
    34     case 0 : format = "%s%d.txt";   break;
    35     case 1 : format = "%s%01d.txt"; break;
    36     case 2 : format = "%s%02d.txt"; break;
    37     case 3 : format = "%s%03d.txt"; break;
    38     case 4 : format = "%s%04d.txt"; break;
    39     case 5 : format = "%s%05d.txt"; break;
    40     case 6 : format = "%s%06d.txt"; break;
    41     case 7 : format = "%s%07d.txt"; break;
    42     case 8 : format = "%s%08d.txt"; break;
    43     case 9 : format = "%s%09d.txt"; break;
    44   }
    45   snprintf(complete_filename, maxlen, format, filename, k);
     33    switch (ndigit) {
     34        case 0 : format = "%s%d.txt";   break;
     35        case 1 : format = "%s%01d.txt"; break;
     36        case 2 : format = "%s%02d.txt"; break;
     37        case 3 : format = "%s%03d.txt"; break;
     38        case 4 : format = "%s%04d.txt"; break;
     39        case 5 : format = "%s%05d.txt"; break;
     40        case 6 : format = "%s%06d.txt"; break;
     41        case 7 : format = "%s%07d.txt"; break;
     42        case 8 : format = "%s%08d.txt"; break;
     43        case 9 : format = "%s%09d.txt"; break;
     44    }
     45    snprintf(complete_filename, maxlen, format, filename, k);
    4646}
    4747/* ------------------------------------------------------------------------------------------------------------------------------------------ */
    48 IMAGE_EXPORT(void) generate_filename_k_ndigit_extension(char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen)
     48void generate_filename_k_ndigit_extension(char * filename, int k, int ndigit, char * extension, char * complete_filename, int maxlen)
    4949/* ------------------------------------------------------------------------------------------------------------------------------------------ */
    5050{
    51   char *format = "%s%d.%s";
     51    char * format = "%s%d.%s";
    5252
    53   switch(ndigit) {
    54     case 0 : format = "%s%d.%s";   break;
    55     case 1 : format = "%s%01d.%s"; break;
    56     case 2 : format = "%s%02d.%s"; break;
    57     case 3 : format = "%s%03d.%s"; break;
    58     case 4 : format = "%s%04d.%s"; break;
    59     case 5 : format = "%s%05d.%s"; break;
    60     case 6 : format = "%s%06d.%s"; break;
    61     case 7 : format = "%s%07d.%s"; break;
    62     case 8 : format = "%s%08d.%s"; break;
    63     case 9 : format = "%s%09d.%s"; break;
    64   }
    65   snprintf(complete_filename, maxlen, format, filename, k, extension);
     53    switch (ndigit) {
     54        case 0 : format = "%s%d.%s";   break;
     55        case 1 : format = "%s%01d.%s"; break;
     56        case 2 : format = "%s%02d.%s"; break;
     57        case 3 : format = "%s%03d.%s"; break;
     58        case 4 : format = "%s%04d.%s"; break;
     59        case 5 : format = "%s%05d.%s"; break;
     60        case 6 : format = "%s%06d.%s"; break;
     61        case 7 : format = "%s%07d.%s"; break;
     62        case 8 : format = "%s%08d.%s"; break;
     63        case 9 : format = "%s%09d.%s"; break;
     64    }
     65    snprintf(complete_filename, maxlen, format, filename, k, extension);
    6666}
     67
     68
    6769/* ---------------------------------------------------------------------------------------------------- */
    68 IMAGE_EXPORT(void) generate_path_filename(char *path, char *filename, char *complete_filename, int maxlen)
     70void generate_path_filename(char * path, char * filename, char * complete_filename, int maxlen)
    6971/* ---------------------------------------------------------------------------------------------------- */
    7072{
    71   snprintf(complete_filename, maxlen, "%s%s", path, filename);
     73    snprintf(complete_filename, maxlen, "%s%s", path, filename);
    7274}
     75
     76
    7377/* ------------------------------------------------------------------------------------------------------------------------------- */
    74 IMAGE_EXPORT(void) generate_path_filename_extension(char *path, char *filename, char *extension, char *complete_filename, int maxlen)
     78void generate_path_filename_extension(char * path, char * filename, char * extension, char * complete_filename, int maxlen)
    7579/* ------------------------------------------------------------------------------------------------------------------------------- */
    7680{
    77   snprintf(complete_filename, maxlen, "%s%s.%s", path, filename, extension);
     81    snprintf(complete_filename, maxlen, "%s%s.%s", path, filename, extension);
    7882}
     83
     84
    7985/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
    80 IMAGE_EXPORT(void) generate_path_filename_suffix_extension(char *path, char *filename, char *suffix, char *extension, char *complete_filename, int maxlen)
     86void generate_path_filename_suffix_extension(char * path, char * filename, char * suffix, char * extension, char * complete_filename, int maxlen)
    8187/* ---------------------------------------------------------------------------------------------------------------------------------------------------- */
    8288{
    8389    snprintf(complete_filename, maxlen, "%s%s%s.%s", path, filename, suffix, extension);
    8490}
     91
     92
    8593/* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */
    86 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_extension(char *path, char *filename, int k, int ndigit, char *extension, char *complete_filename, int maxlen)
     94void generate_path_filename_k_ndigit_extension(char * path, char * filename, int k, int ndigit, char * extension, char * complete_filename, int maxlen)
    8795/* ----------------------------------------------------------------------------------------------------------------------------------------------------------- */
    8896{
    89   char *format = "%s%s%d.%s";
     97    char * format = "%s%s%d.%s";
    9098
    91   switch(ndigit) {
    92     case 0 : format = "%s%s%d.%s";   break;
    93     case 1 : format = "%s%s%01d.%s"; break;
    94     case 2 : format = "%s%s%02d.%s"; break;
    95     case 3 : format = "%s%s%03d.%s"; break;
    96     case 4 : format = "%s%s%04d.%s"; break;
    97     case 5 : format = "%s%s%05d.%s"; break;
    98     case 6 : format = "%s%s%06d.%s"; break;
    99     case 7 : format = "%s%s%07d.%s"; break;
    100     case 8 : format = "%s%s%08d.%s"; break;
    101     case 9 : format = "%s%s%09d.%s"; break;
    102   }
    103   snprintf(complete_filename, maxlen, format, path, filename, k, extension);
     99    switch(ndigit) {
     100        case 0 : format = "%s%s%d.%s";   break;
     101        case 1 : format = "%s%s%01d.%s"; break;
     102        case 2 : format = "%s%s%02d.%s"; break;
     103        case 3 : format = "%s%s%03d.%s"; break;
     104        case 4 : format = "%s%s%04d.%s"; break;
     105        case 5 : format = "%s%s%05d.%s"; break;
     106        case 6 : format = "%s%s%06d.%s"; break;
     107        case 7 : format = "%s%s%07d.%s"; break;
     108        case 8 : format = "%s%s%08d.%s"; break;
     109        case 9 : format = "%s%s%09d.%s"; break;
     110    }
     111    snprintf(complete_filename, maxlen, format, path, filename, k, extension);
    104112}
     113
     114
    105115/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
    106 IMAGE_EXPORT(void) generate_path_filename_k_ndigit_l_extension(char *path, char *filename, int k, int ndigit, int l, char *extension, char *complete_filename, int maxlen)
     116void generate_path_filename_k_ndigit_l_extension(char * path, char * filename, int k, int ndigit, int l, char * extension, char * complete_filename, int maxlen)
    107117/* -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
    108118{
    109   char *format = "%s%s%d_%d.%s";
     119    char * format = "%s%s%d_%d.%s";
    110120
    111   switch(ndigit) {
    112     case 0 : format = "%s%s%d_%d.%s";   break;
    113     case 1 : format = "%s%s%01d_%01d.%s"; break;
    114     case 2 : format = "%s%s%02d_%02d.%s"; break;
    115     case 3 : format = "%s%s%03d_%03d.%s"; break;
    116     case 4 : format = "%s%s%04d_%04d.%s"; break;
    117     case 5 : format = "%s%s%05d_%05d.%s"; break;
    118     case 6 : format = "%s%s%06d_%06d.%s"; break;
    119     case 7 : format = "%s%s%07d_%07d.%s"; break;
    120     case 8 : format = "%s%s%08d_%08d.%s"; break;
    121     case 9 : format = "%s%s%09d_%09d.%s"; break;
    122   }
    123   snprintf(complete_filename, maxlen, format, path, filename, k, l, extension);
     121    switch (ndigit) {
     122        case 0 : format = "%s%s%d_%d.%s";     break;
     123        case 1 : format = "%s%s%01d_%01d.%s"; break;
     124        case 2 : format = "%s%s%02d_%02d.%s"; break;
     125        case 3 : format = "%s%s%03d_%03d.%s"; break;
     126        case 4 : format = "%s%s%04d_%04d.%s"; break;
     127        case 5 : format = "%s%s%05d_%05d.%s"; break;
     128        case 6 : format = "%s%s%06d_%06d.%s"; break;
     129        case 7 : format = "%s%s%07d_%07d.%s"; break;
     130        case 8 : format = "%s%s%08d_%08d.%s"; break;
     131        case 9 : format = "%s%s%09d_%09d.%s"; break;
     132    }
     133    snprintf(complete_filename, maxlen, format, path, filename, k, l, extension);
    124134}
    125 // ----------------------------------------------------------------------------
    126 void select_display_positive_parameters(int iformat, char **format, char **str)
    127 // ----------------------------------------------------------------------------
     135
     136
     137// ------------------------------------------------------------------------------
     138void select_display_positive_parameters(int iformat, char ** format, char ** str)
     139// ------------------------------------------------------------------------------
    128140{
    129     char *format1 = "%1d", *str1 = " ";
    130     char *format2 = "%2d", *str2 = "  ";
    131     char *format3 = "%3d", *str3 = "   ";
    132     char *format4 = "%4d", *str4 = "    ";
    133     char *format5 = "%5d", *str5 = "     ";
    134     char *format6 = "%6d", *str6 = "      ";
    135     char *format7 = "%7d", *str7 = "       ";
    136     char *format8 = "%8d", *str8 = "        ";
    137     char *format9 = "%9d", *str9 = "         ";
    138    
    139     switch(iformat) {
     141    char * format1 = "%1d", * str1 = " ";
     142    char * format2 = "%2d", * str2 = "  ";
     143    char * format3 = "%3d", * str3 = "   ";
     144    char * format4 = "%4d", * str4 = "    ";
     145    char * format5 = "%5d", * str5 = "     ";
     146    char * format6 = "%6d", * str6 = "      ";
     147    char * format7 = "%7d", * str7 = "       ";
     148    char * format8 = "%8d", * str8 = "        ";
     149    char * format9 = "%9d", * str9 = "         ";
     150
     151    switch (iformat) {
    140152        case 1:  *format = format1; *str = str1; break;
    141153        case 2:  *format = format2; *str = str2; break;
     
    150162    }
    151163}
     164
     165// Local Variables:
     166// tab-width: 4
     167// c-basic-offset: 4
     168// c-file-offsets:((innamespace . 0)(inline-open . 0))
     169// indent-tabs-mode: nil
     170// End:
     171
     172// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     173
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1.c

    r805 r822  
    3333 */
    3434
    35 /* ------------------------------------------------------------------------------- */
    36 IMAGE_EXPORT(void) display_bvector(byte *v,long nl,long nh, char *format, char *name)
    37 /* ------------------------------------------------------------------------------- */
    38 {
    39   long i;
    40 
    41   if(name != NULL) printf("%s", name);
    42 
    43   for(i=nl; i<=nh; i++) {
    44     printf(format, v[i]);
    45   }
    46   printf("\n");
    47 }
    48 /* ---------------------------------------------------------------------------------- */
    49 IMAGE_EXPORT(void) display_si8vector(sint8 *v,long nl,long nh, char *format, char *name)
    50 /* ---------------------------------------------------------------------------------- */
    51 {
    52     long i;
    53    
    54     if(name != NULL) printf("%s", name);
    55    
    56     for(i=nl; i<=nh; i++) {
    57         printf(format, v[i]);
    58     }
    59     printf("\n");
    60 }
    61 /* ---------------------------------------------------------------------------------- */
    62 IMAGE_EXPORT(void) display_ui8vector(uint8 *v,long nl,long nh, char *format, char *name)
    63 /* ---------------------------------------------------------------------------------- */
    64 {
    65     long i;
    66    
    67     if(name != NULL) printf("%s", name);
    68    
    69     for(i=nl; i<=nh; i++) {
    70         printf(format, v[i]);
    71     }
    72     printf("\n");
    73 }
    74 /* ------------------------------------------------------------------------------------ */
    75 IMAGE_EXPORT(void) display_si16vector(sint16 *v,long nl,long nh, char *format, char *name)
    76 /* ------------------------------------------------------------------------------------ */
    77 {
    78   long i;
    79 
    80   if(name != NULL) printf("%s", name);
    81 
    82   for(i=nl; i<=nh; i++) {
    83     printf(format, v[i]);
    84   }
    85   printf("\n");
    86 }
    87 /* ------------------------------------------------------------------------------------- */
    88 IMAGE_EXPORT(void) display_ui16vector(uint16 *v,long nl,long nh, char *format, char *name)
    89 /* ------------------------------------------------------------------------------------- */
    90 {
    91   long i;
    92 
    93   if(name != NULL) printf("%s", name);
    94 
    95   for(i=nl; i<=nh; i++) {
    96     printf(format, v[i]);
    97   }
    98   printf("\n");
    99 }
    100 /* ------------------------------------------------------------------------------------ */
    101 IMAGE_EXPORT(void) display_si32vector(sint32 *v,long nl,long nh, char *format, char *name)
    102 /* ------------------------------------------------------------------------------------ */
    103 {
    104   long i;
    105 
    106   if(name != NULL) printf("%s", name);
    107 
    108   for(i=nl; i<=nh; i++) {
    109     printf(format, v[i]);
    110   }
    111   printf("\n");
    112 }
    113 /* ------------------------------------------------------------------------------------ */
    114 IMAGE_EXPORT(void) display_ui32vector(uint32 *v,long nl,long nh, char *format, char *name)
    115 /* ------------------------------------------------------------------------------------ */
    116 {
    117   long i;
    118 
    119   if(name != NULL) printf("%s", name);
    120 
    121   for(i=nl; i<=nh; i++) {
    122     printf(format, v[i]);
    123   }
    124   printf("\n");
    125 }
    126 /* ------------------------------------------------------------------------------------ */
    127 IMAGE_EXPORT(void) display_si64vector(sint64 *v,long nl,long nh, char *format, char *name)
    128 /* ------------------------------------------------------------------------------------ */
    129 {
    130   long i;
    131 
    132   if(name != NULL) printf("%s", name);
    133 
    134   for(i=nl; i<=nh; i++) {
    135     printf(format, v[i]);
    136   }
    137   printf("\n");
    138 }
    139 /* ------------------------------------------------------------------------------------ */
    140 IMAGE_EXPORT(void) display_ui64vector(uint64 *v,long nl,long nh, char *format, char *name)
    141 /* ------------------------------------------------------------------------------------ */
    142 {
    143   long i;
    144 
    145   if(name != NULL) printf("%s", name);
    146 
    147   for(i=nl; i<=nh; i++) {
    148     printf(format, v[i]);
    149   }
    150   printf("\n");
    151 }
    152 /* ------------------------------------------------------------------------------------ */
    153 IMAGE_EXPORT(void) display_f32vector(float32 *v,long nl,long nh, char *format, char *name)
    154 /* ------------------------------------------------------------------------------------ */
    155 {
    156     long i;
    157    
    158     if(name != NULL) printf("%s", name);
    159    
    160     for(i=nl; i<=nh; i++) {
    161         printf(format, v[i]);
    162     }
    163     printf("\n");
    164 }
    165 /* ------------------------------------------------------------------------------------ */
    166 IMAGE_EXPORT(void) display_f64vector(float64 *v,long nl,long nh, char *format, char *name)
    167 /* ------------------------------------------------------------------------------------ */
    168 {
    169     long i;
    170    
    171     if(name != NULL) printf("%s", name);
    172    
    173     for(i=nl; i<=nh; i++) {
    174         printf(format, v[i]);
    175     }
    176     printf("\n");
    177 }
    178 /* ---------------------------------------------------------------------------------- */
    179 IMAGE_EXPORT(void) display_rgb8vector(rgb8 *v,long nl,long nh, char *format, char *name)
    180 /* ---------------------------------------------------------------------------------- */
    181 {
    182     long i;
    183    
    184     if(name != NULL) printf("%s", name);
    185    
    186     for(i=nl; i<=nh; i++) {
    187         printf(format, v[i]);
    188     }
    189     printf("\n");
    190 }
    191 /* ------------------------------------------------------------------------------------ */
    192 IMAGE_EXPORT(void) display_rgbx8vector(rgbx8 *v,long nl,long nh, char *format, char *name)
    193 /* ------------------------------------------------------------------------------------ */
    194 {
    195     long i;
    196    
    197     if(name != NULL) printf("%s", name);
    198    
    199     for(i=nl; i<=nh; i++) {
    200         printf(format, v[i]);
    201     }
    202     printf("\n");
    203 }
     35#undef display_type_vector
     36#define display_type_vector(t) \
     37void short_name(t,display_,vector)(t * v, int32_t nl, int32_t nh, char * format, char * name) \
     38{                                        \
     39    if (name != NULL) {                  \
     40        printf("%s", name);              \
     41    }                                    \
     42    for (int32_t i = nl; i <= nh; i++) { \
     43        printf(format, v[i]);            \
     44    }                                    \
     45    printf("\n");                        \
     46}
     47
     48display_type_vector(int8_t);
     49display_type_vector(uint8_t);
     50display_type_vector(int16_t);
     51display_type_vector(uint16_t);
     52display_type_vector(int32_t);
     53display_type_vector(uint32_t);
     54display_type_vector(int64_t);
     55display_type_vector(uint64_t);
     56display_type_vector(float);
     57display_type_vector(double);
     58display_type_vector(rgb8);
     59display_type_vector(rgbx8);
     60
    20461
    20562/*
     
    20966 */
    21067
    211 /* -------------------------------------------------------------------------------------- */
    212 IMAGE_EXPORT(void) display_bvector_number(byte *v,long nl,long nh, char *format, char *name)
    213 /* -------------------------------------------------------------------------------------- */
    214 {
    215   long i;
    216 
    217   if(name != NULL) printf("%s\n", name);
    218 
    219   for(i=nl; i<=nh; i++) {
    220     printf(format, i);
    221   }
    222   printf("\n");
    223 
    224   for(i=nl; i<=nh; i++) {
    225     printf(format, v[i]);
    226   }
    227   printf("\n");
    228 }
    229 /* ----------------------------------------------------------------------------------------- */
    230 IMAGE_EXPORT(void) display_si8vector_number(sint8 *v,long nl,long nh, char *format, char *name)
    231 /* ----------------------------------------------------------------------------------------- */
    232 {
    233   long i;
    234 
    235   if(name != NULL) printf(name);
    236   for(i=nl; i<=nh; i++) {
    237     printf(format, i);
    238   }
    239   printf("\n");
    240 
    241   for(i=nl; i<=nh; i++) {
    242     printf(format, v[i]);
    243   }
    244   printf("\n");
    245 }
    246 /* ----------------------------------------------------------------------------------------- */
    247 IMAGE_EXPORT(void) display_ui8vector_number(uint8 *v,long nl,long nh, char *format, char *name)
    248 /* ----------------------------------------------------------------------------------------- */
    249 {
    250   long i;
    251 
    252   if(name != NULL) printf(name);
    253   for(i=nl; i<=nh; i++) {
    254     printf(format, i);
    255   }
    256   printf("\n");
    257 
    258   for(i=nl; i<=nh; i++) {
    259     printf(format, v[i]);
    260   }
    261   printf("\n");
    262 }
    263 /* ------------------------------------------------------------------------------------------- */
    264 IMAGE_EXPORT(void) display_si16vector_number(sint16 *v,long nl,long nh, char *format, char *name)
    265 /* ------------------------------------------------------------------------------------------- */
    266 {
    267   long i;
    268 
    269   if(name != NULL) printf(name);
    270   for(i=nl; i<=nh; i++) {
    271     printf(format, i);
    272   }
    273   printf("\n");
    274 
    275   for(i=nl; i<=nh; i++) {
    276     printf(format, v[i]);
    277   }
    278   printf("\n");
    279 }
    280 /* ------------------------------------------------------------------------------------------- */
    281 IMAGE_EXPORT(void) display_ui16vector_number(uint16 *v,long nl,long nh, char *format, char *name)
    282 /* ------------------------------------------------------------------------------------------- */
    283 {
    284   long i;
    285 
    286   if(name != NULL) printf(name);
    287   for(i=nl; i<=nh; i++) {
    288     printf(format, i);
    289   }
    290   printf("\n");
    291 
    292   for(i=nl; i<=nh; i++) {
    293     printf(format, v[i]);
    294   }
    295   printf("\n");
    296 }
    297 /* ------------------------------------------------------------------------------------------- */
    298 IMAGE_EXPORT(void) display_si32vector_number(sint32 *v,long nl,long nh, char *format, char *name)
    299 /* ------------------------------------------------------------------------------------------- */
    300 {
    301   long i;
    302 
    303   if(name != NULL) printf("%s\n", name);
    304 
    305   for(i=nl; i<=nh; i++) {
    306     printf(format, i);
    307   }
    308   printf("\n");
    309 
    310   for(i=nl; i<=nh; i++) {
    311     printf(format, v[i]);
    312   }
    313   printf("\n");
    314 }
    315 /* ------------------------------------------------------------------------------------------- */
    316 IMAGE_EXPORT(void) display_ui32vector_number(uint32 *v,long nl,long nh, char *format, char *name)
    317 /* ------------------------------------------------------------------------------------------- */
    318 {
    319   long i;
    320 
    321   if(name != NULL) printf("%s\n", name);
    322 
    323   for(i=nl; i<=nh; i++) {
    324     printf(format, i);
    325     printf(" ");
    326   }
    327   printf("\n");
    328 
    329   for(i=nl; i<=nh; i++) {
    330     printf(format, v[i]);
    331     printf(" ");
    332   }
    333   printf("\n");
    334 }
    335 /* ------------------------------------------------------------------------------------------- */
    336 IMAGE_EXPORT(void) display_si64vector_number(sint64 *v,long nl,long nh, char *format, char *name)
    337 /* ------------------------------------------------------------------------------------------- */
    338 {
    339   long i;
    340 
    341   if(name != NULL) printf("%s\n", name);
    342 
    343   for(i=nl; i<=nh; i++) {
    344     printf(format, i);
    345   }
    346   printf("\n");
    347 
    348   for(i=nl; i<=nh; i++) {
    349     printf(format, v[i]);
    350   }
    351   printf("\n");
    352 }
    353 /* ------------------------------------------------------------------------------------------- */
    354 IMAGE_EXPORT(void) display_ui64vector_number(uint64 *v,long nl,long nh, char *format, char *name)
    355 /* ------------------------------------------------------------------------------------------- */
    356 {
    357   long i;
    358 
    359   if(name != NULL) printf("%s\n", name);
    360 
    361   for(i=nl; i<=nh; i++) {
    362     printf(format, i);
    363   }
    364   printf("\n");
    365 
    366   for(i=nl; i<=nh; i++) {
    367     printf(format, v[i]);
    368   }
    369   printf("\n");
    370 }
    371 /* ------------------------------------------------------------------------------------------- */
    372 IMAGE_EXPORT(void) display_f32vector_number(float32 *v,long nl,long nh, char *format, char *name)
    373 /* ------------------------------------------------------------------------------------------- */
    374 {
    375   long i;
    376 
    377   if(name != NULL) printf("%s\n", name);
    378 
    379   for(i=nl; i<=nh; i++) {
    380     printf(format, i);
    381   }
    382   printf("\n");
    383 
    384   for(i=nl; i<=nh; i++) {
    385     printf(format, v[i]);
    386   }
    387   printf("\n");
    388 }
    389 /* ------------------------------------------------------------------------------------------- */
    390 IMAGE_EXPORT(void) display_f64vector_number(float64 *v,long nl,long nh, char *format, char *name)
    391 /* ------------------------------------------------------------------------------------------- */
    392 {
    393   long i;
    394 
    395   if(name != NULL) printf("%s\n", name);
    396 
    397   for(i=nl; i<=nh; i++) {
    398     printf(format, i);
    399   }
    400   printf("\n");
    401 
    402   for(i=nl; i<=nh; i++) {
    403     printf(format, v[i]);
    404   }
    405   printf("\n");
    406 }
    407 /* ----------------------------------------------------------------------------------------- */
    408 IMAGE_EXPORT(void) display_rgb8vector_number(rgb8 *v,long nl,long nh, char *format, char *name)
    409 /* ----------------------------------------------------------------------------------------- */
    410 {
    411   long i;
    412 
    413   if(name != NULL) printf("%s\n", name);
    414 
    415   for(i=nl; i<=nh; i++) {
    416     printf(format, i);
    417   }
    418   printf("\n");
    419 
    420   for(i=nl; i<=nh; i++) {
    421     printf(format, v[i]);
    422   }
    423   printf("\n");
    424 }
    425 /* ------------------------------------------------------------------------------------------- */
    426 IMAGE_EXPORT(void) display_rgbx8vector_number(rgbx8 *v,long nl,long nh, char *format, char *name)
    427 /* ------------------------------------------------------------------------------------------- */
    428 {
    429   long i;
    430 
    431   if(name != NULL) printf("%s\n", name);
    432 
    433   for(i=nl; i<=nh; i++) {
    434     printf(format, i);
    435   }
    436   printf("\n");
    437 
    438   for(i=nl; i<=nh; i++) {
    439     printf(format, v[i]);
    440   }
    441   printf("\n");
    442 }
     68#undef display_type_vector_number
     69#define display_type_vector_number(t) \
     70void short_name(t,display_,vector_number)(t * v, int32_t nl, int32_t nh, char * format, char * name) \
     71{                                        \
     72    if (name != NULL) {                  \
     73        printf("%s\n", name);            \
     74    }                                    \
     75    for (int32_t i = nl; i <= nh; i++) { \
     76        printf(format, i);               \
     77    }                                    \
     78    printf("\n");                        \
     79    for (int32_t i = nl; i <= nh; i++) { \
     80        printf(format, v[i]);            \
     81    }                                    \
     82    printf("\n");                        \
     83}
     84
     85
     86display_type_vector_number(int8_t);
     87display_type_vector_number(uint8_t);
     88display_type_vector_number(int16_t);
     89display_type_vector_number(uint16_t);
     90display_type_vector_number(int32_t);
     91display_type_vector_number(uint32_t);
     92display_type_vector_number(int64_t);
     93display_type_vector_number(uint64_t);
     94display_type_vector_number(float);
     95display_type_vector_number(double);
     96display_type_vector_number(rgb8);
     97display_type_vector_number(rgbx8);
     98
     99
    443100/*
    444101 * ------------------------
     
    447104 */
    448105
    449 /* ----------------------------------------------------------------------------------- */
    450 IMAGE_EXPORT(void) display_si8vector_T(sint8 *v,int i0, int i1, char *format, char *name)
    451 /* ----------------------------------------------------------------------------------- */
    452 {
    453     int i;
    454    
    455     if(name != NULL) printf(name);
    456    
    457     for(i=i0; i<=i1; i++) {           
    458         printf(format, v[i]);
    459         printf("\n");
    460     }
    461 }
    462 /* ----------------------------------------------------------------------------------- */
    463 IMAGE_EXPORT(void) display_ui8vector_T(uint8 *v,int i0, int i1, char *format, char *name)
    464 /* ----------------------------------------------------------------------------------- */
    465 {
    466     int i;
    467    
    468     if(name != NULL) printf(name);
    469    
    470     for(i=i0; i<=i1; i++) {           
    471         printf(format, v[i]);
    472         printf("\n");
    473     }
    474 }
    475 /* ------------------------------------------------------------------------------------- */
    476 IMAGE_EXPORT(void) display_si16vector_T(sint16 *v,int i0, int i1, char *format, char *name)
    477 /* ------------------------------------------------------------------------------------- */
    478 {
    479     int i;
    480    
    481     if(name != NULL) printf(name);
    482    
    483     for(i=i0; i<=i1; i++) {           
    484         printf(format, v[i]);
    485         printf("\n");
    486     }
    487 }
    488 /* ------------------------------------------------------------------------------------- */
    489 IMAGE_EXPORT(void) display_ui16vector_T(uint16 *v,int i0, int i1, char *format, char *name)
    490 /* ------------------------------------------------------------------------------------- */
    491 {
    492     int i;
    493    
    494     if(name != NULL) printf(name);
    495    
    496     for(i=i0; i<=i1; i++) {           
    497         printf(format, v[i]);
    498         printf("\n");
    499     }
    500 }
    501 /* ------------------------------------------------------------------------------------- */
    502 IMAGE_EXPORT(void) display_si32vector_T(sint32 *v,int i0, int i1, char *format, char *name)
    503 /* ------------------------------------------------------------------------------------- */
    504 {
    505     int i;
    506    
    507     if(name != NULL) printf(name);
    508    
    509     for(i=i0; i<=i1; i++) {           
    510         printf(format, v[i]);
    511         printf("\n");
    512     }
    513 }
    514 /* ------------------------------------------------------------------------------------- */
    515 IMAGE_EXPORT(void) display_ui32vector_T(uint32 *v,int i0, int i1, char *format, char *name)
    516 /* ------------------------------------------------------------------------------------- */
    517 {
    518     int i;
    519    
    520     if(name != NULL) printf(name);
    521    
    522     for(i=i0; i<=i1; i++) {           
    523         printf(format, v[i]);
    524         printf("\n");
    525     }
    526 }
    527 /* ------------------------------------------------------------------------------------- */
    528 IMAGE_EXPORT(void) display_si64vector_T(sint64 *v,int i0, int i1, char *format, char *name)
    529 /* ------------------------------------------------------------------------------------- */
    530 {
    531     int i;
    532    
    533     if(name != NULL) printf(name);
    534    
    535     for(i=i0; i<=i1; i++) {           
    536         printf(format, v[i]);
    537         printf("\n");
    538     }
    539 }
    540 /* ------------------------------------------------------------------------------------- */
    541 IMAGE_EXPORT(void) display_ui64vector_T(uint64 *v,int i0, int i1, char *format, char *name)
    542 /* ------------------------------------------------------------------------------------- */
    543 {
    544     int i;
    545    
    546     if(name != NULL) printf(name);
    547    
    548     for(i=i0; i<=i1; i++) {           
    549         printf(format, v[i]);
    550         printf("\n");
    551     }
    552 }
    553 /* ------------------------------------------------------------------------------------- */
    554 IMAGE_EXPORT(void) display_f32vector_T(float32 *v,int i0, int i1, char *format, char *name)
    555 /* ------------------------------------------------------------------------------------- */
    556 {
    557     int i;
    558    
    559     if(name != NULL) printf(name);
    560    
    561     for(i=i0; i<=i1; i++) {           
    562         printf(format, v[i]);
    563         printf("\n");
    564     }
    565 }
    566 /* ------------------------------------------------------------------------------------- */
    567 IMAGE_EXPORT(void) display_f64vector_T(float64 *v,int i0, int i1, char *format, char *name)
    568 /* ------------------------------------------------------------------------------------- */
    569 {
    570     int i;
    571    
    572     if(name != NULL) printf(name);
    573    
    574     for(i=i0; i<=i1; i++) {           
    575         printf(format, v[i]);
    576         printf("\n");
    577     }
    578 }
    579 /* ----------------------------------------------------------------------------------- */
    580 IMAGE_EXPORT(void) display_rgb8vector_T(rgb8 *v,int i0, int i1, char *format, char *name)
    581 /* ----------------------------------------------------------------------------------- */
    582 {
    583     int i;
    584    
    585     if(name != NULL) printf(name);
    586    
    587     for(i=i0; i<=i1; i++) {           
    588         printf(format, v[i]);
    589         printf("\n");
    590     }
    591 }
    592 /* ------------------------------------------------------------------------------------- */
    593 IMAGE_EXPORT(void) display_rgbx8vector_T(rgbx8 *v,int i0, int i1, char *format, char *name)
    594 /* ------------------------------------------------------------------------------------- */
    595 {
    596     int i;
    597    
    598     if(name != NULL) printf(name);
    599    
    600     for(i=i0; i<=i1; i++) {           
    601         printf(format, v[i]);
    602         printf("\n");
    603     }
    604 }
     106
     107#undef display_type_vector_T
     108#define display_type_vector_T(t) \
     109void short_name(t,display_,vector_T)(t * v, int32_t i0, int32_t i1, char * format, char * name) \
     110{                                        \
     111    if (name != NULL) {                  \
     112        printf("%s", name);              \
     113    }                                    \
     114    for (int32_t i = i0; i <= i1; i++) { \
     115        printf(format, v[i]);            \
     116        printf("\n");                    \
     117    }                                    \
     118    printf("\n");                        \
     119}
     120
     121display_type_vector_T(int8_t);
     122display_type_vector_T(uint8_t);
     123display_type_vector_T(int16_t);
     124display_type_vector_T(uint16_t);
     125display_type_vector_T(int32_t);
     126display_type_vector_T(uint32_t);
     127display_type_vector_T(int64_t);
     128display_type_vector_T(uint64_t);
     129display_type_vector_T(float);
     130display_type_vector_T(double);
     131display_type_vector_T(rgb8);
     132display_type_vector_T(rgbx8);
     133
    605134
    606135/*
     
    610139 */
    611140
    612 /* ------------------------------------------------------------------------------------------ */
    613 IMAGE_EXPORT(void) display_si8vector_number_T(sint8 *v,int i0, int i1, char *format, char *name)
    614 /* ------------------------------------------------------------------------------------------ */
    615 {
    616     int i;
    617    
    618     if(name != NULL) printf(name);
    619    
    620     for(i=i0; i<=i1; i++) {
    621         printf("%8d ", i);
    622         printf(format, v[i]);
    623         printf("\n");
    624     }
    625 }
    626 /* ------------------------------------------------------------------------------------------ */
    627 IMAGE_EXPORT(void) display_ui8vector_number_T(uint8 *v,int i0, int i1, char *format, char *name)
    628 /* ------------------------------------------------------------------------------------------ */
    629 {
    630     int i;
    631    
    632     if(name != NULL) printf(name);
    633    
    634     for(i=i0; i<=i1; i++) {
    635         printf("%8d ", i);
    636         printf(format, v[i]);
    637         printf("\n");
    638     }
    639 }
    640 /* -------------------------------------------------------------------------------------------- */
    641 IMAGE_EXPORT(void) display_si16vector_number_T(sint16 *v,int i0, int i1, char *format, char *name)
    642 /* -------------------------------------------------------------------------------------------- */
    643 {
    644     int i;
    645    
    646     if(name != NULL) printf(name);
    647    
    648     for(i=i0; i<=i1; i++) {           
    649         printf("%8d ", i);
    650         printf(format, v[i]);
    651         printf("\n");
    652     }
    653 }
    654 /* -------------------------------------------------------------------------------------------- */
    655 IMAGE_EXPORT(void) display_ui16vector_number_T(uint16 *v,int i0, int i1, char *format, char *name)
    656 /* -------------------------------------------------------------------------------------------- */
    657 {
    658     int i;
    659    
    660     if(name != NULL) printf(name);
    661    
    662     for(i=i0; i<=i1; i++) {
    663         printf("%8d ", i);
    664         printf(format, v[i]);
    665         printf("\n");
    666     }
    667 }
    668 /* -------------------------------------------------------------------------------------------- */
    669 IMAGE_EXPORT(void) display_si32vector_number_T(sint32 *v,int i0, int i1, char *format, char *name)
    670 /* -------------------------------------------------------------------------------------------- */
    671 {
    672     int i;
    673    
    674     if(name != NULL) printf(name);
    675    
    676     for(i=i0; i<=i1; i++) {           
    677         printf("%8d ", i);
    678         printf(format, v[i]);
    679         printf("\n");
    680     }
    681 }
    682 /* -------------------------------------------------------------------------------------------- */
    683 IMAGE_EXPORT(void) display_ui32vector_number_T(uint32 *v,int i0, int i1, char *format, char *name)
    684 /* -------------------------------------------------------------------------------------------- */
    685 {
    686     int i;
    687    
    688     if(name != NULL) printf(name);
    689    
    690     for(i=i0; i<=i1; i++) {           
    691         printf("%8d ", i);
    692         printf(format, v[i]);
    693         printf("\n");
    694     }
    695 }
    696 /* -------------------------------------------------------------------------------------------- */
    697 IMAGE_EXPORT(void) display_si64vector_number_T(sint64 *v,int i0, int i1, char *format, char *name)
    698 /* -------------------------------------------------------------------------------------------- */
    699 {
    700     int i;
    701    
    702     if(name != NULL) printf(name);
    703    
    704     for(i=i0; i<=i1; i++) {           
    705         printf("%8d ", i);
    706         printf(format, v[i]);
    707         printf("\n");
    708     }
    709 }
    710 /* -------------------------------------------------------------------------------------------- */
    711 IMAGE_EXPORT(void) display_ui64vector_number_T(uint64 *v,int i0, int i1, char *format, char *name)
    712 /* -------------------------------------------------------------------------------------------- */
    713 {
    714     int i;
    715    
    716     if(name != NULL) printf(name);
    717    
    718     for(i=i0; i<=i1; i++) {           
    719         printf("%8d ", i);
    720         printf(format, v[i]);
    721         printf("\n");
    722     }
    723 }
    724 /* -------------------------------------------------------------------------------------------- */
    725 IMAGE_EXPORT(void) display_f32vector_number_T(float32 *v,int i0, int i1, char *format, char *name)
    726 /* -------------------------------------------------------------------------------------------- */
    727 {
    728     int i;
    729    
    730     if(name != NULL) printf(name);
    731    
    732     for(i=i0; i<=i1; i++) { 
    733         printf("%8d ", i);
    734         printf(format, v[i]);
    735         printf("\n");
    736     }
    737 }
    738 /* -------------------------------------------------------------------------------------------- */
    739 IMAGE_EXPORT(void) display_f64vector_number_T(float64 *v,int i0, int i1, char *format, char *name)
    740 /* -------------------------------------------------------------------------------------------- */
    741 {
    742     int i;
    743    
    744     if(name != NULL) printf(name);
    745    
    746     for(i=i0; i<=i1; i++) {           
    747         printf("%8d ", i);
    748         printf(format, v[i]);
    749         printf("\n");
    750     }
    751 }
    752 /* ------------------------------------------------------------------------------------------ */
    753 IMAGE_EXPORT(void) display_rgb8vector_number_T(rgb8 *v,int i0, int i1, char *format, char *name)
    754 /* ------------------------------------------------------------------------------------------ */
    755 {
    756     int i;
    757    
    758     if(name != NULL) printf(name);
    759    
    760     for(i=i0; i<=i1; i++) {           
    761         printf("%8d ", i);
    762         printf(format, v[i]);
    763         printf("\n");
    764     }
    765 }
    766 /* -------------------------------------------------------------------------------------------- */
    767 IMAGE_EXPORT(void) display_rgbx8vector_number_T(rgbx8 *v,int i0, int i1, char *format, char *name)
    768 /* -------------------------------------------------------------------------------------------- */
    769 {
    770     int i;
    771    
    772     if(name != NULL) printf(name);
    773    
    774     for(i=i0; i<=i1; i++) {           
    775         printf("%8d ", i);
    776         printf(format, v[i]);
    777         printf("\n");
    778     }
    779 }
     141
     142#undef display_type_vector_number_T
     143#define display_type_vector_number_T(t) \
     144void short_name(t,display_,vector_number_T)(t * v, int32_t i0, int32_t i1, char * format, char * name) \
     145{                                        \
     146    if (name != NULL) {                  \
     147        printf("%s", name);              \
     148    }                                    \
     149    for (int32_t i = i0; i <= i1; i++) { \
     150        printf("%8d ", i);               \
     151        printf(format, v[i]);            \
     152        printf("\n");                    \
     153    }                                    \
     154    printf("\n");                        \
     155}
     156
     157display_type_vector_number_T(int8_t);
     158display_type_vector_number_T(uint8_t);
     159display_type_vector_number_T(int16_t);
     160display_type_vector_number_T(uint16_t);
     161display_type_vector_number_T(int32_t);
     162display_type_vector_number_T(uint32_t);
     163display_type_vector_number_T(int64_t);
     164display_type_vector_number_T(uint64_t);
     165display_type_vector_number_T(float);
     166display_type_vector_number_T(double);
     167display_type_vector_number_T(rgb8);
     168display_type_vector_number_T(rgbx8);
     169
    780170
    781171/*
     
    785175 */
    786176
    787 // -------------------------------------------------------------------------------
    788 void display_ui8vector_positive(uint8 *v, int j0, int j1, int iformat, char *name)
    789 // -------------------------------------------------------------------------------
    790 {
    791     int j;
    792     char *format, *str;
    793    
    794     select_display_positive_parameters(iformat, &format, &str);
    795    
    796     if(name != NULL) printf(name);
    797    
    798     for(j=j0; j<=j1; j++) {
    799         if(v[j]) {
    800             printf(format, v[j]);
    801         } else {
    802             printf("%s", str);
    803         }
    804     }
    805     printf("\n");
    806 }
    807 
    808 // ---------------------------------------------------------------------------------
    809 void display_ui16vector_positive(uint16 *v, int j0, int j1, int iformat, char *name)
    810 // ---------------------------------------------------------------------------------
    811 {
    812     int j;
    813     char *format, *str;
    814    
    815     select_display_positive_parameters(iformat, &format, &str);
    816    
    817     if(name != NULL) printf(name);
    818    
    819     for(j=j0; j<=j1; j++) {
    820         if(v[j]) {
    821             printf(format, v[j]);
    822         } else {
    823             printf("%s", str);
    824         }
    825     }
    826     printf("\n");
    827 }
    828 // ---------------------------------------------------------------------------------
    829 void display_ui32vector_positive(uint32 *v, int j0, int j1, int iformat, char *name)
    830 // ---------------------------------------------------------------------------------
    831 {
    832     int j;
    833     char *format, *str;
    834    
    835     select_display_positive_parameters(iformat, &format, &str);
    836    
    837     if(name != NULL) printf(name);
    838    
    839     for(j=j0; j<=j1; j++) {
    840         if(v[j]) {
    841             printf(format, v[j]);
    842         } else {
    843             printf("%s", str);
    844         }
    845     }
    846     printf("\n");
    847 }
     177#undef display_type_vector_positive
     178#define display_type_vector_positive(t) \
     179void short_name(t,display_,vector_positive)(t * v, int32_t j0, int32_t j1, int32_t iformat, char * name) \
     180{                                                               \
     181    char * format;                                              \
     182    char * str;                                                 \
     183    select_display_positive_parameters(iformat, &format, &str); \
     184    if (name != NULL) {                                         \
     185        printf(name);                                           \
     186    }                                                           \
     187    for (int32_t j = j0; j <= j1; j++) {                        \
     188        if (v[j] != 0) {                                        \
     189            printf(format, v[j]);                               \
     190        }                                                       \
     191        else {                                                  \
     192            printf("%s", str);                                  \
     193        }                                                       \
     194    }                                                           \
     195    printf("\n");                                               \
     196}
     197
     198
     199display_type_vector_positive(int8_t);
     200display_type_vector_positive(uint8_t);
     201display_type_vector_positive(int16_t);
     202display_type_vector_positive(uint16_t);
     203display_type_vector_positive(int32_t);
     204display_type_vector_positive(uint32_t);
     205display_type_vector_positive(int64_t);
     206display_type_vector_positive(uint64_t);
     207display_type_vector_positive(float);
     208display_type_vector_positive(double);
     209
     210// Local Variables:
     211// tab-width: 4
     212// c-basic-offset: 4
     213// c-file-offsets:((innamespace . 0)(inline-open . 0))
     214// indent-tabs-mode: nil
     215// End:
     216
     217// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     218
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1f.c

    r772 r822  
    1616#include <stdlib.h>
    1717
     18#include "nrc_os_config.h"
    1819#include "mypredef.h"
    1920#include "nrtype.h"
     
    3132 * --------------------
    3233 */
    33 /* ------------------------------------------------------------------------------------ */
    34 IMAGE_EXPORT(void) write_si8vector(sint8 *v,long nl,long nh, char *format, char *filename)
    35 /* ------------------------------------------------------------------------------------ */
    36 {
    37   long  k;
    38   FILE *f;
    39 
    40   f = fopen(filename, "wt");
    41   if(f == NULL) { nrerror("Can't open file in write_si8vector"); }
    42   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    43   fclose(f);
    44 }
    45 /* ------------------------------------------------------------------------------------ */
    46 IMAGE_EXPORT(void) write_ui8vector(uint8 *v,long nl,long nh, char *format, char *filename)
    47 /* ------------------------------------------------------------------------------------ */
    48 {
    49   long  k;
    50   FILE *f;
    51 
    52   f = fopen(filename, "wt");
    53   if(f == NULL) { nrerror("Can't open file in write_ui8vector"); }
    54   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    55   fclose(f);
     34
     35#undef write_type_vector
     36#define write_type_vector(t) \
     37void short_name(t,write_,vector)(t * v, int32_t nl, int32_t nh, char * format, char * filename) \
     38{                                                                  \
     39    FILE * f = fopen(filename, "wt");                              \
     40    if (f == NULL) {                                               \
     41        nrerror("Can't open file %s in %s\n", filename, __func__); \
     42    }                                                              \
     43    for (int32_t k = nl; k <= nh; k++) {                           \
     44        fprintf(f, format, v[k]);                                  \
     45    }                                                              \
     46    fprintf(f, "\n");                                              \
     47    fclose(f);                                                     \
     48}
     49
     50write_type_vector(int8_t);
     51write_type_vector(uint8_t);
     52write_type_vector(int16_t);
     53write_type_vector(uint16_t);
     54write_type_vector(int32_t);
     55write_type_vector(uint32_t);
     56write_type_vector(int64_t);
     57write_type_vector(uint64_t);
     58write_type_vector(float);
     59write_type_vector(double);
     60
     61
     62/* ---------------------------------------------------------------------------------- */
     63void write_rgb8vector(rgb8 * v,int32_t nl, int32_t nh, char * format, char * filename)
     64/* ---------------------------------------------------------------------------------- */
     65{
     66    FILE * f = fopen(filename, "wt");
     67    if (f == NULL) {
     68        nrerror("Can't open file %s in %s\n", filename, __func__); \
     69    }
     70    for (int32_t k = nl; k <= nh; k++) {
     71        fprintf(f, format, v[k].r, v[k].g, v[k].b);
     72    }
     73    fprintf(f, "\n");
     74    fclose(f);
    5675}
    5776
    5877/* -------------------------------------------------------------------------------------- */
    59 IMAGE_EXPORT(void) write_si16vector(sint16 *v,long nl,long nh, char *format, char *filename)
     78void write_rgbx8vector(rgbx8 * v, int32_t nl, int32_t nh, char * format, char * filename)
    6079/* -------------------------------------------------------------------------------------- */
    6180{
    62   long  k;
    63   FILE *f;
    64 
    65   f = fopen(filename, "wt");
    66   if(f == NULL) { nrerror("Can't open file in write_si16vector"); }
    67   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    68   fclose(f);
    69 }
    70 /* -------------------------------------------------------------------------------------- */
    71 IMAGE_EXPORT(void) write_ui16vector(uint16 *v,long nl,long nh, char *format, char *filename)
    72 /* -------------------------------------------------------------------------------------- */
    73 {
    74   long  k;
    75   FILE *f;
    76 
    77   f = fopen(filename, "wt");
    78   if(f == NULL) { nrerror("Can't open file in write_ui16vector"); }
    79   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    80   fclose(f);
    81 }
    82 /* -------------------------------------------------------------------------------------- */
    83 IMAGE_EXPORT(void) write_si32vector(sint32 *v,long nl,long nh, char *format, char *filename)
    84 /* -------------------------------------------------------------------------------------- */
    85 {
    86   long  k;
    87   FILE *f;
    88 
    89   f = fopen(filename, "wt");
    90   if(f == NULL) { nrerror("Can't open file in write_si32vector"); }
    91   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    92   fclose(f);
    93 }
    94 /* -------------------------------------------------------------------------------------- */
    95 IMAGE_EXPORT(void) write_ui32vector(uint32 *v,long nl,long nh, char *format, char *filename)
    96 /* -------------------------------------------------------------------------------------- */
    97 {
    98   long  k;
    99   FILE *f;
    100 
    101   f = fopen(filename, "wt");
    102   if(f == NULL) { nrerror("Can't open file in write_ui32vector"); }
    103   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    104   fclose(f);
    105 }
    106 /* -------------------------------------------------------------------------------------- */
    107 IMAGE_EXPORT(void) write_si64vector(sint64 *v,long nl,long nh, char *format, char *filename)
    108 /* -------------------------------------------------------------------------------------- */
    109 {
    110   long  k;
    111   FILE *f;
    112 
    113   f = fopen(filename, "wt");
    114   if(f == NULL) { nrerror("Can't open file in write_si64vector"); }
    115   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    116   fclose(f);
    117 }
    118 /* ------------------------------------------------------------------------------------- */
    119 IMAGE_EXPORT(void) write_i64vector(uint64 *v,long nl,long nh, char *format, char *filename)
    120 /* ------------------------------------------------------------------------------------- */
    121 {
    122   long  k;
    123   FILE *f;
    124 
    125   f = fopen(filename, "wt");
    126   if(f == NULL) { nrerror("Can't open file in write_ui64vector"); }
    127   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    128   fclose(f);
    129 }
    130 /* -------------------------------------------------------------------------------------- */
    131 IMAGE_EXPORT(void) write_f32vector(float32 *v,long nl,long nh, char *format, char *filename)
    132 /* -------------------------------------------------------------------------------------- */
    133 {
    134   long  k;
    135   FILE *f;
    136 
    137   f = fopen(filename, "wt");
    138   if(f == NULL) { nrerror("Can't open file in write_f32vector"); }
    139   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    140   fclose(f);
    141 }
    142 /* -------------------------------------------------------------------------------------- */
    143 IMAGE_EXPORT(void) write_f64vector(float64 *v,long nl,long nh, char *format, char *filename)
    144 /* -------------------------------------------------------------------------------------- */
    145 {
    146   long  k;
    147   FILE *f;
    148 
    149   f = fopen(filename, "wt");
    150   if(f == NULL) { nrerror("Can't open file in write_f64vector"); }
    151   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    152   fclose(f);
    153 }
    154 /* ---------------------------------------------------------------------------------- */
    155 IMAGE_EXPORT(void) write_rgb8vector(rgb8 *v,long nl,long nh, char *format, char *filename)
    156 /* ---------------------------------------------------------------------------------- */
    157 {
    158   long  k;
    159   FILE *f;
    160 
    161   f = fopen(filename, "wt");
    162   if(f == NULL) { nrerror("Can't open file in write_rgb8vector"); }
    163   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); } fputc('\n', f);
    164   fclose(f);
    165 }
    166 /* -------------------------------------------------------------------------------------- */
    167 IMAGE_EXPORT(void) write_rgbx8vector(rgbx8 *v,long nl,long nh, char *format, char *filename)
    168 /* -------------------------------------------------------------------------------------- */
    169 {
    170   long  k;
    171   FILE *f;
    172 
    173   f = fopen(filename, "wt");
    174   if(f == NULL) { nrerror("Can't open file in write_rgbx8vector"); }
    175   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); } fputc('\n', f);
    176   fclose(f);
    177 }
     81    FILE * f = fopen(filename, "wt");
     82    if (f == NULL) {
     83        nrerror("Can't open file %s in %s\n", filename, __func__); \
     84    }
     85    for (int32_t k = nl; k <= nh; k++) {
     86        fprintf(f, format, v[k].r, v[k].g, v[k].b);
     87    }
     88    fprintf(f, "\n");
     89    fclose(f);
     90}
     91
     92
    17893/*
    17994 * ----------------------
     
    18196 * ----------------------
    18297 */
     98
     99#undef write_type_vector_T
     100#define write_type_vector_T(t) \
     101void short_name(t,write_,vector_T)(t * v, int32_t nl, int32_t nh, char * format, char * filename) \
     102{                                                                  \
     103    FILE * f = fopen(filename, "wt");                              \
     104    if (f == NULL) {                                               \
     105        nrerror("Can't open file %s in %s\n", filename, __func__); \
     106    }                                                              \
     107    for (int32_t k = nl; k <= nh; k++) {                           \
     108        fprintf(f, format, v[k]);                                  \
     109        fprintf(f, "\n");                                          \
     110    }                                                              \
     111    fclose(f);                                                     \
     112}
     113
     114write_type_vector_T(int8_t);
     115write_type_vector_T(uint8_t);
     116write_type_vector_T(int16_t);
     117write_type_vector_T(uint16_t);
     118write_type_vector_T(int32_t);
     119write_type_vector_T(uint32_t);
     120write_type_vector_T(int64_t);
     121write_type_vector_T(uint64_t);
     122write_type_vector_T(float);
     123write_type_vector_T(double);
     124
     125
     126/* ---------------------------------------------------------------------------------- */
     127void write_rgb8vector_T(rgb8 * v,int32_t nl, int32_t nh, char * format, char * filename)
     128/* ---------------------------------------------------------------------------------- */
     129{
     130    FILE * f = fopen(filename, "wt");
     131    if (f == NULL) {
     132        nrerror("Can't open file %s in %s\n", filename, __func__); \
     133    }
     134    for (int32_t k = nl; k <= nh; k++) {
     135        fprintf(f, format, v[k].r, v[k].g, v[k].b);
     136        fprintf(f, "\n");
     137    }
     138    fclose(f);
     139}
     140
    183141/* -------------------------------------------------------------------------------------- */
    184 IMAGE_EXPORT(void) write_si8vector_T(sint8 *v,long nl,long nh, char *format, char *filename)
     142void write_rgbx8vector_T(rgbx8 * v, int32_t nl, int32_t nh, char * format, char * filename)
    185143/* -------------------------------------------------------------------------------------- */
    186144{
    187   long  k;
    188   FILE *f;
    189 
    190   f = fopen(filename, "wt");
    191   if(f == NULL) { nrerror("Can't open file in write_si8vector"); }
    192   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); }
    193   fclose(f);
    194 }
    195 /* -------------------------------------------------------------------------------------- */
    196 IMAGE_EXPORT(void) write_ui8vector_T(uint8 *v,long nl,long nh, char *format, char *filename)
    197 /* -------------------------------------------------------------------------------------- */
    198 {
    199   long  k;
    200   FILE *f;
    201 
    202   f = fopen(filename, "wt");
    203   if(f == NULL) { nrerror("Can't open file in write_ui8vector"); }
    204   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); }
    205   fclose(f);
    206 }
    207 /* ---------------------------------------------------------------------------------------- */
    208 IMAGE_EXPORT(void) write_si16vector_T(sint16 *v,long nl,long nh, char *format, char *filename)
    209 /* ---------------------------------------------------------------------------------------- */
    210 {
    211   long  k;
    212   FILE *f;
    213 
    214   f = fopen(filename, "wt");
    215   if(f == NULL) { nrerror("Can't open file in write_si16vector"); }
    216   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); }
    217   fclose(f);
    218 }
    219 /* -------------------------------------------------------------------------------------- */
    220 IMAGE_EXPORT(void) write_ui16vector_T(uint16 *v,long nl,long nh, char *format, char *filename)
    221 /* -------------------------------------------------------------------------------------- */
    222 {
    223   long  k;
    224   FILE *f;
    225 
    226   f = fopen(filename, "wt");
    227   if(f == NULL) { nrerror("Can't open file in write_ui16vector"); }
    228   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); }
    229   fclose(f);
    230 }
    231 /* ---------------------------------------------------------------------------------------- */
    232 IMAGE_EXPORT(void) write_si32vector_T(sint32 *v,long nl,long nh, char *format, char *filename)
    233 /* ---------------------------------------------------------------------------------------- */
    234 {
    235   long  k;
    236   FILE *f;
    237 
    238   f = fopen(filename, "wt");
    239   if(f == NULL) { nrerror("Can't open file in write_si32vector"); }
    240   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); }
    241   fclose(f);
    242 }
    243 /* ---------------------------------------------------------------------------------------- */
    244 IMAGE_EXPORT(void) write_ui32vector_T(uint32 *v,long nl,long nh, char *format, char *filename)
    245 /* ---------------------------------------------------------------------------------------- */
    246 {
    247   long  k;
    248   FILE *f;
    249 
    250   f = fopen(filename, "wt");
    251   if(f == NULL) { nrerror("Can't open file in write_ui32vector"); }
    252   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); }
    253   fclose(f);
    254 }
    255 /* ---------------------------------------------------------------------------------------- */
    256 IMAGE_EXPORT(void) write_si64vector_T(sint64 *v,long nl,long nh, char *format, char *filename)
    257 /* ---------------------------------------------------------------------------------------- */
    258 {
    259   long  k;
    260   FILE *f;
    261 
    262   f = fopen(filename, "wt");
    263   if(f == NULL) { nrerror("Can't open file in write_si64vector"); }
    264   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); }
    265   fclose(f);
    266 }
    267 /* ---------------------------------------------------------------------------------------- */
    268 IMAGE_EXPORT(void) write_ui64vector_T(uint64 *v,long nl,long nh, char *format, char *filename)
    269 /* ---------------------------------------------------------------------------------------- */
    270 {
    271   long  k;
    272   FILE *f;
    273 
    274   f = fopen(filename, "wt");
    275   if(f == NULL) { nrerror("Can't open file in write_ui64vector"); }
    276   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); fputc('\n', f); }
    277   fclose(f);
    278 }
    279 /* -------------------------------------------------------------------------------------- */
    280 IMAGE_EXPORT(void) write_rgb8vector_T(rgb8 *v,long nl,long nh, char *format, char *filename)
    281 /* -------------------------------------------------------------------------------------- */
    282 {
    283   long  k;
    284   FILE *f;
    285 
    286   f = fopen(filename, "wt");
    287   if(f == NULL) { nrerror("Can't open file in write_rgb8vector_T"); }
    288   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); fputc('\n', f); }
    289   fclose(f);
    290 }
    291 /* ---------------------------------------------------------------------------------------- */
    292 IMAGE_EXPORT(void) write_rgbx8vector_T(rgbx8 *v,long nl,long nh, char *format, char *filename)
    293 /* ---------------------------------------------------------------------------------------- */
    294 {
    295   long  k;
    296   FILE *f;
    297 
    298   f = fopen(filename, "wt");
    299   if(f == NULL) { nrerror("Can't open file in write_rgbx8vector_T"); }
    300   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); fputc('\n', f); }
    301   fclose(f);
    302 }
     145    FILE * f = fopen(filename, "wt");
     146    if (f == NULL) {
     147        nrerror("Can't open file %s in %s\n", filename, __func__); \
     148    }
     149    for (int32_t k = nl; k <= nh; k++) {
     150        fprintf(f, format, v[k].r, v[k].g, v[k].b);
     151        fprintf(f, "\n");
     152    }
     153    fclose(f);
     154}
     155
    303156
    304157/*
     
    307160 * ---------------------------
    308161 */
     162
     163// @QM : fprintf(f, format, k, k, k); ?
     164#undef write_type_vector_number
     165#define write_type_vector_number(t) \
     166void short_name(t,write_,vector_number)(t * v, int32_t nl, int32_t nh, char * format, char * filename) \
     167{                                                                  \
     168    FILE * f = fopen(filename, "wt");                              \
     169    if (f == NULL) {                                               \
     170        nrerror("Can't open file %s in %s\n", filename, __func__); \
     171    }                                                              \
     172    for (int32_t k = nl; k <= nh; k++) {                           \
     173        fprintf(f, format, k);                                     \
     174    }                                                              \
     175    fprintf(f, "\n");                                              \
     176    for (int32_t k = nl; k <= nh; k++) {                           \
     177        fprintf(f, format, v[k]);                                  \
     178    }                                                              \
     179    fprintf(f, "\n");                                              \
     180    fclose(f);                                                     \
     181}
     182
     183write_type_vector_number(int8_t);
     184write_type_vector_number(uint8_t);
     185write_type_vector_number(int16_t);
     186write_type_vector_number(uint16_t);
     187write_type_vector_number(int32_t);
     188write_type_vector_number(uint32_t);
     189write_type_vector_number(int64_t);
     190write_type_vector_number(uint64_t);
     191write_type_vector_number(float);
     192write_type_vector_number(double);
     193
     194
     195/* ------------------------------------------------------------------------------------------- */
     196void write_rgb8vector_number(rgb8 * v, int32_t nl, int32_t nh, char * format, char * filename)
     197/* ------------------------------------------------------------------------------------------- */
     198{
     199    FILE * f = fopen(filename, "wt");
     200    if (f == NULL) {
     201        nrerror("Can't open file %s in %s\n", filename, __func__);
     202    }
     203    for (int32_t k = nl; k <= nh; k++) {
     204        fprintf(f, "%3d", k);
     205    }
     206    fprintf(f, "\n");
     207    for (int32_t k = nl; k <= nh; k++) {
     208        fprintf(f, format, v[k].r, v[k].g, v[k].b);
     209    }
     210    fprintf(f, "\n");
     211    fclose(f);
     212}
     213
     214
    309215/* --------------------------------------------------------------------------------------------- */
    310 IMAGE_EXPORT(void) write_si8vector_number(sint8 *v,long nl,long nh, char *format, char *filename)
     216void write_rgbx8vector_number(rgbx8 * v, int32_t nl, int32_t nh, char * format, char * filename)
    311217/* --------------------------------------------------------------------------------------------- */
    312218{
    313   int  k;
    314   FILE *f;
    315 
    316   f = fopen(filename, "wt");
    317   if(f == NULL) { nrerror("Can't open file in write_si8vector_number"); }
    318   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    319   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    320   fclose(f);
    321 }
    322 /* ------------------------------------------------------------------------------------------- */
    323 IMAGE_EXPORT(void) write_ui8vector_number(uint8 *v,long nl,long nh, char *format, char *filename)
    324 /* ------------------------------------------------------------------------------------------- */
    325 {
    326   int  k;
    327   FILE *f;
    328 
    329   f = fopen(filename, "wt");
    330   if(f == NULL) { nrerror("Can't open file in write_ui8vector_number"); }
    331   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    332   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    333   fclose(f);
    334 }
    335 /* --------------------------------------------------------------------------------------------- */
    336 IMAGE_EXPORT(void) write_si16vector_number(sint16 *v,long nl,long nh, char *format, char *filename)
    337 /* --------------------------------------------------------------------------------------------- */
    338 {
    339   int  k;
    340   FILE *f;
    341 
    342   f = fopen(filename, "wt");
    343   if(f == NULL) { nrerror("Can't open file in write_si16vector_number"); }
    344   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    345   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    346   fclose(f);
    347 }
    348 /* ------------------------------------------------------------------------------------------- */
    349 IMAGE_EXPORT(void) write_ui16vector_number(uint16 *v,long nl,long nh, char *format, char *filename)
    350 /* ------------------------------------------------------------------------------------------- */
    351 {
    352   int  k;
    353   FILE *f;
    354 
    355   f = fopen(filename, "wt");
    356   if(f == NULL) { nrerror("Can't open file in write_ui16vector_number"); }
    357   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    358   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    359   fclose(f);
    360 }
    361 /* --------------------------------------------------------------------------------------------- */
    362 IMAGE_EXPORT(void) write_si32vector_number(sint32 *v,long nl,long nh, char *format, char *filename)
    363 /* --------------------------------------------------------------------------------------------- */
    364 {
    365   int  k;
    366   FILE *f;
    367 
    368   f = fopen(filename, "wt");
    369   if(f == NULL) { nrerror("Can't open file in write_si32vector_number"); }
    370   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    371   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    372   fclose(f);
    373 }
    374 /* ------------------------------------------------------------------------------------------- */
    375 IMAGE_EXPORT(void) write_ui32vector_number(uint32 *v,long nl,long nh, char *format, char *filename)
    376 /* ------------------------------------------------------------------------------------------- */
    377 {
    378   int  k;
    379   FILE *f;
    380 
    381   f = fopen(filename, "wt");
    382   if(f == NULL) { nrerror("Can't open file in write_ui32vector_number"); }
    383   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    384   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    385   fclose(f);
    386 }
    387 /* --------------------------------------------------------------------------------------------- */
    388 IMAGE_EXPORT(void) write_si64vector_number(sint64 *v,long nl,long nh, char *format, char *filename)
    389 /* --------------------------------------------------------------------------------------------- */
    390 {
    391   int  k;
    392   FILE *f;
    393 
    394   f = fopen(filename, "wt");
    395   if(f == NULL) { nrerror("Can't open file in write_si64vector_number"); }
    396   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    397   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    398   fclose(f);
    399 }
    400 /* ------------------------------------------------------------------------------------------- */
    401 IMAGE_EXPORT(void) write_ui64vector_number(uint64 *v,long nl,long nh, char *format, char *filename)
    402 /* ------------------------------------------------------------------------------------------- */
    403 {
    404   int  k;
    405   FILE *f;
    406 
    407   f = fopen(filename, "wt");
    408   if(f == NULL) { nrerror("Can't open file in write_ui64vector_number"); }
    409   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    410   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    411   fclose(f);
    412 }
    413 /* --------------------------------------------------------------------------------------------- */
    414 IMAGE_EXPORT(void) write_f32vector_number(float32 *v,long nl,long nh, char *format, char *filename)
    415 /* --------------------------------------------------------------------------------------------- */
    416 {
    417   int k;
    418   FILE *f;
    419 
    420   f = fopen(filename, "wt");
    421   if(f == NULL) { nrerror("Can't open file in write_f32vector_number"); }
    422   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    423   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    424   fclose(f);
    425 }
    426 /* --------------------------------------------------------------------------------------------- */
    427 IMAGE_EXPORT(void) write_f64vector_number(float64 *v,long nl,long nh, char *format, char *filename)
    428 /* --------------------------------------------------------------------------------------------- */
    429 {
    430   int k;
    431   FILE *f;
    432 
    433   f = fopen(filename, "wt");
    434   if(f == NULL) { nrerror("Can't open file in write_f32vector_number"); }
    435   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    436   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k]); } fputc('\n', f);
    437   fclose(f);
    438 }
    439 /* ------------------------------------------------------------------------------------------- */
    440 IMAGE_EXPORT(void) write_rgb8vector_number(rgb8 *v,long nl,long nh, char *format, char *filename)
    441 /* ------------------------------------------------------------------------------------------- */
    442 {
    443   int  k;
    444   FILE *f;
    445 
    446   f = fopen(filename, "wt");
    447   if(f == NULL) { nrerror("Can't open file in write_rgb8vector_number"); }
    448   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    449   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); } fputc('\n', f);
    450   fclose(f);
    451 }
    452 /* --------------------------------------------------------------------------------------------- */
    453 IMAGE_EXPORT(void) write_rgbx8vector_number(rgbx8 *v,long nl,long nh, char *format, char *filename)
    454 /* --------------------------------------------------------------------------------------------- */
    455 {
    456   int  k;
    457   FILE *f;
    458 
    459   f = fopen(filename, "wt");
    460   if(f == NULL) { nrerror("Can't open file in write_rgbx8vector_number"); }
    461   for(k=nl; k<=nh; k++) { fprintf(f, format, k,k,k);} fputc('\n', f);
    462   for(k=nl; k<=nh; k++) { fprintf(f, format, v[k].r, v[k].g, v[k].b); } fputc('\n', f);
    463   fclose(f);
    464 }
     219    FILE * f = fopen(filename, "wt");
     220    if (f == NULL) {
     221        nrerror("Can't open file %s in %s\n", filename, __func__);
     222    }
     223    for (int32_t k = nl; k <= nh; k++) {
     224        fprintf(f, "%3d", k);
     225    }
     226    fprintf(f, "\n");
     227    for (int32_t k = nl; k <= nh; k++) {
     228        fprintf(f, format, v[k].r, v[k].g, v[k].b);
     229    }
     230    fprintf(f, "\n");
     231    fclose(f);
     232}
     233
     234
    465235/*
    466236 * -----------------------------
     
    469239 */
    470240
     241#undef write_type_vector_T_number
     242#define write_type_vector_T_number(t) \
     243void short_name(t,write_,vector_T_number)(t * v, int32_t nl, int32_t nh, char * format, char * filename) \
     244{                                                                  \
     245    FILE * f = fopen(filename, "wt");                              \
     246    if (f == NULL) {                                               \
     247        nrerror("Can't open file %s in %s\n", filename, __func__); \
     248    }                                                              \
     249    for (int32_t k = nl; k <= nh; k++) {                           \
     250        fprintf(f, "%3d", k);                                      \
     251        fprintf(f, format, v[k]);                                  \
     252        fprintf(f, "\n");                                          \
     253    }                                                              \
     254    fclose(f);                                                     \
     255}
     256
     257write_type_vector_T_number(int8_t);
     258write_type_vector_T_number(uint8_t);
     259write_type_vector_T_number(int16_t);
     260write_type_vector_T_number(uint16_t);
     261write_type_vector_T_number(int32_t);
     262write_type_vector_T_number(uint32_t);
     263write_type_vector_T_number(int64_t);
     264write_type_vector_T_number(uint64_t);
     265write_type_vector_T_number(float);
     266write_type_vector_T_number(double);
     267
     268
     269/* ------------------------------------------------------------------------------------------- */
     270void write_rgb8vector_T_number(rgb8 * v, int32_t nl, int32_t nh, char * format, char * filename)
     271/* ------------------------------------------------------------------------------------------- */
     272{
     273    FILE * f = fopen(filename, "wt");
     274    if (f == NULL) {
     275        nrerror("Can't open file %s in %s\n", filename, __func__);
     276    }
     277    for (int32_t k = nl; k <= nh; k++) {
     278        fprintf(f, "%3d", k);
     279        fprintf(f, format, v[k].r, v[k].g, v[k].b);
     280        fprintf(f, "\n");
     281    }
     282    fclose(f);
     283}
     284
     285
    471286/* --------------------------------------------------------------------------------------------- */
    472 IMAGE_EXPORT(void) write_si8vector_T_number(sint8 *v,long nl,long nh, char *format, char *filename)
     287void write_rgbx8vector_T_number(rgbx8 * v, int32_t nl, int32_t nh, char * format, char * filename)
    473288/* --------------------------------------------------------------------------------------------- */
    474289{
    475   int  k;
    476   FILE *f;
    477 
    478   f = fopen(filename, "wt");
    479   if(f == NULL) { nrerror("Can't open file in write_si8vector"); }
    480   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    481   fclose(f);
    482 }
    483 /* --------------------------------------------------------------------------------------------- */
    484 IMAGE_EXPORT(void) write_ui8vector_T_number(uint8 *v,long nl,long nh, char *format, char *filename)
    485 /* --------------------------------------------------------------------------------------------- */
    486 {
    487   int  k;
    488   FILE *f;
    489 
    490   f = fopen(filename, "wt");
    491   if(f == NULL) { nrerror("Can't open file in write_ui8vector"); }
    492   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    493   fclose(f);
    494 }
    495 /* ----------------------------------------------------------------------------------------------- */
    496 IMAGE_EXPORT(void) write_si16vector_T_number(sint16 *v,long nl,long nh, char *format, char *filename)
    497 /* ----------------------------------------------------------------------------------------------- */
    498 {
    499   int  k;
    500   FILE *f;
    501 
    502   f = fopen(filename, "wt");
    503   if(f == NULL) { nrerror("Can't open file in write_si16vector"); }
    504   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    505   fclose(f);
    506 }
    507 /* ----------------------------------------------------------------------------------------------- */
    508 IMAGE_EXPORT(void) write_ui16vector_T_number(uint16 *v,long nl,long nh, char *format, char *filename)
    509 /* ----------------------------------------------------------------------------------------------- */
    510 {
    511   int  k;
    512   FILE *f;
    513 
    514   f = fopen(filename, "wt");
    515   if(f == NULL) { nrerror("Can't open file in write_ui16vector"); }
    516   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    517   fclose(f);
    518 }
    519 /* ----------------------------------------------------------------------------------------------- */
    520 IMAGE_EXPORT(void) write_si32vector_T_number(sint32 *v,long nl,long nh, char *format, char *filename)
    521 /* ----------------------------------------------------------------------------------------------- */
    522 {
    523   int  k;
    524   FILE *f;
    525 
    526   f = fopen(filename, "wt");
    527   if(f == NULL) { nrerror("Can't open file in write_si32vector"); }
    528   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    529   fclose(f);
    530 }
    531 /* ------------------------------------------------------------------------------------------- */
    532 IMAGE_EXPORT(void) write_ui32vector_T_number(uint32 *v,long nl,long nh, char *format, char *filename)
    533 /* ------------------------------------------------------------------------------------------- */
    534 {
    535   int  k;
    536   FILE *f;
    537 
    538   f = fopen(filename, "wt");
    539   if(f == NULL) { nrerror("Can't open file in write_ui32vector_T_number"); }
    540   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    541   fclose(f);
    542 }
    543 /* ----------------------------------------------------------------------------------------------- */
    544 IMAGE_EXPORT(void) write_si64vector_T_number(sint64 *v,long nl,long nh, char *format, char *filename)
    545 /* ----------------------------------------------------------------------------------------------- */
    546 {
    547   int  k;
    548   FILE *f;
    549 
    550   f = fopen(filename, "wt");
    551   if(f == NULL) { nrerror("Can't open file in write_i64vector"); }
    552   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    553   fclose(f);
    554 }
    555 /* ----------------------------------------------------------------------------------------------- */
    556 IMAGE_EXPORT(void) write_ui64vector_T_number(uint64 *v,long nl,long nh, char *format, char *filename)
    557 /* ----------------------------------------------------------------------------------------------- */
    558 {
    559   int  k;
    560   FILE *f;
    561 
    562   f = fopen(filename, "wt");
    563   if(f == NULL) { nrerror("Can't open file in write_i64vector"); }
    564   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    565   fclose(f);
    566 }
    567 /* ----------------------------------------------------------------------------------------------- */
    568 IMAGE_EXPORT(void) write_f32vector_T_number(float32 *v,long nl,long nh, char *format, char *filename)
    569 /* ----------------------------------------------------------------------------------------------- */
    570 {
    571   int  k;
    572   FILE *f;
    573 
    574   f = fopen(filename, "wt");
    575   if(f == NULL) { nrerror("Can't open file in write_f32vector"); }
    576   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    577   fclose(f);
    578 }
    579 /* ----------------------------------------------------------------------------------------------- */
    580 IMAGE_EXPORT(void) write_f64vector_T_number(float64 *v,long nl,long nh, char *format, char *filename)
    581 /* ----------------------------------------------------------------------------------------------- */
    582 {
    583   int  k;
    584   FILE *f;
    585 
    586   f = fopen(filename, "wt");
    587   if(f == NULL) { nrerror("Can't open file in write_f64vector"); }
    588   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k]); fputc('\n', f); }
    589   fclose(f);
    590 }
    591 /* ------------------------------------------------------------------------------------------- */
    592 IMAGE_EXPORT(void) write_rgb8vector_T_number(rgb8 *v,long nl,long nh, char *format, char *filename)
    593 /* ------------------------------------------------------------------------------------------- */
    594 {
    595   int  k;
    596   FILE *f;
    597 
    598   f = fopen(filename, "wt");
    599   if(f == NULL) { nrerror("Can't open file in write_rgb8vector_T"); }
    600   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k].r, v[k].g, v[k].b); fputc('\n', f); }
    601   fclose(f);
    602 }
    603 /* ----------------------------------------------------------------------------------------------- */
    604 IMAGE_EXPORT(void) write_rgbx8vector_T_number(rgbx8 *v,long nl,long nh, char *format, char *filename)
    605 /* ----------------------------------------------------------------------------------------------- */
    606 {
    607   int  k;
    608   FILE *f;
    609 
    610   f = fopen(filename, "wt");
    611   if(f == NULL) { nrerror("Can't open file in write_rgb8vector_T"); }
    612   for(k=nl; k<=nh; k++) { fprintf(f, "%3d ", k); fprintf(f, format, v[k].r, v[k].g, v[k].b); fputc('\n', f); }
    613   fclose(f);
    614 }
     290    FILE * f = fopen(filename, "wt");
     291    if (f == NULL) {
     292        nrerror("Can't open file %s in %s\n", filename, __func__);
     293    }
     294    for (int32_t k = nl; k <= nh; k++) {
     295        fprintf(f, "%3d", k);
     296        fprintf(f, format, v[k].r, v[k].g, v[k].b);
     297        fprintf(f, "\n");
     298    }
     299    fclose(f);
     300}
     301
     302
    615303
    616304/*
     
    620308 */
    621309
    622 /* ---------------------------------------------------------------------- */
    623 IMAGE_EXPORT(void) fread_si8vector(char *filename, sint8 *v,long nl,long nh)
    624 /* ---------------------------------------------------------------------- */
    625 {
    626   long ncol=nh-nl+1, nread;
    627   FILE *f;
    628 
    629   f = fopen(filename, "rb");
    630   if(f == NULL) nrerror("Can't open file in fread_si8vector");
    631 
    632   nread = fread(v+nl, sizeof(sint8), ncol, f);
    633   if(nread != ncol) nrerror("fread_si8vector can't read the whole vector");
    634   fclose(f);
    635 }
    636 /* ---------------------------------------------------------------------- */
    637 IMAGE_EXPORT(void) fread_ui8vector(char *filename, uint8 *v,long nl,long nh)
    638 /* ---------------------------------------------------------------------- */
    639 {
    640   long ncol=nh-nl+1, nread;
    641   FILE *f;
    642 
    643   f = fopen(filename, "rb");
    644   if(f == NULL) nrerror("Can't open file in fread_ui8vector");
    645 
    646   nread = fread(v+nl, sizeof(uint8), ncol, f);
    647   if(nread != ncol) nrerror("fread_ui8vector can't read the whole vector");
    648   fclose(f);
    649 }
    650 /* ------------------------------------------------------------------------ */
    651 IMAGE_EXPORT(void) fread_si16vector(char *filename, sint16 *v,long nl,long nh)
    652 /* ------------------------------------------------------------------------ */
    653 {
    654   long ncol=nh-nl+1, nread;
    655   FILE *f;
    656 
    657   f = fopen(filename, "rb");
    658   if(f == NULL) nrerror("Can't open file in fread_si16vector");
    659 
    660   nread = fread(v+nl, sizeof(int16), ncol, f);
    661   if(nread != ncol) nrerror("fread_si16vector can't read the whole vector");
    662   fclose(f);
    663 }
    664 /* ------------------------------------------------------------------------ */
    665 IMAGE_EXPORT(void) fread_ui16vector(char *filename, uint16 *v,long nl,long nh)
    666 /* ------------------------------------------------------------------------ */
    667 {
    668   long ncol=nh-nl+1, nread;
    669   FILE *f;
    670 
    671   f = fopen(filename, "rb");
    672   if(f == NULL) nrerror("Can't open file in fread_ui16vector");
    673 
    674   nread = fread(v+nl, sizeof(int16), ncol, f);
    675   if(nread != ncol) nrerror("fread_ui16vector can't read the whole vector");
    676   fclose(f);
    677 }
    678 /* ------------------------------------------------------------------------ */
    679 IMAGE_EXPORT(void) fread_si32vector(char *filename, sint32 *v,long nl,long nh)
    680 /* ------------------------------------------------------------------------ */
    681 {
    682   long ncol=nh-nl+1, nread;
    683   FILE *f;
    684 
    685   f = fopen(filename, "rb");
    686   if(f == NULL) nrerror("Can't open file in fread_si32vector");
    687 
    688   nread = fread(v+nl, sizeof(sint32), ncol, f);
    689   if(nread != ncol) nrerror("fread_si32vector can't read the whole vector");
    690   fclose(f);
    691 }
    692 /* ------------------------------------------------------------------------ */
    693 IMAGE_EXPORT(void) fread_ui32vector(char *filename, uint32 *v,long nl,long nh)
    694 /* ------------------------------------------------------------------------ */
    695 {
    696   long ncol=nh-nl+1, nread;
    697   FILE *f;
    698 
    699   f = fopen(filename, "rb");
    700   if(f == NULL) nrerror("Can't open file in fread_ui32vector");
    701 
    702   nread = fread(v+nl, sizeof(uint32), ncol, f);
    703   if(nread != ncol) nrerror("fread_ui32vector can't read the whole vector");
    704   fclose(f);
    705 }
    706 /* ------------------------------------------------------------------------ */
    707 IMAGE_EXPORT(void) fread_si64vector(char *filename, sint64 *v,long nl,long nh)
    708 /* ------------------------------------------------------------------------ */
    709 {
    710   long ncol=nh-nl+1, nread;
    711   FILE *f;
    712 
    713   f = fopen(filename, "rb");
    714   if(f == NULL) nrerror("Can't open file in fread_si64vector");
    715 
    716   nread = fread(v+nl, sizeof(sint64), ncol, f);
    717   if(nread != ncol) nrerror("fread_si64vector can't read the whole vector");
    718   fclose(f);
    719 }
    720 /* ------------------------------------------------------------------------ */
    721 IMAGE_EXPORT(void) fread_ui64vector(char *filename, uint64 *v,long nl,long nh)
    722 /* ------------------------------------------------------------------------ */
    723 {
    724   long ncol=nh-nl+1, nread;
    725   FILE *f;
    726 
    727   f = fopen(filename, "rb");
    728   if(f == NULL) nrerror("Can't open file in fread_ui64vector");
    729 
    730   nread = fread(v+nl, sizeof(uint64), ncol, f);
    731   if(nread != ncol) nrerror("fread_ui64vector can't read the whole vector");
    732   fclose(f);
    733 }
    734 /* ------------------------------------------------------------------------ */
    735 IMAGE_EXPORT(void) fread_f32vector(char *filename, float32 *v,long nl,long nh)
    736 /* ------------------------------------------------------------------------ */
    737 {
    738   long ncol=nh-nl+1, nread;
    739   FILE *f;
    740 
    741   f = fopen(filename, "rb");
    742   if(f == NULL) nrerror("Can't open file in fread_f32vector");
    743 
    744   nread = fread(v+nl, sizeof(float32), ncol, f);
    745   if(nread != ncol) nrerror("fread_f32vector can't read the whole vector");
    746   fclose(f);
    747 }
    748 /* ------------------------------------------------------------------------ */
    749 IMAGE_EXPORT(void) fread_f64vector(char *filename, float64 *v,long nl,long nh)
    750 /* ------------------------------------------------------------------------ */
    751 {
    752   long ncol=nh-nl+1, nread;
    753   FILE *f;
    754 
    755   f = fopen(filename, "rb");
    756   if(f == NULL) nrerror("Can't open file in fread_f64vector");
    757 
    758   nread = fread(v+nl, sizeof(float64), ncol, f);
    759   if(nread != ncol) nrerror("fread_f64vector can't read the whole vector");
    760   fclose(f);
    761 }
    762 /* ---------------------------------------------------------------------- */
    763 IMAGE_EXPORT(void) fread_rgb8vector(char *filename, rgb8 *v,long nl,long nh)
    764 /* ---------------------------------------------------------------------- */
    765 {
    766   long ncol=nh-nl+1, nread;
    767   FILE *f;
    768 
    769   f = fopen(filename, "rb");
    770   if(f == NULL) nrerror("Can't open file in fread_rgb8vector");
    771 
    772   nread = fread(v+nl, sizeof(float32), ncol, f);
    773   if(nread != ncol) nrerror("fread_rgb8vector can't read the whole vector");
    774   fclose(f);
    775 }
    776 /* ------------------------------------------------------------------------ */
    777 IMAGE_EXPORT(void) fread_rgbx8vector(char *filename, rgbx8 *v,long nl,long nh)
    778 /* ------------------------------------------------------------------------ */
    779 {
    780   long ncol=nh-nl+1, nread;
    781   FILE *f;
    782 
    783   f = fopen(filename, "rb");
    784   if(f == NULL) nrerror("Can't open file in fread_rgbx8vector");
    785 
    786   nread = fread(v+nl, sizeof(float32), ncol, f);
    787   if(nread != ncol) nrerror("fread_rgbx8vector can't read the whole vector");
    788   fclose(f);
    789 }
     310#undef fread_type_vector
     311#define fread_type_vector(t) \
     312void short_name(t,fread_,vector)(char * filename, t * v, int32_t nl, int32_t nh) \
     313{                                                                  \
     314    int32_t ncol = nh - nl + 1;                                    \
     315    int32_t nread;                                                 \
     316    FILE * f = fopen(filename, "rb");                              \
     317    if (f == NULL) {                                               \
     318        nrerror("Can't open file %s in %s\n", filename, __func__); \
     319    }                                                              \
     320                                                                   \
     321    nread = fread(v + nl, sizeof(t), ncol, f);                     \
     322    if (nread != ncol) {                                           \
     323        nrerror("%s can't read the whole vector", __func__);       \
     324    }                                                              \
     325    fclose(f);                                                     \
     326}
     327
     328fread_type_vector(int8_t);
     329fread_type_vector(uint8_t);
     330fread_type_vector(int16_t);
     331fread_type_vector(uint16_t);
     332fread_type_vector(int32_t);
     333fread_type_vector(uint32_t);
     334fread_type_vector(int64_t);
     335fread_type_vector(uint64_t);
     336fread_type_vector(float);
     337fread_type_vector(double);
     338fread_type_vector(rgb8);
     339fread_type_vector(rgbx8);
     340
     341
    790342/* ------------------- */
    791343/* -- fwrite_vector -- */
    792344/* ------------------- */
    793 /* ---------------------------------------------------------------------- */
    794 IMAGE_EXPORT(void) fwrite_si8vector(sint8 *v,long nl,long nh,char *filename)
    795 /* ---------------------------------------------------------------------- */
    796 {
    797   long  ncol = nh-nl+1;
    798   FILE *f;
    799 
    800   f = fopen(filename, "wb");
    801   if(f == NULL) nrerror("Can't open file in fwrite_si8vector");
    802   fwrite(v+nl, sizeof(sint8), ncol, f);
    803   fclose(f);
    804 }
    805 /* ---------------------------------------------------------------------- */
    806 IMAGE_EXPORT(void) fwrite_ui8vector(uint8 *v,long nl,long nh,char *filename)
    807 /* ---------------------------------------------------------------------- */
    808 {
    809   long  ncol = nh-nl+1;
    810   FILE *f;
    811 
    812   f = fopen(filename, "wb");
    813   if(f == NULL) nrerror("Can't open file in fwrite_ui8vector");
    814   fwrite(v+nl, sizeof(uint8), ncol, f);
    815   fclose(f);
    816 }
    817 /* ------------------------------------------------------------------------ */
    818 IMAGE_EXPORT(void) fwrite_si16vector(sint16 *v,long nl,long nh,char *filename)
    819 /* ------------------------------------------------------------------------ */
    820 {
    821   long  ncol = nh-nl+1;
    822   FILE *f;
    823 
    824   f = fopen(filename, "wb");
    825   if(f == NULL) nrerror("Can't open file in fwrite_si16vector");
    826   fwrite(v+nl, sizeof(sint16), ncol, f);
    827   fclose(f);
    828 }
    829 /* ------------------------------------------------------------------------- */
    830 IMAGE_EXPORT(void) fwrite_ui16vector(uint16 *v,long nl,long nh,char *filename)
    831 /* ------------------------------------------------------------------------- */
    832 {
    833   long  ncol = nh-nl+1;
    834   FILE *f;
    835 
    836   f = fopen(filename, "wb");
    837   if(f == NULL) nrerror("Can't open file in fwrite_ui16vector");
    838   fwrite(v+nl, sizeof(uint16), ncol, f);
    839   fclose(f);
    840 }
    841 /* ------------------------------------------------------------------------ */
    842 IMAGE_EXPORT(void) fwrite_si32vector(sint32 *v,long nl,long nh,char *filename)
    843 /* ------------------------------------------------------------------------ */
    844 {
    845   long  ncol = nh-nl+1;
    846   FILE *f;
    847 
    848   f = fopen(filename, "wb");
    849   if(f == NULL) nrerror("Can't open file in fwrite_si32vector");
    850   fwrite(v+nl, sizeof(sint32), ncol, f);
    851   fclose(f);
    852 }
    853 /* ------------------------------------------------------------------------ */
    854 IMAGE_EXPORT(void) fwrite_ui32vector(uint32 *v,long nl,long nh,char *filename)
    855 /* ------------------------------------------------------------------------ */
    856 {
    857   long  ncol = nh-nl+1;
    858   FILE *f;
    859 
    860   f = fopen(filename, "wb");
    861   if(f == NULL) nrerror("Can't open file in fwrite_ui32vector");
    862   fwrite(v+nl, sizeof(uint32), ncol, f);
    863   fclose(f);
    864 }
    865 /* ------------------------------------------------------------------------ */
    866 IMAGE_EXPORT(void) fwrite_si64vector(sint64 *v,long nl,long nh,char *filename)
    867 /* ------------------------------------------------------------------------ */
    868 {
    869   long  ncol = nh-nl+1;
    870   FILE *f;
    871 
    872   f = fopen(filename, "wb");
    873   if(f == NULL) nrerror("Can't open file in fwrite_si64vector");
    874   fwrite(v+nl, sizeof(sint64), ncol, f);
    875   fclose(f);
    876 }
    877 /* ------------------------------------------------------------------------ */
    878 IMAGE_EXPORT(void) fwrite_ui64vector(uint64 *v,long nl,long nh,char *filename)
    879 /* ------------------------------------------------------------------------ */
    880 {
    881   long  ncol = nh-nl+1;
    882   FILE *f;
    883 
    884   f = fopen(filename, "wb");
    885   if(f == NULL) nrerror("Can't open file in fwrite_ui-'vector");
    886   fwrite(v+nl, sizeof(uint64), ncol, f);
    887   fclose(f);
    888 }
    889 /* ------------------------------------------------------------------------ */
    890 IMAGE_EXPORT(void) fwrite_f32vector(float32 *v,long nl,long nh,char *filename)
    891 /* ------------------------------------------------------------------------ */
    892 {
    893   long  ncol = nh-nl+1;
    894   FILE *f;
    895 
    896   f = fopen(filename, "wb");
    897   if(f == NULL) nrerror("Can't open file in f32write_vector");
    898   fwrite(v+nl, sizeof(float32), ncol, f);
    899   fclose(f);
    900 }
    901 /* ------------------------------------------------------------------------ */
    902 IMAGE_EXPORT(void) fwrite_f64vector(float64 *v,long nl,long nh,char *filename)
    903 /* ------------------------------------------------------------------------ */
    904 {
    905   long  ncol = nh-nl+1;
    906   FILE *f;
    907 
    908   f = fopen(filename, "wb");
    909   if(f == NULL) nrerror("Can't open file in f64write_vector");
    910   fwrite(v+nl, sizeof(float64), ncol, f);
    911   fclose(f);
    912 }
    913 /* ---------------------------------------------------------------------- */
    914 IMAGE_EXPORT(void) fwrite_rgb8vector(rgb8 *v,long nl,long nh,char *filename)
    915 /* ---------------------------------------------------------------------- */
    916 {
    917   long  ncol = nh-nl+1;
    918   FILE *f;
    919 
    920   f = fopen(filename, "wb");
    921   if(f == NULL) nrerror("Can't open file in write_rgb8vector");
    922   fwrite(v+nl, sizeof(rgb8), ncol, f);
    923   fclose(f);
    924 }
    925 /* ------------------------------------------------------------------------ */
    926 IMAGE_EXPORT(void) fwrite_rgbx8vector(rgbx8 *v,long nl,long nh,char *filename)
    927 /* ------------------------------------------------------------------------ */
    928 {
    929   long  ncol = nh-nl+1;
    930   FILE *f;
    931 
    932   f = fopen(filename, "wb");
    933   if(f == NULL) nrerror("Can't open file in write_rgbx8vector");
    934   fwrite(v+nl, sizeof(rgbx8), ncol, f);
    935   fclose(f);
    936 }
     345
     346#undef fwrite_type_vector
     347#define fwrite_type_vector(t) \
     348void short_name(t,fwrite_,vector)(t * v, int32_t nl, int32_t nh, char * filename) \
     349{                                                                  \
     350    int32_t ncol = nh - nl + 1;                                    \
     351    FILE * f = fopen(filename, "rb");                              \
     352    if (f == NULL) {                                               \
     353        nrerror("Can't open file %s in %s\n", filename, __func__); \
     354    }                                                              \
     355    fwrite(v + nl, sizeof(t), ncol, f);                            \
     356    fclose(f);                                                     \
     357}
     358
     359fwrite_type_vector(int8_t);
     360fwrite_type_vector(uint8_t);
     361fwrite_type_vector(int16_t);
     362fwrite_type_vector(uint16_t);
     363fwrite_type_vector(int32_t);
     364fwrite_type_vector(uint32_t);
     365fwrite_type_vector(int64_t);
     366fwrite_type_vector(uint64_t);
     367fwrite_type_vector(float);
     368fwrite_type_vector(double);
     369fwrite_type_vector(rgb8);
     370fwrite_type_vector(rgbx8);
     371
     372
     373
     374// Local Variables:
     375// tab-width: 4
     376// c-basic-offset: 4
     377// c-file-offsets:((innamespace . 0)(inline-open . 0))
     378// indent-tabs-mode: nil
     379// End:
     380
     381// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     382
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1x.c

    r772 r822  
    2121#include "nrio1x.h"
    2222
    23 /* ---------------------------------------------------------------------------------------------------------- */
    24 IMAGE_EXPORT(void) display_bvector_circular(byte *v,long nl,long nh, long c0, long c1, char *format, char *name)
    25 /* ---------------------------------------------------------------------------------------------------------- */
    26 {
    27   long i, n=nh-nl+1;
    28 
    29   if(name != NULL) puts(name);
    30 
    31   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    32 }
    33 /* ----------------------------------------------------------------------------------------------------------- */
    34 IMAGE_EXPORT(void) display_si16vector_circular(sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    35 /* ----------------------------------------------------------------------------------------------------------- */
    36 {
    37   long i, n=nh-nl+1;
    38 
    39   if(name != NULL) puts(name);
    40 
    41   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    42 }
    43 /* --------------------------------------------------------------------------------------------------------- */
    44 IMAGE_EXPORT(void) display_ui32vector_circular(uint32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    45 /* --------------------------------------------------------------------------------------------------------- */
    46 {
    47   long i, n=nh-nl+1;
    48 
    49   if(name != NULL) puts(name);
    50 
    51   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    52 }
    53 /* ---------------------------------------------------------------------------------------------------------- */
    54 IMAGE_EXPORT(void) display_f32vector_circular(float32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    55 /* ---------------------------------------------------------------------------------------------------------- */
    56 {
    57   long i, n=nh-nl+1;
    58 
    59   if(name != NULL) puts(name);
    60 
    61   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    62 }
    63 /* ------------------------------------------------------------------------------------------------------------ */
    64 IMAGE_EXPORT(void) display_f64vector_circular(float64 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    65 /* ------------------------------------------------------------------------------------------------------------ */
    66 {
    67   long i, n=nh-nl+1;
    68 
    69   if(name != NULL) puts(name);
    70 
    71   for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    72 }
    73 /* ----------------------------------------------------------------------------------------------------------------- */
    74 IMAGE_EXPORT(void) display_bvector_circular_number(byte *v,long nl,long nh, long c0, long c1, char *format, char *name)
    75 /* ----------------------------------------------------------------------------------------------------------------- */
    76 {
    77   long i, n=nh-nl+1;
    78 
    79   if(name != NULL) puts(name);
    80 
    81   putchar('#');
    82   for(i=c0; i<=c1; i++) {
    83     printf(format,   i%n+nl);
    84   }
    85   putchar('\n');
    86   putchar(' ');
    87   for(i=c0; i<=c1; i++) {
    88     printf(format, v[i%n+nl]);
    89   }
    90   putchar('\n');
    91 }
    92 /* ------------------------------------------------------------------------------------------------------------------ */
    93 IMAGE_EXPORT(void) display_si16vector_circular_number(sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    94 /* ------------------------------------------------------------------------------------------------------------------ */
    95 {
    96   long i, n=nh-nl+1;
    97 
    98   if(name != NULL) puts(name);
    99 
    100   putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
    101   putchar(' ');  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    102 }
    103 /* ---------------------------------------------------------------------------------------------------------------- */
    104 IMAGE_EXPORT(void) display_ui32vector_circular_number(uint32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    105 /* ---------------------------------------------------------------------------------------------------------------- */
    106 {
    107   long i, n=nh-nl+1;
    108 
    109   if(name != NULL) puts(name);
    110 
    111   putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
    112   putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    113 }
    114 /* ----------------------------------------------------------------------------------------------------------------- */
    115 IMAGE_EXPORT(void) display_f32vector_circular_number(float32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    116 /* ----------------------------------------------------------------------------------------------------------------- */
    117 {
    118   long i, n=nh-nl+1;
    119 
    120   if(name != NULL) puts(name);
    121 
    122   putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
    123   putchar(' ');  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
    124 }
    125 /* ------------------------------------------------------------------------------------------------------------------- */
    126 IMAGE_EXPORT(void) display_dvector_circular_number(float64 *v,long nl,long nh, long c0, long c1, char *format, char *name)
    127 /* ------------------------------------------------------------------------------------------------------------------- */
    128 {
    129   long i, n=nh-nl+1;
    130 
    131   if(name != NULL) puts(name);
    132 
    133   putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
    134   putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
     23#undef display_type_vector_circular
     24#define display_type_vector_circular(t) \
     25void short_name(t,display_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name) \
     26{                                        \
     27    int32_t n = nh - nl + 1;             \
     28    if (name != NULL) {                  \
     29        printf("%s\n", name);            \
     30    }                                    \
     31    for (int32_t i = c0; i <= c1; i++) { \
     32        printf(format, v[i % n + nl]);   \
     33    }                                    \
     34    printf("\n");                        \
    13535}
    13636
    137 /* ------------------------------------------------------------------------------------- */
    138 IMAGE_EXPORT(void) display_bvector_cycle(byte *v,long nl,long nh, char *format, char *name)
    139 /* ------------------------------------------------------------------------------------- */
    140 {
    141   long i;
    142   uint8 first, next;
    143   uint8 *displayed;
    14437
    145   if(name != NULL) printf("%s", name);
     38display_type_vector_circular(int8_t);
     39display_type_vector_circular(uint8_t);
     40display_type_vector_circular(int16_t);
     41display_type_vector_circular(uint16_t);
     42display_type_vector_circular(int32_t);
     43display_type_vector_circular(uint32_t);
     44display_type_vector_circular(int64_t);
     45display_type_vector_circular(uint64_t);
     46display_type_vector_circular(float);
     47display_type_vector_circular(double);
    14648
    147   displayed = ui8vector0(nl, nh);
    148  
    149   for(i=nl; i<=nh; i++) {
    150     if(!displayed[i]) {
    151       displayed[i] = 1;
    152       printf(format, i);
    153       first = (byte) i;
    154       next = v[i];
    155       while(first != next) {
    156         displayed[next] = 1;
    157         printf(format, next);
    158         next = v[next];
    159       }
    160       putchar('\n');
    161     }
    162   }
    163   putchar('\n');
    164   free_ui8vector(displayed, nl, nh);
     49
     50
     51#undef display_type_vector_circular_number
     52#define display_type_vector_circular_number(t) \
     53void short_name(t,display_,vector_circular_number)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * name) \
     54{                                        \
     55    int32_t n = nh - nl + 1;             \
     56    if (name != NULL) {                  \
     57        printf("%s", name);              \
     58    }                                    \
     59    printf("#");                         \
     60    for (int32_t i = c0; i <= c1; i++) { \
     61        printf(format, i % n + nl);      \
     62    }                                    \
     63    printf("\n ");                       \
     64    for (int32_t i = c0; i <= c1; i++) { \
     65        printf(format, v[i % n + nl]);   \
     66    }                                    \
     67    printf("\n");                        \
    16568}
    166 /* -------------------------------------------------------------------------------------- */
    167 IMAGE_EXPORT(void) display_si16vector_cycle(sint16 *v,long nl,long nh, char *format, char *name)
    168 /* -------------------------------------------------------------------------------------- */
    169 {
    170   long i;
    171   uint16 first, next;
    172   uint8 *displayed;
    17369
    174   if(name != NULL) printf("%s", name);
    17570
    176   displayed = ui8vector0(nl, nh);
    177  
    178   for(i=nl; i<=nh; i++) {
    179     if(!displayed[i]) {
    180       displayed[i] = 1;
    181       printf(format, i);
    182       first = (sint16) i;
    183       next = v[i];
    184       while(first != next) {
    185         displayed[next] = 1;
    186         printf(format, next);
    187         next = v[next];
    188       }
    189       putchar('\n');
    190     }
    191   }
    192   putchar('\n');
    193   free_ui8vector(displayed, nl, nh);
     71display_type_vector_circular_number(int8_t);
     72display_type_vector_circular_number(uint8_t);
     73display_type_vector_circular_number(int16_t);
     74display_type_vector_circular_number(uint16_t);
     75display_type_vector_circular_number(int32_t);
     76display_type_vector_circular_number(uint32_t);
     77display_type_vector_circular_number(int64_t);
     78display_type_vector_circular_number(uint64_t);
     79display_type_vector_circular_number(float);
     80display_type_vector_circular_number(double);
     81
     82
     83
     84#undef display_type_vector_cycle
     85#define display_type_vector_cycle(t) \
     86void short_name(t,display_,vector_cycle)(t * v, int32_t nl, int32_t nh, char * format, char * name) \
     87{                                        \
     88    uint8_t first;                       \
     89    uint8_t next;                        \
     90    uint8_t * displayed;                 \
     91                                         \
     92    if (name != NULL) {                  \
     93        printf("%s", name);              \
     94    }                                    \
     95    displayed = ui8vector0(nl, nh);      \
     96    for (int32_t i = nl; i <= nh; i++) { \
     97        if (!displayed[i]) {             \
     98            displayed[i] = 1;            \
     99            printf(format, i);           \
     100            first = (t) i;               \
     101            next = v[i];                 \
     102            while (first != next) {      \
     103                displayed[next] = 1;     \
     104                printf(format, next);    \
     105                next = v[next];          \
     106            }                            \
     107            printf("\n");                \
     108        }                                \
     109    }                                    \
     110    printf("\n");                        \
     111    free_ui8vector(displayed, nl, nh);   \
    194112}
    195 /* ---------------------------------------------------------------------------------------- */
    196 IMAGE_EXPORT(void) display_ui16vector_cycle(uint16 *v,long nl,long nh, char *format, char *name)
    197 /* ---------------------------------------------------------------------------------------- */
    198 {
    199   long i;
    200   uint16 first, next;
    201   uint8 *displayed;
    202113
    203   if(name != NULL) printf("%s", name);
    204114
    205   displayed = ui8vector0(nl, nh);
    206  
    207   for(i=nl; i<=nh; i++) {
    208     if(!displayed[i]) {
    209       displayed[i] = 1;
    210       printf(format, i);
    211       first = (uint16) i;
    212       next = v[i];
    213       while(first != next) {
    214         displayed[next] = 1;
    215         printf(format, next);
    216         next = v[next];
    217       }
    218       putchar('\n');
    219     }
    220   }
    221   putchar('\n');
    222   free_ui8vector(displayed, nl, nh);
    223 }
     115display_type_vector_cycle(int8_t);
     116display_type_vector_cycle(uint8_t);
     117display_type_vector_cycle(int16_t);
     118display_type_vector_cycle(uint16_t);
     119display_type_vector_cycle(int32_t);
     120display_type_vector_cycle(uint32_t);
     121display_type_vector_cycle(int64_t);
     122display_type_vector_cycle(uint64_t);
     123display_type_vector_cycle(float);
     124display_type_vector_cycle(double);
     125
     126
     127// Local Variables:
     128// tab-width: 4
     129// c-basic-offset: 4
     130// c-file-offsets:((innamespace . 0)(inline-open . 0))
     131// indent-tabs-mode: nil
     132// End:
     133
     134// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     135
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1xf.c

    r772 r822  
    1111#include <stdio.h>
    1212
     13#include "nrc_os_config.h"
    1314#include "mypredef.h"
    1415#include "nrtype.h"
     
    1819
    1920#include "nralloc1.h"
    20 #include "nrio1xf.h"
     21#include "nrio1x.h"
    2122
    2223
     
    2425/* -- write_vector_circular -- */
    2526/* --------------------------- */
    26 /* ------------------------------------------------------------------------------------------------------------ */
    27 IMAGE_EXPORT(void) write_bvector_circular(byte *v,long nl,long nh, long c0, long c1, char *format, char *filename)
    28 /* ------------------------------------------------------------------------------------------------------------ */
    29 {
    30   long i, n=nh-nl+1;
    31   FILE *f;
    3227
    33   f = fopen(filename, "wt");
    34   if(f == NULL) { nrerror("Can't open file in write_bvector_circular"); }
     28#undef write_type_vector_circular
     29#define write_type_vector_circular(t) \
     30void short_name(t,write_,vector_circular)(t * v, int32_t nl, int32_t nh, int32_t c0, int32_t c1, char * format, char * filename) \
     31{                                                                  \
     32    int32_t n = nh - nl + 1;                                       \
     33    FILE * f = fopen(filename, "wt");                              \
     34    if (f == NULL) {                                               \
     35        nrerror("Can't open file %s in %s\n", filename, __func__); \
     36    }                                                              \
     37    for (int32_t i = c0; i <= c1; i++) {                           \
     38        fprintf(f, format, v[i % n + nl]);                         \
     39    }                                                              \
     40    fprintf(f, "\n");                                              \
     41    fclose(f);                                                     \
     42}
    3543
    36   for(i=c0; i<=c1; i++) { fprintf(f, format, v[i%n+nl]);} fputc('\n', f);
    37   fclose(f);
    38 }
     44write_type_vector_circular(int8_t);
     45write_type_vector_circular(uint8_t);
     46write_type_vector_circular(int16_t);
     47write_type_vector_circular(uint16_t);
     48write_type_vector_circular(int32_t);
     49write_type_vector_circular(uint32_t);
     50write_type_vector_circular(int64_t);
     51write_type_vector_circular(uint64_t);
     52write_type_vector_circular(float);
     53write_type_vector_circular(double);
     54
     55
     56
     57// Local Variables:
     58// tab-width: 4
     59// c-basic-offset: 4
     60// c-file-offsets:((innamespace . 0)(inline-open . 0))
     61// indent-tabs-mode: nil
     62// End:
     63
     64// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     65
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2.c

    r821 r822  
    4949 */
    5050
     51
     52#undef display_type_matrix
     53#define display_type_matrix(t) \
     54void short_name(t,display_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \
     55{                                              \
     56    if (name != NULL) {                        \
     57        printf("%s\n", name);                  \
     58    }                                          \
     59                                               \
     60    for (int32_t i = nrl; i <= nrh; i++) {     \
     61        for (int32_t j = ncl; j <= nch; j++) { \
     62            printf(format, m[i][j]);           \
     63        }                                      \
     64        printf("\n");                          \
     65    }                                          \
     66}
     67
     68display_type_matrix(int8_t);
     69display_type_matrix(uint8_t);
     70display_type_matrix(int16_t);
     71display_type_matrix(uint16_t);
     72display_type_matrix(int32_t);
     73display_type_matrix(uint32_t);
     74display_type_matrix(int64_t);
     75display_type_matrix(uint64_t);
     76display_type_matrix(float);
     77display_type_matrix(double);
     78
     79
    5180/* -------------------------------------------------------------------------------------------------------- */
    52 IMAGE_EXPORT(void) display_ui8matrix(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
     81void display_rgb8matrix(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
    5382/* -------------------------------------------------------------------------------------------------------- */
    5483{
    55     long i,j;
    56    
    57     if(name != NULL) printf(name);
    58    
    59     for(i=nrl; i<=nrh; i++) {
    60         for(j=ncl; j<=nch; j++) {
    61             printf(format, m[i][j]);
     84    if (name != NULL) {
     85        printf(name);
     86    }
     87   
     88    for (int32_t i = nrl; i <= nrh; i++) {
     89        for (int32_t j = ncl; j <= nch; j++) {
     90            printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
    6291        }
    6392        printf("\n");
    6493    }
    6594}
    66 /* -------------------------------------------------------------------------------------------------------- */
    67 IMAGE_EXPORT(void) display_si8matrix(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    68 /* -------------------------------------------------------------------------------------------------------- */
    69 {
    70     long i,j;
    71    
    72     if(name != NULL) printf(name);
    73    
    74     for(i=nrl; i<=nrh; i++) {
    75         for(j=ncl; j<=nch; j++) {
    76             printf(format, m[i][j]);
     95
     96/* ---------------------------------------------------------------------------------------------------------- */
     97void display_rgbx8matrix(rgbx8 ** m,int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
     98/* ---------------------------------------------------------------------------------------------------------- */
     99{
     100    if (name != NULL) {
     101        printf(name);
     102    }
     103   
     104    for (int32_t i = nrl; i <= nrh; i++) {
     105        for (int32_t j = ncl; j <= nch; j++) {
     106            printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
    77107        }
    78108        printf("\n");
    79109    }
    80110}
    81 /* ---------------------------------------------------------------------------------------------------------- */
    82 IMAGE_EXPORT(void) display_si16matrix(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    83 /* ---------------------------------------------------------------------------------------------------------- */
    84 {
    85     long i,j;
    86    
    87     if(name != NULL) printf(name);
    88    
    89     for(i=nrl; i<=nrh; i++) {
    90         for(j=ncl; j<=nch; j++) {
    91             printf(format, m[i][j]);
    92         }
    93         printf("\n");
    94     }
    95 }
    96 /* ---------------------------------------------------------------------------------------------------------- */
    97 IMAGE_EXPORT(void) display_ui16matrix(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    98 /* ---------------------------------------------------------------------------------------------------------- */
    99 {
    100     long i,j;
    101    
    102     if(name != NULL) printf(name);
    103    
    104     for(i=nrl; i<=nrh; i++) {
    105         for(j=ncl; j<=nch; j++) {
    106             printf(format, m[i][j]);
    107         }
    108         printf("\n");
    109     }
    110 }
    111 /* ---------------------------------------------------------------------------------------------------------- */
    112 IMAGE_EXPORT(void) display_si32matrix(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    113 /* ---------------------------------------------------------------------------------------------------------- */
    114 {
    115     long i,j;
    116    
    117     if(name != NULL) printf(name);
    118    
    119     for(i=nrl; i<=nrh; i++) {
    120         for(j=ncl; j<=nch; j++) {
    121             printf(format, m[i][j]);
    122         }
    123         printf("\n");
    124     }
    125 }
    126 /* ---------------------------------------------------------------------------------------------------------- */
    127 IMAGE_EXPORT(void) display_ui32matrix(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    128 /* ---------------------------------------------------------------------------------------------------------- */
    129 {
    130     long i,j;
    131    
    132     if(name != NULL) printf(name);
    133    
    134     for(i=nrl; i<=nrh; i++) {
    135         for(j=ncl; j<=nch; j++) {
    136             printf(format, m[i][j]);
    137         }
    138         printf("\n");
    139     }
    140 }
    141 /* ---------------------------------------------------------------------------------------------------------- */
    142 IMAGE_EXPORT(void) display_si64matrix(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    143 /* ---------------------------------------------------------------------------------------------------------- */
    144 {
    145     long i,j;
    146    
    147     if(name != NULL) printf(name);
    148    
    149     for(i=nrl; i<=nrh; i++) {
    150         for(j=ncl; j<=nch; j++) {
    151             printf(format, m[i][j]);
    152         }
    153         printf("\n");
    154     }
    155 }
    156 /* --------------------------------------------------------------------------------------------------------- */
    157 IMAGE_EXPORT(void) display_i64matrix(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    158 /* --------------------------------------------------------------------------------------------------------- */
    159 {
    160     long i,j;
    161    
    162     if(name != NULL) printf(name);
    163    
    164     for(i=nrl; i<=nrh; i++) {
    165         for(j=ncl; j<=nch; j++) {
    166             printf(format, m[i][j]);
    167         }
    168         printf("\n");
    169     }
    170 }
    171 /* ---------------------------------------------------------------------------------------------------------- */
    172 IMAGE_EXPORT(void) display_f32matrix(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    173 /* ---------------------------------------------------------------------------------------------------------- */
    174 {
    175     long i,j;
    176    
    177     if(name != NULL) printf(name);
    178    
    179     for(i=nrl; i<=nrh; i++) {
    180         for(j=ncl; j<=nch; j++) {
    181             printf(format, m[i][j]);
    182         }
    183         printf("\n");
    184     }
    185 }
    186 /* ---------------------------------------------------------------------------------------------------------- */
    187 IMAGE_EXPORT(void) display_f64matrix(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    188 /* ---------------------------------------------------------------------------------------------------------- */
    189 {
    190     long i,j;
    191    
    192     if(name != NULL) printf(name);
    193    
    194     for(i=nrl; i<=nrh; i++) {
    195         for(j=ncl; j<=nch; j++) {
    196             printf(format, m[i][j]);
    197         }
    198         printf("\n");
    199     }
    200 }
    201 /* -------------------------------------------------------------------------------------------------------- */
    202 IMAGE_EXPORT(void) display_rgb8matrix(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    203 /* -------------------------------------------------------------------------------------------------------- */
    204 {
    205     long i,j;
    206    
    207     if(name != NULL) printf(name);
    208    
    209     for(i=nrl; i<=nrh; i++) {
    210         for(j=ncl; j<=nch; j++) {
    211             printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
    212         }
    213         printf("\n");
    214     }
    215 }
    216 /* ---------------------------------------------------------------------------------------------------------- */
    217 IMAGE_EXPORT(void) display_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    218 /* ---------------------------------------------------------------------------------------------------------- */
    219 {
    220     long i,j;
    221    
    222     if(name != NULL) printf(name);
    223    
    224     for(i=nrl; i<=nrh; i++) {
    225         for(j=ncl; j<=nch; j++) {
    226             printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
    227         }
    228         printf("\n");
    229     }
    230 }
    231 /*
    232  * ----------------------
    233  * --- display_matrix ---
    234  * ----------------------
    235  */
    236 
    237 /* ---------------------------------------------------------------------------------------------------------- */
    238 IMAGE_EXPORT(void) display_si8matrix_T(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    239 /* ---------------------------------------------------------------------------------------------------------- */
    240 {
    241     long i,j;
    242    
    243     if(name != NULL) printf(name);
    244    
    245     for(j=ncl; j<=nch; j++) {
    246         for(i=nrl; i<=nrh; i++) {           
    247             printf(format, m[i][j]);
    248         }
    249         printf("\n");
    250     }
    251 }
    252 /* ---------------------------------------------------------------------------------------------------------- */
    253 IMAGE_EXPORT(void) display_ui8matrix_T(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    254 /* ---------------------------------------------------------------------------------------------------------- */
    255 {
    256     long i,j;
    257    
    258     if(name != NULL) printf(name);
    259    
    260     for(j=ncl; j<=nch; j++) {
    261         for(i=nrl; i<=nrh; i++) {           
    262             printf(format, m[i][j]);
    263         }
    264         printf("\n");
    265     }
    266 }
    267 /* ------------------------------------------------------------------------------------------------------------ */
    268 IMAGE_EXPORT(void) display_si16matrix_T(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    269 /* ------------------------------------------------------------------------------------------------------------ */
    270 {
    271     long i,j;
    272    
    273     if(name != NULL) printf(name);
    274    
    275     for(j=ncl; j<=nch; j++) {
    276         for(i=nrl; i<=nrh; i++) {           
    277             printf(format, m[i][j]);
    278         }
    279         printf("\n");
    280     }
    281 }
    282 /* ------------------------------------------------------------------------------------------------------------ */
    283 IMAGE_EXPORT(void) display_ui16matrix_T(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    284 /* ------------------------------------------------------------------------------------------------------------ */
    285 {
    286     long i,j;
    287    
    288     if(name != NULL) printf(name);
    289    
    290     for(j=ncl; j<=nch; j++) {
    291         for(i=nrl; i<=nrh; i++) {           
    292             printf(format, m[i][j]);
    293         }
    294         printf("\n");
    295     }
    296 }
    297 /* ------------------------------------------------------------------------------------------------------------ */
    298 IMAGE_EXPORT(void) display_si32matrix_T(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    299 /* ------------------------------------------------------------------------------------------------------------ */
    300 {
    301     long i,j;
    302    
    303     if(name != NULL) printf(name);
    304    
    305     for(j=ncl; j<=nch; j++) {
    306         for(i=nrl; i<=nrh; i++) {           
    307             printf(format, m[i][j]);
    308         }
    309         printf("\n");
    310     }
    311 }
    312 /* ---------------------------------------------------------------------------------------------------------- */
    313 IMAGE_EXPORT(void) display_ui32matrix_T(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    314 /* ---------------------------------------------------------------------------------------------------------- */
    315 {
    316     long i,j;
    317    
    318     if(name != NULL) printf(name);
    319    
    320     for(j=ncl; j<=nch; j++) {
    321         for(i=nrl; i<=nrh; i++) {           
    322             printf(format, m[i][j]);
    323         }
    324         printf("\n");
    325     }
    326 }
    327 /* ------------------------------------------------------------------------------------------------------------ */
    328 IMAGE_EXPORT(void) display_si64matrix_T(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    329 /* ------------------------------------------------------------------------------------------------------------ */
    330 {
    331     long i,j;
    332    
    333     if(name != NULL) printf(name);
    334    
    335     for(j=ncl; j<=nch; j++) {
    336         for(i=nrl; i<=nrh; i++) {           
    337             printf(format, m[i][j]);
    338         }
    339         printf("\n");
    340     }
    341 }
    342 /* ------------------------------------------------------------------------------------------------------------ */
    343 IMAGE_EXPORT(void) display_ui64matrix_T(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    344 /* ------------------------------------------------------------------------------------------------------------ */
    345 {
    346     long i,j;
    347    
    348     if(name != NULL) printf(name);
    349    
    350     for(j=ncl; j<=nch; j++) {
    351         for(i=nrl; i<=nrh; i++) {           
    352             printf(format, m[i][j]);
    353         }
    354         printf("\n");
    355     }
    356 }
    357 /* ------------------------------------------------------------------------------------------------------------ */
    358 IMAGE_EXPORT(void) display_f32matrix_T(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    359 /* ------------------------------------------------------------------------------------------------------------ */
    360 {
    361     long i,j;
    362    
    363     if(name != NULL) printf(name);
    364    
    365     for(j=ncl; j<=nch; j++) {
    366         for(i=nrl; i<=nrh; i++) {           
    367             printf(format, m[i][j]);
    368         }
    369         printf("\n");
    370     }
    371 }
    372 /* ------------------------------------------------------------------------------------------------------------ */
    373 IMAGE_EXPORT(void) display_f64matrix_T(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    374 /* ------------------------------------------------------------------------------------------------------------ */
    375 {
    376     long i,j;
    377    
    378     if(name != NULL) printf(name);
    379    
    380     for(j=ncl; j<=nch; j++) {
    381         for(i=nrl; i<=nrh; i++) {           
    382             printf(format, m[i][j]);
    383         }
    384         printf("\n");
    385     }
    386 }
    387 /* ---------------------------------------------------------------------------------------------------------- */
    388 IMAGE_EXPORT(void) display_rgb8matrix_T(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    389 /* ---------------------------------------------------------------------------------------------------------- */
    390 {
    391     long i,j;
    392    
    393     if(name != NULL) printf(name);
    394    
    395     for(j=ncl; j<=nch; j++) {
    396         for(i=nrl; i<=nrh; i++) {           
    397             printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
    398         }
    399         printf("\n");
    400     }
    401 }
    402 /* ------------------------------------------------------------------------------------------------------------ */
    403 IMAGE_EXPORT(void) display_rgbx8matrix_T(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    404 /* ------------------------------------------------------------------------------------------------------------ */
    405 {
    406     long i,j;
    407    
    408     if(name != NULL) printf(name);
    409    
    410     for(j=ncl; j<=nch; j++) {
    411         for(i=nrl; i<=nrh; i++) {           
    412             printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
    413         }
    414         printf("\n");
    415     }
    416 }
     111
    417112
    418113/*
     
    422117 */
    423118
     119#undef display_type_matrix_T
     120#define display_type_matrix_T(t) \
     121void short_name(t,display_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \
     122{                                              \
     123    if (name != NULL) {                        \
     124        printf("%s\n", name);                  \
     125    }                                          \
     126                                               \
     127    for (int32_t j = ncl; j <= nch; j++) {     \
     128        for (int32_t i = nrl; i <= nrh; i++) { \
     129            printf(format, m[i][j]);           \
     130        }                                      \
     131        printf("\n");                          \
     132    }                                          \
     133}
     134
     135display_type_matrix_T(int8_t);
     136display_type_matrix_T(uint8_t);
     137display_type_matrix_T(int16_t);
     138display_type_matrix_T(uint16_t);
     139display_type_matrix_T(int32_t);
     140display_type_matrix_T(uint32_t);
     141display_type_matrix_T(int64_t);
     142display_type_matrix_T(uint64_t);
     143display_type_matrix_T(float);
     144display_type_matrix_T(double);
     145
     146
     147/* -------------------------------------------------------------------------------------------------------- */
     148void display_rgb8matrix_T(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
     149/* -------------------------------------------------------------------------------------------------------- */
     150{
     151    if (name != NULL) {
     152        printf(name);
     153    }
     154   
     155    for (int32_t j = ncl; j <= nch; j++) {
     156        for (int32_t i = nrl; i <= nrh; i++) {
     157            printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
     158        }
     159        printf("\n");
     160    }
     161}
     162
     163/* ---------------------------------------------------------------------------------------------------------- */
     164void display_rgbx8matrix_T(rgbx8 ** m,int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
     165/* ---------------------------------------------------------------------------------------------------------- */
     166{
     167    if (name != NULL) {
     168        printf(name);
     169    }
     170   
     171    for (int32_t j = ncl; j <= nch; j++) {
     172        for (int32_t i = nrl; i <= nrh; i++) {
     173            printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
     174        }
     175        printf("\n");
     176    }
     177}
     178
     179
     180
     181/*
     182 * -----------------------------
     183 * --- display_matrix_number ---
     184 * -----------------------------
     185 */
     186
     187#undef display_type_matrix_number
     188#define display_type_matrix_number(t) \
     189void short_name(t,display_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \
     190{                                              \
     191    if (name != NULL) {                        \
     192        printf("%s\n", name);                  \
     193    }                                          \
     194    printf("%5c", '#');                        \
     195    for (int32_t j = ncl; j <= nch; j++) {     \
     196        printf(format, j);                     \
     197    }                                          \
     198    printf("\n");                              \
     199    for (int32_t i = nrl; i <= nrh; i++) {     \
     200        printf("[%3d]", i);                    \
     201        for (int32_t j = ncl; j <= nch; j++) { \
     202            printf(format, m[i][j]);           \
     203        }                                      \
     204        printf("\n");                          \
     205    }                                          \
     206    printf("\n");                              \
     207}
     208
     209display_type_matrix_number(int8_t);
     210display_type_matrix_number(uint8_t);
     211display_type_matrix_number(int16_t);
     212display_type_matrix_number(uint16_t);
     213display_type_matrix_number(int32_t);
     214display_type_matrix_number(uint32_t);
     215display_type_matrix_number(int64_t);
     216display_type_matrix_number(uint64_t);
     217display_type_matrix_number(float);
     218display_type_matrix_number(double);
     219
     220
    424221/* --------------------------------------------------------------------------------------------------------------- */
    425 IMAGE_EXPORT(void) display_si8matrix_number(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
     222void display_rgb8matrix_number(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name)
    426223/* --------------------------------------------------------------------------------------------------------------- */
    427224{
    428     int i,j;
    429    
    430     if(name != NULL) printf(name);
    431    
     225    if (name != NULL) {
     226        printf(name);
     227    }
    432228    // 1ere ligne
    433229    printf("%5c", '#');
    434     for(j=ncl; j<=nch; j++) {
     230    for (int32_t j = ncl; j <= nch; j++) {
    435231        printf(format, j);
    436232    }
    437233    printf("\n");
    438     for(i=nrl; i<=nrh; i++) {
     234    for (int32_t i = nrl; i <= nrh; i++) {
    439235        printf("[%3d]", i);
    440         for(j=ncl; j<=nch; j++) {
    441             printf(format, m[i][j]);
     236        for (int32_t j = ncl; j <= nch; j++) {
     237            printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
    442238        }
    443239        printf("\n");
     
    445241    printf("\n");
    446242}
    447 /* --------------------------------------------------------------------------------------------------------------- */
    448 IMAGE_EXPORT(void) display_ui8matrix_number(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    449 /* --------------------------------------------------------------------------------------------------------------- */
    450 {
    451     int i,j;
    452    
    453     if(name != NULL) printf(name);
    454    
     243
     244/* ----------------------------------------------------------------------------------------------------------------- */
     245void display_rgbx8matrix_number(rgbx8 **m,int32_t nrl,int32_t nrh,int32_t ncl, int32_t nch, char *format, char *name)
     246/* ----------------------------------------------------------------------------------------------------------------- */
     247{
     248    if (name != NULL) {
     249        printf(name);
     250    }
    455251    // 1ere ligne
    456252    printf("%5c", '#');
    457     for(j=ncl; j<=nch; j++) {
     253    for (int32_t j = ncl; j <= nch; j++) {
    458254        printf(format, j);
    459255    }
    460256    printf("\n");
    461     for(i=nrl; i<=nrh; i++) {
     257    for (int32_t i = nrl; i <= nrh; i++) {
    462258        printf("[%3d]", i);
    463         for(j=ncl; j<=nch; j++) {
    464             printf(format, m[i][j]);
     259        for (int32_t j = ncl; j <= nch; j++) {
     260            printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
    465261        }
    466262        printf("\n");
     
    468264    printf("\n");
    469265}
    470 /* ----------------------------------------------------------------------------------------------------------------- */
    471 IMAGE_EXPORT(void) display_si16matrix_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    472 /* ----------------------------------------------------------------------------------------------------------------- */
    473 {
    474     int i,j;
    475    
    476     if(name != NULL) printf(name);
    477    
    478     // 1ere ligne
    479     printf("%5c", '#');
    480     for(j=ncl; j<=nch; j++) {
    481         printf(format, j);
    482     }
    483     printf("\n");
    484     for(i=nrl; i<=nrh; i++) {
    485         printf("[%3d]", i);
    486         for(j=ncl; j<=nch; j++) {
    487             printf(format, m[i][j]);
    488         }
    489         printf("\n");
    490     }
    491     printf("\n");
    492 }
    493 /* ----------------------------------------------------------------------------------------------------------------- */
    494 IMAGE_EXPORT(void) display_ui16matrix_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    495 /* ----------------------------------------------------------------------------------------------------------------- */
    496 {
    497     int i,j;
    498    
    499     if(name != NULL) printf(name);
    500    
    501     // 1ere ligne
    502     printf("%5c", '#');
    503     for(j=ncl; j<=nch; j++) {
    504         printf(format, j);
    505     }
    506     printf("\n");
    507     for(i=nrl; i<=nrh; i++) {
    508         printf("[%3d]", i);
    509         for(j=ncl; j<=nch; j++) {
    510             printf(format, m[i][j]);
    511         }
    512         printf("\n");
    513     }
    514     printf("\n");
    515 }
    516 /* ----------------------------------------------------------------------------------------------------------------- */
    517 IMAGE_EXPORT(void) display_si32matrix_number(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    518 /* ----------------------------------------------------------------------------------------------------------------- */
    519 {
    520     int i,j;
    521    
    522     if(name != NULL) printf(name);
    523    
    524     // 1ere ligne
    525     printf("%5c", '#');
    526     for(j=ncl; j<=nch; j++) {
    527         printf(format, j);
    528     }
    529     printf("\n");
    530     for(i=nrl; i<=nrh; i++) {
    531         printf("[%3d]", i);
    532         for(j=ncl; j<=nch; j++) {
    533             printf(format, m[i][j]);
    534         }
    535         printf("\n");
    536     }
    537     printf("\n");
    538 }
    539 /* ----------------------------------------------------------------------------------------------------------------- */
    540 IMAGE_EXPORT(void) display_ui32matrix_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    541 /* ----------------------------------------------------------------------------------------------------------------- */
    542 {
    543     int i,j;
    544    
    545     if(name != NULL) printf(name);
    546    
    547     // 1ere ligne
    548     printf("%5c", '#');
    549     for(j=ncl; j<=nch; j++) {
    550         printf(format, j);
    551     }
    552     printf("\n");
    553     for(i=nrl; i<=nrh; i++) {
    554         printf("[%3d]", i);
    555         for(j=ncl; j<=nch; j++) {
    556             printf(format, m[i][j]);
    557         }
    558         printf("\n");
    559     }
    560     printf("\n");
    561 }
    562 /* ----------------------------------------------------------------------------------------------------------------- */
    563 IMAGE_EXPORT(void) display_si64matrix_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    564 /* ----------------------------------------------------------------------------------------------------------------- */
    565 {
    566     int i,j;
    567    
    568     if(name != NULL) printf(name);
    569    
    570     // 1ere ligne
    571     printf("%5c", '#');
    572     for(j=ncl; j<=nch; j++) {
    573         printf(format, j);
    574     }
    575     printf("\n");
    576     for(i=nrl; i<=nrh; i++) {
    577         printf("[%3d]", i);
    578         for(j=ncl; j<=nch; j++) {
    579             printf(format, m[i][j]);
    580         }
    581         printf("\n");
    582     }
    583     printf("\n");
    584 }
    585 /* ----------------------------------------------------------------------------------------------------------------- */
    586 IMAGE_EXPORT(void) display_ui64matrix_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    587 /* ----------------------------------------------------------------------------------------------------------------- */
    588 {
    589     int i,j;
    590    
    591     if(name != NULL) printf(name);
    592    
    593     // 1ere ligne
    594     printf("%5c", '#');
    595     for(j=ncl; j<=nch; j++) {
    596         printf(format, j);
    597     }
    598     printf("\n");
    599     for(i=nrl; i<=nrh; i++) {
    600         printf("[%3d]", i);
    601         for(j=ncl; j<=nch; j++) {
    602             printf(format, m[i][j]);
    603         }
    604         printf("\n");
    605     }
    606     printf("\n");
    607 }
    608 /* ----------------------------------------------------------------------------------------------------------------- */
    609 IMAGE_EXPORT(void) display_f32matrix_number(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    610 /* ----------------------------------------------------------------------------------------------------------------- */
    611 {
    612     int i,j;
    613    
    614     if(name != NULL) printf(name);
    615    
    616     // 1ere ligne
    617     printf("%5c", '#');
    618     for(j=ncl; j<=nch; j++) {
    619         printf(format, j);
    620     }
    621     printf("\n");
    622     for(i=nrl; i<=nrh; i++) {
    623         printf("[%3d]", i);
    624         for(j=ncl; j<=nch; j++) {
    625             printf(format, m[i][j]);
    626         }
    627         printf("\n");
    628     }
    629     printf("\n");
    630 }
    631 /* ----------------------------------------------------------------------------------------------------------------- */
    632 IMAGE_EXPORT(void) display_f64matrix_number(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    633 /* ----------------------------------------------------------------------------------------------------------------- */
    634 {
    635     int i,j;
    636    
    637     if(name != NULL) printf(name);
    638    
    639     // 1ere ligne
    640     printf("%5c", '#');
    641     for(j=ncl; j<=nch; j++) {
    642         printf(format, j);
    643     }
    644     printf("\n");
    645     for(i=nrl; i<=nrh; i++) {
    646         printf("[%3d]", i);
    647         for(j=ncl; j<=nch; j++) {
    648             printf(format, m[i][j]);
    649         }
    650         printf("\n");
    651     }
    652     printf("\n");
    653 }
    654 /* --------------------------------------------------------------------------------------------------------------- */
    655 IMAGE_EXPORT(void) display_rgb8matrix_number(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    656 /* --------------------------------------------------------------------------------------------------------------- */
    657 {
    658     int i,j;
    659    
    660     if(name != NULL) printf(name);
    661    
    662     // 1ere ligne
    663     printf("%5c", '#');
    664     for(j=ncl; j<=nch; j++) {
    665         printf(format, j);
    666     }
    667     printf("\n");
    668     for(i=nrl; i<=nrh; i++) {
    669         printf("[%3d]", i);
    670         for(j=ncl; j<=nch; j++) {
    671             printf(format, m[i][j].r, m[i][j].g, m[i][j].b);
    672         }
    673         printf("\n");
    674     }
    675     printf("\n");
    676 }
    677 /* ----------------------------------------------------------------------------------------------------------------- */
    678 IMAGE_EXPORT(void) display_rgbx8matrix_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *name)
    679 /* ----------------------------------------------------------------------------------------------------------------- */
    680 {
    681     int i,j;
    682    
    683     if(name != NULL) printf(name);
    684    
    685     // 1ere ligne
    686     printf("%5c", '#');
    687     for(j=ncl; j<=nch; j++) {
    688         printf(format, j);
    689     }
    690     printf("\n");
    691     for(i=nrl; i<=nrh; i++) {
    692         printf("[%3d]", i);
    693         for(j=ncl; j<=nch; j++) {
    694             printf(format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
    695         }
    696         printf("\n");
    697     }
    698     printf("\n");
    699 }
     266
     267
    700268
    701269/*
     
    705273 */
    706274
    707 // ------------------------------------------------------------------------------------------------
    708 void display_si8matrix_positive(sint8 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
    709 // ------------------------------------------------------------------------------------------------
    710 {
    711     int i, j;
    712    
    713     char *format, *str;
    714    
    715     select_display_positive_parameters(iformat, &format, &str);
    716    
    717     if(name != NULL) printf(name);
    718    
    719     for(i=i0; i<=i1; i++) {
    720         for(j=j0; j<=j1; j++) {
    721             if(m[i][j]) {
    722                 printf(format, m[i][j]);
    723             } else {
    724                 printf("%s", str);
    725             }
    726         }
    727         printf("\n");
    728     }   
    729 }
    730 // ------------------------------------------------------------------------------------------------
    731 void display_ui8matrix_positive(uint8 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
    732 // ------------------------------------------------------------------------------------------------
    733 {
    734     int i, j;
    735    
    736     char * format;
    737     char * str;
    738    
    739     select_display_positive_parameters(iformat, &format, &str);
    740    
    741     if (name != NULL) {
    742         printf("%s\n", name);
    743     }
    744    
    745     // @QM have to hack this function for the giet
    746     for (i = i0; i <= i1; i++) {
    747         for (j = j0; j <= j1; j++) {
    748             if (m[i][j]) {
    749                 // For the giet
    750                 int a = m[i][j];
    751                 int len = 0;
    752                 if (a == 0) {
    753                     len = 1;
    754                 }
    755                 else {
    756                     while (a != 0) {
    757                         a = a / 10;
    758                         len++;
    759                     }
    760                 }
    761                 for (int k = len; k < iformat; k++) {
    762                     printf(" ");
    763                 }
    764                 printf("%d", m[i][j]);
    765             }
    766             else {
    767                 printf("%s", str);
    768             }
    769         }
    770         printf("\n");
    771     }   
    772 }
    773 
    774 
    775 // --------------------------------------------------------------------------------------------------
    776 void display_si16matrix_positive(sint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
    777 // --------------------------------------------------------------------------------------------------
    778 {
    779     int i, j;
    780    
    781     char *format, *str;
    782    
    783     select_display_positive_parameters(iformat, &format, &str);
    784    
    785     if(name != NULL) printf(name);
    786    
    787     for(i=i0; i<=i1; i++) {
    788         for(j=j0; j<=j1; j++) {
    789             if(m[i][j]) {
    790                 printf(format, m[i][j]);
    791             } else {
    792                 printf("%s", str);
    793             }
    794         }
    795         printf("\n");
    796     }   
    797 }
    798 // --------------------------------------------------------------------------------------------------
    799 void display_ui16matrix_positive(uint16 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
    800 // --------------------------------------------------------------------------------------------------
    801 {
    802     int i, j;
    803     char *format, *str;
    804    
    805     select_display_positive_parameters(iformat, &format, &str);
    806    
    807     if(name != NULL) printf(name);
    808    
    809     for(i=i0; i<=i1; i++) {
    810         for(j=j0; j<=j1; j++) {
    811             if(m[i][j]) {
    812                 printf(format, m[i][j]);
    813             } else {
    814                 printf("%s", str);
    815             }
    816         }
    817         printf("\n");
    818     }   
    819 }
    820 // --------------------------------------------------------------------------------------------------
    821 void display_si32matrix_positive(sint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
    822 // --------------------------------------------------------------------------------------------------
    823 {
    824     int i, j;
    825     char *format, *str;
    826    
    827     select_display_positive_parameters(iformat, &format, &str);
    828    
    829     if(name != NULL) printf(name);
    830    
    831     for(i=i0; i<=i1; i++) {
    832         for(j=j0; j<=j1; j++) {
    833             if(m[i][j]) {
    834                 printf(format, m[i][j]);
    835             } else {
    836                 printf("%s", str);
    837             }
    838         }
    839         printf("\n");
    840     }   
    841 }
    842 // --------------------------------------------------------------------------------------------------
    843 void display_ui32matrix_positive(uint32 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
    844 // --------------------------------------------------------------------------------------------------
    845 {
    846     int i, j;
    847     char * format;
    848     char * str;
    849    
    850     select_display_positive_parameters(iformat, &format, &str);
    851    
    852     if (name != NULL) {
    853         printf("%s\n", name);
    854     }
    855    
    856     // @QM have to hack this function for the giet
    857     for (i = i0; i <= i1; i++) {
    858         for (j = j0; j <= j1; j++) {
    859             if (m[i][j] != 0) {
    860                 int a = m[i][j];
    861                 int len = 0;
    862                 if (a == 0) {
    863                     len = 1;
    864                 }
    865                 else {
    866                     while (a != 0) {
    867                         a = a / 10;
    868                         len++;
    869                     }
    870                 }
    871                 for (int k = len; k < iformat; k++) {
    872                     printf(" ");
    873                 }
    874                 printf("%d", m[i][j]);
    875             }
    876             else {
    877                 printf("%s", str);
    878             }
    879         }
    880         printf("\n");
    881     }   
    882 
    883 }
    884 // --------------------------------------------------------------------------------------------------
    885 void display_si64matrix_positive(sint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
    886 // --------------------------------------------------------------------------------------------------
    887 {
    888     int i, j;
    889     char *format, *str;
    890    
    891     select_display_positive_parameters(iformat, &format, &str);
    892    
    893     if(name != NULL) printf(name);
    894    
    895     for(i=i0; i<=i1; i++) {
    896         for(j=j0; j<=j1; j++) {
    897             if(m[i][j]) {
    898                 printf(format, m[i][j]);
    899             } else {
    900                 printf("%s", str);
    901             }
    902         }
    903         printf("\n");
    904     }   
    905 }
    906 // --------------------------------------------------------------------------------------------------
    907 void display_ui64matrix_positive(uint64 **m, int i0, int i1, int j0, int j1, int iformat, char *name)
    908 // --------------------------------------------------------------------------------------------------
    909 {
    910     int i, j;
    911     char *format, *str;
    912    
    913     select_display_positive_parameters(iformat, &format, &str);
    914    
    915     if(name != NULL) printf(name);
    916    
    917     for(i=i0; i<=i1; i++) {
    918         for(j=j0; j<=j1; j++) {
    919             if(m[i][j]) {
    920                 printf(format, m[i][j]);
    921             } else {
    922                 printf("%s", str);
    923             }
    924         }
    925         printf("\n");
    926     }   
    927 }
    928 
     275#if TARGET_OS != GIETVM
     276
     277#undef display_type_matrix_positive
     278#define display_type_matrix_positive(t) \
     279void 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) \
     280{                                                               \
     281    char * format;                                              \
     282    char * str;                                                 \
     283    select_display_positive_parameters(iformat, &format, &str); \
     284    if (name != NULL) {                                         \
     285        printf("%s\n", name);                                   \
     286    }                                                           \
     287    for (int32_t i = i0; i <= i1; i++) {                        \
     288        for (int32_t j = j0; j <= j1; j++) {                    \
     289            if (m[i][j] != 0) {                                 \
     290                printf(format, m[i][j]);                        \
     291            }                                                   \
     292            else {                                              \
     293                printf("%s", str);                              \
     294            }                                                   \
     295        }                                                       \
     296        printf("\n");                                           \
     297    }                                                           \
     298    printf("\n");                                               \
     299}
     300
     301#else
     302
     303#undef display_type_matrix_positive
     304#define display_type_matrix_positive(t) \
     305void 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) \
     306{                                                               \
     307    char * format;                                              \
     308    char * str;                                                 \
     309    select_display_positive_parameters(iformat, &format, &str); \
     310    if (name != NULL) {                                         \
     311        printf("%s\n", name);                                   \
     312    }                                                           \
     313    for (int32_t i = i0; i <= i1; i++) {                        \
     314        for (int32_t j = j0; j <= j1; j++) {                    \
     315            if (m[i][j] != 0) {                                 \
     316                int32_t a = m[i][j];                            \
     317                int32_t len = 0;                                \
     318                if (a == 0) {                                   \
     319                    len = 1;                                    \
     320                }                                               \
     321                else {                                          \
     322                    while (a != 0) {                            \
     323                        a = a / 10;                             \
     324                        len++;                                  \
     325                    }                                           \
     326                }                                               \
     327                for (int32_t k = len; k < iformat; k++) {       \
     328                    printf(" ");                                \
     329                }                                               \
     330                printf(format, m[i][j]);                        \
     331            }                                                   \
     332            else {                                              \
     333                printf("%s", str);                              \
     334            }                                                   \
     335        }                                                       \
     336        printf("\n");                                           \
     337    }                                                           \
     338    printf("\n");                                               \
     339}
     340
     341#endif
     342
     343
     344display_type_matrix_positive(int8_t);
     345display_type_matrix_positive(uint8_t);
     346display_type_matrix_positive(int16_t);
     347display_type_matrix_positive(uint16_t);
     348display_type_matrix_positive(int32_t);
     349display_type_matrix_positive(uint32_t);
     350display_type_matrix_positive(int64_t);
     351display_type_matrix_positive(uint64_t);
     352display_type_matrix_positive(float);
     353display_type_matrix_positive(double);
    929354
    930355
     
    974399
    975400/* ------------------------------------------------- */
    976 static void ReadPGMrow(int fd, int width, uint8 * line)
     401static void ReadPGMrow(int32_t fd, int32_t width, uint8 * line)
    977402/* ------------------------------------------------- */
    978403{
    979     read(fd, &line[0], sizeof(uint8) * width);
     404    read(fd, &line[0], sizeof(uint8_t) * width);
    980405}
    981406
    982407
    983408/* -------------------------------------------------- */
    984 static void WritePGMrow(uint8 * line, int width, int fd)
     409static void WritePGMrow(uint8_t * line, int32_t width, int32_t fd)
    985410/* -------------------------------------------------- */
    986411{
    987     write(fd, &line[0], sizeof(uint8) * width);
     412    write(fd, &line[0], sizeof(uint8_t) * width);
    988413}
    989414
    990415
    991416/* ----------------------------------------------------------------------------------------------- */
    992 IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch)
     417uint8_t ** LoadPGM_ui8matrix(char * filename, int * nrl, int * nrh, int * ncl, int * nch)
    993418/* ----------------------------------------------------------------------------------------------- */
    994419{
    995420    // only for P5 binary type, not for text type
    996421   
    997     int height, width, gris;
    998     uint8 ** m;
    999     int fd;
     422    int32_t height, width, gris;
     423    uint8_t ** m;
     424    int32_t fd;
    1000425   
    1001426    char buffer[80];
    1002     int i;
    1003427    (void) gris;
    1004428   
     
    1026450    m = ui8matrix(*nrl, *nrh, *ncl, *nch);
    1027451   
    1028     for (i = 0; i < height; i++) {
     452    for (int32_t i = 0; i < height; i++) {
    1029453        ReadPGMrow(fd, width, m[i]);
    1030454    }
     
    1037461
    1038462/* ----------------------------------------------------------------------------------------------- */
    1039 IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename)
     463void SavePGM_ui8matrix(uint8 ** m, int nrl, int nrh, int ncl, int nch, char * filename)
    1040464/* ----------------------------------------------------------------------------------------------- */
    1041465{
    1042     int nrow = nrh - nrl + 1;
    1043     int ncol = nch - ncl + 1;
     466    int32_t nrow = nrh - nrl + 1;
     467    int32_t ncol = nch - ncl + 1;
    1044468   
    1045469    char buffer[80];
    1046470   
    1047     int fd;
    1048     int i;
     471    int32_t fd;
    1049472   
    1050473    //fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT);
     
    1058481    snprintf(buffer, 80, "P5\n%d %d\n255\n", ncol, nrow);
    1059482    write(fd, buffer, strlen(buffer));
    1060     for (i = nrl; i <= nrh; i++) {
     483    for (int32_t i = nrl; i <= nrh; i++) {
    1061484        WritePGMrow(m[i], ncol, fd);
    1062485    }
     
    1068491
    1069492
     493// Local Variables:
     494// tab-width: 4
     495// c-basic-offset: 4
     496// c-file-offsets:((innamespace . 0)(inline-open . 0))
     497// indent-tabs-mode: nil
     498// End:
     499
     500// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     501
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2f.c

    r772 r822  
    1515#include <stddef.h>
    1616#include <stdlib.h>
    17 
     17#include <string.h>
     18#include <ctype.h>
     19
     20#include "nrc_os_config.h"
    1821#include "mypredef.h"
    1922#include "nrtype.h"
     
    3437 */
    3538
    36 /* ---------------------------------------------------------------------------------------------------------- */
    37 IMAGE_EXPORT(void) write_si8matrix(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    38 /* ---------------------------------------------------------------------------------------------------------- */
    39 {
    40     int  i,j;
    41    
    42     FILE *f;
    43    
    44     f = fopen(filename, "wt");
    45     if(f == NULL) {
    46         nrerror("Can't open file in write_si8matrix");
    47     }
    48    
    49     for(i=nrl; i<=nrh; i++) {
    50         for(j=ncl; j<=nch; j++) {
    51             fprintf(f, format, m[i][j]);
    52         }
    53         fputc('\n', f);
    54     }
    55     fclose(f);
    56 }
    57 /* ---------------------------------------------------------------------------------------------------------- */
    58 IMAGE_EXPORT(void) write_ui8matrix(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    59 /* ---------------------------------------------------------------------------------------------------------- */
    60 {
    61     int  i,j;
    62    
    63     FILE *f;
    64    
    65     f = fopen(filename, "wt");
    66     if(f == NULL) {
    67         nrerror("Can't open file in write_ui8matrix");
    68     }
    69    
    70     for(i=nrl; i<=nrh; i++) {
    71         for(j=ncl; j<=nch; j++) {
    72             fprintf(f, format, m[i][j]);
    73         }
    74         fputc('\n', f);
    75     }
    76     fclose(f);
    77 }
    78 /* ------------------------------------------------------------------------------------------------------------ */
    79 IMAGE_EXPORT(void) write_si16matrix(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    80 /* ------------------------------------------------------------------------------------------------------------ */
    81 {
    82     int  i,j;
    83    
    84     FILE *f;
    85    
    86     f = fopen(filename, "wt");
    87     if(f == NULL) {
    88         nrerror("Can't open file in write_si16matrix");
    89     }
    90    
    91     for(i=nrl; i<=nrh; i++) {
    92         for(j=ncl; j<=nch; j++) {
    93             fprintf(f, format, m[i][j]);
    94         }
    95         fputc('\n', f);
    96     }
    97     fclose(f);
    98 }
    99 /* ------------------------------------------------------------------------------------------------------------ */
    100 IMAGE_EXPORT(void) write_ui16matrix(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    101 /* ------------------------------------------------------------------------------------------------------------ */
    102 {
    103     int i,j;
    104    
    105     FILE *f;
    106    
    107     f = fopen(filename, "wt");
    108     if(f == NULL) {
    109         nrerror("Can't open file in write_ui16matrix");
    110     }
    111    
    112     for(i=nrl; i<=nrh; i++) {
    113         for(j=ncl; j<=nch; j++) {
    114             fprintf(f, format, m[i][j]);
    115         }
    116         fputc('\n', f);
    117     }
    118     fclose(f);
    119 }
    120 /* ------------------------------------------------------------------------------------------------------------ */
    121 IMAGE_EXPORT(void) write_si32matrix(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    122 /* ------------------------------------------------------------------------------------------------------------ */
    123 {
    124     int i,j;
    125    
    126     FILE *f;
    127    
    128     f = fopen(filename, "wt");
    129     if(f == NULL) {
    130         nrerror("Can't open file in write_si32matrix");
    131     }
    132    
    133     for(i=nrl; i<=nrh; i++) {
    134         for(j=ncl; j<=nch; j++) {
    135             fprintf(f, format, m[i][j]);
    136         }
    137         fputc('\n', f);
    138     }
    139     fclose(f);
    140 }
    141 /* ------------------------------------------------------------------------------------------------------------ */
    142 IMAGE_EXPORT(void) write_ui32matrix(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    143 /* ------------------------------------------------------------------------------------------------------------ */
    144 {
    145     int i,j;
    146    
    147     FILE *f;
    148    
    149     f = fopen(filename, "wt");
    150     if(f == NULL) {
    151         nrerror("Can't open file in write_ui32matrix");
    152     }
    153    
    154     for(i=nrl; i<=nrh; i++) {
    155         for(j=ncl; j<=nch; j++) {
    156             fprintf(f, format, m[i][j]);
    157         }
    158         fputc('\n', f);
    159     }
    160     fclose(f);
    161 }
    162 /* ------------------------------------------------------------------------------------------------------------ */
    163 IMAGE_EXPORT(void) write_si64matrix(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    164 /* ------------------------------------------------------------------------------------------------------------ */
    165 {
    166     int i,j;
    167    
    168     FILE *f;
    169    
    170     f = fopen(filename, "wt");
    171     if(f == NULL) {
    172         nrerror("Can't open file in write_si64matrix");
    173     }
    174    
    175     for(i=nrl; i<=nrh; i++) {
    176         for(j=ncl; j<=nch; j++) {
    177             fprintf(f, format, m[i][j]);
    178         }
    179         fputc('\n', f);
    180     }
    181     fclose(f);
    182 }
    183 /* ------------------------------------------------------------------------------------------------------------ */
    184 IMAGE_EXPORT(void) write_ui64matrix(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    185 /* ------------------------------------------------------------------------------------------------------------ */
    186 {
    187     int i,j;
    188    
    189     FILE *f;
    190    
    191     f = fopen(filename, "wt");
    192     if(f == NULL) {
    193         nrerror("Can't open file in write_ui64matrix");
    194     }
    195    
    196     for(i=nrl; i<=nrh; i++) {
    197         for(j=ncl; j<=nch; j++) {
    198             fprintf(f, format, m[i][j]);
    199         }
    200         fputc('\n', f);
    201     }
    202     fclose(f);
    203 }
    204 /* ------------------------------------------------------------------------------------------------------------ */
    205 IMAGE_EXPORT(void) write_f32matrix(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    206 /* ------------------------------------------------------------------------------------------------------------ */
    207 {
    208     int i,j;
    209    
    210     FILE *f;
    211    
    212     f = fopen(filename, "wt");
    213     if(f == NULL) {
    214         nrerror("Can't open file in write_f32matrix");
    215     }
    216    
    217     for(i=nrl; i<=nrh; i++) {
    218         for(j=ncl; j<=nch; j++) {
    219             fprintf(f, format, m[i][j]);
    220         }
    221         fputc('\n', f);
    222     }
    223     fclose(f);
    224 }
    225 /* ------------------------------------------------------------------------------------------------------------ */
    226 IMAGE_EXPORT(void) write_f64matrix(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    227 /* ------------------------------------------------------------------------------------------------------------ */
    228 {
    229     int i,j;
    230    
    231     FILE *f;
    232    
    233     f = fopen(filename, "wt");
    234     if(f == NULL) {
    235         nrerror("Can't open file in write_f64matrix");
    236     }
    237    
    238     for(i=nrl; i<=nrh; i++) {
    239         for(j=ncl; j<=nch; j++) {
    240             fprintf(f, format, m[i][j]);
    241         }
    242         fputc('\n', f);
    243     }
    244     fclose(f);
    245 }
    246 /* ---------------------------------------------------------------------------------------------------------- */
    247 IMAGE_EXPORT(void) write_rgb8matrix(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    248 /* ---------------------------------------------------------------------------------------------------------- */
    249 {
    250     int i,j;
    251    
    252     FILE *f;
    253    
    254     f = fopen(filename, "wt");
    255     if(f == NULL) {
    256         nrerror("Can't open file in write_rgb8matrix");
    257     }
    258    
    259     for(i=nrl; i<=nrh; i++) {
    260         for(j=ncl; j<=nch; j++) {
    261             fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b);
    262         }
    263         fputc('\n', f);
    264     }
    265     fclose(f);
    266 }
    267 /* ------------------------------------------------------------------------------------------------------------ */
    268 IMAGE_EXPORT(void) write_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    269 /* ------------------------------------------------------------------------------------------------------------ */
    270 {
    271     int i,j;
    272    
    273     FILE *f;
    274    
    275     f = fopen(filename, "wt");
    276     if(f == NULL) {
    277         nrerror("Can't open file in write_rgbx8matrix");
    278     }
    279    
    280     for(i=nrl; i<=nrh; i++) {
    281         for(j=ncl; j<=nch; j++) {
    282             fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
    283         }
    284         fputc('\n', f);
    285     }
    286     fclose(f);
    287 }
     39#undef write_type_matrix
     40#define write_type_matrix(t) \
     41void short_name(t,write_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \
     42{                                                                \
     43    FILE * f = fopen(filename, "wt");                            \
     44    if (f == NULL) {                                             \
     45        nrerror("Can't open file %s in %s", filename, __func__); \
     46    }                                                            \
     47    for (int32_t i = nrl; i <= nrh; i++) {                       \
     48        for (int32_t j = ncl; j <= nch; j++) {                   \
     49            fprintf(f, format, elem);                            \
     50        }                                                        \
     51        fprintf(f, "\n");                                        \
     52    }                                                            \
     53    fclose(f);                                                   \
     54}
     55
     56#undef elem
     57#define elem m[i][j]
     58write_type_matrix(int8_t);
     59write_type_matrix(uint8_t);
     60write_type_matrix(int16_t);
     61write_type_matrix(uint16_t);
     62write_type_matrix(int32_t);
     63write_type_matrix(uint32_t);
     64write_type_matrix(int64_t);
     65write_type_matrix(uint64_t);
     66write_type_matrix(float);
     67write_type_matrix(double);
     68#undef elem
     69#define elem m[i][j].r, m[i][j].g, m[i][j].b
     70write_type_matrix(rgb8);
     71#undef elem
     72#define elem m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x
     73write_type_matrix(rgbx8);
     74
    28875
    28976/*
     
    29380 */
    29481
    295 /* ------------------------------------------------------------------------------------------------------------ */
    296 IMAGE_EXPORT(void) write_si8matrix_T(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    297 /* ------------------------------------------------------------------------------------------------------------ */
    298 {
    299     long  i,j;
    300    
    301     FILE *f;
    302    
    303     f = fopen(filename, "wt");
    304     if(f == NULL) {
    305         nrerror("Can't open file in write_si8matrix_T");
    306     }
    307    
    308     for(j=ncl; j<=nch; j++) {
    309         for(i=nrl; i<=nrh; i++) {
    310             fprintf(f, format, m[i][j]);
    311         }
    312         fputc('\n', f);
    313     }
    314     fclose(f);
    315 }
    316 /* ------------------------------------------------------------------------------------------------------------ */
    317 IMAGE_EXPORT(void) write_ui8matrix_T(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    318 /* ------------------------------------------------------------------------------------------------------------ */
    319 {
    320     long  i,j;
    321    
    322     FILE *f;
    323    
    324     f = fopen(filename, "wt");
    325     if(f == NULL) {
    326         nrerror("Can't open file in write_ui8matrix_T");
    327     }
    328    
    329     for(j=ncl; j<=nch; j++) {
    330         for(i=nrl; i<=nrh; i++) {
    331             fprintf(f, format, m[i][j]);
    332         }
    333         fputc('\n', f);
    334     }
    335     fclose(f);
    336 }
    337 /* -------------------------------------------------------------------------------------------------------------- */
    338 IMAGE_EXPORT(void) write_si32matrix_T(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    339 /* -------------------------------------------------------------------------------------------------------------- */
    340 {
    341     long  i,j;
    342    
    343     FILE *f;
    344    
    345     f = fopen(filename, "wt");
    346     if(f == NULL) {
    347         nrerror("Can't open file in write_si32matrix_T");
    348     }
    349    
    350     for(j=ncl; j<=nch; j++) {
    351         for(i=nrl; i<=nrh; i++) {
    352             fprintf(f, format, m[i][j]);
    353         }
    354         fputc('\n', f);
    355     }
    356     fclose(f);
    357 }
    358 /* -------------------------------------------------------------------------------------------------------------- */
    359 IMAGE_EXPORT(void) write_ui32matrix_T(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    360 /* -------------------------------------------------------------------------------------------------------------- */
    361 {
    362     long  i,j;
    363    
    364     FILE *f;
    365    
    366     f = fopen(filename, "wt");
    367     if(f == NULL) {
    368         nrerror("Can't open file in write_ui32matrix_T");
    369     }
    370    
    371     for(j=ncl; j<=nch; j++) {
    372         for(i=nrl; i<=nrh; i++) {
    373             fprintf(f, format, m[i][j]);
    374         }
    375         fputc('\n', f);
    376     }
    377     fclose(f);
    378 }
    379 /* -------------------------------------------------------------------------------------------------------------- */
    380 IMAGE_EXPORT(void) write_si64matrix_T(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    381 /* -------------------------------------------------------------------------------------------------------------- */
    382 {
    383     long  i,j;
    384    
    385     FILE *f;
    386    
    387     f = fopen(filename, "wt");
    388     if(f == NULL) {
    389         nrerror("Can't open file in write_si64matrix_T");
    390     }
    391    
    392     for(j=ncl; j<=nch; j++) {
    393         for(i=nrl; i<=nrh; i++) {
    394             fprintf(f, format, m[i][j]);
    395         }
    396         fputc('\n', f);
    397     }
    398     fclose(f);
    399 }
    400 /* -------------------------------------------------------------------------------------------------------------- */
    401 IMAGE_EXPORT(void) write_ui64matrix_T(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    402 /* -------------------------------------------------------------------------------------------------------------- */
    403 {
    404     long  i,j;
    405    
    406     FILE *f;
    407    
    408     f = fopen(filename, "wt");
    409     if(f == NULL) {
    410         nrerror("Can't open file in write_ui64matrix_T");
    411     }
    412    
    413     for(j=ncl; j<=nch; j++) {
    414         for(i=nrl; i<=nrh; i++) {
    415             fprintf(f, format, m[i][j]);
    416         }
    417         fputc('\n', f);
    418     }
    419     fclose(f);
    420 }
    421 /* -------------------------------------------------------------------------------------------------------------- */
    422 IMAGE_EXPORT(void) write_f32matrix_T(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    423 /* -------------------------------------------------------------------------------------------------------------- */
    424 {
    425     long  i,j;
    426    
    427     FILE *f;
    428    
    429     f = fopen(filename, "wt");
    430     if(f == NULL) {
    431         nrerror("Can't open file in write_f32matrix");
    432     }
    433    
    434     for(j=ncl; j<=nch; j++) {
    435         for(i=nrl; i<=nrh; i++) {
    436             fprintf(f, format, m[i][j]);
    437         }
    438         fputc('\n', f);
    439     }
    440     fclose(f);
    441 }
    442 /* -------------------------------------------------------------------------------------------------------------- */
    443 IMAGE_EXPORT(void) write_f64matrix_T(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    444 /* -------------------------------------------------------------------------------------------------------------- */
    445 {
    446     long  i,j;
    447    
    448     FILE *f;
    449    
    450     f = fopen(filename, "wt");
    451     if(f == NULL) {
    452         nrerror("Can't open file in write_f64matrix");
    453     }
    454    
    455     for(j=ncl; j<=nch; j++) {
    456         for(i=nrl; i<=nrh; i++) {
    457             fprintf(f, format, m[i][j]);
    458         }
    459         fputc('\n', f);
    460     }
    461     fclose(f);
    462 }
    463 /* ------------------------------------------------------------------------------------------------------------ */
    464 IMAGE_EXPORT(void) write_rgb8matrix_T(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    465 /* ------------------------------------------------------------------------------------------------------------ */
    466 {
    467     long  i,j;
    468    
    469     FILE *f;
    470    
    471     f = fopen(filename, "wt");
    472     if(f == NULL) {
    473         nrerror("Can't open file in write_rgb8matrix");
    474     }
    475    
    476     for(j=ncl; j<=nch; j++) {
    477         for(i=nrl; i<=nrh; i++) {
    478             fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b);
    479         }
    480         fputc('\n', f);
    481     }
    482     fclose(f);
    483 }
    484 /* -------------------------------------------------------------------------------------------------------------- */
    485 IMAGE_EXPORT(void) write_rgbx8matrix_T(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    486 /* -------------------------------------------------------------------------------------------------------------- */
    487 {
    488     long  i,j;
    489    
    490     FILE *f;
    491    
    492     f = fopen(filename, "wt");
    493     if(f == NULL) {
    494         nrerror("Can't open file in write_rgb8matrix");
    495     }
    496    
    497     for(j=ncl; j<=nch; j++) {
    498         for(i=nrl; i<=nrh; i++) {
    499             fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
    500         }
    501         fputc('\n', f);
    502     }
    503     fclose(f);
    504 }
     82
     83#undef write_type_matrix_T
     84#define write_type_matrix_T(t) \
     85void short_name(t,write_,matrix_T)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \
     86{                                                                \
     87    FILE * f = fopen(filename, "wt");                            \
     88    if (f == NULL) {                                             \
     89        nrerror("Can't open file %s in %s", filename, __func__); \
     90    }                                                            \
     91    for (int32_t j = ncl; j <= nch; j++) {                       \
     92        for (int32_t i = nrl; i <= nrh; i++) {                   \
     93            fprintf(f, format, elem);                            \
     94        }                                                        \
     95        fprintf(f, "\n");                                        \
     96    }                                                            \
     97    fclose(f);                                                   \
     98}
     99
     100#undef elem
     101#define elem m[i][j]
     102write_type_matrix_T(int8_t);
     103write_type_matrix_T(uint8_t);
     104write_type_matrix_T(int16_t);
     105write_type_matrix_T(uint16_t);
     106write_type_matrix_T(int32_t);
     107write_type_matrix_T(uint32_t);
     108write_type_matrix_T(int64_t);
     109write_type_matrix_T(uint64_t);
     110write_type_matrix_T(float);
     111write_type_matrix_T(double);
     112#undef elem
     113#define elem m[i][j].r, m[i][j].g, m[i][j].b
     114write_type_matrix_T(rgb8);
     115#undef elem
     116#define elem m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x
     117write_type_matrix_T(rgbx8);
     118
     119
    505120
    506121/*
     
    510125 */
    511126
    512 /* ----------------------------------------------------------------------------------------------------------------- */
    513 IMAGE_EXPORT(void) write_si8matrix_number(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    514 /* ----------------------------------------------------------------------------------------------------------------- */
    515 {
    516     int i,j;
    517    
    518     FILE *f;
    519    
    520     f = fopen(filename, "wt");
    521     if(f == NULL) {
    522         nrerror("Can't open file in write_si8matrix_number");
    523     }
    524    
    525     // entete
    526     fprintf(f, "%5c", '#');
    527     for(j=ncl; j<=nch; j++) {
    528         fprintf(f, format, j);
    529     }
    530     fputc('\n', f);
    531    
    532     for(i=nrl; i<=nrh; i++) {
    533         fprintf(f, "[%3d]", i);
    534         for(j=ncl; j<=nch; j++) {
    535             fprintf(f, format, m[i][j]);
    536         }
    537         fputc('\n', f);
    538     }
    539     fclose(f);
    540 }
    541 /* ----------------------------------------------------------------------------------------------------------------- */
    542 IMAGE_EXPORT(void) write_ui8matrix_number(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    543 /* ----------------------------------------------------------------------------------------------------------------- */
    544 {
    545     int i,j;
    546    
    547     FILE *f;
    548    
    549     f = fopen(filename, "wt");
    550     if(f == NULL) {
    551         nrerror("Can't open file in write_ui8matrix_number");
    552     }
    553    
    554     // entete
    555     fprintf(f, "%5c", '#');
    556     for(j=ncl; j<=nch; j++) {
    557         fprintf(f, format, j);
    558     }
    559     fputc('\n', f);
    560    
    561     for(i=nrl; i<=nrh; i++) {
    562         fprintf(f, "[%3d]", i);
    563         for(j=ncl; j<=nch; j++) {
    564             fprintf(f, format, m[i][j]);
    565         }
    566         fputc('\n', f);
    567     }
    568     fclose(f);
    569 }
    570 /* ------------------------------------------------------------------------------------------------------------------- */
    571 IMAGE_EXPORT(void) write_si16matrix_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    572 /* ------------------------------------------------------------------------------------------------------------------- */
    573 {
    574     int i,j;
    575    
    576     FILE *f;
    577    
    578     f = fopen(filename, "wt");
    579     if(f == NULL) {
    580         nrerror("Can't open file in write_si16matrix");
    581     }
    582    
    583     // entete
    584     fprintf(f, "%5c", '#');
    585     for(j=ncl; j<=nch; j++) {
    586         fprintf(f, format, j);
    587     }
    588     fputc('\n', f);
    589    
    590     for(i=nrl; i<=nrh; i++) {
    591         fprintf(f, "[%3d]", i);
    592         for(j=ncl; j<=nch; j++) {
    593             fprintf(f, format, m[i][j]);
    594         }
    595         fputc('\n', f);
    596     }
    597     fclose(f);
    598 }
    599 /* ------------------------------------------------------------------------------------------------------------------- */
    600 IMAGE_EXPORT(void) write_ui16matrix_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    601 /* ------------------------------------------------------------------------------------------------------------------- */
    602 {
    603     int i,j;
    604    
    605     FILE *f;
    606    
    607     f = fopen(filename, "wt");
    608     if(f == NULL) {
    609         nrerror("Can't open file in write_ui16matrix");
    610     }
    611    
    612     // entete
    613     fprintf(f, "%5c", '#');
    614     for(j=ncl; j<=nch; j++) {
    615         fprintf(f, format, j);
    616     }
    617     fputc('\n', f);
    618    
    619     for(i=nrl; i<=nrh; i++) {
    620         fprintf(f, "[%3d]", i);
    621         for(j=ncl; j<=nch; j++) {
    622             fprintf(f, format, m[i][j]);
    623         }
    624         fputc('\n', f);
    625     }
    626     fclose(f);
    627 }
    628 /* ------------------------------------------------------------------------------------------------------------------- */
    629 IMAGE_EXPORT(void) write_si32matrix_number(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    630 /* ------------------------------------------------------------------------------------------------------------------- */
    631 {
    632     int i,j;
    633    
    634     FILE *f;
    635    
    636     f = fopen(filename, "wt");
    637     if(f == NULL) {
    638         nrerror("Can't open file in write_si32matrix");
    639     }
    640    
    641     // entete
    642     fprintf(f, "%5c", '#');
    643     for(j=ncl; j<=nch; j++) {
    644         fprintf(f, format, j);
    645     }
    646     fputc('\n', f);
    647    
    648     for(i=nrl; i<=nrh; i++) {
    649         fprintf(f, "[%3d]", i);
    650         for(j=ncl; j<=nch; j++) {
    651             fprintf(f, format, m[i][j]);
    652         }
    653         fputc('\n', f);
    654     }
    655     fclose(f);
    656 }
    657 /* ------------------------------------------------------------------------------------------------------------------- */
    658 IMAGE_EXPORT(void) write_ui32matrix_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    659 /* ------------------------------------------------------------------------------------------------------------------- */
    660 {
    661     int i,j;
    662    
    663     FILE *f;
    664    
    665     f = fopen(filename, "wt");
    666     if(f == NULL) {
    667         nrerror("Can't open file in write_ui32matrix");
    668     }
    669    
    670     // entete
    671     fprintf(f, "%5c", '#');
    672     for(j=ncl; j<=nch; j++) {
    673         fprintf(f, format, j);
    674     }
    675     fputc('\n', f);
    676    
    677     for(i=nrl; i<=nrh; i++) {
    678         fprintf(f, "[%3d]", i);
    679         for(j=ncl; j<=nch; j++) {
    680             fprintf(f, format, m[i][j]);
    681         }
    682         fputc('\n', f);
    683     }
    684     fclose(f);
    685 }
    686 /* ------------------------------------------------------------------------------------------------------------------- */
    687 IMAGE_EXPORT(void) write_si64matrix_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    688 /* ------------------------------------------------------------------------------------------------------------------- */
    689 {
    690     int i,j;
    691    
    692     FILE *f;
    693    
    694     f = fopen(filename, "wt");
    695     if(f == NULL) {
    696         nrerror("Can't open file in write_si64matrix");
    697     }
    698    
    699     // entete
    700     fprintf(f, "%5c", '#');
    701     for(j=ncl; j<=nch; j++) {
    702         fprintf(f, format, j);
    703     }
    704     fputc('\n', f);
    705    
    706     for(i=nrl; i<=nrh; i++) {
    707         fprintf(f, "[%3d]", i);
    708         for(j=ncl; j<=nch; j++) {
    709             fprintf(f, format, m[i][j]);
    710         }
    711         fputc('\n', f);
    712     }
    713     fclose(f);
    714 }
    715 /* ------------------------------------------------------------------------------------------------------------------- */
    716 IMAGE_EXPORT(void) write_ui64matrix_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    717 /* ------------------------------------------------------------------------------------------------------------------- */
    718 {
    719     int i,j;
    720    
    721     FILE *f;
    722    
    723     f = fopen(filename, "wt");
    724     if(f == NULL) {
    725         nrerror("Can't open file in write_ui64matrix");
    726     }
    727    
    728     // entete
    729     fprintf(f, "%5c", '#');
    730     for(j=ncl; j<=nch; j++) {
    731         fprintf(f, format, j);
    732     }
    733     fputc('\n', f);
    734    
    735     for(i=nrl; i<=nrh; i++) {
    736         fprintf(f, "[%3d]", i);
    737         for(j=ncl; j<=nch; j++) {
    738             fprintf(f, format, m[i][j]);
    739         }
    740         fputc('\n', f);
    741     }
    742     fclose(f);
    743 }
    744 /* ------------------------------------------------------------------------------------------------------------------- */
    745 IMAGE_EXPORT(void) write_f32matrix_number(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    746 /* ------------------------------------------------------------------------------------------------------------------- */
    747 {
    748     int i,j;
    749    
    750     FILE *f;
    751    
    752     f = fopen(filename, "wt");
    753     if(f == NULL) {
    754         nrerror("Can't open file in write_f32matrix_number");
    755     }
    756    
    757     // entete
    758     fprintf(f, "%4d", 0);
    759     for(j=ncl; j<=nch; j++) {
    760         fprintf(f, format, (float32)j);
    761     }
    762     fputc('\n', f);
    763    
    764     for(i=nrl; i<=nrh; i++) {
    765         fprintf(f, "%4d", i);
    766         for(j=ncl; j<=nch; j++) {
    767             fprintf(f, format, m[i][j]);
    768         }
    769         fputc('\n', f);
    770     }
    771     fclose(f);
    772 }
    773 /* ------------------------------------------------------------------------------------------------------------------- */
    774 IMAGE_EXPORT(void) write_f64matrix_number(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    775 /* ------------------------------------------------------------------------------------------------------------------- */
    776 {
    777     int i,j;
    778    
    779     FILE *f;
    780    
    781     f = fopen(filename, "wt");
    782     if(f == NULL) {
    783         nrerror("Can't open file in write_f64matrix_number");
    784     }
    785    
    786     // entete
    787     fprintf(f, "%4d", 0);
    788     for(j=ncl; j<=nch; j++) {
    789         fprintf(f, format, (float32)j);
    790     }
    791     fputc('\n', f);
    792    
    793     for(i=nrl; i<=nrh; i++) {
    794         fprintf(f, "%4d", i);
    795         for(j=ncl; j<=nch; j++) {
    796             fprintf(f, format, m[i][j]);
    797         }
    798         fputc('\n', f);
    799     }
    800     fclose(f);
    801 }
    802 /* ----------------------------------------------------------------------------------------------------------------- */
    803 IMAGE_EXPORT(void) write_rgb8matrix_number(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    804 /* ----------------------------------------------------------------------------------------------------------------- */
    805 {
    806     int i,j;
    807    
    808     FILE *f;
    809    
    810     f = fopen(filename, "wt");
    811     if(f == NULL) {
    812         nrerror("Can't open file in write_rgb8matrix_number");
    813     }
    814    
    815     // entete
    816     fprintf(f, "%4d", 0);
    817     for(j=ncl; j<=nch; j++) {
    818         fprintf(f, format, (float32)j);
    819     }
    820     fputc('\n', f);
    821    
    822     for(i=nrl; i<=nrh; i++) {
    823         fprintf(f, "%4d", i);
    824         for(j=ncl; j<=nch; j++) {
    825             fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b);
    826         }
    827         fputc('\n', f);
    828     }
    829     fclose(f);
    830 }
    831 /* ------------------------------------------------------------------------------------------------------------------- */
    832 IMAGE_EXPORT(void) write_rgb8xmatrix_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    833 /* ------------------------------------------------------------------------------------------------------------------- */
    834 {
    835     int i,j;
    836    
    837     FILE *f;
    838    
    839     f = fopen(filename, "wt");
    840     if(f == NULL) {
    841         nrerror("Can't open file in write_rgbx8matrix_number");
    842     }
    843    
    844     // entete
    845     fprintf(f, "%4d", 0);
    846     for(j=ncl; j<=nch; j++) {
    847         fprintf(f, format, (float32)j);
    848     }
    849     fputc('\n', f);
    850    
    851     for(i=nrl; i<=nrh; i++) {
    852         fprintf(f, "%4d", i);
    853         for(j=ncl; j<=nch; j++) {
    854             fprintf(f, format, m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x);
    855         }
    856         fputc('\n', f);
    857     }
    858     fclose(f);
    859 }
     127
     128#undef write_type_matrix_number
     129#define write_type_matrix_number(t) \
     130void short_name(t,write_,matrix_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \
     131{                                                                \
     132    FILE * f = fopen(filename, "wt");                            \
     133    if (f == NULL) {                                             \
     134        nrerror("Can't open file %s in %s", filename, __func__); \
     135    }                                                            \
     136    fprintf(f, "%5c", '#');                                      \
     137    for (int32_t j = ncl; j <= nch; j++) {                       \
     138        fprintf(f, format, j);                                   \
     139    }                                                            \
     140    fprintf(f, "\n");                                            \
     141    for (int32_t i = nrl; i <= nrh; i++) {                       \
     142        fprintf(f, "[%3d]", i);                                  \
     143        for (int32_t j = ncl; j <= nch; j++) {                   \
     144            fprintf(f, format, m[i][j]);                         \
     145        }                                                        \
     146        fprintf(f, "\n");                                        \
     147    }                                                            \
     148    fclose(f);                                                   \
     149}
     150
     151
     152#undef elem
     153#define elem m[i][j]
     154write_type_matrix_number(int8_t);
     155write_type_matrix_number(uint8_t);
     156write_type_matrix_number(int16_t);
     157write_type_matrix_number(uint16_t);
     158write_type_matrix_number(int32_t);
     159write_type_matrix_number(uint32_t);
     160write_type_matrix_number(int64_t);
     161write_type_matrix_number(uint64_t);
     162write_type_matrix_number(float);
     163write_type_matrix_number(double);
     164#undef elem
     165#define elem m[i][j].r, m[i][j].g, m[i][j].b
     166write_type_matrix_number(rgb8);
     167#undef elem
     168#define elem m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x
     169write_type_matrix_number(rgbx8);
     170
     171
    860172/*
    861173 * -----------------------------
     
    863175 * -----------------------------
    864176 */
    865 /* ------------------------------------------------------------------------------------------------------------------- */
    866 IMAGE_EXPORT(void) write_si8matrix_T_number(sint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    867 /* ------------------------------------------------------------------------------------------------------------------- */
    868 {
    869     int i,j;
    870    
    871     FILE *f;
    872    
    873     f = fopen(filename, "wt");
    874     if(f == NULL) {
    875         nrerror("Can't open file in write_si8matrix_T_number");
    876     }
    877    
    878     fprintf(f, "%5c", '#');
    879     for(i=nrl; i<=nrh; i++) {
    880         fprintf(f, format, i);
    881     }
    882     fputc('\n', f);
    883        
    884     for(j=ncl; j<=nch; j++) {
    885         fprintf(f, "[%3d]", j);
    886         for(i=nrl; i<=nrh; i++) {
    887             fprintf(f, format, m[i][j]);
    888         }
    889         fputc('\n', f);
    890     }
    891     fclose(f);
    892 }
    893 /* ------------------------------------------------------------------------------------------------------------------- */
    894 IMAGE_EXPORT(void) write_ui8matrix_T_number(uint8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    895 /* ------------------------------------------------------------------------------------------------------------------- */
    896 {
    897     int i,j;
    898    
    899     FILE *f;
    900    
    901     f = fopen(filename, "wt");
    902     if(f == NULL) {
    903         nrerror("Can't open file in write_ui8matrix_T_number");
    904     }
    905    
    906     fprintf(f, "%5c", '#');
    907     for(i=nrl; i<=nrh; i++) {
    908         fprintf(f, format, i);
    909     }
    910     fputc('\n', f);
    911    
    912    
    913     for(j=ncl; j<=nch; j++) {
    914         fprintf(f, "[%3d]", j);
    915         for(i=nrl; i<=nrh; i++) {
    916             fprintf(f, format, m[i][j]);
    917         }
    918         fputc('\n', f);
    919     }
    920     fclose(f);
    921 }
    922 /* --------------------------------------------------------------------------------------------------------------------- */
    923 IMAGE_EXPORT(void) write_si16matrix_T_number(sint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    924 /* --------------------------------------------------------------------------------------------------------------------- */
    925 {
    926     int i,j;
    927    
    928     FILE *f;
    929    
    930     f = fopen(filename, "wt");
    931     if(f == NULL) {
    932         nrerror("Can't open file in write_si16matrix_T_number");
    933     }
    934    
    935     fprintf(f, "%5c", '#');
    936     for(i=nrl; i<=nrh; i++) {
    937         fprintf(f, format, (float)i);
    938     }
    939     fputc('\n', f);
    940    
    941     for(j=ncl; j<=nch; j++) {
    942         fprintf(f, "[%3d]", j);
    943         for(i=nrl; i<=nrh; i++) {
    944             fprintf(f, format, m[i][j]);
    945         }
    946         fputc('\n', f);
    947     }
    948     fclose(f);
    949 }
    950 /* --------------------------------------------------------------------------------------------------------------------- */
    951 IMAGE_EXPORT(void) write_ui16matrix_T_number(uint16 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    952 /* --------------------------------------------------------------------------------------------------------------------- */
    953 {
    954     int i,j;
    955    
    956     FILE *f;
    957    
    958     f = fopen(filename, "wt");
    959     if(f == NULL) {
    960         nrerror("Can't open file in write_ui16matrix_T_number");
    961     }
    962    
    963     fprintf(f, "%5c", '#');
    964     for(i=nrl; i<=nrh; i++) {
    965         fprintf(f, format, (float)i);
    966     }
    967     fputc('\n', f);
    968    
    969     for(j=ncl; j<=nch; j++) {
    970         fprintf(f, "[%3d]", j);
    971         for(i=nrl; i<=nrh; i++) {
    972             fprintf(f, format, m[i][j]);
    973         }
    974         fputc('\n', f);
    975     }
    976     fclose(f);
    977 }
    978 /* --------------------------------------------------------------------------------------------------------------------- */
    979 IMAGE_EXPORT(void) write_si32matrix_T_number(sint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    980 /* --------------------------------------------------------------------------------------------------------------------- */
    981 {
    982     int i,j;
    983    
    984     FILE *f;
    985    
    986     f = fopen(filename, "wt");
    987     if(f == NULL) {
    988         nrerror("Can't open file in write_si32matrix_T_number");
    989     }
    990    
    991     fprintf(f, "%5c", '#');
    992     for(i=nrl; i<=nrh; i++) {
    993         fprintf(f, format, (float)i);
    994     }
    995     fputc('\n', f);
    996    
    997     for(j=ncl; j<=nch; j++) {
    998         fprintf(f, "[%3d]", j);
    999         for(i=nrl; i<=nrh; i++) {
    1000             fprintf(f, format, m[i][j]);
    1001         }
    1002         fputc('\n', f);
    1003     }
    1004     fclose(f);
    1005 }
    1006 
    1007 /* --------------------------------------------------------------------------------------------------------------------- */
    1008 IMAGE_EXPORT(void) write_ui32matrix_T_number(uint32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    1009 /* --------------------------------------------------------------------------------------------------------------------- */
    1010 {
    1011     int i,j;
    1012    
    1013     FILE *f;
    1014    
    1015     f = fopen(filename, "wt");
    1016     if(f == NULL) {
    1017         nrerror("Can't open file in write_ui32matrix_T_number");
    1018     }
    1019    
    1020     fprintf(f, "%5c", '#');
    1021     for(i=nrl; i<=nrh; i++) {
    1022         fprintf(f, format, (float)i);
    1023     }
    1024     fputc('\n', f);
    1025    
    1026    
    1027     for(j=ncl; j<=nch; j++) {
    1028         fprintf(f, "[%3d]", j);
    1029         for(i=nrl; i<=nrh; i++) {
    1030             fprintf(f, format, m[i][j]);
    1031         }
    1032         fputc('\n', f);
    1033     }
    1034     fclose(f);
    1035 }
    1036 /* --------------------------------------------------------------------------------------------------------------------- */
    1037 IMAGE_EXPORT(void) write_si64matrix_T_number(sint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    1038 /* --------------------------------------------------------------------------------------------------------------------- */
    1039 {
    1040     int i,j;
    1041    
    1042     FILE *f;
    1043    
    1044     f = fopen(filename, "wt");
    1045     if(f == NULL) {
    1046         nrerror("Can't open file in write_si64matrix_T_number");
    1047     }
    1048    
    1049     fprintf(f, "%5c", '#');
    1050     for(i=nrl; i<=nrh; i++) {
    1051         fprintf(f, format, (float)i);
    1052     }
    1053     fputc('\n', f);
    1054    
    1055     for(j=ncl; j<=nch; j++) {
    1056         fprintf(f, "[%3d]", j);
    1057         for(i=nrl; i<=nrh; i++) {
    1058             fprintf(f, format, m[i][j]);
    1059         }
    1060         fputc('\n', f);
    1061     }
    1062     fclose(f);
    1063 }
    1064 /* --------------------------------------------------------------------------------------------------------------------- */
    1065 IMAGE_EXPORT(void) write_ui64matrix_T_number(uint64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    1066 /* --------------------------------------------------------------------------------------------------------------------- */
    1067 {
    1068     int i,j;
    1069    
    1070     FILE *f;
    1071    
    1072     f = fopen(filename, "wt");
    1073     if(f == NULL) {
    1074         nrerror("Can't open file in write_ui64matrix_T_number");
    1075     }
    1076    
    1077     fprintf(f, "%5c", '#');
    1078     for(i=nrl; i<=nrh; i++) {
    1079         fprintf(f, format, (float)i);
    1080     }
    1081     fputc('\n', f);
    1082    
    1083     for(j=ncl; j<=nch; j++) {
    1084         fprintf(f, "[%3d]", j);
    1085         for(i=nrl; i<=nrh; i++) {
    1086             fprintf(f, format, m[i][j]);
    1087         }
    1088         fputc('\n', f);
    1089     }
    1090     fclose(f);
    1091 }
    1092 
    1093 /* --------------------------------------------------------------------------------------------------------------------- */
    1094 IMAGE_EXPORT(void) write_f32matrix_T_number(float32 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    1095 /* --------------------------------------------------------------------------------------------------------------------- */
    1096 {
    1097     int i,j;
    1098    
    1099     FILE *f;
    1100    
    1101     f = fopen(filename, "wt");
    1102     if(f == NULL) {
    1103         nrerror("Can't open file in write_f32matrix_T_number");
    1104     }
    1105    
    1106     fprintf(f, "%5c", '#');
    1107     for(i=nrl; i<=nrh; i++) {
    1108         fprintf(f, format, (float)i);
    1109     }
    1110     fputc('\n', f);
    1111    
    1112     for(j=ncl; j<=nch; j++) {
    1113         fprintf(f, "[%3d]", j);
    1114         for(i=nrl; i<=nrh; i++) {
    1115             fprintf(f, format, m[i][j]);
    1116         }
    1117         fputc('\n', f);
    1118     }
    1119     fclose(f);
    1120 }
    1121 /* --------------------------------------------------------------------------------------------------------------------- */
    1122 IMAGE_EXPORT(void) write_f64matrix_T_number(float64 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    1123 /* --------------------------------------------------------------------------------------------------------------------- */
    1124 {
    1125     int i,j;
    1126    
    1127     FILE *f;
    1128    
    1129     f = fopen(filename, "wt");
    1130     if(f == NULL) {
    1131         nrerror("Can't open file in write_f64matrix_T_number");
    1132     }
    1133    
    1134     fprintf(f, "%5c", '#');
    1135     for(i=nrl; i<=nrh; i++) {
    1136         fprintf(f, format, (float)i);
    1137     }
    1138     fputc('\n', f);
    1139    
    1140     for(j=ncl; j<=nch; j++) {
    1141         fprintf(f, "[%3d]", j);
    1142         for(i=nrl; i<=nrh; i++) {
    1143             fprintf(f, format, m[i][j]);
    1144         }
    1145         fputc('\n', f);
    1146     }
    1147     fclose(f);
    1148 }
    1149 /* ------------------------------------------------------------------------------------------------------------------- */
    1150 IMAGE_EXPORT(void) write_rgb8matrix_T_number(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    1151 /* ------------------------------------------------------------------------------------------------------------------- */
    1152 {
    1153     int i,j;
    1154    
    1155     FILE *f;
    1156    
    1157     f = fopen(filename, "wt");
    1158     if(f == NULL) {
    1159         nrerror("Can't open file in write_rgb8matrix_T_number");
    1160     }
    1161    
    1162     fprintf(f, "%5c", '#');
    1163     for(i=nrl; i<=nrh; i++) {
    1164         fprintf(f, format, (float)i);
    1165     }
    1166     fputc('\n', f);   
    1167    
    1168     for(j=ncl; j<=nch; j++) {
    1169         fprintf(f, "[%3d]", j);
    1170         for(i=nrl; i<=nrh; i++) {
    1171             fprintf(f, format, m[i][j]);
    1172         }
    1173         fputc('\n', f);
    1174     }
    1175     fclose(f);
    1176 }
    1177 /* --------------------------------------------------------------------------------------------------------------------- */
    1178 IMAGE_EXPORT(void) write_rgbx8matrix_T_number(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *format, char *filename)
    1179 /* --------------------------------------------------------------------------------------------------------------------- */
    1180 {
    1181     int i,j;
    1182    
    1183     FILE *f;
    1184    
    1185     f = fopen(filename, "wt");
    1186     if(f == NULL) {
    1187         nrerror("Can't open file in write_rgbx8matrix_T_number");
    1188     }
    1189    
    1190     fprintf(f, "%5c", '#');
    1191     for(i=nrl; i<=nrh; i++) {
    1192         fprintf(f, format, (float)i);
    1193     }
    1194     fputc('\n', f);
    1195    
    1196     for(j=ncl; j<=nch; j++) {
    1197         fprintf(f, "[%3d]", j);
    1198         for(i=nrl; i<=nrh; i++) {
    1199             fprintf(f, format, m[i][j]);
    1200         }
    1201         fputc('\n', f);
    1202     }
    1203     fclose(f);
    1204 }
     177
     178
     179#undef write_type_matrix_T_number
     180#define write_type_matrix_T_number(t) \
     181void short_name(t,write_,matrix_T_number)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \
     182{                                                                \
     183    FILE * f = fopen(filename, "wt");                            \
     184    if (f == NULL) {                                             \
     185        nrerror("Can't open file %s in %s", filename, __func__); \
     186    }                                                            \
     187    fprintf(f, "%5c", '#');                                      \
     188    for (int32_t i = nrl; i <= nrh; i++) {                       \
     189        fprintf(f, format, i);                                   \
     190    }                                                            \
     191    fprintf(f, "\n");                                            \
     192    for (int32_t j = ncl; j <= nch; j++) {                       \
     193        fprintf(f, "[%3d]", j);                                  \
     194        for (int32_t i = nrl; i <= nrh; i++) {                   \
     195            fprintf(f, format, m[i][j]);                         \
     196        }                                                        \
     197        fprintf(f, "\n");                                        \
     198    }                                                            \
     199    fclose(f);                                                   \
     200}
     201
     202
     203#undef elem
     204#define elem m[i][j]
     205write_type_matrix_T_number(int8_t);
     206write_type_matrix_T_number(uint8_t);
     207write_type_matrix_T_number(int16_t);
     208write_type_matrix_T_number(uint16_t);
     209write_type_matrix_T_number(int32_t);
     210write_type_matrix_T_number(uint32_t);
     211write_type_matrix_T_number(int64_t);
     212write_type_matrix_T_number(uint64_t);
     213write_type_matrix_T_number(float);
     214write_type_matrix_T_number(double);
     215#undef elem
     216#define elem m[i][j].r, m[i][j].g, m[i][j].b
     217write_type_matrix_T_number(rgb8);
     218#undef elem
     219#define elem m[i][j].r, m[i][j].g, m[i][j].b, m[i][j].x
     220write_type_matrix_T_number(rgbx8);
     221
     222
    1205223/*
    1206224 * ---------------------
     
    1209227 */
    1210228
    1211 /* ----------------------------------------------------------------------------------------------- */
    1212 IMAGE_EXPORT(void) fwrite_si8matrix(sint8 **m,long nrl, long nrh, long ncl, long nch, char *filename)
    1213 /* ----------------------------------------------------------------------------------------------- */
    1214 {
    1215     long  i, ncol = nch-ncl+1;
    1216     FILE *f;
    1217    
    1218     f = fopen(filename, "wb");
    1219     if(f == NULL) nrerror("Can't open file in fwrite_si8matrix");
    1220    
    1221     for(i=nrl; i<=nrh; i++) {
    1222         fwrite(m[i]+nrl, sizeof(sint8), ncol, f);
    1223     }
    1224     fclose(f);
    1225 }
    1226 /* ------------------------------------------------------------------------------------------------ */
    1227 IMAGE_EXPORT(void) fwrite_ui8matrix(uint8 **m, long nrl, long nrh, long ncl, long nch, char *filename)
    1228 /* ------------------------------------------------------------------------------------------------ */
    1229 {
    1230     long  i, ncol = nch-ncl+1;
    1231     FILE *f;
    1232    
    1233     f = fopen(filename, "wb");
    1234     if(f == NULL) nrerror("Can't open file in fwrite_ui8matrix");
    1235    
    1236     for(i=nrl; i<=nrh; i++) {
    1237         fwrite(m[i]+nrl, sizeof(int8), ncol, f);
    1238     }
    1239     fclose(f);
    1240 }
    1241 /* ------------------------------------------------------------------------------------------------- */
    1242 IMAGE_EXPORT(void) fwrite_si16matrix(sint16 **m,long nrl, long nrh, long ncl, long nch, char *filename)
    1243 /* ------------------------------------------------------------------------------------------------- */
    1244 {
    1245     long  i, ncol = nch-ncl+1;
    1246     FILE *f;
    1247    
    1248     f = fopen(filename, "wb");
    1249     if(f == NULL)
    1250         nrerror("Can't open file in fwrite_i16matrix");
    1251    
    1252     for(i=nrl; i<=nrh; i++) {
    1253         fwrite(m[i]+nrl, sizeof(sint16), ncol, f);
    1254     }
    1255     fclose(f);
    1256 }
    1257 /* ------------------------------------------------------------------------------------------------- */
    1258 IMAGE_EXPORT(void) fwrite_ui16matrix(uint16 **m,long nrl, long nrh, long ncl, long nch, char *filename)
    1259 /* ------------------------------------------------------------------------------------------------- */
    1260 {
    1261     long  i, ncol = nch-ncl+1;
    1262     FILE *f;
    1263    
    1264     f = fopen(filename, "wb");
    1265     if(f == NULL)
    1266         nrerror("Can't open file in fwrite_ui16matrix");
    1267    
    1268     for(i=nrl; i<=nrh; i++) {
    1269         fwrite(m[i]+nrl, sizeof(uint16), ncol, f);
    1270     }
    1271     fclose(f);
    1272 }
    1273 /* ------------------------------------------------------------------------------------------------- */
    1274 IMAGE_EXPORT(void) fwrite_si32matrix(sint32 **m,long nrl, long nrh, long ncl, long nch, char *filename)
    1275 /* ------------------------------------------------------------------------------------------------- */
    1276 {
    1277     long  i, ncol = nch-ncl+1;
    1278     FILE *f;
    1279    
    1280     f = fopen(filename, "wb");
    1281     if(f == NULL)
    1282         nrerror("Can't open file in fwrite_si32matrix");
    1283    
    1284     for(i=nrl; i<=nrh; i++) {
    1285         fwrite(m[i]+nrl, sizeof(sint32), ncol, f);
    1286     }
    1287     fclose(f);
    1288 }
    1289 /* ------------------------------------------------------------------------------------------------- */
    1290 IMAGE_EXPORT(void) fwrite_ui32matrix(uint32 **m,long nrl, long nrh, long ncl, long nch, char *filename)
    1291 /* ------------------------------------------------------------------------------------------------- */
    1292 {
    1293     long  i, ncol = nch-ncl+1;
    1294     FILE *f;
    1295    
    1296     f = fopen(filename, "wb");
    1297     if(f == NULL)
    1298         nrerror("Can't open file in fwrite_ui32matrix");
    1299    
    1300     for(i=nrl; i<=nrh; i++) {
    1301         fwrite(m[i]+nrl, sizeof(uint32), ncol, f);
    1302     }
    1303     fclose(f);
    1304 }
    1305 /* ----------------------------------------------------------------------------------------------- */
    1306 IMAGE_EXPORT(void) fwrite_si64matrix(sint64 **m,long nrl,long nrh,long ncl, long nch, char *filename)
    1307 /* ----------------------------------------------------------------------------------------------- */
    1308 {
    1309     long  i, ncol = nch-ncl+1;
    1310     FILE *f;
    1311    
    1312     f = fopen(filename, "wb");
    1313     if(f == NULL)
    1314         nrerror("Can't open file in fwrite_si64matrix");
    1315    
    1316     for(i=nrl; i<=nrh; i++) {
    1317         fwrite(m[i]+nrl, sizeof(sint64), ncol, f);
    1318     }
    1319     fclose(f);
    1320 }
    1321 /* ----------------------------------------------------------------------------------------------- */
    1322 IMAGE_EXPORT(void) fwrite_ui64matrix(uint64 **m,long nrl,long nrh,long ncl, long nch, char *filename)
    1323 /* ----------------------------------------------------------------------------------------------- */
    1324 {
    1325     long  i, ncol = nch-ncl+1;
    1326     FILE *f;
    1327    
    1328     f = fopen(filename, "wb");
    1329     if(f == NULL)
    1330         nrerror("Can't open file in fwrite_ui64matrix");
    1331    
    1332     for(i=nrl; i<=nrh; i++) {
    1333         fwrite(m[i]+nrl, sizeof(uint64), ncol, f);
    1334     }
    1335     fclose(f);
    1336 }
    1337 /* ----------------------------------------------------------------------------------------------- */
    1338 IMAGE_EXPORT(void) fwrite_f32matrix(float32 **m,long nrl,long nrh,long ncl, long nch, char *filename)
    1339 /* ----------------------------------------------------------------------------------------------- */
    1340 {
    1341     long  i, ncol = nch-ncl+1;
    1342     FILE *f;
    1343    
    1344     f = fopen(filename, "wb");
    1345     if(f == NULL) nrerror("Can't open file in fwrite_f32matrix");
    1346    
    1347     for(i=nrl; i<=nrh; i++) {
    1348         fwrite(m[i]+nrl, sizeof(float32), ncol, f);
    1349     }
    1350     fclose(f);
    1351 }
    1352 /* ----------------------------------------------------------------------------------------------- */
    1353 IMAGE_EXPORT(void) fwrite_f64matrix(float64 **m,long nrl,long nrh,long ncl, long nch, char *filename)
    1354 /* ----------------------------------------------------------------------------------------------- */
    1355 {
    1356     long  i, ncol = nch-ncl+1;
    1357     FILE *f;
    1358    
    1359     f = fopen(filename, "wb");
    1360     if(f == NULL) nrerror("Can't open file in f64write_matrix");
    1361    
    1362     for(i=nrl; i<=nrh; i++) {
    1363         fwrite(m[i]+nrl, sizeof(float64), ncol, f);
    1364     }
    1365     fclose(f);
    1366 }
    1367 /* --------------------------------------------------------------------------------------------- */
    1368 IMAGE_EXPORT(void) fwrite_rgb8matrix(rgb8 **m,long nrl,long nrh,long ncl, long nch, char *filename)
    1369 /* --------------------------------------------------------------------------------------------- */
    1370 {
    1371     long  i, ncol = nch-ncl+1;
    1372     FILE *f;
    1373    
    1374     f = fopen(filename, "wb");
    1375     if(f == NULL) nrerror("Can't open file in fwrite_rgb8matrix");
    1376    
    1377     for(i=nrl; i<=nrh; i++) {
    1378         fwrite(m[i]+nrl, sizeof(rgb8), ncol, f);
    1379     }
    1380     fclose(f);
    1381 }
    1382 /* ----------------------------------------------------------------------------------------------- */
    1383 IMAGE_EXPORT(void) fwrite_rgbx8matrix(rgbx8 **m,long nrl,long nrh,long ncl, long nch, char *filename)
    1384 /* ----------------------------------------------------------------------------------------------- */
    1385 {
    1386     long  i, ncol = nch-ncl+1;
    1387     FILE *f;
    1388    
    1389     f = fopen(filename, "wb");
    1390     if(f == NULL) nrerror("Can't open file in fwrite_rgbx8matrix");
    1391    
    1392     for(i=nrl; i<=nrh; i++) {
    1393         fwrite(m[i]+nrl, sizeof(rgbx8), ncol, f);
    1394     }
    1395     fclose(f);
    1396 }
     229#undef fwrite_type_matrix
     230#define fwrite_type_matrix(t) \
     231void short_name(t,fwrite_,matrix)(t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename) \
     232{                                                                \
     233    int32_t ncol = nch - ncl + 1;                                \
     234    FILE * f = fopen(filename, "wb");                            \
     235    if (f == NULL) {                                             \
     236        nrerror("Can't open file %s in %s", filename, __func__); \
     237    }                                                            \
     238    for (int32_t i = nrl; i <= nrh; i++) {                       \
     239        fwrite(m[i] + nrl, sizeof(t), ncol, f);                  \
     240    }                                                            \
     241    fclose(f);                                                   \
     242}
     243
     244fwrite_type_matrix(int8_t);
     245fwrite_type_matrix(uint8_t);
     246fwrite_type_matrix(int16_t);
     247fwrite_type_matrix(uint16_t);
     248fwrite_type_matrix(int32_t);
     249fwrite_type_matrix(uint32_t);
     250fwrite_type_matrix(int64_t);
     251fwrite_type_matrix(uint64_t);
     252fwrite_type_matrix(float);
     253fwrite_type_matrix(double);
     254fwrite_type_matrix(rgb8);
     255fwrite_type_matrix(rgbx8);
     256
     257
    1397258
    1398259/*
     
    1402263 */
    1403264
    1404 /* -------------------------------------------------------------------------------------------- */
    1405 IMAGE_EXPORT(void) fread_si8matrix(char *filename, sint8 **m,long nrl,long nrh,long ncl, long nch)
    1406 /* -------------------------------------------------------------------------------------------- */
    1407 {
    1408     long  i, ncol = nch-ncl+1, nread;
    1409     FILE *f;
    1410    
    1411     f = fopen(filename, "rb");
    1412     if(f == NULL) nrerror("Can't open file in fread_i8matrix");
    1413    
    1414     for(i=nrl; i<=nrh; i++) {
    1415         nread = fread(m[i]+ncl, sizeof(sint8), ncol, f);
    1416         if(nread != ncol) nrerror("fread_si8matrix : can't read data");
    1417     }
    1418     fclose(f);
    1419 }
    1420 /* -------------------------------------------------------------------------------------------- */
    1421 IMAGE_EXPORT(void) fread_ui8matrix(char *filename, uint8 **m,long nrl,long nrh,long ncl, long nch)
    1422 /* -------------------------------------------------------------------------------------------- */
    1423 {
    1424     long  i, ncol = nch-ncl+1, nread;
    1425     FILE *f;
    1426    
    1427     f = fopen(filename, "rb");
    1428     if(f == NULL) nrerror("Can't open file in fread_ui8matrix");
    1429    
    1430     for(i=nrl; i<=nrh; i++) {
    1431         nread = fread(m[i]+ncl, sizeof(uint8), ncol, f);
    1432         if(nread != ncol) nrerror("fread_ui8matrix : can't read data");
    1433     }
    1434     fclose(f);
    1435 }
    1436 /* ---------------------------------------------------------------------------------------------- */
    1437 IMAGE_EXPORT(void) fread_si32matrix(char *filename, sint32 **m,long nrl,long nrh,long ncl, long nch)
    1438 /* ---------------------------------------------------------------------------------------------- */
    1439 {
    1440     long  i, ncol = nch-ncl+1, nread;
    1441     FILE *f;
    1442    
    1443     f = fopen(filename, "rb");
    1444     if(f == NULL)
    1445         nrerror("Can't open file in fread_si32matrix");
    1446    
    1447     for(i=nrl; i<=nrh; i++) {
    1448         nread = fread(m[i]+ncl, sizeof(sint32), ncol, f);
    1449         if(nread != ncol) nrerror("fread_si32matrix : can't read data");
    1450     }
    1451     fclose(f);
    1452 }
    1453 /* ---------------------------------------------------------------------------------------------- */
    1454 IMAGE_EXPORT(void) fread_ui32matrix(char *filename, uint32 **m,long nrl,long nrh,long ncl, long nch)
    1455 /* ---------------------------------------------------------------------------------------------- */
    1456 {
    1457     long  i, ncol = nch-ncl+1, nread;
    1458     FILE *f;
    1459    
    1460     f = fopen(filename, "rb");
    1461     if(f == NULL)
    1462         nrerror("Can't open file in fread_ui32matrix");
    1463    
    1464     for(i=nrl; i<=nrh; i++) {
    1465         nread = fread(m[i]+ncl, sizeof(uint32), ncol, f);
    1466         if(nread != ncol) nrerror("fread_ui32matrix : can't read data");
    1467     }
    1468     fclose(f);
    1469 }
    1470 /* ---------------------------------------------------------------------------------------------- */
    1471 IMAGE_EXPORT(void) fread_si64matrix(char *filename, sint64 **m,long nrl,long nrh,long ncl, long nch)
    1472 /* ---------------------------------------------------------------------------------------------- */
    1473 {
    1474     long  i, ncol = nch-ncl+1, nread;
    1475     FILE *f;
    1476    
    1477     f = fopen(filename, "rb");
    1478     if(f == NULL)
    1479         nrerror("Can't open file in fread_si64matrix");
    1480    
    1481     for(i=nrl; i<=nrh; i++) {
    1482         nread = fread(m[i]+ncl, sizeof(sint32), ncol, f);
    1483         if(nread != ncol) nrerror("fread_si64matrix : can't read data");
    1484     }
    1485     fclose(f);
    1486 }
    1487 /* ---------------------------------------------------------------------------------------------- */
    1488 IMAGE_EXPORT(void) fread_ui64matrix(char *filename, uint64 **m,long nrl,long nrh,long ncl, long nch)
    1489 /* ---------------------------------------------------------------------------------------------- */
    1490 {
    1491     long  i, ncol = nch-ncl+1, nread;
    1492     FILE *f;
    1493    
    1494     f = fopen(filename, "rb");
    1495     if(f == NULL)
    1496         nrerror("Can't open file in fread_ui64matrix");
    1497    
    1498     for(i=nrl; i<=nrh; i++) {
    1499         nread = fread(m[i]+ncl, sizeof(uint64), ncol, f);
    1500         if(nread != ncol) nrerror("fread_ui64matrix : can't read data");
    1501     }
    1502     fclose(f);
    1503 }
    1504 /* ---------------------------------------------------------------------------------------------- */
    1505 IMAGE_EXPORT(void) fread_f32matrix(char *filename, float32 **m,long nrl,long nrh,long ncl, long nch)
    1506 /* ---------------------------------------------------------------------------------------------- */
    1507 {
    1508     long  i, ncol = nch-ncl+1, nread;
    1509     FILE *f;
    1510    
    1511     f = fopen(filename, "rb");
    1512     if(f == NULL) nrerror("Can't open file in fread_f32matrix");
    1513    
    1514     for(i=nrl; i<=nrh; i++) {
    1515         nread = fread(m[i]+ncl, sizeof(float32), ncol, f);
    1516         if(nread != ncol) nrerror("fread_f32matrix : can't read data");
    1517     }
    1518     fclose(f);
    1519 }
    1520 /* ---------------------------------------------------------------------------------------------- */
    1521 IMAGE_EXPORT(void) fread_f64matrix(char *filename, float64 **m,long nrl,long nrh,long ncl, long nch)
    1522 /* ---------------------------------------------------------------------------------------------- */
    1523 {
    1524     long  i, ncol = nch-ncl+1, nread;
    1525     FILE *f;
    1526    
    1527     f = fopen(filename, "rb");
    1528     if(f == NULL) nrerror("Can't open file in fread_f64matrix");
    1529    
    1530     for(i=nrl; i<=nrh; i++) {
    1531         nread = fread(m[i]+ncl, sizeof(float64), ncol, f);
    1532         if(nread != ncol) nrerror("fread_f64matrix : can't read data");
    1533     }
    1534     fclose(f);
    1535 }
    1536 /* -------------------------------------------------------------------------------------------- */
    1537 IMAGE_EXPORT(void) fread_rgb8matrix(char *filename, rgb8 **m,long nrl,long nrh,long ncl, long nch)
    1538 /* -------------------------------------------------------------------------------------------- */
    1539 {
    1540     long  i, ncol = nch-ncl+1, nread;
    1541     FILE *f;
    1542    
    1543     f = fopen(filename, "rb");
    1544     if(f == NULL) nrerror("Can't open file in fread_rgb8matrix");
    1545    
    1546     for(i=nrl; i<=nrh; i++) {
    1547         nread = fread(m[i]+ncl, sizeof(rgb8), ncol, f);
    1548         if(nread != ncol) nrerror("fread_rgb8matrix : can't read data");
    1549     }
    1550     fclose(f);
    1551 }
    1552 /* ---------------------------------------------------------------------------------------------- */
    1553 IMAGE_EXPORT(void) fread_rgbx8matrix(char *filename, rgbx8 **m,long nrl,long nrh,long ncl, long nch)
    1554 /* ---------------------------------------------------------------------------------------------- */
    1555 {
    1556     long  i, ncol = nch-ncl+1, nread;
    1557     FILE *f;
    1558    
    1559     f = fopen(filename, "rb");
    1560     if(f == NULL) nrerror("Can't open file in fread_rgbx8matrix");
    1561    
    1562     for(i=nrl; i<=nrh; i++) {
    1563         nread = fread(m[i]+ncl, sizeof(rgbx8), ncol, f);
    1564         if(nread != ncol) nrerror("fread_rgbx8matrix : can't read data");
    1565     }
    1566     fclose(f);
    1567 }
    1568 // --------------------------------------------------------------------------------------------------
    1569 void write_ui8matrix_positive(uint8 **m, int i0, int i1, int j0, int j1, int iformat, char *filename)
    1570 // --------------------------------------------------------------------------------------------------
    1571 {
    1572     int i, j;
    1573     char *format, *str;
    1574     FILE *f;
    1575    
    1576     select_display_positive_parameters(iformat, &format, &str);
    1577    
    1578     f = fopen(filename, "wt");
    1579     if(f == NULL) {
    1580         nrerror("Can't open file in write_ui8matrix_positive");
    1581     }
    1582    
    1583     for(i=i0; i<=i1; i++) {
    1584         for(j=j0; j<=j1; j++) {
    1585             if(m[i][j]) {
    1586                 fprintf(f, format, m[i][j]);
    1587             } else {
    1588                 fprintf(f, "%s", str);
    1589             }
    1590         }
    1591         fputc('\n', f);
    1592     }
    1593     fclose(f);
    1594 }
    1595 
    1596 // ----------------------------------------------------------------------------------------------------
    1597 void write_ui16matrix_positive(uint16 **m, int i0, int i1, int j0, int j1, int iformat, char *filename)
    1598 // ----------------------------------------------------------------------------------------------------
    1599 {
    1600     int i, j;
    1601     char *format, *str;
    1602     FILE *f;
    1603    
    1604     select_display_positive_parameters(iformat, &format, &str);
    1605    
    1606     f = fopen(filename, "wt");
    1607     if(f == NULL) {
    1608         nrerror("Can't open file in write_ui16matrix_positive");
    1609     }
    1610    
    1611     for(i=i0; i<=i1; i++) {
    1612         for(j=j0; j<=j1; j++) {
    1613             if(m[i][j]) {
    1614                 fprintf(f, format, m[i][j]);
    1615             } else {
    1616                 fprintf(f, "%s", str);
    1617             }
    1618         }
    1619         fputc('\n', f);
    1620     }
    1621     fclose(f);
    1622 }
    1623 // ---------------------------------------------------------------------------------------------------
    1624 void write_ui32matrix_positive(uint32 **m,int i0, int i1, int j0, int j1, int iformat, char *filename)
    1625 // ---------------------------------------------------------------------------------------------------
    1626 {
    1627     int i, j;
    1628     char *format, *str;
    1629     FILE *f;
    1630    
    1631     select_display_positive_parameters(iformat, &format, &str);
    1632    
    1633     f = fopen(filename, "wt");
    1634     if(f == NULL) {
    1635         nrerror("Can't open file in write_ui32matrix_positive");
    1636     }
    1637    
    1638     for(i=i0; i<=i1; i++) {
    1639         for(j=j0; j<=j1; j++) {
    1640             if(m[i][j]) {
    1641                 fprintf(f, format, m[i][j]);
    1642             } else {
    1643                 fprintf(f, "%s", str);
    1644             }
    1645         }
    1646         fputc('\n', f);
    1647     }
    1648     fclose(f);
    1649 }
     265#undef fread_type_matrix
     266#define fread_type_matrix(t) \
     267void short_name(t,fread_,matrix)(char * filename, t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch)  \
     268{                                                                \
     269    int32_t ncol = nch - ncl + 1;                                \
     270    int32_t nread;                                               \
     271    FILE * f = fopen(filename, "rb");                            \
     272    if (f == NULL) {                                             \
     273        nrerror("Can't open file %s in %s", filename, __func__); \
     274    }                                                            \
     275    for (int32_t i = nrl; i <= nrh; i++) {                       \
     276        nread = fread(m[i] + ncl, sizeof(t), ncol, f);           \
     277        if (nread != ncol) {                                     \
     278            nrerror("%s : can't read data", __func__);           \
     279        }                                                        \
     280    }                                                            \
     281    fclose(f);                                                   \
     282}
     283
     284fread_type_matrix(int8_t);
     285fread_type_matrix(uint8_t);
     286fread_type_matrix(int16_t);
     287fread_type_matrix(uint16_t);
     288fread_type_matrix(int32_t);
     289fread_type_matrix(uint32_t);
     290fread_type_matrix(int64_t);
     291fread_type_matrix(uint64_t);
     292fread_type_matrix(float);
     293fread_type_matrix(double);
     294fread_type_matrix(rgb8);
     295fread_type_matrix(rgbx8);
     296
     297
     298
     299#undef write_type_matrix_positive
     300#define write_type_matrix_positive(t) \
     301void short_name(t,write_,matrix_positive)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t iformat, char * filename) \
     302{                                                                \
     303    char * format;                                               \
     304    char * str;                                                  \
     305    FILE * f;                                                    \
     306    select_display_positive_parameters(iformat, &format, &str);  \
     307    f = fopen(filename, "wt");                                   \
     308    if (f == NULL) {                                             \
     309        nrerror("Can't open file %s in %s", filename, __func__); \
     310    }                                                            \
     311    for (int32_t i = i0; i <= i1; i++) {                         \
     312        for (int32_t j = j0; j <= j1; j++) {                     \
     313            if (m[i][j] != 0) {                                  \
     314                fprintf(f, format, m[i][j]);                     \
     315            }                                                    \
     316            else {                                               \
     317                fprintf(f, "%s", str);                           \
     318            }                                                    \
     319        }                                                        \
     320        fprintf(f, "\n");                                        \
     321    }                                                            \
     322    fclose(f);                                                   \
     323}
     324
     325write_type_matrix_positive(uint8_t);
     326write_type_matrix_positive(uint16_t);
     327write_type_matrix_positive(uint32_t);
     328
    1650329
    1651330/* ------------------------ */
     
    1653332/* ------------------------ */
    1654333
    1655 PRIVATE char *readitem   (FILE *file, char *buffer);
    1656 PRIVATE void  ReadPGMrow (FILE *file, int width, uint8  *line);
    1657 PRIVATE void  WritePGMrow(uint8 *line, int width, FILE  *file);
    1658334
    1659335/* ------------------------------------------ */
    1660 PRIVATE char *readitem(FILE *file, char *buffer)
     336static char * readitem(FILE * file, char * buffer)
    1661337/* ------------------------------------------ */
    1662 // read a word
    1663 // public domain function: author is unknown
    1664 {
    1665     char *aux;
    1666     int k;
    1667    
    1668     k=0;
    1669     aux=buffer;
    1670     while (!feof(file))
    1671     {
    1672         *aux=fgetc(file);
    1673         switch(k)
    1674         {
    1675         case 0:
    1676             if (*aux=='#') k=1;
    1677             if (isalnum(*aux)) k=2, aux++;
    1678             break;
    1679         case 1:
    1680             if (*aux==0xA) k=0;
    1681             break;
    1682         case 2:
    1683             if (!isalnum(*aux))
    1684             {
    1685                 *aux=0;
    1686                 return buffer;
    1687             }
    1688             aux++;
    1689             break;
     338    // read a word
     339    // public domain function: author is unknown
     340{
     341    char * aux;
     342    int32_t k;
     343
     344    k = 0;
     345    aux = buffer;
     346    while (!feof(file)) {
     347        *aux = fgetc(file);
     348        switch (k) {
     349            case 0:
     350                if (*aux == '#') {
     351                    k = 1;
     352                }
     353                if (isalnum(*aux)) {
     354                    k = 2;
     355                    aux++;
     356                }
     357                break;
     358            case 1:
     359                if (*aux == 0xA) {
     360                    k = 0;
     361                }
     362                break;
     363            case 2:
     364                if (!isalnum(*aux)) {
     365                    *aux = 0;
     366                    return buffer;
     367                }
     368                aux++;
     369                break;
    1690370        }
    1691371    }
    1692     *aux=0;
     372    *aux = 0;
    1693373    return buffer;
    1694374}
     375
    1695376/* ----------------------------------------------------- */
    1696 PRIVATE void ReadPGMrow(FILE  *file, int width, uint8 *line)
     377static void ReadPGMrow(FILE * file, int32_t width, uint8_t * line)
    1697378/* ----------------------------------------------------- */
    1698379{
    1699380    // file is already open (in read) and will not be closed at the end
    1700     fread(&(line[0]), sizeof(uint8), width, file);
    1701 }
     381    fread(&(line[0]), sizeof(uint8_t), width, file);
     382}
     383
     384
    1702385/* ------------------------------------------------------- */
    1703 PRIVATE void WritePGMrow(uint8  *line, int width, FILE  *file)
     386static void WritePGMrow(uint8_t * line, int32_t width, FILE  * file)
    1704387/* ------------------------------------------------------- */
    1705388{
    1706389    // file is already open (in read) and will not be closed at the end
    1707     fwrite(&(line[0]), sizeof(uint8), width, file);
    1708 }
     390    fwrite(&(line[0]), sizeof(uint8_t), width, file);
     391}
     392
     393
    1709394/* --------------------------------------------------------------------------------------- */
    1710 IMAGE_EXPORT(uint8 **) LoadPGM_ui8matrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch)
     395uint8_t ** LoadPGM_ui8matrix(char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch)
    1711396/* --------------------------------------------------------------------------------------- */
    1712397{
    1713398    // only for P5 binary type, not for text type
    1714    
    1715     int height, width, gris;
    1716     uint8 **m;
    1717     FILE *file;
    1718    
    1719     char *buffer;
     399
     400    int32_t height, width, gris;
     401    uint8_t ** m;
     402    FILE * file;
     403
     404    char * buffer;
    1720405    char msg[1024];
    1721     //char  c;
    1722     int i;
    1723    
    1724     buffer = (char*) calloc(80, sizeof(char));
     406    (void) gris;
     407
     408    buffer = (char *) calloc(80, sizeof(char));
    1725409
    1726410    // open file
    1727     file = fopen(filename,"rb");
    1728     if (file==NULL) {
    1729         //nrerror("ouverture du fichier impossible\n");
    1730         sprintf(msg, "ouverture du fichier %s impossible dans LoadPGM_ui8matrix\n", filename);
     411    file = fopen(filename, "rb");
     412    if (file == NULL) {
     413        snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__);
    1731414        nrerror(msg);
    1732415    }
    1733    
     416
    1734417    // read PGM header
    1735418    readitem(file, buffer);
    1736     /*fscanf(fichier, "%s", buffer);*/
    1737     if(strcmp(buffer, "P5") != 0) nrerror("entete du fichier %s invalide\n");
    1738     //nrerror("entete du fichier %s invalide\n", filename);
    1739    
     419    if (strcmp(buffer, "P5") != 0) {
     420        nrerror("Entete du fichier %s invalide\n", filename);
     421    }
     422
    1740423    width  = atoi(readitem(file, buffer));
    1741424    height = atoi(readitem(file, buffer));
    1742425    gris   = atoi(readitem(file, buffer));
    1743    
     426
    1744427    *nrl = 0;
    1745428    *nrh = height - 1;
     
    1747430    *nch = width - 1;
    1748431    m = ui8matrix(*nrl, *nrh, *ncl, *nch);
    1749    
    1750     for(i=0; i<height; i++) {
     432
     433    for(int32_t i = 0; i < height; i++) {
    1751434        ReadPGMrow(file, width, m[i]);
    1752435    }
    1753    
     436
    1754437    fclose(file);
    1755438    free(buffer);
    1756    
     439
    1757440    return m;
    1758441}
    1759 /* ---------------------------------------------------------------------------------------- */
    1760 IMAGE_EXPORT(uint8 **) LoadPGM_bmatrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch)
    1761 /* ---------------------------------------------------------------------------------------- */
     442
     443
     444/* ----------------------------------------------------------------------------------------------- */
     445void LoadPGM_ui8matrix2(char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch, uint8_t ** m)
     446/* ----------------------------------------------------------------------------------------------- */
    1762447{
    1763448    // only for P5 binary type, not for text type
    1764    
    1765     int height, width, gris;
    1766     uint8 **m;
    1767     FILE *file;
    1768    
    1769     char *buffer;
     449    int32_t height, width, gris;
     450    FILE * file;
     451
     452    char * buffer;
    1770453    char msg[1024];
    1771     //char  c;
    1772     int i;
    1773    
    1774     buffer = (char*) calloc(80, sizeof(char));
    1775    
    1776     // open file
    1777     file = fopen(filename,"rb");
    1778     if (file==NULL) {
    1779         //nrerror("ouverture du fichier impossible\n");
    1780         sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename);
     454    (void) gris;
     455
     456    buffer = (char *) calloc(80, sizeof(char));
     457    /* ouverture du fichier */
     458    file = fopen(filename, "rb");
     459    if (file == NULL) {
     460        snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__);
    1781461        nrerror(msg);
    1782462    }
    1783    
    1784     // read PGM header
     463
     464    /* lecture de l'entete du fichier pgm */
    1785465    readitem(file, buffer);
    1786     /*fscanf(fichier, "%s", buffer);*/
    1787     if(strcmp(buffer, "P5") != 0)
    1788         nrerror("entete du fichier %s invalide\n");
    1789     //nrerror("entete du fichier %s invalide\n", filename);
    1790    
     466    if (strcmp(buffer, "P5") != 0) {
     467        nrerror("Entete du fichier %s invalide\n", filename);
     468    }
     469
    1791470    width  = atoi(readitem(file, buffer));
    1792471    height = atoi(readitem(file, buffer));
    1793472    gris   = atoi(readitem(file, buffer));
    1794    
     473
    1795474    *nrl = 0;
    1796475    *nrh = height - 1;
    1797476    *ncl = 0;
    1798477    *nch = width - 1;
    1799     m = ui8matrix(*nrl, *nrh, *ncl, *nch);
    1800    
    1801     for(i=0; i<height; i++) {
     478
     479    for (int32_t i = 0; i < height; i++) {
    1802480        ReadPGMrow(file, width, m[i]);
    1803481    }
    1804    
     482
    1805483    fclose(file);
    1806484    free(buffer);
    1807    
    1808     return m;
    1809 }
    1810 /* ----------------------------------------------------------------------------------------------- */
    1811 IMAGE_EXPORT(void) LoadPGM_bmatrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, uint8 **m)
    1812 /* ----------------------------------------------------------------------------------------------- */
     485}
     486
     487
     488/* -------------------------------------------------------------------------------------------- */
     489void MLoadPGM_ui8matrix(char * filename, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t ** m)
     490/* -------------------------------------------------------------------------------------------- */
    1813491{
    1814492    // only for P5 binary type, not for text type
    1815    
    1816     int height, width, gris;
    1817     FILE *file;
    1818    
    1819     char *buffer;
     493    int32_t height, width, gris;
     494    FILE * file;
     495
     496    char * buffer;
    1820497    char msg[1024];
    1821     int i;
    1822    
    1823     buffer = (char*) calloc(80, sizeof(char));
     498    (void) gris;
     499
     500    buffer = (char *) calloc(80, sizeof(char));
    1824501    /* ouverture du fichier */
    1825     file = fopen(filename,"rb");
    1826     if (file==NULL) {
    1827         //nrerror("ouverture du fichier impossible\n");
    1828         sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename);
     502    file = fopen(filename, "rb");
     503    if (file == NULL) {
     504        snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__);
    1829505        nrerror(msg);
    1830506    }
    1831    
     507
    1832508    /* lecture de l'entete du fichier pgm */
    1833509    readitem(file, buffer);
    1834     /*fscanf(fichier, "%s", buffer);*/
    1835     if(strcmp(buffer, "P5") != 0)
    1836         nrerror("entete du fichier %s invalide\n");
    1837     //nrerror("entete du fichier %s invalide\n", filename);
    1838    
     510    if (strcmp(buffer, "P5") != 0) {
     511        nrerror("Entete du fichier %s invalide\n", filename);
     512    }
     513
    1839514    width  = atoi(readitem(file, buffer));
    1840515    height = atoi(readitem(file, buffer));
    1841516    gris   = atoi(readitem(file, buffer));
    1842    
    1843     *nrl = 0;
    1844     *nrh = height - 1;
    1845     *ncl = 0;
    1846     *nch = width - 1;
    1847    
    1848     for(i=0; i<height; i++) {
     517
     518    for (int32_t i = 0; i < height; i++) {
    1849519        ReadPGMrow(file, width, m[i]);
    1850520    }
    1851    
     521
    1852522    fclose(file);
    1853523    free(buffer);
    1854524}
    1855 /* -------------------------------------------------------------------------------------------- */
    1856 IMAGE_EXPORT(void) MLoadPGM_bmatrix(char *filename, int nrl, int nrh, int ncl, int nch, uint8 **m)
    1857 /* -------------------------------------------------------------------------------------------- */
    1858 {
    1859     // only for P5 binary type, not for text type
    1860    
    1861     int height, width, gris;
    1862     FILE *file;
    1863    
    1864     char *buffer;
     525
     526
     527/* ------------------------------------------------------------------------------------------ */
     528void SavePGM_ui8matrix(uint8_t ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename)
     529/* ------------------------------------------------------------------------------------------ */
     530{
     531    int nrow = nrh - nrl + 1;
     532    int ncol = nch - ncl + 1;
     533
     534    char buffer[80];
    1865535    char msg[1024];
    1866    
    1867     int i;
    1868    
    1869     buffer = (char*) calloc(80, sizeof(char));
     536
     537    FILE * file;
     538
     539    file = fopen(filename, "wb");
     540    if (file == NULL) {
     541        snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__);
     542        nrerror(msg);
     543    }
     544
     545    /* enregistrement de l'image au format rpgm */
     546    snprintf(buffer, 80, "P5\n%d %d\n255\n", ncol, nrow);
     547    fwrite(buffer, strlen(buffer), 1, file);
     548    for (int32_t i = nrl; i <= nrh; i++) {
     549        WritePGMrow(m[i], ncol, file);
     550    }
     551
     552    /* fermeture du fichier */
     553    fclose(file);
     554}
     555
     556
     557/* --------------------------- */
     558/* -- PNM IO for rgb8matrix -- */
     559/* --------------------------- */
     560
     561/* ------------------------------------------------------ */
     562static void ReadPNMrow(FILE * file, int32_t width, uint8_t * line)
     563/* ------------------------------------------------------ */
     564{
     565    /* Le fichier est ouvert (en lecture) et ne sera pas ferme a la fin */
     566    fread(&(line[0]), sizeof(uint8_t), 3 * sizeof(uint8_t) * width, file);
     567}
     568
     569
     570/* ------------------------------------------------------- */
     571static void WritePNMrow(uint8_t * line, int32_t width, FILE * file)
     572/* ------------------------------------------------------- */
     573{
     574    /* Le fichier est deja ouvert et ne sera pas ferme a la fin */
     575    fwrite(&(line[0]), sizeof(uint8_t), 3 * sizeof(uint8_t) * width, file);
     576}
     577
     578
     579/* ------------------------------------------------------------------------------------------ */
     580rgb8 ** LoadPPM_rgb8matrix(char * filename, int32_t * nrl, int32_t * nrh, int32_t * ncl, int32_t * nch)
     581/* ------------------------------------------------------------------------------------------ */
     582{
     583    /* cette version ne lit plus que le type P6 */
     584    int32_t height, width, gris;
     585    rgb8 ** m;
     586    FILE * file;
     587
     588    char * buffer;
     589    char msg[1024];
     590    (void) gris;
     591
     592    buffer = (char *) calloc(80, sizeof(char));
    1870593    /* ouverture du fichier */
    1871594    file = fopen(filename,"rb");
    1872     if (file==NULL) {
    1873         //nrerror("ouverture du fichier impossible\n");
    1874         sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename);
     595    if (file == NULL) {
     596        snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__);
    1875597        nrerror(msg);
    1876598    }
    1877    
     599
    1878600    /* lecture de l'entete du fichier pgm */
    1879601    readitem(file, buffer);
    1880     /*fscanf(fichier, "%s", buffer);*/
    1881     if(strcmp(buffer, "P5") != 0)
    1882         nrerror("entete du fichier %s invalide\n");
    1883     //nrerror("entete du fichier %s invalide\n", filename);
    1884    
     602    if (strcmp(buffer, "P6") != 0) {
     603        nrerror("Entete du fichier %s invalide\n", filename);
     604    }
     605
    1885606    width  = atoi(readitem(file, buffer));
    1886607    height = atoi(readitem(file, buffer));
    1887608    gris   = atoi(readitem(file, buffer));
    1888    
    1889     for(i=0; i<height; i++) {
    1890         ReadPGMrow(file, width, m[i]);
    1891     }
    1892    
    1893     fclose(file);
    1894     free(buffer);
    1895 }
    1896 /* ------------------------------------------------------------------------------------------ */
    1897 IMAGE_EXPORT(void) SavePGM_bmatrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename)
    1898 /* ------------------------------------------------------------------------------------------ */
    1899 {
    1900     int nrow = nrh-nrl+1;
    1901     int ncol = nch-ncl+1;
    1902    
    1903     char buffer[80];
    1904     char msg[1024];
    1905    
    1906     FILE *file;
    1907     int  i;
    1908    
    1909     file = fopen(filename, "wb");
    1910     if (file == NULL) {
    1911         //nrerror("ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename);
    1912         sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename);
    1913         nrerror(msg);
    1914     }
    1915    
    1916     /* enregistrement de l'image au format rpgm */
    1917     sprintf(buffer,"P5\n%d %d\n255\n",ncol, nrow);
    1918     fwrite(buffer,strlen(buffer),1,file);
    1919     for(i=nrl; i<=nrh; i++)
    1920         WritePGMrow(m[i], ncol, file);
    1921    
    1922     /* fermeture du fichier */
    1923     fclose(file);
    1924 }
    1925 /* --------------------------------------------------------------------------------------------- */
    1926 IMAGE_EXPORT(void) SavePGM_ui8matrix(uint8 **m, int nrl, int nrh, int ncl, int nch, char *filename)
    1927 /* --------------------------------------------------------------------------------------------- */
    1928 {
    1929     int nrow = nrh-nrl+1;
    1930     int ncol = nch-ncl+1;
    1931    
    1932     char buffer[80];
    1933     char msg[1024];
    1934    
    1935     FILE *file;
    1936     int  i;
    1937    
    1938     file = fopen(filename, "wb");
    1939     if (file == NULL) {
    1940         //nrerror("ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename);
    1941         sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename);
    1942         nrerror(msg);
    1943     }
    1944    
    1945     /* enregistrement de l'image au format rpgm */
    1946     sprintf(buffer,"P5\n%d %d\n255\n",ncol, nrow);
    1947     fwrite(buffer,strlen(buffer),1,file);
    1948     for(i=nrl; i<=nrh; i++)
    1949         WritePGMrow(m[i], ncol, file);
    1950    
    1951     /* fermeture du fichier */
    1952     fclose(file);
    1953 }
    1954 /* --------------------------- */
    1955 /* -- PNM IO for rgb8matrix -- */
    1956 /* --------------------------- */
    1957 
    1958 /* ------------------------------------------------------ */
    1959 PRIVATE void ReadPNMrow(FILE  *file, int width, byte  *line)
    1960 /* ------------------------------------------------------ */
    1961 {
    1962     /* Le fichier est ouvert (en lecture) et ne sera pas ferme a la fin */
    1963     fread(&(line[0]), sizeof(byte), 3*sizeof(byte)*width, file);
    1964 }
    1965 /* ------------------------------------------------------- */
    1966 PRIVATE void WritePNMrow(byte  *line, int width, FILE  *file)
    1967 /* ------------------------------------------------------- */
    1968 {
    1969     /* Le fichier est deja ouvert et ne sera pas ferme a la fin */
    1970    
    1971     fwrite(&(line[0]), sizeof(byte), 3*sizeof(byte)*width, file);
    1972 }
    1973 /* ------------------------------------------------------------------------------------------ */
    1974 IMAGE_EXPORT(rgb8 **) LoadPPM_rgb8matrix(char *filename, int *nrl, int *nrh, int *ncl, int *nch)
    1975 /* ------------------------------------------------------------------------------------------ */
    1976 {
    1977     /* cette version ne lit plus que le type P6 */
    1978    
    1979     int height, width, gris;
    1980     rgb8 **m;
    1981     FILE *file;
    1982     //int   format;
    1983    
    1984     char *buffer;
    1985     char msg[1024];
    1986     //char  c;
    1987     int i;
    1988    
    1989     buffer = (char*) calloc(80, sizeof(char));
    1990     /* ouverture du fichier */
    1991     file = fopen(filename,"rb");
    1992     if (file==NULL) {
    1993         //nrerror("ouverture du fichier impossible\n");
    1994         sprintf(msg, "ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename);
    1995         nrerror(msg);
    1996     }
    1997    
    1998     /* lecture de l'entete du fichier pgm */
    1999     readitem(file, buffer);
    2000     /*fscanf(fichier, "%s", buffer);*/
    2001     if(strcmp(buffer, "P6") != 0)
    2002         nrerror("entete du fichier %s invalide\n");
    2003     //nrerror("entete du fichier %s invalide\n", filename);
    2004    
    2005     width  = atoi(readitem(file, buffer));
    2006     height = atoi(readitem(file, buffer));
    2007     gris   = atoi(readitem(file, buffer));
    2008    
     609
    2009610    *nrl = 0;
    2010611    *nrh = height - 1;
     
    2012613    *nch = width - 1;
    2013614    m = rgb8matrix(*nrl, *nrh, *ncl, *nch);
    2014    
    2015     for(i=0; i<height; i++) {
    2016         ReadPNMrow(file, width, (byte*)m[i]);
    2017     }
    2018    
     615
     616    for (int32_t i = 0; i < height; i++) {
     617        ReadPNMrow(file, width, (uint8_t *) m[i]);
     618    }
     619
    2019620    fclose(file);
    2020621    free(buffer);
    2021    
     622
    2022623    return m;
    2023624}
     625
     626
    2024627/* -------------------------------------------------------------------------------------------------- */
    2025 IMAGE_EXPORT(void) LoadPPM_rgb8matrix2(char *filename, int *nrl, int *nrh, int *ncl, int *nch, rgb8 **m)
    2026 /* -------------------------------------------------------------------------------------------------- */
     628void LoadPPM_rgb8matrix2(char * filename, int * nrl, int * nrh, int * ncl, int * nch, rgb8 ** m)
     629    /* -------------------------------------------------------------------------------------------------- */
    2027630{
    2028631    /* cette version ne lit plus que le type P6 */
    2029    
    2030632    int height, width, gris;
    2031     FILE *file;
    2032     //int   format;
    2033    
    2034     char *buffer;
     633    FILE * file;
     634
     635    char * buffer;
    2035636    char msg[1024];
    2036     //char  c;
    2037     int i;
    2038    
    2039     buffer = (char*) calloc(80, sizeof(char));
     637    (void) gris;
     638
     639    buffer = (char *) calloc(80, sizeof(char));
    2040640    /* ouverture du fichier */
    2041     file = fopen(filename,"rb");
    2042     if (file==NULL) {
    2043         //nrerror("ouverture du fichier impossible\n");
    2044         sprintf(msg, "ouverture du fichier %s impossible dans LoadPPM_rgb8matrix2\n", filename);
     641    file = fopen(filename, "rb");
     642    if (file == NULL) {
     643        snprintf(msg, 1024, "ouverture du fichier %s impossible dans LoadPPM_rgb8matrix2\n", filename);
    2045644        nrerror(msg);
    2046645    }
    2047    
     646
    2048647    /* lecture de l'entete du fichier pgm */
    2049648    readitem(file, buffer);
    2050     /*fscanf(fichier, "%s", buffer);*/
    2051     if(strcmp(buffer, "P6") != 0)
    2052         nrerror("entete du fichier %s invalide\n");
     649    if (strcmp(buffer, "P6") != 0) {
     650        nrerror("Entete du fichier %s invalide\n", filename);
     651    }
    2053652    //nrerror("entete du fichier %s invalide\n", filename);
    2054    
     653
    2055654    width  = atoi(readitem(file, buffer));
    2056655    height = atoi(readitem(file, buffer));
    2057656    gris   = atoi(readitem(file, buffer));
    2058    
     657
    2059658    *nrl = 0;
    2060659    *nrh = height - 1;
    2061660    *ncl = 0;
    2062661    *nch = width - 1;
    2063    
    2064     for(i=0; i<height; i++) {
    2065         ReadPNMrow(file, width, (byte*)m[i]);
     662
     663    for (int32_t i = 0; i < height; i++) {
     664        ReadPNMrow(file, width, (uint8_t *) m[i]);
    2066665    }
    2067666    fclose(file);
    2068667    free(buffer);
    2069668}
     669
     670
    2070671/* ------------------------------------------------------------------------------------------------- */
    2071 IMAGE_EXPORT(void) SavePPM_rgb8matrix(rgb8 **m, int nrl, int nrh, int ncl, int nch, char *filename)
     672void SavePPM_rgb8matrix(rgb8 ** m, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * filename)
    2072673/* ------------------------------------------------------------------------------------------------- */
    2073674{
    2074     int nrow = nrh-nrl+1;
    2075     int ncol = nch-ncl+1;
    2076    
     675    int32_t nrow = nrh - nrl + 1;
     676    int32_t ncol = nch - ncl + 1;
     677
    2077678    char buffer[80];
    2078679    char msg[1024];
    2079    
    2080     FILE *file;
    2081     int  i;
    2082    
     680
     681    FILE * file;
     682
    2083683    file = fopen(filename, "wb");
    2084684    if (file == NULL) {
    2085         //nrerror("ouverture du fichier %s impossible dans SavePGM_bmatrix\n", filename);
    2086         //nrerror("ouverture du fichier %s impossible dans SavePPM_bmatrix\n");
    2087         sprintf(msg, "ouverture du fichier %s impossible dans SavePPM_rgb8matrix\n", filename);
    2088        
     685        snprintf(msg, 1024, "ouverture du fichier %s impossible dans %s\n", filename, __func__);
    2089686        nrerror(msg);
    2090687    }
    2091    
     688
    2092689    /* enregistrement de l'image au format rpgm */
    2093    
    2094     sprintf(buffer,"P6\n%d %d\n255\n",ncol, nrow);
    2095     fwrite(buffer,strlen(buffer),1,file);
    2096     for(i=nrl; i<=nrh; i++)
    2097         WritePNMrow((byte*)m[i], ncol, file);
    2098    
     690    snprintf(buffer, 80, "P6\n%d %d\n255\n", ncol, nrow);
     691    fwrite(buffer, strlen(buffer), 1, file);
     692    for (int32_t i = nrl; i <= nrh; i++) {
     693        WritePNMrow((uint8_t *) m[i], ncol, file);
     694    }
     695
    2099696    /* fermeture du fichier */
    2100697    fclose(file);
    2101698}
     699
     700
     701// Local Variables:
     702// tab-width: 4
     703// c-basic-offset: 4
     704// c-file-offsets:((innamespace . 0)(inline-open . 0))
     705// indent-tabs-mode: nil
     706// End:
     707
     708// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     709
Note: See TracChangeset for help on using the changeset viewer.