Ignore:
Timestamp:
Jun 14, 2016, 5:23:56 PM (9 years ago)
Author:
meunier
Message:
  • Improved scripts for simulations and graphes
  • Continued to clean up the lib nrc2 (from nrio2x.x to nrmem1.c)
  • Added a version (Fast - Parmerge - No stats)
Location:
soft/giet_vm/applications/rosenfeld/nrc2
Files:
13 edited

Legend:

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

    r822 r823  
    88# -- File list ----------
    99FILE = 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
    10 FILE := $(FILE), nrio1f.c, nrio1xf.c, nrio2f.c # comment if giet
     10FILE := $(FILE), nrio1f.c, nrio1xf.c, nrio2f.c nrio2x.c nrio2xf.c nrio3.c # comment if giet
    1111
    1212
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio2x.h

    r772 r823  
    1111#define __NRIO2X_H__
    1212
    13 #ifdef __cplusplus
    14 #pragma message ("C++")
    15 extern "C" {
    16 #endif
    17    
    18 #ifdef VERBOSE_PRAGMA
    19 //#pragma message ("- *** include nrio2x.h ***")
    20 #endif
    2113
    22 IMAGE_EXPORT(void) display_matrix_endline    (byte   **m, long i0, long i1, long j0, long j1, char *format, char *name);
    23 IMAGE_EXPORT(void) display_i16matrix_endline (int16  **m, long i0, long i1, long j0, long j1, char *format, char *name);
    24 IMAGE_EXPORT(void) display_ui16matrix_endline(uint16 **m, long i0, long i1, long j0, long j1, char *format, char *name);
    25 IMAGE_EXPORT(void) display_i32matrix_endline (int32  **m, long i0, long i1, long j0, long j1, char *format, char *name);
    26 IMAGE_EXPORT(void) display_ui32matrix_endline(uint32 **m, long i0, long i1, long j0, long j1, char *format, char *name);
    27 IMAGE_EXPORT(void) display_i64matrix_endline (int64  **m, long i0, long i1, long j0, long j1, char *format, char *name);
    28 IMAGE_EXPORT(void) display_imatrix_endline   (int    **m, long i0, long i1, long j0, long j1, char *format, char *name);
     14/* ------------------------------ */
     15/* --- display_matrix_endline --- */
     16/* --- display_matrix_endline0 --- */
     17/* --- display_matrix_endline1 --- */
     18/* --- display_matrix_number_endline0 --- */
     19/* --- display_matrix_number_endline1 --- */
     20/* ------------------------------ */
    2921
    30 /* ------------------------------- */
    31 /* --- display_matrix_endline0 --- */
     22#define display_type_matrix_endline(t) \
     23void short_name(t,display_,matrix_endline)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name); \
     24void short_name(t,display_,matrix_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name); \
     25void short_name(t,display_,matrix_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name); \
     26void short_name(t,display_,matrix_number_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name); \
     27void short_name(t,display_,matrix_number_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name);
    3228
    33 IMAGE_EXPORT(void) display_bmatrix_endline0   (byte   **m, long i0, long i1, char *format, char *name);
    34 IMAGE_EXPORT(void) display_i16matrix_endline0 (int16  **m, long i0, long i1, char *format, char *name);
    35 IMAGE_EXPORT(void) display_ui16matrix_endline0(uint16 **m, long i0, long i1, char *format, char *name);
    36 IMAGE_EXPORT(void) display_i32matrix_endline0 (int32  **m, long i0, long i1, char *format, char *name);
    37 IMAGE_EXPORT(void) display_ui32matrix_endline0(uint32 **m, long i0, long i1, char *format, char *name);
    38 IMAGE_EXPORT(void) display_i64matrix_endline0 (int64  **m, long i0, long i1, char *format, char *name);
    39 IMAGE_EXPORT(void) display_imatrix_endline0   (int    **m, long i0, long i1, char *format, char *name);
     29display_type_matrix_endline(int8_t);
     30display_type_matrix_endline(uint8_t);
     31display_type_matrix_endline(int16_t);
     32display_type_matrix_endline(uint16_t);
     33display_type_matrix_endline(int32_t);
     34display_type_matrix_endline(uint32_t);
     35display_type_matrix_endline(int64_t);
     36display_type_matrix_endline(uint64_t);
    4037
    41 /* ------------------------------- */
    42 /* --- display_matrix_endline1 --- */
    43 /* ------------------------------- */
    44 IMAGE_EXPORT(void) display_bmatrix_endline1   (byte   **m,long i0, long i1, long j0, long j1, char *format, char *name);
    45 IMAGE_EXPORT(void) display_i16matrix_endline1 (int16  **m,long i0, long i1, long j0, long j1, char *format, char *name);
    46 IMAGE_EXPORT(void) display_ui16matrix_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *name);
    47 IMAGE_EXPORT(void) display_i32matrix_endline1 (int32  **m,long i0, long i1, long j0, long j1, char *format, char *name);
    48 IMAGE_EXPORT(void) display_ui32matrix_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *name);
    49 IMAGE_EXPORT(void) display_i64matrix_endline1 (int64  **m,long i0, long i1, long j0, long j1, char *format, char *name);
    50 IMAGE_EXPORT(void) display_imatrix_endline1   (int    **m,long i0, long i1, long j0, long j1, char *format, char *name);
    51 
    52 /* -------------------------------------- */
    53 /* --- display_matrix_number_endline0 --- */
    54 /* -------------------------------------- */
    55 
    56 IMAGE_EXPORT(void) display_bmatrix_number_endline0   (byte   **m,long i0, long i1, long j0, long j1, char *format, char *name);
    57 IMAGE_EXPORT(void) display_i16matrix_number_endline0 (int16  **m,long i0, long i1, long j0, long j1, char *format, char *name);
    58 IMAGE_EXPORT(void) display_ui16matrix_number_endline0(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *name);
    59 IMAGE_EXPORT(void) display_i32matrix_number_endline0 (int32  **m,long i0, long i1, long j0, long j1, char *format, char *name);
    60 IMAGE_EXPORT(void) display_ui32matrix_number_endline0(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *name);
    61 IMAGE_EXPORT(void) display_i64matrix_number_endline0 (int64  **m,long i0, long i1, long j0, long j1, char *format, char *name);
    62 IMAGE_EXPORT(void) display_imatrix_number_endline0   (int    **m,long i0, long i1, long j0, long j1, char *format, char *name);
    63 
    64 /* -------------------------------------- */
    65 /* --- display_matrix_number_endline1 --- */
    66 /* -------------------------------------- */
    67 
    68 IMAGE_EXPORT(void) display_bmatrix_number_endline1   (byte   **m,long i0, long i1, long j0, long j1, char *format, char *name);
    69 IMAGE_EXPORT(void) display_i16matrix_number_endline1 (int16  **m,long i0, long i1, long j0, long j1, char *format, char *name);
    70 IMAGE_EXPORT(void) display_ui16matrix_number_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *name);
    71 IMAGE_EXPORT(void) display_i32matrix_number_endline1 (int32  **m,long i0, long i1, long j0, long j1, char *format, char *name);
    72 IMAGE_EXPORT(void) display_ui32matrix_number_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *name);
    73 IMAGE_EXPORT(void) display_i64matrix_number_endline1 (int64  **m,long i0, long i1, long j0, long j1, char *format, char *name);
    74 IMAGE_EXPORT(void) display_imatrix_number_endline1   (int    **m,long i0, long i1, long j0, long j1, char *format, char *name);
    7538
    7639/* ------------------------- */
     
    7841/* ------------------------- */
    7942
    80 IMAGE_EXPORT(void) display_btrimatrix   (byte    **m, long i0, long i1, long j0, long j1, long step, char *format, char *name);
    81 IMAGE_EXPORT(void) display_i16trimatrix (int16   **m, long i0, long i1, long j0, long j1, long step, char *format, char *name);
    82 IMAGE_EXPORT(void) display_ui16trimatrix(uint16  **m, long i0, long i1, long j0, long j1, long step, char *format, char *name);
    83 IMAGE_EXPORT(void) display_itrimatrix   (int     **m, long i0, long i1, long j0, long j1, long step, char *format, char *name);
    84 IMAGE_EXPORT(void) display_i32trimatrix (int32   **m, long i0, long i1, long j0, long j1, long step, char *format, char *name);
    85 IMAGE_EXPORT(void) display_f32trimatrix (float32 **m, long i0, long i1, long j0, long j1, long step, char *format, char *name);
    86 IMAGE_EXPORT(void) display_f64trimatrix (float64 **m, long i0, long i1, long j0, long j1, long step, char *format, char *name);
     43#define display_type_trimatrix(t) \
     44void short_name(t,display_,trimatrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step, char * format, char * name);
     45
     46display_type_trimatrix(int8_t);
     47display_type_trimatrix(uint8_t);
     48display_type_trimatrix(int16_t);
     49display_type_trimatrix(uint16_t);
     50display_type_trimatrix(int32_t);
     51display_type_trimatrix(uint32_t);
     52display_type_trimatrix(int64_t);
     53display_type_trimatrix(uint64_t);
     54display_type_trimatrix(float);
     55display_type_trimatrix(double);
     56
     57
     58
    8759
    8860/* ----------------------- */
    8961/* --- write_trimatrix --- */
     62/* --- write_matrix_endline --- */
     63/* --- write_imatrix_endline0 --- */
     64/* --- write_imatrix_endline1 --- */
     65/* --- write_imatrix_number_endline0 --- */
     66/* --- write_imatrix_number_endline1 --- */
     67/* -- fwrite_trimatrix -- */
     68/* -- fread_trimatrix -- */
    9069/* ----------------------- */
    9170
    92 IMAGE_EXPORT(void) write_btrimatrix   (byte    **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename);
    93 IMAGE_EXPORT(void) write_i16trimatrix (int16   **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename);
    94 IMAGE_EXPORT(void) write_ui16trimatrix(uint16  **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename);
    95 IMAGE_EXPORT(void) write_itrimatrix   (int     **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename);
    96 IMAGE_EXPORT(void) write_i32trimatrix (int32   **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename);
    97 IMAGE_EXPORT(void) write_f32trimatrix (float32 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename);
    98 IMAGE_EXPORT(void) write_f64trimatrix (float64 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename);
     71#define write_type_trimatrix(t) \
     72void short_name(t,write_,trimatrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step, char * format, char * filename); \
     73void short_name(t,write_,matrix_endline)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename); \
     74void short_name(t,write_,matrix_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename); \
     75void short_name(t,write_,matrix_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename); \
     76void short_name(t,write_,matrix_number_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename); \
     77void short_name(t,write_,matrix_number_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename); \
     78void short_name(t,fwrite_,trimatrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step, char * filename); \
     79void short_name(t,fread_,trimatrix)(char * filename, t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step);
    9980
    100 /* ---------------------------- */
    101 /* --- write_matrix_endline --- */
    102 /* ---------------------------- */
     81write_type_trimatrix(int8_t);
     82write_type_trimatrix(uint8_t);
     83write_type_trimatrix(int16_t);
     84write_type_trimatrix(uint16_t);
     85write_type_trimatrix(int32_t);
     86write_type_trimatrix(uint32_t);
     87write_type_trimatrix(int64_t);
     88write_type_trimatrix(uint64_t);
     89write_type_trimatrix(float);
     90write_type_trimatrix(double);
    10391
    104 IMAGE_EXPORT(void) write_bmatrix_endline   (byte   **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    105 IMAGE_EXPORT(void) write_i16matrix_endline (int16  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    106 IMAGE_EXPORT(void) write_ui16matrix_endline(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    107 IMAGE_EXPORT(void) write_i32matrix_endline (int32  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    108 IMAGE_EXPORT(void) write_ui32matrix_endline(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    109 IMAGE_EXPORT(void) write_i64matrix_endline (int64  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    110 IMAGE_EXPORT(void) write_imatrix_endline   (int    **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    11192
    112 /* ------------------------------ */
    113 /* --- write_imatrix_endline0 --- */
    114 /* ------------------------------ */
    115 
    116 IMAGE_EXPORT(void) write_bmatrix_endline0   (byte   **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    117 IMAGE_EXPORT(void) write_i16matrix_endline0 (int16  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    118 IMAGE_EXPORT(void) write_ui16matrix_endline0(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    119 IMAGE_EXPORT(void) write_i32matrix_endline0 (int32  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    120 IMAGE_EXPORT(void) write_i64matrix_endline0 (int64  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    121 IMAGE_EXPORT(void) write_ui32matrix_endline0(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    122 IMAGE_EXPORT(void) write_imatrix_endline0   (int    **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    123 
    124 /* ------------------------------ */
    125 /* --- write_imatrix_endline1 --- */
    126 /* ------------------------------ */
    127 
    128 IMAGE_EXPORT(void) write_bmatrix_endline1   (byte   **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    129 IMAGE_EXPORT(void) write_i16matrix_endline1 (int16  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    130 IMAGE_EXPORT(void) write_ui16matrix_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    131 IMAGE_EXPORT(void) write_i32matrix_endline1 (int32  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    132 IMAGE_EXPORT(void) write_ui32matrix_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    133 IMAGE_EXPORT(void) write_i64matrix_endline1 (int64  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    134 IMAGE_EXPORT(void) write_imatrix_endline1   (int    **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    135 
    136 /* ------------------------------------- */
    137 /* --- write_imatrix_number_endline0 --- */
    138 /* ------------------------------------- */
    139 
    140 IMAGE_EXPORT(void) write_bmatrix_number_endline0   (byte   **m, long i0, long i1, long j0, long j1, char *format, char *filename);
    141 IMAGE_EXPORT(void) write_i16matrix_number_endline0 (int16  **m, long i0, long i1, long j0, long j1, char *format, char *filename);
    142 IMAGE_EXPORT(void) write_ui16matrix_number_endline0(uint16 **m, long i0, long i1, long j0, long j1, char *format, char *filename);
    143 IMAGE_EXPORT(void) write_i32matrix_number_endline0 (int32  **m, long i0, long i1, long j0, long j1, char *format, char *filename);
    144 IMAGE_EXPORT(void) write_ui32matrix_number_endline0(uint32 **m, long i0, long i1, long j0, long j1, char *format, char *filename);
    145 IMAGE_EXPORT(void) write_i64matrix_number_endline0 (int64  **m, long i0, long i1, long j0, long j1, char *format, char *filename);
    146 IMAGE_EXPORT(void) write_imatrix_number_endline0   (int    **m, long i0, long i1, long j0, long j1, char *format, char *filename);
    147 
    148 /* ------------------------------------- */
    149 /* --- write_imatrix_number_endline1 --- */
    150 /* ------------------------------------- */
    151 
    152 IMAGE_EXPORT(void) write_bmatrix_number_endline1   (byte   **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    153 IMAGE_EXPORT(void) write_i16matrix_number_endline1 (int16  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    154 IMAGE_EXPORT(void) write_ui16matrix_number_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    155 IMAGE_EXPORT(void) write_i32matrix_number_endline1 (int32  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    156 IMAGE_EXPORT(void) write_ui32matrix_number_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    157 IMAGE_EXPORT(void) write_i64matrix_number_endline1 (int64  **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    158 IMAGE_EXPORT(void) write_imatrix_number_endline1   (int    **m,long i0, long i1, long j0, long j1, char *format, char *filename);
    159 
    160 /* ---------------------- */
    161 /* -- fwrite_trimatrix -- */
    162 /* ---------------------- */
    163 
    164 IMAGE_EXPORT(void) fwrite_btrimatrix   (byte    **m,long i0,long i1,long j0, long j1, long step, char *filename);
    165 IMAGE_EXPORT(void) fwrite_i16trimatrix (int16   **m,long i0,long i1,long j0, long j1, long step, char *filename);
    166 IMAGE_EXPORT(void) fwrite_ui16trimatrix(uint16  **m,long i0,long i1,long j0, long j1, long step, char *filename);
    167 IMAGE_EXPORT(void) fwrite_i32trimatrix (int32   **m,long i0,long i1,long j0, long j1, long step, char *filename);
    168 IMAGE_EXPORT(void) fwrite_f32trimatrix (float32 **m,long i0,long i1,long j0, long j1, long step, char *filename);
    169 IMAGE_EXPORT(void) fwrite_f64trimatrix (float64 **m,long i0,long i1,long j0, long j1, long step, char *filename);
    170 
    171 /* --------------------- */
    172 /* -- fread_trimatrix -- */
    173 /* --------------------- */
    174 
    175 IMAGE_EXPORT(void) fread_btrimatrix   (char *filename, byte    **m,long i0,long i1,long j0, long j1, long step);
    176 IMAGE_EXPORT(void) fread_i16trimatrix (char *filename, int16   **m,long i0,long i1,long j0, long j1, long step);
    177 IMAGE_EXPORT(void) fread_ui16trimatrix(char *filename, uint16  **m,long i0,long i1,long j0, long j1, long step);
    178 IMAGE_EXPORT(void) fread_itrimatrix   (char *filename, int     **m,long i0,long i1,long j0, long j1, long step);
    179 IMAGE_EXPORT(void) fread_i32trimatrix (char *filename, int32   **m,long i0,long i1,long j0, long j1, long step);
    180 IMAGE_EXPORT(void) fread_f32trimatrix (char *filename, float32 **m,long i0,long i1,long j0, long j1, long step);
    181 IMAGE_EXPORT(void) fread_f64trimatrix (char *filename, float64 **m,long i0,long i1,long j0, long j1, long step);
    182 
    183 #ifdef __cplusplus
    184 }
    185 #endif
    18693
    18794#endif /* __NRIO2X_H__ */
     95
     96
     97// Local Variables:
     98// tab-width: 4
     99// c-basic-offset: 4
     100// c-file-offsets:((innamespace . 0)(inline-open . 0))
     101// indent-tabs-mode: nil
     102// End:
     103
     104// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     105
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrio3.h

    r772 r823  
    77 * Univ Paris Sud XI, CNRS
    88*/
     9
     10#ifndef _NR_IO3_H_
     11#define _NR_IO3_H_
     12
    913/* -------------------- */
    1014/* --- display_cube --- */
     15/* -- write_cube -- */
     16/* -- fread_cube -- */
     17/* -- fwrite_cube -- */
    1118/* -------------------- */
    12 IMAGE_EXPORT(void) display_i8cube  (int8    ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name);
    13 IMAGE_EXPORT(void) display_i16cube (int16   ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name);
    14 IMAGE_EXPORT(void) display_ui16cube(uint16  ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name);
    15 IMAGE_EXPORT(void) display_i32cube (int32   ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name);
    16 IMAGE_EXPORT(void) display_ui32cube(uint32  ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name);
    17 IMAGE_EXPORT(void) display_i64cube (int64   ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name);
    18 IMAGE_EXPORT(void) display_f32cube (float32 ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name);
    1919
    20 /* ---------------- */
    21 /* -- write_cube -- */
    22 /* ---------------- */
    23 IMAGE_EXPORT(void) write_i8cube  (int8    ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename);
    24 IMAGE_EXPORT(void) write_i16cube (int16   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename);
    25 IMAGE_EXPORT(void) write_ui16cube(uint16  ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename);
    26 IMAGE_EXPORT(void) write_i32cube (int32   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename);
    27 IMAGE_EXPORT(void) write_ui32cube(uint32  ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename);
    28 IMAGE_EXPORT(void) write_i64cube (int64   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename);
    29 IMAGE_EXPORT(void) write_f32cube (float32 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename);
     20#define display_type_cube(t) \
     21void short_name(t,display_,cube)(t *** c, int32_t ndl, int32_t ndh, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name); \
     22void short_name(t,write_,cube)(t *** c, int32_t ndl, int32_t ndh, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \
     23void short_name(t,fread_,cube)(t *** c, int32_t ndl, int32_t ndh, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename); \
     24void short_name(t,fwrite_,cube)(t *** c, int32_t ndl, int32_t ndh, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename);
    3025
    31 IMAGE_EXPORT(void) fread_i8cube(char   *filename, int8    ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
    32 IMAGE_EXPORT(void) fread_i16cube(char  *filename, int16   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
    33 IMAGE_EXPORT(void) fread_ui16cube(char *filename, uint16  ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
    34 IMAGE_EXPORT(void) fread_i32cube(char  *filename, int32   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
    35 IMAGE_EXPORT(void) fread_ui32cube(char *filename, uint32  ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
    36 IMAGE_EXPORT(void) fread_i64cube(char  *filename, int64   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
    37 IMAGE_EXPORT(void) fread_f32cube(char  *filename, float32 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
     26display_type_cube(int8_t);
     27display_type_cube(uint8_t);
     28display_type_cube(int16_t);
     29display_type_cube(uint16_t);
     30display_type_cube(int32_t);
     31display_type_cube(uint32_t);
     32display_type_cube(int64_t);
     33display_type_cube(uint64_t);
     34display_type_cube(float);
     35display_type_cube(double);
    3836
    39 /* ----------------- */
    40 /* -- fwrite_cube -- */
    41 /* ----------------- */
    42 IMAGE_EXPORT(void) fwrite_i8cube(int8     ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    43 IMAGE_EXPORT(void) fwrite_i16cube(int16   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    44 IMAGE_EXPORT(void) fwrite_ui16cube(uint16 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    45 IMAGE_EXPORT(void) fwrite_i32cube(int32   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    46 IMAGE_EXPORT(void) fwrite_ui32cube(uint32 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    47 IMAGE_EXPORT(void) fwrite_i64cube(int64   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
     37#endif
     38
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrlinalg.h

    r772 r823  
    1111#define __NRLINALG_H__
    1212
    13 #ifdef __cplusplus
    14 extern "C" {
    15 #endif
     13#define transpose_type_matrix(t) \
     14void short_name(t,transpose_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** D); \
     15void short_name(t,transpose1_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch);
    1616
    17 IMAGE_EXPORT(void) transpose_bmatrix(byte **S, long nrl,long nrh,long ncl, long nch, byte **D);
    18 IMAGE_EXPORT(void) transpose_si16matrix(sint16 **S, long nrl,long nrh,long ncl, long nch, sint16 **D);
    19 IMAGE_EXPORT(void) transpose_ui16matrix(uint16 **S, long nrl,long nrh,long ncl, long nch, uint16 **D);
    20 IMAGE_EXPORT(void) transpose_si32matrix(sint32 **S, long nrl,long nrh,long ncl, long nch, sint32 **D);
    21 IMAGE_EXPORT(void) transpose_ui32matrix(uint32 **S, long nrl,long nrh,long ncl, long nch, uint32 **D);
    22 IMAGE_EXPORT(void) transpose_f32matrix(float32 **S, long nrl,long nrh,long ncl, long nch, float32 **D);
    23 IMAGE_EXPORT(void) transpose_dmatrix(float64 **S, long nrl,long nrh,long ncl, long nch, float64 **D);
    24 IMAGE_EXPORT(void) transpose_rgb8matrix(rgb8 **S, long nrl,long nrh,long ncl, long nch, rgb8 **D);
    25 IMAGE_EXPORT(void) transpose1_bmatrix(byte **S, long nrl,long nrh,long ncl, long nch);
    26 IMAGE_EXPORT(void) transpose1_si16matrix(sint16 **S, long nrl,long nrh,long ncl, long nch);
    27 IMAGE_EXPORT(void) transpose1_ui16matrix(uint16 **S, long nrl,long nrh,long ncl, long nch);
    28 IMAGE_EXPORT(void) transpose1_si32matrix(sint32 **S, long nrl,long nrh,long ncl, long nch);
    29 IMAGE_EXPORT(void) transpose1_ui32matrix(uint32 **S, long nrl,long nrh,long ncl, long nch);
    30 IMAGE_EXPORT(void) transpose1_f32matrix(float32 **S, long nrl,long nrh,long ncl, long nch);
    31 IMAGE_EXPORT(void) transpose1_f64matrix(float64 **S, long nrl,long nrh,long ncl, long nch);
    32 IMAGE_EXPORT(void) transpose1_rgb8matrix(rgb8 **S, long nrl,long nrh,long ncl, long nch);
     17transpose_type_matrix(int8_t);
     18transpose_type_matrix(uint8_t);
     19transpose_type_matrix(int16_t);
     20transpose_type_matrix(uint16_t);
     21transpose_type_matrix(int32_t);
     22transpose_type_matrix(uint32_t);
     23transpose_type_matrix(int64_t);
     24transpose_type_matrix(uint64_t);
     25transpose_type_matrix(float);
     26transpose_type_matrix(double);
     27transpose_type_matrix(rgb8);
     28transpose_type_matrix(rgbx8);
    3329
    34 #ifdef __cplusplus
    35 }
    36 #endif
    3730
    3831#endif // __NRLINALG_H__
     32
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrlut.h

    r772 r823  
    55/*
    66 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved
    7 * Univ Paris Sud XI, CNRS
    8 */
     7 * Univ Paris Sud XI, CNRS
     8 */
    99
    1010#ifndef _NRLUT_H_
    1111#define _NRLUT_H_
    1212
    13 #ifdef __cplusplus
    14 #ifdef PRAGMA_VERBOSE
    15 #pragma message ("C++")
    16 #endif
    17 extern "C" {
    18 #endif
     13#define init_type_lut(t) \
     14void short_name(t,init_,lut)(t * v, int32_t nl, int32_t nh, int32_t n0, int32_t n1, t k); \
     15void short_name(t,lut_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t * L, t ** D);
    1916
    20 #ifdef PRAGMA_VERBOSE
    21 #pragma message("- include nrlut.h")
    22 #endif
     17init_type_lut(int8_t);
     18init_type_lut(uint8_t);
     19init_type_lut(int16_t);
     20init_type_lut(uint16_t);
     21init_type_lut(int32_t);
     22init_type_lut(uint32_t);
     23init_type_lut(rgb8);
    2324
    2425
    25 IMAGE_EXPORT(void) init_blut   (byte   *v, int nl, int nh, int n0, int n1, byte   k);
    26 IMAGE_EXPORT(void) init_i8lut  (int8   *v, int nl, int nh, int n0, int n1, int8   k);
    27 IMAGE_EXPORT(void) init_i16lut (int16  *v, int nl, int nh, int n0, int n1, int16  k);
    28 IMAGE_EXPORT(void) init_i32lut (int32  *v, int nl, int nh, int n0, int n1, int32  k);
    29 IMAGE_EXPORT(void) init_ui16lut(uint16 *v, int nl, int nh, int n0, int n1, uint16 k);
    30 IMAGE_EXPORT(void) init_rgb8lut(rgb8   *v, int nl, int nh, int n0, int n1, rgb8   k);
     26void lut_si16matrix_si8matrix(int16_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int8_t * L, int8_t ** D);
     27void lut_ui16matrix_ui8matrix(uint16_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t * L, uint8_t ** D);
     28void lut_si32matrix_si16matrix(int32_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int16_t * L, int16_t ** D);
     29void lut_ui32matrix_ui16matrix(uint32_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint16_t * L, uint16_t ** D);
    3130
    32 IMAGE_EXPORT(void) lut_bmatrix   (byte    **S, long nrl, long nrh, long ncl, long nch, byte    *L, byte    **D);
    33 IMAGE_EXPORT(void) lut_ui8matrix (uint8   **S, long nrl, long nrh, long ncl, long nch, uint8   *L, uint8   **D);
    34 IMAGE_EXPORT(void) lut_si8matrix (sint8   **S, long nrl, long nrh, long ncl, long nch, sint8   *L, sint8   **D);
    35 IMAGE_EXPORT(void) lut_ui16matrix(uint16  **S, long nrl, long nrh, long ncl, long nch, uint16  *L, uint16  **D);
    36 IMAGE_EXPORT(void) lut_si16matrix(sint16  **S, long nrl, long nrh, long ncl, long nch, sint16  *L, sint16  **D);
    37 IMAGE_EXPORT(void) lut_ui32matrix(uint32  **S, long nrl, long nrh, long ncl, long nch, uint32  *L, uint32  **D);
    38 IMAGE_EXPORT(void) lut_si32matrix(sint32  **S, long nrl, long nrh, long ncl, long nch, sint32  *L, sint32  **D);
    39 IMAGE_EXPORT(void) lut_rgb8matrix(rgb8    **S, long nrl, long nrh, long ncl, long nch, rgb8    *L, rgb8    **D);
    4031
    41 IMAGE_EXPORT(void) lut_si16matrix_si8matrix(sint16 **S, long nrl, long nrh, long ncl, long nch, sint8 *L, sint8 **D);
    42 IMAGE_EXPORT(void) lut_ui16matrix_ui8matrix(uint16 **S, long nrl, long nrh, long ncl, long nch, uint8 *L, uint8 **D);
    43 IMAGE_EXPORT(void) lut_si32matrix_si16matrix(sint32 **S, long nrl, long nrh, long ncl, long nch, sint16 *L, sint16 **D);
    44 IMAGE_EXPORT(void) lut_ui32matrix_ui16matrix(uint32 **S, long nrl, long nrh, long ncl, long nch, uint16 *L, uint16 **D);
    45    
    46 IMAGE_EXPORT(void) histogram_bmatrix   (byte   **S, long nrl, long nrh, long ncl, long nch, int32 *H);
    47 IMAGE_EXPORT(void) histogram_ui16matrix(uint16 **S, long nrl, long nrh, long ncl, long nch, int32 *H);
    48 IMAGE_EXPORT(void) histogram_rgb8matrix(rgb8   **S, long nrl, long nrh, long ncl, long nch, rgb32 *H);
     32#define histogram_type_matrix(t) \
     33void short_name(t,histogram_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t * H);
    4934
    50 #ifdef __cplusplus
    51 }
    52 #endif
     35histogram_type_matrix(int8_t);
     36histogram_type_matrix(uint8_t);
     37histogram_type_matrix(int16_t);
     38histogram_type_matrix(uint16_t);
     39histogram_type_matrix(int32_t);
     40histogram_type_matrix(uint32_t);
     41void histogram_rgb8matrix(rgb8 ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb32 * H);
     42
    5343
    5444#endif /* _NRLUT_H_ */
     45
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrmem1.h

    r772 r823  
    1212#define __NRMEM1_H__
    1313
    14 #ifdef __cplusplus
    15 #pragma message ("C++")
    16 extern "C" {
    17 #endif
    18    
    19 #ifdef VERBOSE_PRAGMA
    20 //#pragma message ("- *** include nrmem1.h ***")
    21 #endif
     14
     15#define dup_type_vector(t) \
     16void short_name(t,dup_,vector)(t * X, int32_t nl, int32_t nh, t * Y);
     17
     18dup_type_vector(int8_t);
     19dup_type_vector(uint8_t);
     20dup_type_vector(int16_t);
     21dup_type_vector(uint16_t);
     22dup_type_vector(int32_t);
     23dup_type_vector(uint32_t);
     24dup_type_vector(int64_t);
     25dup_type_vector(uint64_t);
     26dup_type_vector(float);
     27dup_type_vector(double);
     28dup_type_vector(rgb8);
     29dup_type_vector(rgbx8);
     30
     31/* --------------------- */
     32/* --- split & merge --- */
     33/* --------------------- */
     34
     35void split_rgb8vector(rgb8 * X, int32_t nl, int32_t nh,  uint8_t * R,  uint8_t * G,  uint8_t * B);
     36void split_rgb32vector(rgb32 * X, int32_t nl, int32_t nh, uint32_t * R, uint32_t * G, uint32_t * B);
     37
     38void merge_rgb8vector(uint8_t * R, uint8_t * G, uint8_t * B, int32_t nl, int32_t nh, rgb8 * X);
     39void merge_rgb32vector(uint32_t * R, uint32_t * G, uint32_t * B, int32_t nl, int32_t nh, rgb32 * X);
    2240
    2341
    24 IMAGE_EXPORT(void) dup_si8vector   (sint8   *X, long nl, long nh, sint8   *Y);
    25 IMAGE_EXPORT(void) dup_ui8vector   (uint8   *X, long nl, long nh, uint8   *Y);
    26 IMAGE_EXPORT(void) dup_si16vector  (sint16  *X, long nl, long nh, sint16  *Y);
    27 IMAGE_EXPORT(void) dup_ui16vector  (uint16  *X, long nl, long nh, uint16  *Y);
    28 IMAGE_EXPORT(void) dup_si32vector  (sint32  *X, long nl, long nh, sint32  *Y);
    29 IMAGE_EXPORT(void) dup_ui32vector  (uint32  *X, long nl, long nh, uint32  *Y);
    30 IMAGE_EXPORT(void) dup_si64vector  (sint64  *X, long nl, long nh, sint64  *Y);
    31 IMAGE_EXPORT(void) dup_ui64vector  (uint64  *X, long nl, long nh, uint64  *Y);
    32 IMAGE_EXPORT(void) dup_f32vector   (float32 *X, long nl, long nh, float32 *Y);
    33 IMAGE_EXPORT(void) dup_f64vector   (float64 *X, long nl, long nh, float64 *Y);
    34 IMAGE_EXPORT(void) dup_rgb8vector  (rgb8    *X, long nl, long nh, rgb8    *Y);
    35 IMAGE_EXPORT(void) dup_rgbx8vector (rgbx8   *X, long nl, long nh, rgbx8   *Y);
    3642
    3743/* ---------------- */
    38 /* -- Convertion -- */
     44/* -- Conversion -- */
    3945/* ---------------- */
    4046
    41 // UP
     47#define convert_type1_vector_type2_vector(t1, t2) \
     48void short_name(t1,convert_,short_name(t2,vector_,vector))(t1 * X, int32_t nl, int32_t nh, t2 * Y);
    4249
    43 IMAGE_EXPORT(void) convert_si8vector_si16vector (sint8 *X, long nl, long nh, sint16  *Y);
    44 IMAGE_EXPORT(void) convert_si8vector_si32vector (sint8 *X, long nl, long nh, sint32  *Y);
    45 IMAGE_EXPORT(void) convert_si8vector_f32vector  (sint8 *X, long nl, long nh, float32 *Y);
    46 IMAGE_EXPORT(void) convert_si8vector_f64vector  (sint8 *X, long nl, long nh, float64 *Y);
     50convert_type1_vector_type2_vector(int8_t,int16_t);
     51convert_type1_vector_type2_vector(int8_t,int32_t);
     52convert_type1_vector_type2_vector(int8_t,float);
     53convert_type1_vector_type2_vector(int8_t,double);
     54convert_type1_vector_type2_vector(uint8_t,uint16_t);
     55convert_type1_vector_type2_vector(uint8_t,uint32_t);
     56convert_type1_vector_type2_vector(uint8_t,float);
     57convert_type1_vector_type2_vector(uint8_t,double);
     58convert_type1_vector_type2_vector(int16_t,int32_t);
     59convert_type1_vector_type2_vector(int16_t,float);
     60convert_type1_vector_type2_vector(int16_t,double);
     61convert_type1_vector_type2_vector(uint16_t,uint32_t);
     62convert_type1_vector_type2_vector(uint16_t,float);
     63convert_type1_vector_type2_vector(uint16_t,double);
     64convert_type1_vector_type2_vector(int32_t,float);
     65convert_type1_vector_type2_vector(int32_t,double);
     66convert_type1_vector_type2_vector(uint32_t,float);
     67convert_type1_vector_type2_vector(uint32_t,double);
     68convert_type1_vector_type2_vector(int16_t,int8_t);
     69convert_type1_vector_type2_vector(uint16_t,uint8_t);
     70convert_type1_vector_type2_vector(int32_t,int8_t);
     71convert_type1_vector_type2_vector(int32_t,int16_t);
     72convert_type1_vector_type2_vector(uint32_t,uint8_t);
     73convert_type1_vector_type2_vector(uint32_t,uint16_t);
     74convert_type1_vector_type2_vector(float,int8_t);
     75convert_type1_vector_type2_vector(float,uint8_t);
     76convert_type1_vector_type2_vector(float,int16_t);
     77convert_type1_vector_type2_vector(float,uint16_t);
     78convert_type1_vector_type2_vector(float,int32_t);
     79convert_type1_vector_type2_vector(float,uint32_t);
     80convert_type1_vector_type2_vector(double,int8_t);
     81convert_type1_vector_type2_vector(double,uint8_t);
     82convert_type1_vector_type2_vector(double,int16_t);
     83convert_type1_vector_type2_vector(double,uint16_t);
     84convert_type1_vector_type2_vector(double,int32_t);
     85convert_type1_vector_type2_vector(double,uint32_t);
     86convert_type1_vector_type2_vector(double,float);
     87convert_type1_vector_type2_vector(uint8_t,rgb8);
     88convert_type1_vector_type2_vector(uint8_t,rgbx8);
     89convert_type1_vector_type2_vector(rgb8,uint8_t);
     90convert_type1_vector_type2_vector(rgbx8,uint8_t);
    4791
    48 IMAGE_EXPORT(void) convert_ui8vector_ui16vector (uint8 *X, long nl, long nh, uint16  *Y);
    49 IMAGE_EXPORT(void) convert_ui8vector_ui32vector (uint8 *X, long nl, long nh, uint32  *Y);
    50 IMAGE_EXPORT(void) convert_ui8vector_f32vector  (uint8 *X, long nl, long nh, float32 *Y);
    51 IMAGE_EXPORT(void) convert_ui8vector_f64vector  (uint8 *X, long nl, long nh, float64 *Y);
    52 IMAGE_EXPORT(void) convert_ui8vector_rgb8vector (uint8 *X, long nl, long nh, rgb8    *Y);
    53 IMAGE_EXPORT(void) convert_ui8vector_rgbx8vector(uint8 *X, long nl, long nh, rgbx8   *Y);
    54 
    55 IMAGE_EXPORT(void) convert_si16vector_si32vector (sint16 *X, long nl, long nh, sint32  *Y);
    56 IMAGE_EXPORT(void) convert_si16vector_f32vector  (sint16 *X, long nl, long nh, float32 *Y);
    57 IMAGE_EXPORT(void) convert_si16vector_f64vector  (sint16 *X, long nl, long nh, float64 *Y);
    58 
    59 IMAGE_EXPORT(void) convert_ui16vector_ui32vector (uint16 *X, long nl, long nh, uint32  *Y);
    60 IMAGE_EXPORT(void) convert_ui16vector_f32vector  (uint16 *X, long nl, long nh, float32 *Y);
    61 IMAGE_EXPORT(void) convert_ui16vector_f64vector  (uint16 *X, long nl, long nh, float64 *Y);
    62 
    63 IMAGE_EXPORT(void) convert_si32vector_f32vector (sint32 *X, long nl, long nh, float32 *Y);
    64 IMAGE_EXPORT(void) convert_si32vector_f64vector (sint32 *X, long nl, long nh, float64 *Y);
    65 
    66 IMAGE_EXPORT(void) convert_ui32vector_f32vector (uint32 *X, long nl, long nh, float32 *Y);
    67 IMAGE_EXPORT(void) convert_ui32vector_f64vector (uint32 *X, long nl, long nh, float64 *Y);
    68 
    69 IMAGE_EXPORT(void) convert_f32vector_f64vector (float32 *X, long nl, long nh, float64 *Y);
    70 
    71 // DOWN
    72 
    73 IMAGE_EXPORT(void) convert_si16vector_si8vector(sint16 *X, long nl, long nh, sint8 *Y);
    74 
    75 IMAGE_EXPORT(void) convert_ui16vector_ui8vector(uint16 *X, long nl, long nh, uint8 *Y);
    76 
    77 IMAGE_EXPORT(void) convert_si32vector_si8vector (sint32 *X, long nl, long nh, sint8  *Y);
    78 IMAGE_EXPORT(void) convert_si32vector_si16vector(sint32 *X, long nl, long nh, sint16 *Y);
    79 
    80 IMAGE_EXPORT(void) convert_ui32vector_ui8vector (uint32 *X, long nl, long nh, uint8  *Y);
    81 IMAGE_EXPORT(void) convert_ui32vector_ui16vector(uint32 *X, long nl, long nh, uint16 *Y);
    82 
    83 IMAGE_EXPORT(void) convert_f32vector_si8vector (float32 *X, long nl, long nh, sint8  *Y);
    84 IMAGE_EXPORT(void) convert_f32vector_ui8vector (float32 *X, long nl, long nh, uint8  *Y);
    85 IMAGE_EXPORT(void) convert_f32vector_si16vector(float32 *X, long nl, long nh, sint16 *Y);
    86 IMAGE_EXPORT(void) convert_f32vector_ui16vector(float32 *X, long nl, long nh, uint16 *Y);
    87 IMAGE_EXPORT(void) convert_f32vector_si32vector(float32 *X, long nl, long nh, sint32 *Y);
    88 IMAGE_EXPORT(void) convert_f32vector_ui32vector(float32 *X, long nl, long nh, uint32 *Y);
    89 
    90 IMAGE_EXPORT(void) convert_f64vector_si8vector (float64 *X, long nl, long nh, sint8   *Y);
    91 IMAGE_EXPORT(void) convert_f64vector_ui8vector (float64 *X, long nl, long nh, uint8   *Y);
    92 IMAGE_EXPORT(void) convert_f64vector_si16vector(float64 *X, long nl, long nh, sint16  *Y);
    93 IMAGE_EXPORT(void) convert_f64vector_ui16vector(float64 *X, long nl, long nh, uint16  *Y);
    94 IMAGE_EXPORT(void) convert_f64vector_si32vector(float64 *X, long nl, long nh, sint32  *Y);
    95 IMAGE_EXPORT(void) convert_f64vector_ui32vector(float64 *X, long nl, long nh, uint32  *Y);
    96 IMAGE_EXPORT(void) convert_f64vector_f32vector (float64 *X, long nl, long nh, float32 *Y);
    97 
    98 IMAGE_EXPORT(void) convert_rgb8vector_ui8vector (rgb8  *X, long nl, long nh, uint8 *Y);
    99 IMAGE_EXPORT(void) convert_rgbx8vector_ui8vector(rgbx8 *X, long nl, long nh, uint8 *Y);
    10092
    10193/*
     
    10597 */
    10698
    107 IMAGE_EXPORT(void) lowpart_ui16vector_ui8vector(uint16 *X, long nl,long nh, uint8 *Y);
    108 IMAGE_EXPORT(void) lowpart_ui32vector_ui8vector(uint32 *X, long nl,long nh, uint8 *Y);
    109 
    110 /* --------------------- */
    111 /* --- split & merge --- */
    112 /* --------------------- */
    113 
    114 IMAGE_EXPORT(void) split_rgb8vector(rgb8   *X, long nl, long nh,  uint8 *R,  uint8 *G,  uint8 *B);
    115 IMAGE_EXPORT(void) split_rgb32vector(rgb32 *X, long nl, long nh, uint32 *R, uint32 *G, uint32 *B);
    116 
    117 IMAGE_EXPORT(void) merge_rgb8vector(uint8   *R, uint8  *G, uint8  *B, long nl, long nh, rgb8  *X);
    118 IMAGE_EXPORT(void) merge_rgb32vector(uint32 *R, uint32 *G, uint32 *B, long nl, long nh, rgb32 *X);
    119 
    120 #ifdef __cplusplus
    121 }
    122 #endif
     99void lowpart_ui16vector_ui8vector(uint16_t * X, int32_t nl, int32_t nh, uint8_t * Y);
     100void lowpart_ui32vector_ui8vector(uint32_t * X, int32_t nl, int32_t nh, uint8_t * Y);
    123101
    124102#endif /* __NRMEM1_H__ */
     103
  • soft/giet_vm/applications/rosenfeld/nrc2/include/nrtype.h

    r822 r823  
    2424// Short names
    2525
    26 #define sn_int8_t(p,s)      p##i8##s
    27 #define sn_int16_t(p,s)     p##i16##s
    28 #define sn_int32_t(p,s)     p##i32##s
    29 #define sn_int64_t(p,s)     p##i64##s
     26#define sn_int8_t(p,s)      p##si8##s
     27#define sn_int16_t(p,s)     p##si16##s
     28#define sn_int32_t(p,s)     p##si32##s
     29#define sn_int64_t(p,s)     p##si64##s
    3030#define sn_uint8_t(p,s)     p##ui8##s
    3131#define sn_uint16_t(p,s)    p##ui16##s
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2x.c

    r772 r823  
    2626#include "nrio2x.h"
    2727
     28
     29
    2830/* ------------------------------ */
    2931/* --- display_matrix_endline --- */
    3032/* ------------------------------ */
    31 /* ---------------------------------------------------------------------------------------------------------- */
    32 IMAGE_EXPORT(void) display_matrix_endline(byte **m,long i0, long i1, long j0, long j1, char *format, char *name)
    33 /* ---------------------------------------------------------------------------------------------------------- */
    34 {
    35   int i, j;
    36   int n = (i1-i0+1) * (j1-j0+1);
    37   byte *p = &m[i0][j0];
    38 
    39   if(name != NULL) puts(name);
    40 
    41   for(i=i0; i<=i1; i++) {
    42     for(j=j0; j<=j0+n; j++) {
    43       printf(format, *p++);
    44     }
    45     putchar('\n');
    46   }
    47   putchar('\n');
    48 }
    49 /* -------------------------------------------------------------------------------------------------------------- */
    50 IMAGE_EXPORT(void) display_i16matrix_endline(int16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    51 /* -------------------------------------------------------------------------------------------------------------- */
    52 {
    53   int i, j;
    54   int n = (i1-i0+1) * (j1-j0+1);
    55   int16 *p = &m[i0][j0];
    56 
    57   if(name != NULL) puts(name);
    58 
    59   for(i=i0; i<=i1; i++) {
    60     for(j=j0; j<=j0+n; j++) {
    61       printf(format, *p++);
    62     }
    63     putchar('\n');
    64   }
    65   putchar('\n');
    66 }
    67 /* ---------------------------------------------------------------------------------------------------------------- */
    68 IMAGE_EXPORT(void) display_ui16matrix_endline(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    69 /* ---------------------------------------------------------------------------------------------------------------- */
    70 {
    71   int i, j;
    72   int n = (i1-i0+1) * (j1-j0+1);
    73   uint16 *p = &m[i0][j0];
    74 
    75   if(name != NULL) puts(name);
    76 
    77   for(i=i0; i<=i1; i++) {
    78     for(j=j0; j<=j0+n; j++) {
    79       printf(format, *p++);
    80     }
    81     putchar('\n');
    82   }
    83   putchar('\n');
    84 }
    85 /* -------------------------------------------------------------------------------------------------------------- */
    86 IMAGE_EXPORT(void) display_i32matrix_endline(int32 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    87 /* -------------------------------------------------------------------------------------------------------------- */
    88 {
    89   int i, j;
    90   int n = (i1-i0+1) * (j1-j0+1);
    91   int32 *p = &m[i0][j0];
    92 
    93   if(name != NULL) puts(name);
    94 
    95   for(i=i0; i<=i1; i++) {
    96     for(j=j0; j<=j0+n; j++) {
    97       printf(format, *p++);
    98     }
    99     putchar('\n');
    100   }
    101   putchar('\n');
    102 }
    103 /* ----------------------------------------------------------------------------------------------------------------- */
    104 IMAGE_EXPORT(void) display_ui32matrix_endline(uint32 **m, long i0, long i1, long j0, long j1, char *format, char *name)
    105 /* ----------------------------------------------------------------------------------------------------------------- */
    106 {
    107   int i, j;
    108   int n = (i1-i0+1) * (j1-j0+1);
    109   uint32 *p = &m[i0][j0];
    110 
    111   if(name != NULL) puts(name);
    112 
    113   for(i=i0; i<=i1; i++) {
    114     for(j=j0; j<=j0+n; j++) {
    115       printf(format, *p++);
    116     }
    117     putchar('\n');
    118   }
    119   putchar('\n');
    120 }
    121 /* -------------------------------------------------------------------------------------------------------------- */
    122 IMAGE_EXPORT(void) display_i64matrix_endline(int64 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    123 /* -------------------------------------------------------------------------------------------------------------- */
    124 {
    125   int i, j;
    126   int n = (i1-i0+1) * (j1-j0+1);
    127   int64 *p = &m[i0][j0];
    128 
    129   if(name != NULL) puts(name);
    130 
    131   for(i=i0; i<=i1; i++) {
    132     for(j=j0; j<=j0+n; j++) {
    133       printf(format, *p++);
    134     }
    135     putchar('\n');
    136   }
    137   putchar('\n');
    138 }
    139 /* ---------------------------------------------------------------------------------------------------------- */
    140 IMAGE_EXPORT(void) display_imatrix_endline(int **m,long i0, long i1, long j0, long j1, char *format, char *name)
    141 /* ---------------------------------------------------------------------------------------------------------- */
    142 {
    143   int i, j;
    144   int n = (i1-i0+1) * (j1-j0+1);
    145   int *p = &m[i0][j0];
    146 
    147   if(name != NULL) puts(name);
    148 
    149   for(i=i0; i<=i1; i++) {
    150     for(j=j0; j<=j0+n; j++) {
    151       printf(format, *p++);
    152     }
    153     putchar('\n');
    154   }
    155   putchar('\n');
    156 }
     33
     34#undef display_type_matrix_endline
     35#define display_type_matrix_endline(t) \
     36void short_name(t,display_,matrix_endline)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
     37{                                                \
     38    int32_t n = (i1 - i0 + 1) * (j1 - j0 + 1);   \
     39    t * p = &m[i0][j0];                          \
     40                                                 \
     41    if (name != NULL) {                          \
     42        printf(name);                            \
     43    }                                            \
     44                                                 \
     45    for (int32_t i = i0; i <= i1; i++) {         \
     46        for (int32_t j = j0; j <= j0 + n; j++) { \
     47            printf(format, *p++);                \
     48        }                                        \
     49        printf("\n");                            \
     50    }                                            \
     51    printf("\n");                                \
     52}
     53
     54display_type_matrix_endline(int8_t);
     55display_type_matrix_endline(uint8_t);
     56display_type_matrix_endline(int16_t);
     57display_type_matrix_endline(uint16_t);
     58display_type_matrix_endline(int32_t);
     59display_type_matrix_endline(uint32_t);
     60display_type_matrix_endline(int64_t);
     61display_type_matrix_endline(uint64_t);
     62
     63
    15764/* ------------------------------- */
    15865/* --- display_matrix_endline0 --- */
    15966/* ------------------------------- */
    160 /* ------------------------------------------------------------------------------------------------------------ */
    161 //IMAGE_EXPORT(void) display_bmatrix_endline0(byte **m,long i0, long i1, long j0, long j1, char *format, char *name)
    162 /* ------------------------------------------------------------------------------------------------------------ */
    163 /*{
    164   int i, j, n;
    165 
    166   if(name != NULL) puts(name);
    167 
    168   for(i=i0; i<=i1; i++) {
    169     n = m[i][j0];
    170     for(j=j0; j<=j0+n; j++) {
    171       printf(format, m[i][j]);
    172     }
    173     putchar('\n');
    174   }
    175   putchar('\n');
    176 }*/
    177 /* ----------------------------------------------------------------------------------------- */
    178 IMAGE_EXPORT(void) display_bmatrix_endline0(byte **m,long i0, long i1,char *format, char *name)
    179 /* ----------------------------------------------------------------------------------------- */
    180 {
    181   int i, j, n;
    182 
    183   if(name != NULL) puts(name);
    184 
    185   for(i=i0; i<=i1; i++) {
    186     printf("[%3d] ", i);
    187     n = m[i][0];
    188     for(j=1; j<=+n; j++) {
    189       printf(format, m[i][j]);
    190     }
    191     putchar('\n');
    192   }
    193   putchar('\n');
    194 }
    195 /* --------------------------------------------------------------------------------------------------------------- */
    196 //IMAGE_EXPORT(void) display_i16matrix_endline0(int16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    197 /* --------------------------------------------------------------------------------------------------------------- */
    198 /*{
    199   int i, j, n;
    200 
    201   if(name != NULL) puts(name);
    202 
    203   for(i=i0; i<=i1; i++) {
    204     n = m[i][j0];
    205     for(j=j0; j<=j0+n; j++) {
    206       printf(format, m[i][j]);
    207     }
    208     putchar('\n');
    209   }
    210   putchar('\n');
    211 }*/
    212 /* --------------------------------------------------------------------------------------------- */
    213 IMAGE_EXPORT(void) display_i16matrix_endline0(int16 **m,long i0, long i1, char *format, char *name)
    214 /* --------------------------------------------------------------------------------------------- */
    215 {
    216   int i, j, n;
    217 
    218   if(name != NULL) puts(name);
    219 
    220   for(i=i0; i<=i1; i++) {
    221     printf("[%3d] ", i);
    222     n = m[i][0];
    223     for(j=1; j<=+n; j++) {
    224       printf(format, m[i][j]);
    225     }
    226     putchar('\n');
    227   }
    228   putchar('\n');
    229 }
    230 /* ---------------------------------------------------------------------------------------------------------------- */
    231 //IMAGE_EXPORT(void) display_ui16matrix_endline0(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    232 /* ---------------------------------------------------------------------------------------------------------------- */
    233 /*{
    234   int i, j, n;
    235 
    236   if(name != NULL) puts(name);
    237 
    238   for(i=i0; i<=i1; i++) {
    239     n = m[i][j0];
    240     for(j=j0; j<=j0+n; j++) {
    241       printf(format, m[i][j]);
    242     }
    243     putchar('\n');
    244   }
    245   putchar('\n');
    246 }*/
    247 /* ----------------------------------------------------------------------------------------------- */
    248 IMAGE_EXPORT(void) display_ui16matrix_endline0(uint16 **m,long i0, long i1, char *format, char *name)
    249 /* ----------------------------------------------------------------------------------------------- */
    250 {
    251   int i, j, n;
    252 
    253   if(name != NULL) puts(name);
    254 
    255   for(i=i0; i<=i1; i++) {
    256     printf("[%3d] ", i);
    257     n = m[i][0];
    258     for(j=1; j<=+n; j++) {
    259       printf(format, m[i][j]);
    260     }
    261     putchar('\n');
    262   }
    263   putchar('\n');
    264 }
    265 /* --------------------------------------------------------------------------------------------------------------- */
    266 //IMAGE_EXPORT(void) display_i32matrix_endline0(int32 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    267 /* --------------------------------------------------------------------------------------------------------------- */
    268 /*{
    269   int i, j, n;
    270 
    271   if(name != NULL) puts(name);
    272 
    273   for(i=i0; i<=i1; i++) {
    274     n = m[i][j0];
    275     for(j=j0; j<=j0+n; j++) {
    276       printf(format, m[i][j]);
    277     }
    278     putchar('\n');
    279   }
    280   putchar('\n');
    281 }*/
    282 /* --------------------------------------------------------------------------------------------- */
    283 IMAGE_EXPORT(void) display_i32matrix_endline0(int32 **m,long i0, long i1, char *format, char *name)
    284 /* --------------------------------------------------------------------------------------------- */
    285 {
    286   int i, j, n;
    287 
    288   if(name != NULL) puts(name);
    289 
    290   for(i=i0; i<=i1; i++) {
    291     printf("[%3d] ", i);
    292     n = m[i][0];
    293     for(j=1; j<=+n; j++) {
    294       printf(format, m[i][j]);
    295     }
    296     putchar('\n');
    297   }
    298   putchar('\n');
    299 }
    300 /* ---------------------------------------------------------------------------------------------------------------- */
    301 //IMAGE_EXPORT(void) display_ui32matrix_endline0(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    302 /* ---------------------------------------------------------------------------------------------------------------- */
    303 /*{
    304   int i, j, n;
    305 
    306   if(name != NULL) puts(name);
    307 
    308   for(i=i0; i<=i1; i++) {
    309     n = m[i][j0];
    310     for(j=j0; j<=j0+n; j++) {
    311       printf(format, m[i][j]);
    312     }
    313     putchar('\n');
    314   }
    315   putchar('\n');
    316 }*/
    317 /* ----------------------------------------------------------------------------------------------- */
    318 IMAGE_EXPORT(void) display_ui32matrix_endline0(uint32 **m,long i0, long i1, char *format, char *name)
    319 /* ----------------------------------------------------------------------------------------------- */
    320 {
    321   int i, j, n;
    322 
    323   if(name != NULL) puts(name);
    324 
    325   for(i=i0; i<=i1; i++) {
    326     printf("[%3d] ", i);
    327     n = m[i][0];
    328     for(j=1; j<=+n; j++) {
    329       printf(format, m[i][j]);
    330     }
    331     putchar('\n');
    332   }
    333   putchar('\n');
    334 }
    335 /* --------------------------------------------------------------------------------------------- */
    336 IMAGE_EXPORT(void) display_i64matrix_endline0(int64 **m,long i0, long i1, char *format, char *name)
    337 /* --------------------------------------------------------------------------------------------- */
    338 {
    339   int i, j;
    340   int64 n;
    341 
    342   if(name != NULL) puts(name);
    343 
    344   for(i=i0; i<=i1; i++) {
    345     printf("[%3d] ", i);
    346     n = m[i][0];
    347     for(j=1; j<=+n; j++) {
    348       printf(format, m[i][j]);
    349     }
    350     putchar('\n');
    351   }
    352   putchar('\n');
    353 }
    354 /* ----------------------------------------------------------------------------------------------------------- */
    355 //IMAGE_EXPORT(void) display_imatrix_endline0(int **m,long i0, long i1, long j0, long j1, char *format, char *name)
    356 /* ----------------------------------------------------------------------------------------------------------- */
    357 /*{
    358   int i, j, n;
    359 
    360   if(name != NULL) puts(name);
    361 
    362   for(i=i0; i<=i1; i++) {
    363     n = m[i][j0];
    364     for(j=j0; j<=j0+n; j++) {
    365       printf(format, m[i][j]);
    366     }
    367     putchar('\n');
    368   }
    369   putchar('\n');
    370 }*/
    371 /* ----------------------------------------------------------------------------------------- */
    372 IMAGE_EXPORT(void) display_imatrix_endline0(int **m,long i0, long i1, char *format, char *name)
    373 /* ----------------------------------------------------------------------------------------- */
    374 {
    375   int i, j, n;
    376 
    377   if(name != NULL) puts(name);
    378 
    379   for(i=i0; i<=i1; i++) {
    380     printf("[%3d] ", i);
    381     n = m[i][0];
    382     for(j=1; j<=+n; j++) {
    383       printf(format, m[i][j]);
    384     }
    385     putchar('\n');
    386   }
    387   putchar('\n');
    388 }
     67
     68#undef display_type_matrix_endline0
     69#define display_type_matrix_endline0(t) \
     70void short_name(t,display_,matrix_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
     71{                                                \
     72    if (name != NULL) {                          \
     73        printf(name);                            \
     74    }                                            \
     75                                                 \
     76    for (int32_t i = i0; i <= i1; i++) {         \
     77        int32_t n = (int32_t) m[i][j0];          \
     78        for (int32_t j = j0; j <= j0 + n; j++) { \
     79            printf(format, m[i][j]);             \
     80        }                                        \
     81        printf("\n");                            \
     82    }                                            \
     83    printf("\n");                                \
     84}
     85
     86display_type_matrix_endline0(int8_t);
     87display_type_matrix_endline0(uint8_t);
     88display_type_matrix_endline0(int16_t);
     89display_type_matrix_endline0(uint16_t);
     90display_type_matrix_endline0(int32_t);
     91display_type_matrix_endline0(uint32_t);
     92display_type_matrix_endline0(int64_t);
     93display_type_matrix_endline0(uint64_t);
     94
     95
    38996/* ------------------------------- */
    39097/* --- display_matrix_endline1 --- */
    39198/* ------------------------------- */
    392 /* ------------------------------------------------------------------------------------------------------------ */
    393 IMAGE_EXPORT(void) display_bmatrix_endline1(byte **m,long i0, long i1, long j0, long j1, char *format, char *name)
    394 /* ------------------------------------------------------------------------------------------------------------ */
    395 {
    396   int i, j, n;
    397 
    398   if(name != NULL) puts(name);
    399 
    400   for(i=i0; i<=i1; i++) {
    401     n = m[i][j0-1];
    402     for(j=j0; j<=j0+n-1; j++) {
    403       printf(format, m[i][j]);
    404     }
    405     putchar('\n');
    406   }
    407   putchar('\n');
    408 }
    409 /* --------------------------------------------------------------------------------------------------------------- */
    410 IMAGE_EXPORT(void) display_i16matrix_endline1(int16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    411 /* --------------------------------------------------------------------------------------------------------------- */
    412 {
    413   int i, j, n;
    414 
    415   if(name != NULL) puts(name);
    416 
    417   for(i=i0; i<=i1; i++) {
    418     n = m[i][j0-1];
    419     for(j=j0; j<=j0+n-1; j++) {
    420       printf(format, m[i][j]);
    421     }
    422     putchar('\n');
    423   }
    424   putchar('\n');
    425 }
    426 /* ----------------------------------------------------------------------------------------------------------------- */
    427 IMAGE_EXPORT(void) display_ui16matrix_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    428 /* ----------------------------------------------------------------------------------------------------------------- */
    429 {
    430   int i, j, n;
    431 
    432   if(name != NULL) puts(name);
    433 
    434   for(i=i0; i<=i1; i++) {
    435     n = m[i][j0-1];
    436     for(j=j0; j<=j0+n-1; j++) {
    437       printf(format, m[i][j]);
    438     }
    439     putchar('\n');
    440   }
    441   putchar('\n');
    442 }
    443 /* --------------------------------------------------------------------------------------------------------------- */
    444 IMAGE_EXPORT(void) display_i32matrix_endline1(int32 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    445 /* --------------------------------------------------------------------------------------------------------------- */
    446 {
    447   int i, j, n;
    448 
    449   if(name != NULL) puts(name);
    450 
    451   for(i=i0; i<=i1; i++) {
    452     n = m[i][j0-1];
    453     for(j=j0; j<=j0+n-1; j++) {
    454       printf(format, m[i][j]);
    455     }
    456     putchar('\n');
    457   }
    458   putchar('\n');
    459 }
    460 /* ----------------------------------------------------------------------------------------------------------------- */
    461 IMAGE_EXPORT(void) display_ui32matrix_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    462 /* ----------------------------------------------------------------------------------------------------------------- */
    463 {
    464   int i, j, n;
    465 
    466   if(name != NULL) puts(name);
    467 
    468   for(i=i0; i<=i1; i++) {
    469     n = m[i][j0-1];
    470     for(j=j0; j<=j0+n-1; j++) {
    471       printf(format, m[i][j]);
    472     }
    473     putchar('\n');
    474   }
    475   putchar('\n');
    476 }
    477 /* --------------------------------------------------------------------------------------------------------------- */
    478 IMAGE_EXPORT(void) display_i64matrix_endline1(int64 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    479 /* --------------------------------------------------------------------------------------------------------------- */
    480 {
    481   int i, j;
    482   int64 n;
    483 
    484   if(name != NULL) puts(name);
    485 
    486   for(i=i0; i<=i1; i++) {
    487     n = m[i][j0-1];
    488     for(j=j0; j<=j0+n-1; j++) {
    489       printf(format, m[i][j]);
    490     }
    491     putchar('\n');
    492   }
    493   putchar('\n');
    494 }
    495 /* ----------------------------------------------------------------------------------------------------------- */
    496 IMAGE_EXPORT(void) display_imatrix_endline1(int **m,long i0, long i1, long j0, long j1, char *format, char *name)
    497 /* ----------------------------------------------------------------------------------------------------------- */
    498 {
    499   int i, j, n;
    500 
    501   if(name != NULL) puts(name);
    502 
    503   for(i=i0; i<=i1; i++) {
    504     n = m[i][j0-1];
    505     for(j=j0; j<=j0+n-1; j++) {
    506       printf(format, m[i][j]);
    507     }
    508     putchar('\n');
    509   }
    510   putchar('\n');
    511 }
     99
     100#undef display_type_matrix_endline1
     101#define display_type_matrix_endline1(t) \
     102void short_name(t,display_,matrix_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
     103{                                                    \
     104    if (name != NULL) {                              \
     105        printf(name);                                \
     106    }                                                \
     107                                                     \
     108    for (int32_t i = i0; i <= i1; i++) {             \
     109        int32_t n = (int32_t) m[i][j0 - 1];          \
     110        for (int32_t j = j0; j <= j0 + n - 1; j++) { \
     111            printf(format, m[i][j]);                 \
     112        }                                            \
     113        printf("\n");                                \
     114    }                                                \
     115    printf("\n");                                    \
     116}
     117
     118display_type_matrix_endline1(int8_t);
     119display_type_matrix_endline1(uint8_t);
     120display_type_matrix_endline1(int16_t);
     121display_type_matrix_endline1(uint16_t);
     122display_type_matrix_endline1(int32_t);
     123display_type_matrix_endline1(uint32_t);
     124display_type_matrix_endline1(int64_t);
     125display_type_matrix_endline1(uint64_t);
     126
     127
    512128/* -------------------------------------- */
    513129/* --- display_matrix_number_endline0 --- */
    514130/* -------------------------------------- */
    515 /* ------------------------------------------------------------------------------------------------------------------- */
    516 IMAGE_EXPORT(void) display_bmatrix_number_endline0(byte **m,long i0, long i1, long j0, long j1, char *format, char *name)
    517 /* ------------------------------------------------------------------------------------------------------------------- */
    518 {
    519   int i, j, n;
    520 
    521   if(name != NULL) puts(name);
    522 
    523   for(i=i0; i<=i1; i++) {
    524     printf("[%3d]", i);
    525     n = m[i][j0];
    526     for(j=j0; j<=j0+n; j++) {
    527       printf(format, m[i][j]);
    528     }
    529     putchar('\n');
    530   }
    531   putchar('\n');
    532 }
    533 /* ---------------------------------------------------------------------------------------------------------------------- */
    534 IMAGE_EXPORT(void) display_i16matrix_number_endline0(int16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    535 /* ---------------------------------------------------------------------------------------------------------------------- */
    536 {
    537   int i, j, n;
    538 
    539   if(name != NULL) puts(name);
    540 
    541   for(i=i0; i<=i1; i++) {
    542     printf("[%3d]", i);
    543     n = m[i][j0];
    544     for(j=j0; j<=j0+n; j++) {
    545       printf(format, m[i][j]);
    546     }
    547     putchar('\n');
    548   }
    549   putchar('\n');
    550 }
    551 /* ------------------------------------------------------------------------------------------------------------------------ */
    552 IMAGE_EXPORT(void) display_ui16matrix_number_endline0(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    553 /* ------------------------------------------------------------------------------------------------------------------------ */
    554 {
    555   int i, j, n;
    556 
    557   if(name != NULL) puts(name);
    558 
    559   for(i=i0; i<=i1; i++) {
    560     printf("[%3d]", i);
    561     n = m[i][j0];
    562     for(j=j0; j<=j0+n; j++) {
    563       printf(format, m[i][j]);
    564     }
    565     putchar('\n');
    566   }
    567   putchar('\n');
    568 }
    569 /* ---------------------------------------------------------------------------------------------------------------------- */
    570 IMAGE_EXPORT(void) display_i32matrix_number_endline0(int32 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    571 /* ---------------------------------------------------------------------------------------------------------------------- */
    572 {
    573   int i, j, n;
    574 
    575   if(name != NULL) puts(name);
    576 
    577   for(i=i0; i<=i1; i++) {
    578     printf("[%3d]", i);
    579     n = m[i][j0];
    580     for(j=j0; j<=j0+n; j++) {
    581       printf(format, m[i][j]);
    582     }
    583     putchar('\n');
    584   }
    585   putchar('\n');
    586 }
    587 /* ------------------------------------------------------------------------------------------------------------------------ */
    588 IMAGE_EXPORT(void) display_ui32matrix_number_endline0(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    589 /* ------------------------------------------------------------------------------------------------------------------------ */
    590 {
    591   int i, j, n;
    592 
    593   if(name != NULL) puts(name);
    594 
    595   for(i=i0; i<=i1; i++) {
    596     printf("[%3d]", i);
    597     n = m[i][j0];
    598     for(j=j0; j<=j0+n; j++) {
    599       printf(format, m[i][j]);
    600     }
    601     putchar('\n');
    602   }
    603   putchar('\n');
    604 }
    605 /* ---------------------------------------------------------------------------------------------------------------------- */
    606 IMAGE_EXPORT(void) display_i64matrix_number_endline0(int64 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    607 /* ---------------------------------------------------------------------------------------------------------------------- */
    608 {
    609   int i, j;
    610   int64 n;
    611 
    612   if(name != NULL) puts(name);
    613 
    614   for(i=i0; i<=i1; i++) {
    615     printf("[%3d]", i);
    616     n = m[i][j0];
    617     for(j=j0; j<=j0+n; j++) {
    618       printf(format, m[i][j]);
    619     }
    620     putchar('\n');
    621   }
    622   putchar('\n');
    623 }
    624 /* ------------------------------------------------------------------------------------------------------------------ */
    625 IMAGE_EXPORT(void) display_imatrix_number_endline0(int **m,long i0, long i1, long j0, long j1, char *format, char *name)
    626 /* ------------------------------------------------------------------------------------------------------------------ */
    627 {
    628   int i, j, n;
    629 
    630   if(name != NULL) puts(name);
    631 
    632   for(i=i0; i<=i1; i++) {
    633     printf("[%3d]", i);
    634     n = m[i][j0];
    635     for(j=j0; j<=j0+n; j++) {
    636       printf(format, m[i][j]);
    637     }
    638     putchar('\n');
    639   }
    640   putchar('\n');
    641 }
     131
     132#undef display_type_matrix_number_endline0
     133#define display_type_matrix_number_endline0(t) \
     134void short_name(t,display_,matrix_number_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
     135{                                                    \
     136    if (name != NULL) {                              \
     137        printf(name);                                \
     138    }                                                \
     139                                                     \
     140    for (int32_t i = i0; i <= i1; i++) {             \
     141        printf("[%3d] ", i);                         \
     142        int32_t n = (int32_t) m[i][j0];              \
     143        for (int32_t j = j0; j <= j0 + n; j++) {     \
     144            printf(format, m[i][j]);                 \
     145        }                                            \
     146        printf("\n");                                \
     147    }                                                \
     148    printf("\n");                                    \
     149}
     150
     151display_type_matrix_number_endline0(int8_t);
     152display_type_matrix_number_endline0(uint8_t);
     153display_type_matrix_number_endline0(int16_t);
     154display_type_matrix_number_endline0(uint16_t);
     155display_type_matrix_number_endline0(int32_t);
     156display_type_matrix_number_endline0(uint32_t);
     157display_type_matrix_number_endline0(int64_t);
     158display_type_matrix_number_endline0(uint64_t);
     159
     160
    642161/* -------------------------------------- */
    643162/* --- display_matrix_number_endline1 --- */
    644163/* -------------------------------------- */
    645 /* ------------------------------------------------------------------------------------------------------------------- */
    646 IMAGE_EXPORT(void) display_bmatrix_number_endline1(byte **m,long i0, long i1, long j0, long j1, char *format, char *name)
    647 /* ------------------------------------------------------------------------------------------------------------------- */
    648 {
    649   int i, j, n;
    650 
    651   if(name != NULL) puts(name);
    652 
    653   for(i=i0; i<=i1; i++) {
    654     printf("[%3d]", i);
    655     n = m[i][j0-1];
    656     for(j=j0; j<=j0+n-1; j++) {
    657       printf(format, m[i][j]);
    658     }
    659     putchar('\n');
    660   }
    661   putchar('\n');
    662 }
    663 /* ---------------------------------------------------------------------------------------------------------------------- */
    664 IMAGE_EXPORT(void) display_i16matrix_number_endline1(int16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    665 /* ---------------------------------------------------------------------------------------------------------------------- */
    666 {
    667   int i, j, n;
    668 
    669   if(name != NULL) puts(name);
    670 
    671   for(i=i0; i<=i1; i++) {
    672     printf("[%3d]", i);
    673     n = m[i][j0-1];
    674     for(j=j0; j<=j0+n-1; j++) {
    675       printf(format, m[i][j]);
    676     }
    677     putchar('\n');
    678   }
    679   putchar('\n');
    680 }
    681 /* ------------------------------------------------------------------------------------------------------------------------ */
    682 IMAGE_EXPORT(void) display_ui16matrix_number_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    683 /* ------------------------------------------------------------------------------------------------------------------------ */
    684 {
    685   int i, j, n;
    686 
    687   if(name != NULL) puts(name);
    688 
    689   for(i=i0; i<=i1; i++) {
    690     printf("[%3d]", i);
    691     n = m[i][j0-1];
    692     for(j=j0; j<=j0+n-1; j++) {
    693       printf(format, m[i][j]);
    694     }
    695     putchar('\n');
    696   }
    697   putchar('\n');
    698 }
    699 /* ---------------------------------------------------------------------------------------------------------------------- */
    700 IMAGE_EXPORT(void) display_i32matrix_number_endline1(int32 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    701 /* ---------------------------------------------------------------------------------------------------------------------- */
    702 {
    703   int i, j, n;
    704 
    705   if(name != NULL) puts(name);
    706 
    707   for(i=i0; i<=i1; i++) {
    708     printf("[%3d]", i);
    709     n = m[i][j0-1];
    710     for(j=j0; j<=j0+n-1; j++) {
    711       printf(format, m[i][j]);
    712     }
    713     putchar('\n');
    714   }
    715   putchar('\n');
    716 }
    717 /* ------------------------------------------------------------------------------------------------------------------------ */
    718 IMAGE_EXPORT(void) display_ui32matrix_number_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    719 /* ------------------------------------------------------------------------------------------------------------------------ */
    720 {
    721   int i, j, n;
    722 
    723   if(name != NULL) puts(name);
    724 
    725   for(i=i0; i<=i1; i++) {
    726     printf("[%3d]", i);
    727     n = m[i][j0-1];
    728     for(j=j0; j<=j0+n-1; j++) {
    729       printf(format, m[i][j]);
    730     }
    731     putchar('\n');
    732   }
    733   putchar('\n');
    734 }
    735 /* ---------------------------------------------------------------------------------------------------------------------- */
    736 IMAGE_EXPORT(void) display_i64matrix_number_endline1(int64 **m,long i0, long i1, long j0, long j1, char *format, char *name)
    737 /* ---------------------------------------------------------------------------------------------------------------------- */
    738 {
    739   int i, j;
    740   int64 n;
    741 
    742   if(name != NULL) puts(name);
    743 
    744   for(i=i0; i<=i1; i++) {
    745     printf("[%3d]", i);
    746     n = m[i][j0-1];
    747     for(j=j0; j<=j0+n-1; j++) {
    748       printf(format, m[i][j]);
    749     }
    750     putchar('\n');
    751   }
    752   putchar('\n');
    753 }
    754 /* ------------------------------------------------------------------------------------------------------------------ */
    755 IMAGE_EXPORT(void) display_imatrix_number_endline1(int **m,long i0, long i1, long j0, long j1, char *format, char *name)
    756 /* ------------------------------------------------------------------------------------------------------------------ */
    757 {
    758   int i, j, n;
    759 
    760   if(name != NULL) puts(name);
    761 
    762   for(i=i0; i<=i1; i++) {
    763     printf("[%3d]", i);
    764     n = m[i][j0-1];
    765     for(j=j0; j<=j0+n-1; j++) {
    766       printf(format, m[i][j]);
    767     }
    768     putchar('\n');
    769   }
    770   putchar('\n');
    771 }
     164
     165#undef display_type_matrix_number_endline1
     166#define display_type_matrix_number_endline1(t) \
     167void short_name(t,display_,matrix_number_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
     168{                                                    \
     169    if (name != NULL) {                              \
     170        printf(name);                                \
     171    }                                                \
     172                                                     \
     173    for (int32_t i = i0; i <= i1; i++) {             \
     174        printf("[%3d] ", i);                         \
     175        int32_t n = (int32_t) m[i][j0 - 1];          \
     176        for (int32_t j = j0; j <= j0 + n - 1; j++) { \
     177            printf(format, m[i][j]);                 \
     178        }                                            \
     179        printf("\n");                                \
     180    }                                                \
     181    printf("\n");                                    \
     182}
     183
     184display_type_matrix_number_endline1(int8_t);
     185display_type_matrix_number_endline1(uint8_t);
     186display_type_matrix_number_endline1(int16_t);
     187display_type_matrix_number_endline1(uint16_t);
     188display_type_matrix_number_endline1(int32_t);
     189display_type_matrix_number_endline1(uint32_t);
     190display_type_matrix_number_endline1(int64_t);
     191display_type_matrix_number_endline1(uint64_t);
     192
     193
    772194/* ------------------------- */
    773195/* --- display_trimatrix --- */
    774196/* ------------------------- */
    775 /* ------------------------------------------------------------------------------------------------------------------ */
    776 IMAGE_EXPORT(void) display_btrimatrix(byte **m, long i0, long i1, long j0, long j1, long step, char *format, char *name)
    777 /* ------------------------------------------------------------------------------------------------------------------ */
    778 {
    779   int i, j;
    780   if(name != NULL) puts(name);
    781 
    782   for(i=i0; i<=i1; i++) {
    783     for(j=j0; j<=j1; j++) {
    784       printf(format, m[i][j]);
    785     }
    786     putchar('\n');
    787     j1 += step;
    788   }
    789   putchar('\n');
    790 }
    791 /* --------------------------------------------------------------------------------------------------------------------- */
    792 IMAGE_EXPORT(void) display_i16trimatrix(int16 **m, long i0, long i1, long j0, long j1, long step, char *format, char *name)
    793 /* --------------------------------------------------------------------------------------------------------------------- */
    794 {
    795   int i, j;
    796 
    797   if(name != NULL) puts(name);
    798 
    799   for(i=i0; i<=i1; i++) {
    800     for(j=j0; j<=j1; j++) {
    801       printf(format, m[i][j]);
    802     }
    803     putchar('\n');
    804     j1 += step;
    805   }
    806   putchar('\n');
    807 }
    808 /* ----------------------------------------------------------------------------------------------------------------------- */
    809 IMAGE_EXPORT(void) display_ui16trimatrix(uint16 **m, long i0, long i1, long j0, long j1, long step, char *format, char *name)
    810 /* ----------------------------------------------------------------------------------------------------------------------- */
    811 {
    812   int i, j;
    813 
    814   if(name != NULL) puts(name);
    815 
    816   for(i=i0; i<=i1; i++) {
    817     for(j=j0; j<=j1; j++) {
    818       printf(format, m[i][j]);
    819     }
    820     putchar('\n');
    821     j1 += step;
    822   }
    823   putchar('\n');
    824 }
    825 /* ----------------------------------------------------------------------------------------------------------------- */
    826 IMAGE_EXPORT(void) display_itrimatrix(int **m, long i0, long i1, long j0, long j1, long step, char *format, char *name)
    827 /* ----------------------------------------------------------------------------------------------------------------- */
    828 {
    829   int i, j;
    830 
    831   if(name != NULL) puts(name);
    832 
    833   for(i=i0; i<=i1; i++) {
    834     for(j=j0; j<=j1; j++) {
    835       printf(format, m[i][j]);
    836     }
    837     putchar('\n');
    838     j1 += step;
    839   }
    840   putchar('\n');
    841 }
    842 /* --------------------------------------------------------------------------------------------------------------------- */
    843 IMAGE_EXPORT(void) display_i32trimatrix(int32 **m, long i0, long i1, long j0, long j1, long step, char *format, char *name)
    844 /* --------------------------------------------------------------------------------------------------------------------- */
    845 {
    846   int i, j;
    847 
    848   if(name != NULL) puts(name);
    849 
    850   for(i=i0; i<=i1; i++) {
    851     for(j=j0; j<=j1; j++) {
    852       printf(format, m[i][j]);
    853     }
    854     putchar('\n');
    855     j1 += step;
    856   }
    857   putchar('\n');
    858 }
    859 /* ------------------------------------------------------------------------------------------------------------------ */
    860 IMAGE_EXPORT(void) display_f32trimatrix(float32 **m, long i0, long i1, long j0, long j1, long step, char *format, char *name)
    861 /* ------------------------------------------------------------------------------------------------------------------ */
    862 {
    863   int i, j;
    864 
    865   if(name != NULL) puts(name);
    866 
    867   for(i=i0; i<=i1; i++) {
    868     for(j=j0; j<=j1; j++) {
    869       printf(format, m[i][j]);
    870     }
    871     putchar('\n');
    872     j1 += step;
    873   }
    874   putchar('\n');
    875 }
    876 /* ------------------------------------------------------------------------------------------------------------------ */
    877 IMAGE_EXPORT(void) display_f64trimatrix(float64 **m, long i0, long i1, long j0, long j1, long step, char *format, char *name)
    878 /* ------------------------------------------------------------------------------------------------------------------ */
    879 {
    880   int i, j;
    881 
    882   if(name != NULL) puts(name);
    883 
    884   for(i=i0; i<=i1; i++) {
    885     for(j=j0; j<=j1; j++) {
    886       printf(format, m[i][j]);
    887     }
    888     putchar('\n');
    889     j1 += step;
    890   }
    891   putchar('\n');
    892 }
     197
     198#undef display_type_trimatrix
     199#define display_type_trimatrix(t) \
     200void short_name(t,display_,trimatrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step, char * format, char * name) \
     201{                                                    \
     202    if (name != NULL) {                              \
     203        printf(name);                                \
     204    }                                                \
     205                                                     \
     206    for (int32_t i = i0; i <= i1; i++) {             \
     207        for (int32_t j = j0; j <= j1; j++) {         \
     208            printf(format, m[i][j]);                 \
     209        }                                            \
     210        printf("\n");                                \
     211        j1 += step;                                  \
     212    }                                                \
     213    printf("\n");                                    \
     214}
     215
     216display_type_trimatrix(int8_t);
     217display_type_trimatrix(uint8_t);
     218display_type_trimatrix(int16_t);
     219display_type_trimatrix(uint16_t);
     220display_type_trimatrix(int32_t);
     221display_type_trimatrix(uint32_t);
     222display_type_trimatrix(int64_t);
     223display_type_trimatrix(uint64_t);
     224display_type_trimatrix(float);
     225display_type_trimatrix(double);
     226
     227
     228// Local Variables:
     229// tab-width: 4
     230// c-basic-offset: 4
     231// c-file-offsets:((innamespace . 0)(inline-open . 0))
     232// indent-tabs-mode: nil
     233// End:
     234
     235// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     236
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2xf.c

    r772 r823  
    2525#include "nrio2x.h"
    2626
    27 /* ------------------------------ */
    28 /* --- display_matrix_endline --- */
    29 /* ------------------------------ */
    3027/* ----------------------- */
    3128/* --- write_trimatrix --- */
    3229/* ----------------------- */
    3330
    34 /* ----------------------------------------------------------------------------------------------------------------- */
    35 IMAGE_EXPORT(void) write_btrimatrix(byte **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename)
    36 /* ----------------------------------------------------------------------------------------------------------------- */
    37 {
    38   int i,j;
    39  
    40   FILE *f;
    41 
    42   f = fopen(filename, "wt");
    43   if(f == NULL) {
    44     nrerror("Can't open file in write_btrimatrix");
    45   }
    46 
    47   for(i=i0; i<=i1; i++) {
    48     for(j=j0; j<=j1; j++) {
    49       fprintf(f, format, m[i][j]);
    50     }
    51     fputc('\n', f);
    52     j1 += step;
    53   }
    54   fputc('\n', f);
    55 
    56   fclose(f);
    57 }
    58 
    59 /* -------------------------------------------------------------------------------------------------------------------- */
    60 IMAGE_EXPORT(void) write_i16trimatrix(int16 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename)
    61 /* -------------------------------------------------------------------------------------------------------------------- */
    62 {
    63   int i,j;
    64  
    65   FILE *f;
    66 
    67   f = fopen(filename, "wt");
    68   if(f == NULL) {
    69     nrerror("Can't open file in write_i16trimatrix");
    70   }
    71 
    72   for(i=i0; i<=i1; i++) {
    73     for(j=j0; j<=j1; j++) {
    74       fprintf(f, format, m[i][j]);
    75     }
    76     fputc('\n', f);
    77     j1 += step;
    78   }
    79   fputc('\n', f);
    80 
    81   fclose(f);
    82 }
    83 /* ---------------------------------------------------------------------------------------------------------------------- */
    84 IMAGE_EXPORT(void) write_ui16trimatrix(uint16 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename)
    85 /* ---------------------------------------------------------------------------------------------------------------------- */
    86 {
    87   int i,j;
    88  
    89   FILE *f;
    90 
    91   f = fopen(filename, "wt");
    92   if(f == NULL) {
    93     nrerror("Can't open file in write_ui16trimatrix");
    94   }
    95 
    96   for(i=i0; i<=i1; i++) {
    97     for(j=j0; j<=j1; j++) {
    98       fprintf(f, format, m[i][j]);
    99     }
    100     fputc('\n', f);
    101     j1 += step;
    102   }
    103   fputc('\n', f);
    104 
    105   fclose(f);
    106 }
    107 /* ---------------------------------------------------------------------------------------------------------------- */
    108 IMAGE_EXPORT(void) write_itrimatrix(int **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename)
    109 /* ---------------------------------------------------------------------------------------------------------------- */
    110 {
    111   int i,j;
    112  
    113   FILE *f;
    114 
    115   f = fopen(filename, "wt");
    116   if(f == NULL) {
    117     nrerror("Can't open file in write_itrimatrix");
    118   }
    119 
    120   for(i=i0; i<=i1; i++) {
    121     for(j=j0; j<=j1; j++) {
    122       fprintf(f, format, m[i][j]);
    123     }
    124     fputc('\n', f);
    125     j1 += step;
    126   }
    127   fputc('\n', f);
    128 
    129   fclose(f);
    130 }
    131 /* ------------------------------------------------------------------------------------------------------------------------ */
    132 IMAGE_EXPORT(void) write_i32trimatrix(int32 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename)
    133 /* ------------------------------------------------------------------------------------------------------------------------ */
    134 {
    135   int i,j;
    136  
    137   FILE *f;
    138 
    139   f = fopen(filename, "wt");
    140   if(f == NULL) {
    141     nrerror("Can't open file in write_i32trimatrix");
    142   }
    143 
    144   for(i=i0; i<=i1; i++) {
    145     for(j=j0; j<=j1; j++) {
    146       fprintf(f, format, m[i][j]);
    147     }
    148     fputc('\n', f);
    149     j1 += step;
    150   }
    151   fputc('\n', f);
    152 
    153   fclose(f);
    154 }
    155 /* ---------------------------------------------------------------------------------------------------------------------- */
    156 IMAGE_EXPORT(void) write_f32trimatrix(float32 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename)
    157 /* ---------------------------------------------------------------------------------------------------------------------- */
    158 {
    159   int i,j;
    160  
    161   FILE *f;
    162 
    163   f = fopen(filename, "wt");
    164   if(f == NULL) {
    165     nrerror("Can't open file in write_f32trimatrix");
    166   }
    167 
    168   for(i=i0; i<=i1; i++) {
    169     for(j=j0; j<=j1; j++) {
    170       fprintf(f, format, m[i][j]);
    171     }
    172     fputc('\n', f);
    173     j1 += step;
    174   }
    175   fputc('\n', f);
    176 
    177   fclose(f);
    178 }
    179 /* ---------------------------------------------------------------------------------------------------------------------- */
    180 IMAGE_EXPORT(void) write_f64trimatrix(float64 **m,long i0,long i1,long j0, long j1, long step, char *format, char *filename)
    181 /* ---------------------------------------------------------------------------------------------------------------------- */
    182 {
    183   int i,j;
    184  
    185   FILE *f;
    186 
    187   f = fopen(filename, "wt");
    188   if(f == NULL) {
    189     nrerror("Can't open file in write_f64trimatrix");
    190   }
    191 
    192   for(i=i0; i<=i1; i++) {
    193     for(j=j0; j<=j1; j++) {
    194       fprintf(f, format, m[i][j]);
    195     }
    196     fputc('\n', f);
    197     j1 += step;
    198   }
    199   fputc('\n', f);
    200 
    201   fclose(f);
    202 }
     31#undef write_type_trimatrix
     32#define write_type_trimatrix(t) \
     33void short_name(t,write_,trimatrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step, char * format, char * filename) \
     34{                                                                \
     35    FILE * f = fopen(filename, "wt");                            \
     36    if (f == NULL) {                                             \
     37        nrerror("Can't open file %s in %s", filename, __func__); \
     38    }                                                            \
     39    for (int32_t i = i0; i <= i1; i++) {                         \
     40        for (int32_t j = j0; j <= j1; j++) {                     \
     41            fprintf(f, format, m[i][j]);                         \
     42        }                                                        \
     43        fprintf(f, "\n");                                        \
     44        j1 += step;                                              \
     45    }                                                            \
     46    fprintf(f, "\n");                                            \
     47    fclose(f);                                                   \
     48}
     49
     50write_type_trimatrix(int8_t);
     51write_type_trimatrix(uint8_t);
     52write_type_trimatrix(int16_t);
     53write_type_trimatrix(uint16_t);
     54write_type_trimatrix(int32_t);
     55write_type_trimatrix(uint32_t);
     56write_type_trimatrix(int64_t);
     57write_type_trimatrix(uint64_t);
     58write_type_trimatrix(float);
     59write_type_trimatrix(double);
     60
     61
    20362/* ---------------------------- */
    20463/* --- write_matrix_endline --- */
    20564/* ---------------------------- */
    206 /* ------------------------------------------------------------------------------------------------------------ */
    207 IMAGE_EXPORT(void) write_bmatrix_endline(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    208 /* ------------------------------------------------------------------------------------------------------------ */
    209 {
    210   int i,j;
    211   //int n = (i1-i0+1) * (j1-j0+1);
    212   byte *p = &m[i0][j0];
    213 
    214   FILE *f;
    215 
    216   f = fopen(filename, "wt");
    217   if(f == NULL) {
    218     nrerror("Can't open file in write_bmatrix_endline");
    219   }
    220 
    221   for(i=i0; i<=i1; i++) {
    222     for(j=j0; j<=j1; j++) {
    223       fprintf(f, format, *p++);
    224     }
    225     fputc('\n', f);
    226   }
    227   fclose(f);
    228 }
    229 /* ---------------------------------------------------------------------------------------------------------------- */
    230 IMAGE_EXPORT(void) write_i16matrix_endline(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    231 /* ---------------------------------------------------------------------------------------------------------------- */
    232 {
    233   int i,j;
    234   //int n = (i1-i0+1) * (j1-j0+1);
    235   int16 *p = &m[i0][j0];
    236 
    237   FILE *f;
    238 
    239   f = fopen(filename, "wt");
    240   if(f == NULL) {
    241     nrerror("Can't open file in write_i16matrix_endline");
    242   }
    243 
    244   for(i=i0; i<=i1; i++) {
    245     for(j=j0; j<=j1; j++) {
    246       fprintf(f, format, *p++);
    247     }
    248     fputc('\n', f);
    249   }
    250   fclose(f);
    251 }
    252 /* ------------------------------------------------------------------------------------------------------------------ */
    253 IMAGE_EXPORT(void) write_ui16matrix_endline(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    254 /* ------------------------------------------------------------------------------------------------------------------ */
    255 {
    256   int i,j;
    257   //int n = (i1-i0+1) * (j1-j0+1);
    258   uint16 *p = &m[i0][j0];
    259 
    260   FILE *f;
    261 
    262   f = fopen(filename, "wt");
    263   if(f == NULL) {
    264     nrerror("Can't open file in write_ui16matrix_endline");
    265   }
    266 
    267   for(i=i0; i<=i1; i++) {
    268     for(j=j0; j<=j1; j++) {
    269       fprintf(f, format, *p++);
    270     }
    271     fputc('\n', f);
    272   }
    273   fclose(f);
    274 }
    275 /* ---------------------------------------------------------------------------------------------------------------- */
    276 IMAGE_EXPORT(void) write_i32matrix_endline(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    277 /* ---------------------------------------------------------------------------------------------------------------- */
    278 {
    279   int i,j;
    280   //int n = (i1-i0+1) * (j1-j0+1);
    281   int32 *p = &m[i0][j0];
    282 
    283   FILE *f;
    284 
    285   f = fopen(filename, "wt");
    286   if(f == NULL) {
    287     nrerror("Can't open file in write_i32matrix_endline");
    288   }
    289 
    290   for(i=i0; i<=i1; i++) {
    291     for(j=j0; j<=j1; j++) {
    292       fprintf(f, format, *p++);
    293     }
    294     fputc('\n', f);
    295   }
    296   fclose(f);
    297 }
    298 /* ------------------------------------------------------------------------------------------------------------------ */
    299 IMAGE_EXPORT(void) write_ui32matrix_endline(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    300 /* ------------------------------------------------------------------------------------------------------------------ */
    301 {
    302   int i,j;
    303   //int n = (i1-i0+1) * (j1-j0+1);
    304   uint32 *p = &m[i0][j0];
    305 
    306   FILE *f;
    307 
    308   f = fopen(filename, "wt");
    309   if(f == NULL) {
    310     nrerror("Can't open file in write_ui32matrix_endline");
    311   }
    312 
    313   for(i=i0; i<=i1; i++) {
    314     for(j=j0; j<=j1; j++) {
    315       fprintf(f, format, *p++);
    316     }
    317     fputc('\n', f);
    318   }
    319   fclose(f);
    320 }
    321 /* ---------------------------------------------------------------------------------------------------------------- */
    322 IMAGE_EXPORT(void) write_i64matrix_endline(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    323 /* ---------------------------------------------------------------------------------------------------------------- */
    324 {
    325   int i,j;
    326   //int n = (i1-i0+1) * (j1-j0+1);
    327   int64 *p = &m[i0][j0];
    328 
    329   FILE *f;
    330 
    331   f = fopen(filename, "wt");
    332   if(f == NULL) {
    333     nrerror("Can't open file in write_i64matrix_endline");
    334   }
    335 
    336   for(i=i0; i<=i1; i++) {
    337     for(j=j0; j<=j1; j++) {
    338       fprintf(f, format, *p++);
    339     }
    340     fputc('\n', f);
    341   }
    342   fclose(f);
    343 }
    344 /* ------------------------------------------------------------------------------------------------------------ */
    345 IMAGE_EXPORT(void) write_imatrix_endline(int **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    346 /* ------------------------------------------------------------------------------------------------------------ */
    347 {
    348   int i,j;
    349   //int n = (i1-i0+1) * (j1-j0+1);
    350   int *p = &m[i0][j0];
    351 
    352   FILE *f;
    353 
    354   f = fopen(filename, "wt");
    355   if(f == NULL) {
    356     nrerror("Can't open file in write_imatrix_endline");
    357   }
    358 
    359   for(i=i0; i<=i1; i++) {
    360     for(j=j0; j<=j1; j++) {
    361       fprintf(f, format, *p++);
    362     }
    363     fputc('\n', f);
    364   }
    365   fclose(f);
    366 }
     65
     66#undef write_type_matrix_endline
     67#define write_type_matrix_endline(t) \
     68void short_name(t,write_,matrix_endline)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename) \
     69{                                                                \
     70    t * p = &m[i0][j0];                                          \
     71    FILE * f = fopen(filename, "wt");                            \
     72    if (f == NULL) {                                             \
     73        nrerror("Can't open file %s in %s", filename, __func__); \
     74    }                                                            \
     75    for (int32_t i = i0; i <= i1; i++) {                         \
     76        for (int32_t j = j0; j <= j1; j++) {                     \
     77            fprintf(f, format, *p++);                            \
     78        }                                                        \
     79        fprintf(f, "\n");                                        \
     80    }                                                            \
     81    fprintf(f, "\n");                                            \
     82    fclose(f);                                                   \
     83}
     84
     85write_type_matrix_endline(int8_t);
     86write_type_matrix_endline(uint8_t);
     87write_type_matrix_endline(int16_t);
     88write_type_matrix_endline(uint16_t);
     89write_type_matrix_endline(int32_t);
     90write_type_matrix_endline(uint32_t);
     91write_type_matrix_endline(int64_t);
     92write_type_matrix_endline(uint64_t);
     93write_type_matrix_endline(float);
     94write_type_matrix_endline(double);
     95
     96
    36797/* ------------------------------ */
    36898/* --- write_imatrix_endline0 --- */
    36999/* ------------------------------ */
    370 /* -------------------------------------------------------------------------------------------------------------- */
    371 IMAGE_EXPORT(void) write_bmatrix_endline0(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    372 /* -------------------------------------------------------------------------------------------------------------- */
    373 {
    374   int i,j, n;
    375  
    376   FILE *f;
    377 
    378   f = fopen(filename, "wt");
    379   if(f == NULL) {
    380     nrerror("Can't open file in write_bmatrix_endline0");
    381   }
    382 
    383   for(i=i0; i<=i1; i++) {
    384     n = m[i][j0];
    385     for(j=j0; j<=j0+n; j++) {
    386       fprintf(f, format, m[i][j]);
    387     }
    388     fputc('\n', f);
    389   }
    390   fclose(f);
    391 }
    392 /* ----------------------------------------------------------------------------------------------------------------- */
    393 IMAGE_EXPORT(void) write_i16matrix_endline0(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    394 /* ----------------------------------------------------------------------------------------------------------------- */
    395 {
    396   int i,j, n;
    397  
    398   FILE *f;
    399 
    400   f = fopen(filename, "wt");
    401   if(f == NULL) {
    402     nrerror("Can't open file in write_i16matrix_endline0");
    403   }
    404 
    405   for(i=i0; i<=i1; i++) {
    406     n = m[i][j0];
    407     for(j=j0; j<=j0+n; j++) {
    408       fprintf(f, format, m[i][j]);
    409     }
    410     fputc('\n', f);
    411   }
    412   fclose(f);
    413 }
    414 /* ------------------------------------------------------------------------------------------------------------------- */
    415 IMAGE_EXPORT(void) write_ui16matrix_endline0(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    416 /* ------------------------------------------------------------------------------------------------------------------- */
    417 {
    418   int i,j, n;
    419  
    420   FILE *f;
    421 
    422   f = fopen(filename, "wt");
    423   if(f == NULL) {
    424     nrerror("Can't open file in write_ui16matrix_endline0");
    425   }
    426 
    427   for(i=i0; i<=i1; i++) {
    428     n = m[i][j0];
    429     for(j=j0; j<=j0+n; j++) {
    430       fprintf(f, format, m[i][j]);
    431     }
    432     fputc('\n', f);
    433   }
    434   fclose(f);
    435 }
    436 /* ----------------------------------------------------------------------------------------------------------------- */
    437 IMAGE_EXPORT(void) write_i32matrix_endline0(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    438 /* ----------------------------------------------------------------------------------------------------------------- */
    439 {
    440   int i,j, n;
    441  
    442   FILE *f;
    443 
    444   f = fopen(filename, "wt");
    445   if(f == NULL) {
    446     nrerror("Can't open file in write_i32matrix_endline0");
    447   }
    448 
    449   for(i=i0; i<=i1; i++) {
    450     n = m[i][j0];
    451     for(j=j0; j<=j0+n; j++) {
    452       fprintf(f, format, m[i][j]);
    453     }
    454     fputc('\n', f);
    455   }
    456   fclose(f);
    457 }
    458 /* ----------------------------------------------------------------------------------------------------------------- */
    459 IMAGE_EXPORT(void) write_i64matrix_endline0(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    460 /* ----------------------------------------------------------------------------------------------------------------- */
    461 {
    462   int i,j;
    463   int64 n;
    464  
    465   FILE *f;
    466 
    467   f = fopen(filename, "wt");
    468   if(f == NULL) {
    469     nrerror("Can't open file in write_i64matrix_endline0");
    470   }
    471 
    472   for(i=i0; i<=i1; i++) {
    473     n = m[i][j0];
    474     for(j=j0; j<=j0+n; j++) {
    475       fprintf(f, format, m[i][j]);
    476     }
    477     fputc('\n', f);
    478   }
    479   fclose(f);
    480 }
    481 /* ------------------------------------------------------------------------------------------------------------------- */
    482 IMAGE_EXPORT(void) write_ui32matrix_endline0(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    483 /* ------------------------------------------------------------------------------------------------------------------- */
    484 {
    485   int i,j, n;
    486  
    487   FILE *f;
    488 
    489   f = fopen(filename, "wt");
    490   if(f == NULL) {
    491     nrerror("Can't open file in write_ui32matrix_endline0");
    492   }
    493 
    494   for(i=i0; i<=i1; i++) {
    495     n = m[i][j0];
    496     for(j=j0; j<=j0+n; j++) {
    497       fprintf(f, format, m[i][j]);
    498     }
    499     fputc('\n', f);
    500   }
    501   fclose(f);
    502 }
    503 /* ------------------------------------------------------------------------------------------------------------- */
    504 IMAGE_EXPORT(void) write_imatrix_endline0(int **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    505 /* ------------------------------------------------------------------------------------------------------------- */
    506 {
    507   int i,j, n;
    508  
    509   FILE *f;
    510 
    511   f = fopen(filename, "wt");
    512   if(f == NULL) {
    513     nrerror("Can't open file in write_imatrix_endline0");
    514   }
    515 
    516   for(i=i0; i<=i1; i++) {
    517     n = m[i][j0];
    518     for(j=j0; j<=j0+n; j++) {
    519       fprintf(f, format, m[i][j]);
    520     }
    521     fputc('\n', f);
    522   }
    523   fclose(f);
    524 }
     100
     101#undef write_type_matrix_endline0
     102#define write_type_matrix_endline0(t) \
     103void short_name(t,write_,matrix_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename) \
     104{                                                                \
     105    FILE * f = fopen(filename, "wt");                            \
     106    if (f == NULL) {                                             \
     107        nrerror("Can't open file %s in %s", filename, __func__); \
     108    }                                                            \
     109    for (int32_t i = i0; i <= i1; i++) {                         \
     110        int32_t n = (int32_t) m[i][j0];                          \
     111        for (int32_t j = j0; j <= j0 + n; j++) {                 \
     112            fprintf(f, format, m[i][j]);                         \
     113        }                                                        \
     114        fprintf(f, "\n");                                        \
     115    }                                                            \
     116    fprintf(f, "\n");                                            \
     117    fclose(f);                                                   \
     118}
     119
     120write_type_matrix_endline0(int8_t);
     121write_type_matrix_endline0(uint8_t);
     122write_type_matrix_endline0(int16_t);
     123write_type_matrix_endline0(uint16_t);
     124write_type_matrix_endline0(int32_t);
     125write_type_matrix_endline0(uint32_t);
     126write_type_matrix_endline0(int64_t);
     127write_type_matrix_endline0(uint64_t);
     128write_type_matrix_endline0(float);
     129write_type_matrix_endline0(double);
     130
     131
     132
    525133/* ------------------------------ */
    526134/* --- write_imatrix_endline1 --- */
    527135/* ------------------------------ */
    528 /* -------------------------------------------------------------------------------------------------------------- */
    529 IMAGE_EXPORT(void) write_bmatrix_endline1(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    530 /* -------------------------------------------------------------------------------------------------------------- */
    531 {
    532   int i,j, n;
    533  
    534   FILE *f;
    535 
    536   f = fopen(filename, "wt");
    537   if(f == NULL) {
    538     nrerror("Can't open file in write_bmatrix_endline1");
    539   }
    540 
    541   for(i=i0; i<=i1; i++) {
    542     n = m[i][j0-1];
    543     for(j=j0; j<=j0+n-1; j++) {
    544       fprintf(f, format, m[i][j]);
    545     }
    546     fputc('\n', f);
    547   }
    548   fclose(f);
    549 }
    550 /* ----------------------------------------------------------------------------------------------------------------- */
    551 IMAGE_EXPORT(void) write_i16matrix_endline1(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    552 /* ----------------------------------------------------------------------------------------------------------------- */
    553 {
    554   int i,j, n;
    555  
    556   FILE *f;
    557 
    558   f = fopen(filename, "wt");
    559   if(f == NULL) {
    560     nrerror("Can't open file in write_i16matrix_endline0");
    561   }
    562 
    563   for(i=i0; i<=i1; i++) {
    564     n = m[i][j0-1];
    565     for(j=j0; j<=j0+n-1; j++) {
    566       fprintf(f, format, m[i][j]);
    567     }
    568     fputc('\n', f);
    569   }
    570   fclose(f);
    571 }
    572 /* ------------------------------------------------------------------------------------------------------------------- */
    573 IMAGE_EXPORT(void) write_ui16matrix_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    574 /* ------------------------------------------------------------------------------------------------------------------- */
    575 {
    576   int i,j, n;
    577  
    578   FILE *f;
    579 
    580   f = fopen(filename, "wt");
    581   if(f == NULL) {
    582     nrerror("Can't open file in write_ui16matrix_endline0");
    583   }
    584 
    585   for(i=i0; i<=i1; i++) {
    586     n = m[i][j0-1];
    587     for(j=j0; j<=j0+n-1; j++) {
    588       fprintf(f, format, m[i][j]);
    589     }
    590     fputc('\n', f);
    591   }
    592   fclose(f);
    593 }
    594 /* ----------------------------------------------------------------------------------------------------------------- */
    595 IMAGE_EXPORT(void) write_i32matrix_endline1(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    596 /* ----------------------------------------------------------------------------------------------------------------- */
    597 {
    598   int i,j, n;
    599  
    600   FILE *f;
    601 
    602   f = fopen(filename, "wt");
    603   if(f == NULL) {
    604     nrerror("Can't open file in write_i32matrix_endline0");
    605   }
    606 
    607   for(i=i0; i<=i1; i++) {
    608     n = m[i][j0-1];
    609     for(j=j0; j<=j0+n-1; j++) {
    610       fprintf(f, format, m[i][j]);
    611     }
    612     fputc('\n', f);
    613   }
    614   fclose(f);
    615 }
    616 /* ------------------------------------------------------------------------------------------------------------------- */
    617 IMAGE_EXPORT(void) write_ui32matrix_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    618 /* ------------------------------------------------------------------------------------------------------------------- */
    619 {
    620   int i,j, n;
    621  
    622   FILE *f;
    623 
    624   f = fopen(filename, "wt");
    625   if(f == NULL) {
    626     nrerror("Can't open file in write_ui32matrix_endline0");
    627   }
    628 
    629   for(i=i0; i<=i1; i++) {
    630     n = m[i][j0-1];
    631     for(j=j0; j<=j0+n-1; j++) {
    632       fprintf(f, format, m[i][j]);
    633     }
    634     fputc('\n', f);
    635   }
    636   fclose(f);
    637 }
    638 /* ----------------------------------------------------------------------------------------------------------------- */
    639 IMAGE_EXPORT(void) write_i64matrix_endline1(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    640 /* ----------------------------------------------------------------------------------------------------------------- */
    641 {
    642   int i,j;
    643   int64 n;
    644  
    645   FILE *f;
    646 
    647   f = fopen(filename, "wt");
    648   if(f == NULL) {
    649     nrerror("Can't open file in write_i64matrix_endline0");
    650   }
    651 
    652   for(i=i0; i<=i1; i++) {
    653     n = m[i][j0-1];
    654     for(j=j0; j<=j0+n-1; j++) {
    655       fprintf(f, format, m[i][j]);
    656     }
    657     fputc('\n', f);
    658   }
    659   fclose(f);
    660 }
    661 /* ------------------------------------------------------------------------------------------------------------- */
    662 IMAGE_EXPORT(void) write_imatrix_endline1(int **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    663 /* ------------------------------------------------------------------------------------------------------------- */
    664 {
    665   int i,j, n;
    666  
    667   FILE *f;
    668 
    669   f = fopen(filename, "wt");
    670   if(f == NULL) {
    671     nrerror("Can't open file in write_imatrix_endline0");
    672   }
    673 
    674   for(i=i0; i<=i1; i++) {
    675     n = m[i][j0-1];
    676     for(j=j0; j<=j0+n-1; j++) {
    677       fprintf(f, format, m[i][j]);
    678     }
    679     fputc('\n', f);
    680   }
    681   fclose(f);
    682 }
     136
     137#undef write_type_matrix_endline1
     138#define write_type_matrix_endline1(t) \
     139void short_name(t,write_,matrix_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename) \
     140{                                                                \
     141    FILE * f = fopen(filename, "wt");                            \
     142    if (f == NULL) {                                             \
     143        nrerror("Can't open file %s in %s", filename, __func__); \
     144    }                                                            \
     145    for (int32_t i = i0; i <= i1; i++) {                         \
     146        int32_t n = (int32_t) m[i][j0 - 1];                      \
     147        for (int32_t j = j0; j <= j0 + n - 1; j++) {             \
     148            fprintf(f, format, m[i][j]);                         \
     149        }                                                        \
     150        fprintf(f, "\n");                                        \
     151    }                                                            \
     152    fprintf(f, "\n");                                            \
     153    fclose(f);                                                   \
     154}
     155
     156write_type_matrix_endline1(int8_t);
     157write_type_matrix_endline1(uint8_t);
     158write_type_matrix_endline1(int16_t);
     159write_type_matrix_endline1(uint16_t);
     160write_type_matrix_endline1(int32_t);
     161write_type_matrix_endline1(uint32_t);
     162write_type_matrix_endline1(int64_t);
     163write_type_matrix_endline1(uint64_t);
     164write_type_matrix_endline1(float);
     165write_type_matrix_endline1(double);
     166
     167
    683168/* ------------------------------------- */
    684169/* --- write_imatrix_number_endline0 --- */
    685170/* ------------------------------------- */
    686 /* --------------------------------------------------------------------------------------------------------------------- */
    687 IMAGE_EXPORT(void) write_bmatrix_number_endline0(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    688 /* --------------------------------------------------------------------------------------------------------------------- */
    689 {
    690   int i,j, n;
    691  
    692   FILE *f;
    693 
    694   f = fopen(filename, "wt");
    695   if(f == NULL) {
    696     nrerror("Can't open file in write_bmatrix_number_endline0");
    697   }
    698 
    699   for(i=i0; i<=i1; i++) {
    700     fprintf(f, "[%3d] ", i);
    701     n = m[i][j0];
    702     for(j=j0; j<=j0+n; j++) {
    703       fprintf(f, format, m[i][j]);
    704     }
    705     fputc('\n', f);
    706   }
    707   fclose(f);
    708 }
    709 /* ------------------------------------------------------------------------------------------------------------------------- */
    710 IMAGE_EXPORT(void) write_i16matrix_number_endline0(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    711 /* ------------------------------------------------------------------------------------------------------------------------ */
    712 {
    713   int i,j, n;
    714  
    715   FILE *f;
    716 
    717   f = fopen(filename, "wt");
    718   if(f == NULL) {
    719     nrerror("Can't open file in write_i16matrix_number_endline0");
    720   }
    721 
    722   for(i=i0; i<=i1; i++) {
    723     fprintf(f, "[%3d] ", i);
    724     n = m[i][j0];
    725     for(j=j0; j<=j0+n; j++) {
    726       fprintf(f, format, m[i][j]);
    727     }
    728     fputc('\n', f);
    729   }
    730   fclose(f);
    731 }
    732 /* -------------------------------------------------------------------------------------------------------------------------- */
    733 IMAGE_EXPORT(void) write_ui16matrix_number_endline0(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    734 /* -------------------------------------------------------------------------------------------------------------------------- */
    735 {
    736   int i,j, n;
    737  
    738   FILE *f;
    739 
    740   f = fopen(filename, "wt");
    741   if(f == NULL) {
    742     nrerror("Can't open file in write_ui16matrix_number_endline0");
    743   }
    744 
    745   for(i=i0; i<=i1; i++) {
    746     fprintf(f, "[%3d] ", i);
    747     n = m[i][j0];
    748     for(j=j0; j<=j0+n; j++) {
    749       fprintf(f, format, m[i][j]);
    750     }
    751     fputc('\n', f);
    752   }
    753   fclose(f);
    754 }
    755 /* ------------------------------------------------------------------------------------------------------------------------ */
    756 IMAGE_EXPORT(void) write_i32matrix_number_endline0(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    757 /* ------------------------------------------------------------------------------------------------------------------------ */
    758 {
    759   int i,j, n;
    760  
    761   FILE *f;
    762 
    763   f = fopen(filename, "wt");
    764   if(f == NULL) {
    765     nrerror("Can't open file in write_i32matrix_number_endline0");
    766   }
    767 
    768   for(i=i0; i<=i1; i++) {
    769     fprintf(f, "[%3d] ", i);
    770     n = m[i][j0];
    771     for(j=j0; j<=j0+n; j++) {
    772       fprintf(f, format, m[i][j]);
    773     }
    774     fputc('\n', f);
    775   }
    776   fclose(f);
    777 }
    778 /* -------------------------------------------------------------------------------------------------------------------------- */
    779 IMAGE_EXPORT(void) write_ui32matrix_number_endline0(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    780 /* -------------------------------------------------------------------------------------------------------------------------- */
    781 {
    782   int i,j, n;
    783  
    784   FILE *f;
    785 
    786   f = fopen(filename, "wt");
    787   if(f == NULL) {
    788     nrerror("Can't open file in write_ui32matrix_number_endline0");
    789   }
    790 
    791   for(i=i0; i<=i1; i++) {
    792     fprintf(f, "[%3d] ", i);
    793     n = m[i][j0];
    794     for(j=j0; j<=j0+n; j++) {
    795       fprintf(f, format, m[i][j]);
    796     }
    797     fputc('\n', f);
    798   }
    799   fclose(f);
    800 }
    801 /* ------------------------------------------------------------------------------------------------------------------------ */
    802 IMAGE_EXPORT(void) write_i64matrix_number_endline0(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    803 /* ------------------------------------------------------------------------------------------------------------------------ */
    804 {
    805   int i,j;
    806   int64 n;
    807  
    808   FILE *f;
    809 
    810   f = fopen(filename, "wt");
    811   if(f == NULL) {
    812     nrerror("Can't open file in write_i64matrix_number_endline0");
    813   }
    814 
    815   for(i=i0; i<=i1; i++) {
    816     fprintf(f, "[%3d] ", i);
    817     n = m[i][j0];
    818     for(j=j0; j<=j0+n; j++) {
    819       fprintf(f, format, m[i][j]);
    820     }
    821     fputc('\n', f);
    822   }
    823   fclose(f);
    824 }
    825 /* -------------------------------------------------------------------------------------------------------------------- */
    826 IMAGE_EXPORT(void) write_imatrix_number_endline0(int **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    827 /* -------------------------------------------------------------------------------------------------------------------- */
    828 {
    829   int i,j, n;
    830  
    831   FILE *f;
    832 
    833   f = fopen(filename, "wt");
    834   if(f == NULL) {
    835     nrerror("Can't open file in write_imatrix_number_endline0");
    836   }
    837 
    838   for(i=i0; i<=i1; i++) {
    839     fprintf(f, "[%3d] ", i);
    840     n = m[i][j0];
    841     for(j=j0; j<=j0+n; j++) {
    842       fprintf(f, format, m[i][j]);
    843     }
    844     fputc('\n', f);
    845   }
    846   fclose(f);
    847 }
     171
     172#undef write_type_matrix_number_endline0
     173#define write_type_matrix_number_endline0(t) \
     174void short_name(t,write_,matrix_number_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename) \
     175{                                                                \
     176    FILE * f = fopen(filename, "wt");                            \
     177    if (f == NULL) {                                             \
     178        nrerror("Can't open file %s in %s", filename, __func__); \
     179    }                                                            \
     180    for (int32_t i = i0; i <= i1; i++) {                         \
     181        fprintf(f, "[%3d] ", i);                                 \
     182        int32_t n = (int32_t) m[i][j0];                          \
     183        for (int32_t j = j0; j <= j0 + n; j++) {                 \
     184            fprintf(f, format, m[i][j]);                         \
     185        }                                                        \
     186        fprintf(f, "\n");                                        \
     187    }                                                            \
     188    fprintf(f, "\n");                                            \
     189    fclose(f);                                                   \
     190}
     191
     192write_type_matrix_number_endline0(int8_t);
     193write_type_matrix_number_endline0(uint8_t);
     194write_type_matrix_number_endline0(int16_t);
     195write_type_matrix_number_endline0(uint16_t);
     196write_type_matrix_number_endline0(int32_t);
     197write_type_matrix_number_endline0(uint32_t);
     198write_type_matrix_number_endline0(int64_t);
     199write_type_matrix_number_endline0(uint64_t);
     200write_type_matrix_number_endline0(float);
     201write_type_matrix_number_endline0(double);
     202
     203
    848204/* ------------------------------------- */
    849205/* --- write_imatrix_number_endline1 --- */
    850206/* ------------------------------------- */
    851 /* --------------------------------------------------------------------------------------------------------------------- */
    852 IMAGE_EXPORT(void) write_bmatrix_number_endline1(byte **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    853 /* --------------------------------------------------------------------------------------------------------------------- */
    854 {
    855   int i,j, n;
    856  
    857   FILE *f;
    858 
    859   f = fopen(filename, "wt");
    860   if(f == NULL) {
    861     nrerror("Can't open file in write_bmatrix_number_endline1");
    862   }
    863 
    864   for(i=i0; i<=i1; i++) {
    865     fprintf(f, "[%3d] ", i);
    866     n = m[i][j0-1];
    867     for(j=j0; j<=j0+n-1; j++) {
    868       fprintf(f, format, m[i][j]);
    869     }
    870     fputc('\n', f);
    871   }
    872   fclose(f);
    873 }
    874 /* ------------------------------------------------------------------------------------------------------------------------ */
    875 IMAGE_EXPORT(void) write_i16matrix_number_endline1(int16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    876 /* ------------------------------------------------------------------------------------------------------------------------ */
    877 {
    878   int i,j, n;
    879  
    880   FILE *f;
    881 
    882   f = fopen(filename, "wt");
    883   if(f == NULL) {
    884     nrerror("Can't open file in write_i16matrix_number_endline0");
    885   }
    886 
    887   for(i=i0; i<=i1; i++) {
    888     fprintf(f, "[%3d] ", i);
    889     n = m[i][j0-1];
    890     for(j=j0; j<=j0+n-1; j++) {
    891       fprintf(f, format, m[i][j]);
    892     }
    893     fputc('\n', f);
    894   }
    895   fclose(f);
    896 }
    897 /* -------------------------------------------------------------------------------------------------------------------------- */
    898 IMAGE_EXPORT(void) write_ui16matrix_number_endline1(uint16 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    899 /* -------------------------------------------------------------------------------------------------------------------------- */
    900 {
    901   int i,j, n;
    902  
    903   FILE *f;
    904 
    905   f = fopen(filename, "wt");
    906   if(f == NULL) {
    907     nrerror("Can't open file in write_ui16matrix_number_endline0");
    908   }
    909 
    910   for(i=i0; i<=i1; i++) {
    911     fprintf(f, "[%3d] ", i);
    912     n = m[i][j0-1];
    913     for(j=j0; j<=j0+n-1; j++) {
    914       fprintf(f, format, m[i][j]);
    915     }
    916     fputc('\n', f);
    917   }
    918   fclose(f);
    919 }
    920 /* ------------------------------------------------------------------------------------------------------------------------ */
    921 IMAGE_EXPORT(void) write_i32matrix_number_endline1(int32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    922 /* ------------------------------------------------------------------------------------------------------------------------ */
    923 {
    924   int i,j, n;
    925  
    926   FILE *f;
    927 
    928   f = fopen(filename, "wt");
    929   if(f == NULL) {
    930     nrerror("Can't open file in write_i32matrix_number_endline0");
    931   }
    932 
    933   for(i=i0; i<=i1; i++) {
    934     fprintf(f, "[%3d] ", i);
    935     n = m[i][j0-1];
    936     for(j=j0; j<=j0+n-1; j++) {
    937       fprintf(f, format, m[i][j]);
    938     }
    939     fputc('\n', f);
    940   }
    941   fclose(f);
    942 }
    943 /* -------------------------------------------------------------------------------------------------------------------------- */
    944 IMAGE_EXPORT(void) write_ui32matrix_number_endline1(uint32 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    945 /* -------------------------------------------------------------------------------------------------------------------------- */
    946 {
    947   int i,j, n;
    948  
    949   FILE *f;
    950 
    951   f = fopen(filename, "wt");
    952   if(f == NULL) {
    953     nrerror("Can't open file in write_ui32matrix_number_endline0");
    954   }
    955 
    956   for(i=i0; i<=i1; i++) {
    957     fprintf(f, "[%3d] ", i);
    958     n = m[i][j0-1];
    959     for(j=j0; j<=j0+n-1; j++) {
    960       fprintf(f, format, m[i][j]);
    961     }
    962     fputc('\n', f);
    963   }
    964   fclose(f);
    965 }
    966 /* ------------------------------------------------------------------------------------------------------------------------ */
    967 IMAGE_EXPORT(void) write_i64matrix_number_endline1(int64 **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    968 /* ------------------------------------------------------------------------------------------------------------------------ */
    969 {
    970   int i,j;
    971   int64 n;
    972  
    973   FILE *f;
    974 
    975   f = fopen(filename, "wt");
    976   if(f == NULL) {
    977     nrerror("Can't open file in write_i64matrix_number_endline0");
    978   }
    979 
    980   for(i=i0; i<=i1; i++) {
    981     fprintf(f, "[%3d] ", i);
    982     n = m[i][j0-1];
    983     for(j=j0; j<=j0+n-1; j++) {
    984       fprintf(f, format, m[i][j]);
    985     }
    986     fputc('\n', f);
    987   }
    988   fclose(f);
    989 }
    990 /* -------------------------------------------------------------------------------------------------------------------- */
    991 IMAGE_EXPORT(void) write_imatrix_number_endline1(int **m,long i0, long i1, long j0, long j1, char *format, char *filename)
    992 /* -------------------------------------------------------------------------------------------------------------------- */
    993 {
    994   int i,j, n;
    995  
    996   FILE *f;
    997 
    998   f = fopen(filename, "wt");
    999   if(f == NULL) {
    1000     nrerror("Can't open file in write_imatrix_number_endline0");
    1001   }
    1002 
    1003   for(i=i0; i<=i1; i++) {
    1004     fprintf(f, "[%3d] ", i);
    1005     n = m[i][j0-1];
    1006     for(j=j0; j<=j0+n-1; j++) {
    1007       fprintf(f, format, m[i][j]);
    1008     }
    1009     fputc('\n', f);
    1010   }
    1011   fclose(f);
    1012 }
     207
     208#undef write_type_matrix_number_endline1
     209#define write_type_matrix_number_endline1(t) \
     210void short_name(t,write_,matrix_number_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename) \
     211{                                                                \
     212    FILE * f = fopen(filename, "wt");                            \
     213    if (f == NULL) {                                             \
     214        nrerror("Can't open file %s in %s", filename, __func__); \
     215    }                                                            \
     216    for (int32_t i = i0; i <= i1; i++) {                         \
     217        fprintf(f, "[%3d] ", i);                                 \
     218        int32_t n = (int32_t) m[i][j0 - 1];                      \
     219        for (int32_t j = j0; j <= j0 + n - 1; j++) {             \
     220            fprintf(f, format, m[i][j]);                         \
     221        }                                                        \
     222        fprintf(f, "\n");                                        \
     223    }                                                            \
     224    fprintf(f, "\n");                                            \
     225    fclose(f);                                                   \
     226}
     227
     228write_type_matrix_number_endline1(int8_t);
     229write_type_matrix_number_endline1(uint8_t);
     230write_type_matrix_number_endline1(int16_t);
     231write_type_matrix_number_endline1(uint16_t);
     232write_type_matrix_number_endline1(int32_t);
     233write_type_matrix_number_endline1(uint32_t);
     234write_type_matrix_number_endline1(int64_t);
     235write_type_matrix_number_endline1(uint64_t);
     236write_type_matrix_number_endline1(float);
     237write_type_matrix_number_endline1(double);
     238
     239
    1013240/* ---------------------- */
    1014241/* -- fwrite_trimatrix -- */
    1015242/* ---------------------- */
    1016 /* ---------------------------------------------------------------------------------------------------- */
    1017 IMAGE_EXPORT(void) fwrite_btrimatrix(byte **m,long i0,long i1,long j0, long j1, long step, char *filename)
    1018 /* ---------------------------------------------------------------------------------------------------- */
    1019 {
    1020   long  i, ncol = j1-j0+1;
    1021   FILE *f;
    1022 
    1023   f = fopen(filename, "wb");
    1024   if(f == NULL) nrerror("Can't open file in fwrite_btrimatrix");
    1025 
    1026   for(i=i0; i<=i1; i++) {
    1027     fwrite(m[i]+j0, sizeof(byte), ncol, f);
    1028     ncol += step;
    1029   }
    1030   fclose(f);
    1031 }
    1032 /* ------------------------------------------------------------------------------------------------------- */
    1033 IMAGE_EXPORT(void) fwrite_i16trimatrix(int16 **m,long i0,long i1,long j0, long j1, long step, char *filename)
    1034 /* ------------------------------------------------------------------------------------------------------- */
    1035 {
    1036   long  i, ncol = j1-j0+1;
    1037   FILE *f;
    1038 
    1039   f = fopen(filename, "wb");
    1040   if(f == NULL) nrerror("Can't open file in fwrite_i16trimatrix");
    1041 
    1042   for(i=i0; i<=i1; i++) {
    1043     fwrite(m[i]+j0, sizeof(int16), ncol, f);
    1044     ncol += step;
    1045   }
    1046   fclose(f);
    1047 }
    1048 /* --------------------------------------------------------------------------------------------------------- */
    1049 IMAGE_EXPORT(void) fwrite_ui16trimatrix(uint16 **m,long i0,long i1,long j0, long j1, long step, char *filename)
    1050 /* --------------------------------------------------------------------------------------------------------- */
    1051 {
    1052   long  i, ncol = j1-j0+1;
    1053   FILE *f;
    1054 
    1055   f = fopen(filename, "wb");
    1056   if(f == NULL) nrerror("Can't open file in fwrite_ui16trimatrix");
    1057 
    1058   for(i=i0; i<=i1; i++) {
    1059     fwrite(m[i]+j0, sizeof(uint16), ncol, f);
    1060     ncol += step;
    1061   }
    1062   fclose(f);
    1063 }
    1064 /* ------------------------------------------------------------------------------------------------------- */
    1065 IMAGE_EXPORT(void) fwrite_i32trimatrix(int32 **m,long i0,long i1,long j0, long j1, long step, char *filename)
    1066 /* ------------------------------------------------------------------------------------------------------- */
    1067 {
    1068   long  i, ncol = j1-j0+1;
    1069   FILE *f;
    1070 
    1071   f = fopen(filename, "wb");
    1072   if(f == NULL) nrerror("Can't open file in fwrite_i32trimatrix");
    1073 
    1074   for(i=i0; i<=i1; i++) {
    1075     fwrite(m[i]+j0, sizeof(int32), ncol, f);
    1076     ncol += step;
    1077   }
    1078   fclose(f);
    1079 }
    1080 /* --------------------------------------------------------------------------------------------------------- */
    1081 IMAGE_EXPORT(void) fwrite_f32trimatrix(float32 **m,long i0,long i1,long j0, long j1, long step, char *filename)
    1082 /* --------------------------------------------------------------------------------------------------------- */
    1083 {
    1084   long  i, ncol = j1-j0+1;
    1085   FILE *f;
    1086 
    1087   f = fopen(filename, "wb");
    1088   if(f == NULL) nrerror("Can't open file in fwrite_f32trimatrix");
    1089 
    1090   for(i=i0; i<=i1; i++) {
    1091     fwrite(m[i]+j0, sizeof(float32), ncol, f);
    1092     ncol += step;
    1093   }
    1094   fclose(f);
    1095 }
    1096 /* --------------------------------------------------------------------------------------------------------- */
    1097 IMAGE_EXPORT(void) fwrite_f64trimatrix(float64 **m,long i0,long i1,long j0, long j1, long step, char *filename)
    1098 /* --------------------------------------------------------------------------------------------------------- */
    1099 {
    1100   long  i, ncol = j1-j0+1;
    1101   FILE *f;
    1102 
    1103   f = fopen(filename, "wb");
    1104   if(f == NULL) nrerror("Can't open file in fwrite_f64trimatrix");
    1105 
    1106   for(i=i0; i<=i1; i++) {
    1107     fwrite(m[i]+j0, sizeof(float64), ncol, f);
    1108   }
    1109   fclose(f);
    1110 }
     243
     244#undef fwrite_type_trimatrix
     245#define fwrite_type_trimatrix(t) \
     246void short_name(t,fwrite_,trimatrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step, char * filename) \
     247{                                                                \
     248    int32_t ncol = j1 - j0 + 1;                                  \
     249    FILE * f = fopen(filename, "wb");                            \
     250    if (f == NULL) {                                             \
     251        nrerror("Can't open file %s in %s", filename, __func__); \
     252    }                                                            \
     253    for (int32_t i = i0; i <= i1; i++) {                         \
     254        fwrite(m[i] + j0, sizeof(t), ncol, f);                   \
     255        ncol += step;                                            \
     256    }                                                            \
     257    fclose(f);                                                   \
     258}
     259
     260fwrite_type_trimatrix(int8_t);
     261fwrite_type_trimatrix(uint8_t);
     262fwrite_type_trimatrix(int16_t);
     263fwrite_type_trimatrix(uint16_t);
     264fwrite_type_trimatrix(int32_t);
     265fwrite_type_trimatrix(uint32_t);
     266fwrite_type_trimatrix(int64_t);
     267fwrite_type_trimatrix(uint64_t);
     268fwrite_type_trimatrix(float);
     269fwrite_type_trimatrix(double);
     270
     271
     272
    1111273
    1112274/* --------------------- */
    1113275/* -- fread_trimatrix -- */
    1114276/* --------------------- */
    1115 /* --------------------------------------------------------------------------------------------------- */
    1116 IMAGE_EXPORT(void) fread_btrimatrix(char *filename, byte **m,long i0,long i1,long j0, long j1, long step)
    1117 /* --------------------------------------------------------------------------------------------------- */
    1118 {
    1119   long  i, ncol = j1-j0+1, nread;
    1120   FILE *f;
    1121 
    1122   f = fopen(filename, "rb");
    1123   if(f == NULL) nrerror("Can't open file in fread_btrimatrix");
    1124 
    1125   for(i=i0; i<=i1; i++) {
    1126     nread = fread(m[i]+j0, sizeof(byte), ncol, f);
    1127     if(nread != ncol) nrerror("fread_btrimatrix : can't read data");
    1128     ncol += step;
    1129   }
    1130   fclose(f);
    1131 }
    1132 /* ------------------------------------------------------------------------------------------------------ */
    1133 IMAGE_EXPORT(void) fread_i16trimatrix(char *filename, int16 **m,long i0,long i1,long j0, long j1, long step)
    1134 /* ------------------------------------------------------------------------------------------------------ */
    1135 {
    1136   long  i, ncol = j1-j0+1, nread;
    1137   FILE *f;
    1138 
    1139   f = fopen(filename, "rb");
    1140   if(f == NULL) nrerror("Can't open file in fread_i16trimatrix");
    1141 
    1142   for(i=i0; i<=i1; i++) {
    1143     nread = fread(m[i]+j0, sizeof(int16), ncol, f);
    1144     if(nread != ncol) nrerror("fread_i16trimatrix : can't read data");
    1145     ncol += step;
    1146   }
    1147   fclose(f);
    1148 }
    1149 /* -------------------------------------------------------------------------------------------------------- */
    1150 IMAGE_EXPORT(void) fread_ui16trimatrix(char *filename, uint16 **m,long i0,long i1,long j0, long j1, long step)
    1151 /* -------------------------------------------------------------------------------------------------------- */
    1152 {
    1153   long  i, ncol = j1-j0+1, nread;
    1154   FILE *f;
    1155 
    1156   f = fopen(filename, "rb");
    1157   if(f == NULL) nrerror("Can't open file in fread_ui16trimatrix");
    1158 
    1159   for(i=i0; i<=i1; i++) {
    1160     nread = fread(m[i]+j0, sizeof(uint16), ncol, f);
    1161     if(nread != ncol) nrerror("fread_ui16trimatrix : can't read data");
    1162     ncol += step;
    1163   }
    1164   fclose(f);
    1165 }
    1166 /* -------------------------------------------------------------------------------------------------- */
    1167 IMAGE_EXPORT(void) fread_itrimatrix(char *filename, int **m,long i0,long i1,long j0, long j1, long step)
    1168 /* -------------------------------------------------------------------------------------------------- */
    1169 {
    1170   long  i, ncol = j1-j0+1, nread;
    1171   FILE *f;
    1172 
    1173   f = fopen(filename, "rb");
    1174   if(f == NULL) nrerror("Can't open file in fread_itrimatrix");
    1175 
    1176   for(i=i0; i<=i1; i++) {
    1177     nread = fread(m[i]+j0, sizeof(int), ncol, f);
    1178     if(nread != ncol) nrerror("fread_itrimatrix : can't read data");
    1179     ncol += step;
    1180   }
    1181   fclose(f);
    1182 }
    1183 /* ------------------------------------------------------------------------------------------------------ */
    1184 IMAGE_EXPORT(void) fread_i32trimatrix(char *filename, int32 **m,long i0,long i1,long j0, long j1, long step)
    1185 /* ------------------------------------------------------------------------------------------------------ */
    1186 {
    1187   long  i, ncol = j1-j0+1, nread;
    1188   FILE *f;
    1189 
    1190   f = fopen(filename, "rb");
    1191   if(f == NULL) nrerror("Can't open file in fread_i32trimatrix");
    1192 
    1193   for(i=i0; i<=i1; i++) {
    1194     nread = fread(m[i]+j0, sizeof(byte), ncol, f);
    1195     if(nread != ncol) nrerror("fread_i32trimatrix : can't read data");
    1196     ncol += step;
    1197   }
    1198   fclose(f);
    1199 }
    1200 /* -------------------------------------------------------------------------------------------------------- */
    1201 IMAGE_EXPORT(void) fread_f32trimatrix(char *filename, float32 **m,long i0,long i1,long j0, long j1, long step)
    1202 /* -------------------------------------------------------------------------------------------------------- */
    1203 {
    1204   long  i, ncol = j1-j0+1, nread;
    1205   FILE *f;
    1206 
    1207   f = fopen(filename, "rb");
    1208   if(f == NULL) nrerror("Can't open file in fread_f32trimatrix");
    1209 
    1210   for(i=i0; i<=i1; i++) {
    1211     nread = fread(m[i]+j0, sizeof(byte), ncol, f);
    1212     if(nread != ncol) nrerror("fread_f32trimatrix : can't read data");
    1213     ncol += step;
    1214   }
    1215   fclose(f);
    1216 }
    1217 /* -------------------------------------------------------------------------------------------------------- */
    1218 IMAGE_EXPORT(void) fread_f64trimatrix(char *filename, float64 **m,long i0,long i1,long j0, long j1, long step)
    1219 /* -------------------------------------------------------------------------------------------------------- */
    1220 {
    1221   long  i, ncol = j1-j0+1, nread;
    1222   FILE *f;
    1223 
    1224   f = fopen(filename, "rb");
    1225   if(f == NULL) nrerror("Can't open file in fread_f64trimatrix");
    1226 
    1227   for(i=i0; i<=i1; i++) {
    1228     nread = fread(m[i]+j0, sizeof(byte), ncol, f);
    1229     if(nread != ncol) nrerror("fread_f64trimatrix : can't read data");
    1230     ncol += step;
    1231   }
    1232   fclose(f);
    1233 }
     277
     278#undef fread_type_trimatrix
     279#define fread_type_trimatrix(t) \
     280void short_name(t,fread_,trimatrix)(char * filename, t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step) \
     281{                                                                \
     282    int32_t ncol = j1 - j0 + 1;                                  \
     283    FILE * f = fopen(filename, "rb");                            \
     284    if (f == NULL) {                                             \
     285        nrerror("Can't open file %s in %s", filename, __func__); \
     286    }                                                            \
     287    for (int32_t i = i0; i <= i1; i++) {                         \
     288        fread(m[i] + j0, sizeof(t), ncol, f);    \
     289        ncol += step;                                            \
     290    }                                                            \
     291    fclose(f);                                                   \
     292}
     293
     294fread_type_trimatrix(int8_t);
     295fread_type_trimatrix(uint8_t);
     296fread_type_trimatrix(int16_t);
     297fread_type_trimatrix(uint16_t);
     298fread_type_trimatrix(int32_t);
     299fread_type_trimatrix(uint32_t);
     300fread_type_trimatrix(int64_t);
     301fread_type_trimatrix(uint64_t);
     302fread_type_trimatrix(float);
     303fread_type_trimatrix(double);
     304
     305
     306// Local Variables:
     307// tab-width: 4
     308// c-basic-offset: 4
     309// c-file-offsets:((innamespace . 0)(inline-open . 0))
     310// indent-tabs-mode: nil
     311// End:
     312
     313// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     314
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrio3.c

    r772 r823  
    3030/* --- display_cube --- */
    3131/* -------------------- */
    32 /* ------------------------------------------------------------------------------------------------------------------------- */
    33 IMAGE_EXPORT(void) display_i8cube(int8 ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name)
    34 /* ------------------------------------------------------------------------------------------------------------------------- */
    35 {
    36   long i,j,k;
    3732
    38   if(name != NULL) puts(name);
     33#undef display_type_cube
     34#define display_type_cube(t) \
     35void short_name(t,display_,cube)(t *** c, int32_t ndl, int32_t ndh, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * name) \
     36{                                                  \
     37    if (name != NULL) {                            \
     38        printf(name);                              \
     39    }                                              \
     40    for (int32_t k = ndl; k <= ndh; k++) {         \
     41        for (int32_t i = nrl; i <= nrh; i++) {     \
     42            for (int32_t j = ncl; j <= nch; j++) { \
     43                printf(format, c[k][i][j]);        \
     44            }                                      \
     45            printf("\n");                          \
     46        }                                          \
     47        printf("\n");                              \
     48    }                                              \
     49}
    3950
    40   for(k=ndl; k<=ndh; k++) {
    41     for(i=nrl; i<=nrh; i++) {
    42       for(j=ncl; j<=nch; j++) {
    43         printf(format, c[k][i][j]);
    44       }
    45       putchar('\n');
    46     }
    47     putchar('\n');
    48   }
    49 }
    50 /* --------------------------------------------------------------------------------------------------------------------------- */
    51 IMAGE_EXPORT(void) display_i16cube(int16 ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name)
    52 /* --------------------------------------------------------------------------------------------------------------------------- */
    53 {
    54   long i,j,k;
     51display_type_cube(int8_t);
     52display_type_cube(uint8_t);
     53display_type_cube(int16_t);
     54display_type_cube(uint16_t);
     55display_type_cube(int32_t);
     56display_type_cube(uint32_t);
     57display_type_cube(int64_t);
     58display_type_cube(uint64_t);
     59display_type_cube(float);
     60display_type_cube(double);
    5561
    56   if(name != NULL) puts(name);
    5762
    58   for(k=ndl; k<=ndh; k++) {
    59     for(i=nrl; i<=nrh; i++) {
    60       for(j=ncl; j<=nch; j++) {
    61         printf(format, c[k][i][j]);
    62       }
    63       putchar('\n');
    64     }
    65     putchar('\n');
    66   }
    67 }
    68 /* ----------------------------------------------------------------------------------------------------------------------------- */
    69 IMAGE_EXPORT(void) display_ui16cube(uint16 ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name)
    70 /* ----------------------------------------------------------------------------------------------------------------------------- */
    71 {
    72   long i,j,k;
    73 
    74   if(name != NULL) puts(name);
    75 
    76   for(k=ndl; k<=ndh; k++) {
    77     for(i=nrl; i<=nrh; i++) {
    78       for(j=ncl; j<=nch; j++) {
    79         printf(format, c[k][i][j]);
    80       }
    81       putchar('\n');
    82     }
    83     putchar('\n');
    84   }
    85 }
    86 /* --------------------------------------------------------------------------------------------------------------------------- */
    87 IMAGE_EXPORT(void) display_i32cube(int32 ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name)
    88 /* --------------------------------------------------------------------------------------------------------------------------- */
    89 {
    90   long i,j,k;
    91 
    92   if(name != NULL) puts(name);
    93 
    94   for(k=ndl; k<=ndh; k++) {
    95     for(i=nrl; i<=nrh; i++) {
    96       for(j=ncl; j<=nch; j++) {
    97         printf(format, c[k][i][j]);
    98       }
    99       putchar('\n');
    100     }
    101     putchar('\n');
    102   }
    103 }
    104 /* ----------------------------------------------------------------------------------------------------------------------------- */
    105 IMAGE_EXPORT(void) display_ui32cube(uint32 ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name)
    106 /* ----------------------------------------------------------------------------------------------------------------------------- */
    107 {
    108   long i,j,k;
    109 
    110   if(name != NULL) puts(name);
    111 
    112   for(k=ndl; k<=ndh; k++) {
    113     for(i=nrl; i<=nrh; i++) {
    114       for(j=ncl; j<=nch; j++) {
    115         printf(format, c[k][i][j]);
    116       }
    117       putchar('\n');
    118     }
    119     putchar('\n');
    120   }
    121 }
    122 /* --------------------------------------------------------------------------------------------------------------------------- */
    123 IMAGE_EXPORT(void) display_i64cube(int64 ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name)
    124 /* --------------------------------------------------------------------------------------------------------------------------- */
    125 {
    126   long i,j,k;
    127 
    128   if(name != NULL) puts(name);
    129 
    130   for(k=ndl; k<=ndh; k++) {
    131     for(i=nrl; i<=nrh; i++) {
    132       for(j=ncl; j<=nch; j++) {
    133         printf(format, c[k][i][j]);
    134       }
    135       putchar('\n');
    136     }
    137     putchar('\n');
    138   }
    139 }
    140 /* ----------------------------------------------------------------------------------------------------------------------------- */
    141 IMAGE_EXPORT(void) display_f32cube(float32 ***c,long ndl, long ndh, long nrl,long nrh,long ncl, long nch, char *format, char *name)
    142 /* ----------------------------------------------------------------------------------------------------------------------------- */
    143 {
    144   long i,j,k;
    145 
    146   if(name != NULL) puts(name);
    147 
    148   for(k=ndl; k<=ndh; k++) {
    149     for(i=nrl; i<=nrh; i++) {
    150       for(j=ncl; j<=nch; j++) {
    151         printf(format, c[k][i][j]);
    152       }
    153       putchar('\n');
    154     }
    155     putchar('\n');
    156   }
    157 }
    15863
    15964/* ---------------- */
    16065/* -- write_cube -- */
    16166/* ---------------- */
    162 /* ------------------------------------------------------------------------------------------------------------------------------ */
    163 IMAGE_EXPORT(void) write_i8cube(int8 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename)
    164 /* ------------------------------------------------------------------------------------------------------------------------------ */
    165 {
    166   int i, j, k;
    16767
    168   FILE *f;
     68#undef write_type_cube
     69#define write_type_cube(t) \
     70void short_name(t,write_,cube)(t *** c, int32_t ndl, int32_t ndh, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \
     71{                                                                \
     72    FILE * f = fopen(filename, "wt");                            \
     73    if (f == NULL) {                                             \
     74        nrerror("Can't open file %s in %s", filename, __func__); \
     75    }                                                            \
     76    for (int32_t k = ndl; k <= ndh; k++) {                       \
     77        for (int32_t i = nrl; i <= nrh; i++) {                   \
     78            for (int32_t j = ncl; j <= nch; j++) {               \
     79                fprintf(f, format, c[k][i][j]);                  \
     80            }                                                    \
     81            fprintf(f, "\n");                                    \
     82        }                                                        \
     83        fprintf(f, "\n");                                        \
     84    }                                                            \
     85    fclose(f);                                                   \
     86}
    16987
    170   f = fopen(filename, "wt");
    171   if(f == NULL) {
    172     nrerror("Can't open file in write_i8cube");
    173   }
     88write_type_cube(int8_t);
     89write_type_cube(uint8_t);
     90write_type_cube(int16_t);
     91write_type_cube(uint16_t);
     92write_type_cube(int32_t);
     93write_type_cube(uint32_t);
     94write_type_cube(int64_t);
     95write_type_cube(uint64_t);
     96write_type_cube(float);
     97write_type_cube(double);
    17498
    175   for(k=ndl; k<=ndh; k++) {
    176     for(i=nrl; i<=nrh; i++) {
    177       for(j=ncl; j<=nch; j++) {
    178         fprintf(f, format, c[k][i][j]);
    179       }
    180       fputc('\n', f);
    181     }
    182     fputc('\n', f);
    183   }
    18499
    185   fclose(f);
    186 }
    187 /* -------------------------------------------------------------------------------------------------------------------------------- */
    188 IMAGE_EXPORT(void) write_i16cube(int16 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename)
    189 /* -------------------------------------------------------------------------------------------------------------------------------- */
    190 {
    191   int i, j, k;
    192 
    193   FILE *f;
    194 
    195   f = fopen(filename, "wt");
    196   if(f == NULL) {
    197     nrerror("Can't open file in write_i16cube");
    198   }
    199 
    200   for(k=ndl; k<=ndh; k++) {
    201     for(i=nrl; i<=nrh; i++) {
    202       for(j=ncl; j<=nch; j++) {
    203         fprintf(f, format, c[k][i][j]);
    204       }
    205       fputc('\n', f);
    206     }
    207     fputc('\n', f);
    208   }
    209 
    210   fclose(f);
    211 }
    212 /* ---------------------------------------------------------------------------------------------------------------------------------- */
    213 IMAGE_EXPORT(void) write_ui16cube(uint16 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename)
    214 /* ---------------------------------------------------------------------------------------------------------------------------------- */
    215 {
    216   int i, j, k;
    217 
    218   FILE *f;
    219 
    220   f = fopen(filename, "wt");
    221   if(f == NULL) {
    222     nrerror("Can't open file in write_ui16cube");
    223   }
    224 
    225   for(k=ndl; k<=ndh; k++) {
    226     for(i=nrl; i<=nrh; i++) {
    227       for(j=ncl; j<=nch; j++) {
    228         fprintf(f, format, c[k][i][j]);
    229       }
    230       fputc('\n', f);
    231     }
    232     fputc('\n', f);
    233   }
    234 
    235   fclose(f);
    236 }
    237 /* -------------------------------------------------------------------------------------------------------------------------------- */
    238 IMAGE_EXPORT(void) write_i32cube(int32 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename)
    239 /* -------------------------------------------------------------------------------------------------------------------------------- */
    240 {
    241   int i, j, k;
    242 
    243   FILE *f;
    244 
    245   f = fopen(filename, "wt");
    246   if(f == NULL) {
    247     nrerror("Can't open file in write_i32cube");
    248   }
    249 
    250   for(k=ndl; k<=ndh; k++) {
    251     for(i=nrl; i<=nrh; i++) {
    252       for(j=ncl; j<=nch; j++) {
    253         fprintf(f, format, c[k][i][j]);
    254       }
    255       fputc('\n', f);
    256     }
    257     fputc('\n', f);
    258   }
    259 
    260   fclose(f);
    261 }
    262 /* ---------------------------------------------------------------------------------------------------------------------------------- */
    263 IMAGE_EXPORT(void) write_ui32cube(uint32 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename)
    264 /* ---------------------------------------------------------------------------------------------------------------------------------- */
    265 {
    266   int i, j, k;
    267 
    268   FILE *f;
    269 
    270   f = fopen(filename, "wt");
    271   if(f == NULL) {
    272     nrerror("Can't open file in write_ui32cube");
    273   }
    274 
    275   for(k=ndl; k<=ndh; k++) {
    276     for(i=nrl; i<=nrh; i++) {
    277       for(j=ncl; j<=nch; j++) {
    278         fprintf(f, format, c[k][i][j]);
    279       }
    280       fputc('\n', f);
    281     }
    282     fputc('\n', f);
    283   }
    284 
    285   fclose(f);
    286 }
    287 /* -------------------------------------------------------------------------------------------------------------------------------- */
    288 IMAGE_EXPORT(void) write_i64cube(int64 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename)
    289 /* -------------------------------------------------------------------------------------------------------------------------------- */
    290 {
    291   int i, j, k;
    292 
    293   FILE *f;
    294 
    295   f = fopen(filename, "wt");
    296   if(f == NULL) {
    297     nrerror("Can't open file in write_i64cube");
    298   }
    299 
    300   for(k=ndl; k<=ndh; k++) {
    301     for(i=nrl; i<=nrh; i++) {
    302       for(j=ncl; j<=nch; j++) {
    303         fprintf(f, format, c[k][i][j]);
    304       }
    305       fputc('\n', f);
    306     }
    307     fputc('\n', f);
    308   }
    309 
    310   fclose(f);
    311 }
    312 /* ---------------------------------------------------------------------------------------------------------------------------------- */
    313 IMAGE_EXPORT(void) write_f32cube(float32 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *format, char *filename)
    314 /* ---------------------------------------------------------------------------------------------------------------------------------- */
    315 {
    316   int i, j, k;
    317 
    318   FILE *f;
    319 
    320   f = fopen(filename, "wt");
    321   if(f == NULL) {
    322     nrerror("Can't open file in write_f32cube");
    323   }
    324 
    325   for(k=ndl; k<=ndh; k++) {
    326     for(i=nrl; i<=nrh; i++) {
    327       for(j=ncl; j<=nch; j++) {
    328         fprintf(f, format, c[k][i][j]);
    329       }
    330       fputc('\n', f);
    331     }
    332     fputc('\n', f);
    333   }
    334 
    335   fclose(f);
    336 }
    337100
    338101/* ---------------- */
    339102/* -- fread_cube -- */
    340103/* ---------------- */
    341 /* ----------------------------------------------------------------------------------------------------------- */
    342 IMAGE_EXPORT(void) fread_i8cube(char *filename, int8 ***c,long ndl,long ndh,long nrl,long nrh,long ncl, long nch)
    343 /* ----------------------------------------------------------------------------------------------------------- */
    344 {
    345   long  i, k;
    346   long ncol = nch-ncl+1, nread;
    347   FILE *f;
    348104
    349   f = fopen(filename, "rb");
    350   if(f == NULL)
    351     nrerror("Can't open file in fread_i8cube");
     105#undef fread_type_cube
     106#define fread_type_cube(t) \
     107void short_name(t,fread_,cube)(t *** c, int32_t ndl, int32_t ndh, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, char * format, char * filename) \
     108{                                                                     \
     109    int32_t ncol = nch - ncl + 1;                                     \
     110    FILE * f = fopen(filename, "rb");                                 \
     111    if (f == NULL) {                                                  \
     112        nrerror("Can't open file %s in %s", filename, __func__);      \
     113    }                                                                 \
     114    for (int32_t k = ndl; k <= ndh; k++) {                            \
     115        for (int32_t i = nrl; i <= nrh; i++) {                        \
     116            int32_t nread = fread(&c[k][i][ncl], sizeof(t), ncol, f); \
     117            if (nread != ncol) {                                      \
     118                nrerror("%s: Can't write data", __func__);            \
     119            }                                                         \
     120        }                                                             \
     121    }                                                                 \
     122    fclose(f);                                                        \
     123}
     124
     125fread_type_cube(int8_t);
     126fread_type_cube(uint8_t);
     127fread_type_cube(int16_t);
     128fread_type_cube(uint16_t);
     129fread_type_cube(int32_t);
     130fread_type_cube(uint32_t);
     131fread_type_cube(int64_t);
     132fread_type_cube(uint64_t);
     133fread_type_cube(float);
     134fread_type_cube(double);
    352135
    353136
    354   for(k=ndl; k<=ndh; k++) {
    355     for(i=nrl; i<=nrh; i++) {
    356       nread = fread( &(c[k][i][ncl]), sizeof(int8), ncol, f);
    357       if(nread != ncol) nrerror("fread_i8cube : can't write data");
    358     }
    359   }
    360   fclose(f);
    361 }
    362 /* ------------------------------------------------------------------------------------------------------------- */
    363 IMAGE_EXPORT(void) fread_i16cube(char *filename, int16 ***c,long ndl,long ndh,long nrl,long nrh,long ncl, long nch)
    364 /* ------------------------------------------------------------------------------------------------------------- */
    365 {
    366   long  i, k;
    367   long ncol = nch-ncl+1, nread;
    368   FILE *f;
    369 
    370   f = fopen(filename, "rb");
    371   if(f == NULL)
    372     nrerror("Can't open file in fread_i16cube");
    373 
    374   for(k=ndl; k<=ndh; k++) {
    375     for(i=nrl; i<=nrh; i++) {
    376       nread = fread( &(c[k][i][ncl]), sizeof(int16), ncol, f);
    377       if(nread != ncol) nrerror("fread_i16cube : can't write data");
    378     }
    379   }
    380   fclose(f);
    381 }
    382 /* -------------------------------------------------------------------------------------------------------------------- */
    383 IMAGE_EXPORT(void) fread_ui16cube(char *filename, uint16 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch)
    384 /* -------------------------------------------------------------------------------------------------------------------- */
    385 {
    386   long  i, k;
    387   long ncol = nch-ncl+1, nread;
    388   FILE *f;
    389 
    390   f = fopen(filename, "rb");
    391   if(f == NULL)
    392     nrerror("Can't open file in fread_ui16cube");
    393137
    394138
    395   for(k=ndl; k<=ndh; k++) {
    396     for(i=nrl; i<=nrh; i++) {
    397       nread = fread( &(c[k][i][ncl]), sizeof(uint16), ncol, f);
    398       if(nread != ncol) nrerror("fread_ui16cube : can't write data");
    399     }
    400   }
    401   fclose(f);
    402 }
    403 /* ------------------------------------------------------------------------------------------------------------------ */
    404 IMAGE_EXPORT(void) fread_i32cube(char *filename, int32 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch)
    405 /* ------------------------------------------------------------------------------------------------------------------ */
    406 {
    407   long  i, k;
    408   long ncol = nch-ncl+1, nread;
    409   FILE *f;
    410 
    411   f = fopen(filename, "rb");
    412   if(f == NULL)
    413     nrerror("Can't open file in fread_i32cube");
    414139
    415140
    416   for(k=ndl; k<=ndh; k++) {
    417     for(i=nrl; i<=nrh; i++) {
    418       nread = fread( &(c[k][i][ncl]), sizeof(int32), ncol, f);
    419       if(nread != ncol) nrerror("fread_i32cube : can't write data");
    420     }
    421   }
    422   fclose(f);
    423 }
    424 /* --------------- */
    425 /* --- nrio3.h --- */
    426 /* --------------- */
     141// Local Variables:
     142// tab-width: 4
     143// c-basic-offset: 4
     144// c-file-offsets:((innamespace . 0)(inline-open . 0))
     145// indent-tabs-mode: nil
     146// End:
    427147
    428 #ifndef __NRIO3_H__
    429 #define __NRIO3_H__
     148// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
    430149
    431 #ifdef __cplusplus
    432 #pragma message ("C++")
    433 extern "C" {
    434 #endif
    435    
    436 /* ------------------ */
    437 /* --- fread_cube --- */
    438 /* ------------------ */
    439 
    440 IMAGE_EXPORT(void) fread_ui32cube(char *filename, uint32  ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
    441 IMAGE_EXPORT(void) fread_i64cube (char *filename, int64   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
    442 IMAGE_EXPORT(void) fread_f32cube (char *filename, float32 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch);
    443 
    444 /* ----------------- */
    445 /* -- fwrite_cube -- */
    446 /* ----------------- */
    447 
    448 IMAGE_EXPORT(void) fwrite_i8cube(int8     ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    449 IMAGE_EXPORT(void) fwrite_i16cube(int16   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    450 IMAGE_EXPORT(void) fwrite_ui16cube(uint16 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    451 IMAGE_EXPORT(void) fwrite_i32cube(int32   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    452 IMAGE_EXPORT(void) fwrite_ui32cube(uint32 ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    453 IMAGE_EXPORT(void) fwrite_i64cube(int64   ***c, long ndl, long ndh, long nrl, long nrh, long ncl, long nch, char *filename);
    454 
    455 #ifdef __cplusplus
    456 }
    457 #endif
    458 
    459 #endif /* __NRIO3_H__ */
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrlinalg.c

    r772 r823  
    2424#include "nrlinalg.h"
    2525
     26#undef transpose_type_matrix
     27#define transpose_type_matrix(t) \
     28void short_name(t,transpose_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** D) \
     29{                                              \
     30        for (int32_t i = nrl; i <= nch; i++) {     \
     31                for (int32_t j = ncl; j <= nch; j++) { \
     32                        D[j][i] = S[i][j];                 \
     33                }                                      \
     34        }                                          \
     35}
    2636
    27 /* ---------------------------------------------------------------------------------------- */
    28 IMAGE_EXPORT(void) transpose_bmatrix(byte **S, long nrl,long nrh,long ncl, long nch, byte **D)
    29 /* ---------------------------------------------------------------------------------------- */
    30 {
    31         int i, j;
    32        
    33         for(i=nrl; i<=nch; i++) {
    34                 for(j=ncl; j<=nch; j++) {
    35                         D[j][i] = S[i][j];
    36                 }
    37         }
     37transpose_type_matrix(int8_t);
     38transpose_type_matrix(uint8_t);
     39transpose_type_matrix(int16_t);
     40transpose_type_matrix(uint16_t);
     41transpose_type_matrix(int32_t);
     42transpose_type_matrix(uint32_t);
     43transpose_type_matrix(int64_t);
     44transpose_type_matrix(uint64_t);
     45transpose_type_matrix(float);
     46transpose_type_matrix(double);
     47transpose_type_matrix(rgb8);
     48transpose_type_matrix(rgbx8);
     49
     50
     51#undef transpose1_type_matrix
     52#define transpose1_type_matrix(t) \
     53void short_name(t,transpose1_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch) \
     54{                                                \
     55    t tmp;                                       \
     56        for (int32_t i = nrl; i <= nch; i++) {       \
     57                for (int32_t j = i + 1; j <= nch; j++) { \
     58                        tmp = S[j][i];                       \
     59            S[j][i] = S[i][j];                   \
     60            S[i][j] = tmp;                       \
     61                }                                        \
     62        }                                            \
    3863}
    39 /* ------------------------------------------------------------------------------------------- */
    40 IMAGE_EXPORT(void) transpose_si16matrix(sint16 **S, long nrl,long nrh,long ncl, long nch, sint16 **D)
    41 /* ------------------------------------------------------------------------------------------- */
    42 {
    43         int i, j;
    44        
    45         for(i=nrl; i<=nch; i++) {
    46                 for(j=ncl; j<=nch; j++) {
    47                         D[j][i] = S[i][j];
    48                 }
    49         }
    50 }
    51 /* ------------------------------------------------------------------------------------------- */
    52 IMAGE_EXPORT(void) transpose_ui16matrix(uint16 **S, long nrl,long nrh,long ncl, long nch, uint16 **D)
    53 /* ------------------------------------------------------------------------------------------- */
    54 {
    55         int i, j;
    56        
    57         for(i=nrl; i<=nch; i++) {
    58                 for(j=ncl; j<=nch; j++) {
    59                         D[j][i] = S[i][j];
    60                 }
    61         }
    62 }
    63 /* ----------------------------------------------------------------------------------------------- */
    64 IMAGE_EXPORT(void) transpose_si32matrix(sint32 **S, long nrl,long nrh,long ncl, long nch, sint32 **D)
    65 /* ----------------------------------------------------------------------------------------------- */
    66 {
    67         int i, j;
    68        
    69         for(i=nrl; i<=nch; i++) {
    70                 for(j=ncl; j<=nch; j++) {
    71                         D[j][i] = S[i][j];
    72                 }
    73         }
    74 }
    75 /* ----------------------------------------------------------------------------------------------- */
    76 IMAGE_EXPORT(void) transpose_ui32matrix(uint32 **S, long nrl,long nrh,long ncl, long nch, uint32 **D)
    77 /* ----------------------------------------------------------------------------------------------- */
    78 {
    79         int i, j;
    80        
    81         for(i=nrl; i<=nch; i++) {
    82                 for(j=ncl; j<=nch; j++) {
    83                         D[j][i] = S[i][j];
    84                 }
    85         }
    86 }
    87 /* ----------------------------------------------------------------------------------------- */
    88 IMAGE_EXPORT(void) transpose_f32matrix(float32 **S, long nrl,long nrh,long ncl, long nch, float32 **D)
    89 /* ----------------------------------------------------------------------------------------- */
    90 {
    91         int i, j;
    92        
    93         for(i=nrl; i<=nch; i++) {
    94                 for(j=ncl; j<=nch; j++) {
    95                         D[j][i] = S[i][j];
    96                 }
    97         }
    98 }
    99 /* -------------------------------------------------------------------------------------------- */
    100 IMAGE_EXPORT(void) transpose_dmatrix(float64 **S, long nrl,long nrh,long ncl, long nch, float64 **D)
    101 /* -------------------------------------------------------------------------------------------- */
    102 {
    103         int i, j;
    104        
    105         for(i=nrl; i<=nch; i++) {
    106                 for(j=ncl; j<=nch; j++) {
    107                         D[j][i] = S[i][j];
    108                 }
    109         }
    110 }
    111 /* ------------------------------------------------------------------------------------------- */
    112 IMAGE_EXPORT(void) transpose_rgb8matrix(rgb8 **S, long nrl,long nrh,long ncl, long nch, rgb8 **D)
    113 /* ------------------------------------------------------------------------------------------- */
    114 {
    115         int i, j;
    116        
    117         for(i=nrl; i<=nch; i++) {
    118                 for(j=ncl; j<=nch; j++) {
    119                         D[j][i] = S[i][j];
    120                 }
    121         }
    122 }
    123 /* ------------------------------------------------------------------------------- */
    124 IMAGE_EXPORT(void) transpose1_bmatrix(byte **S, long nrl,long nrh,long ncl, long nch)
    125 /* ------------------------------------------------------------------------------- */
    126 {
    127         int i, j;
    128         byte t;
    129        
    130         for(i=nrl; i<=nch; i++) {
    131                 for(j=i+1; j<=nch; j++) {
    132                         t       = S[j][i];
    133                         S[j][i] = S[i][j];
    134                         S[i][j] = t;
    135                 }
    136         }
    137 }
    138 /* ---------------------------------------------------------------------------------- */
    139 IMAGE_EXPORT(void) transpose1_si16matrix(sint16 **S, long nrl,long nrh,long ncl, long nch)
    140 /* ---------------------------------------------------------------------------------- */
    141 {
    142         int i, j;
    143         int16 t;
    144        
    145         for(i=nrl; i<=nch; i++) {
    146                 for(j=i+1; j<=nch; j++) {
    147                         t       = S[j][i];
    148                         S[j][i] = S[i][j];
    149                         S[i][j] = t;
    150                 }
    151         }
    152 }
    153 /* ------------------------------------------------------------------------------------ */
    154 IMAGE_EXPORT(void) transpose1_ui16matrix(uint16 **S, long nrl,long nrh,long ncl, long nch)
    155 /* ------------------------------------------------------------------------------------ */
    156 {
    157         int i, j;
    158         uint16 t;
    159        
    160         for(i=nrl; i<=nch; i++) {
    161                 for(j=i+1; j<=nch; j++) {
    162                         t       = S[j][i];
    163                         S[j][i] = S[i][j];
    164                         S[i][j] = t;
    165                 }
    166         }
    167 }
    168 /* ---------------------------------------------------------------------------------- */
    169 IMAGE_EXPORT(void) transpose1_si32matrix(sint32 **S, long nrl,long nrh,long ncl, long nch)
    170 /* ---------------------------------------------------------------------------------- */
    171 {
    172         int i, j;
    173         int32 t;
    174        
    175         for(i=nrl; i<=nch; i++) {
    176                 for(j=i+1; j<=nch; j++) {
    177                         t       = S[j][i];
    178                         S[j][i] = S[i][j];
    179                         S[i][j] = t;
    180                 }
    181         }
    182 }
    183 /* ------------------------------------------------------------------------------------ */
    184 IMAGE_EXPORT(void) transpose1_ui32matrix(uint32 **S, long nrl,long nrh,long ncl, long nch)
    185 /* ------------------------------------------------------------------------------------ */
    186 {
    187         int i, j;
    188         uint32 t;
    189        
    190         for(i=nrl; i<=nch; i++) {
    191                 for(j=i+1; j<=nch; j++) {
    192                         t       = S[j][i];
    193                         S[j][i] = S[i][j];
    194                         S[i][j] = t;
    195                 }
    196         }
    197 }
    198 /* ------------------------------------------------------------------------------- */
    199 IMAGE_EXPORT(void) transpose1_f32matrix(float32 **S, long nrl,long nrh,long ncl, long nch)
    200 /* ------------------------------------------------------------------------------- */
    201 {
    202         int i, j;
    203         float t;
    204        
    205         for(i=nrl; i<=nch; i++) {
    206                 for(j=i+1; j<=nch; j++) {
    207                         t       = S[j][i];
    208                         S[j][i] = S[i][j];
    209                         S[i][j] = t;
    210                 }
    211         }
    212 }
    213 /* --------------------------------------------------------------------------------- */
    214 IMAGE_EXPORT(void) transpose1_f64matrix(float64 **S, long nrl,long nrh,long ncl, long nch)
    215 /* --------------------------------------------------------------------------------- */
    216 {
    217         int i, j;
    218         double t;
    219        
    220         for(i=nrl; i<=nch; i++) {
    221                 for(j=i+1; j<=nch; j++) {
    222                         t       = S[j][i];
    223                         S[j][i] = S[i][j];
    224                         S[i][j] = t;
    225                 }
    226         }
    227 }
    228 /* ---------------------------------------------------------------------------------- */
    229 IMAGE_EXPORT(void) transpose1_rgb8matrix(rgb8 **S, long nrl,long nrh,long ncl, long nch)
    230 /* ---------------------------------------------------------------------------------- */
    231 {
    232         int i, j;
    233         rgb8 t;
    234        
    235         for(i=nrl; i<=nch; i++) {
    236                 for(j=i+1; j<=nch; j++) {
    237                         t       = S[j][i];
    238                         S[j][i] = S[i][j];
    239                         S[i][j] = t;
    240                 }
    241         }
    242 }
     64
     65transpose1_type_matrix(int8_t);
     66transpose1_type_matrix(uint8_t);
     67transpose1_type_matrix(int16_t);
     68transpose1_type_matrix(uint16_t);
     69transpose1_type_matrix(int32_t);
     70transpose1_type_matrix(uint32_t);
     71transpose1_type_matrix(int64_t);
     72transpose1_type_matrix(uint64_t);
     73transpose1_type_matrix(float);
     74transpose1_type_matrix(double);
     75transpose1_type_matrix(rgb8);
     76transpose1_type_matrix(rgbx8);
     77
     78
     79
     80
     81// Local Variables:
     82// tab-width: 4
     83// c-basic-offset: 4
     84// c-file-offsets:((innamespace . 0)(inline-open . 0))
     85// indent-tabs-mode: nil
     86// End:
     87
     88// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     89
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrlut.c

    r821 r823  
    1313
    1414/*
    15 * 2002/06/11 ajout des fonctions endline
    16 */
     15 * 2002/06/11 ajout des fonctions endline
     16 */
    1717#include <stdio.h>
    1818#include <stddef.h>
     
    2828#include "nrlut.h"
    2929
    30 /* ----------------------------------------------------------------------- */
    31 IMAGE_EXPORT(void) init_blut(byte *v, int nl, int nh, int n0, int n1, byte k)
    32 /* ----------------------------------------------------------------------- */
    33 {
    34         int i;
    35        
    36         if(nl<=nh) {
    37                 // normal case
    38                 for(i=nl;   i< n0; i++) v[i] = 0;
    39                 for(i=n0;   i<=n1; i++) v[i] = k;
    40                 for(i=n1+1; i<nh; i++)  v[i] = 0;
    41         } else {
    42                 for(i=nl;   i< n1; i++) v[i] = k;
    43                 for(i=n1;   i<=n0; i++) v[i] = 0;
    44                 for(i=n1+1; i<nh;  i++) v[i] = k;
    45         }
    46 }
    47 /* ------------------------------------------------------------------------ */
    48 IMAGE_EXPORT(void) init_ui8lut(uint8 *v, int nl, int nh, int n0, int n1, uint8 k)
    49 /* ------------------------------------------------------------------------ */
    50 {
    51         int i;
    52        
    53         if(nl<=nh) {
    54                 // normal case
    55                 for(i=nl;   i< n0; i++) v[i] = 0;
    56                 for(i=n0;   i<=n1; i++) v[i] = k;
    57                 for(i=n1+1; i<nh; i++)  v[i] = 0;
    58         } else {
    59                 for(i=nl;   i< n1; i++) v[i] = k;
    60                 for(i=n1;   i<=n0; i++) v[i] = 0;
    61                 for(i=n1+1; i<nh;  i++) v[i] = k;
    62         }
    63 }
    64 /* --------------------------------------------------------------------------- */
    65 IMAGE_EXPORT(void) init_ui16lut(uint16 *v, int nl, int nh, int n0, int n1, uint16 k)
    66 /* --------------------------------------------------------------------------- */
    67 {
    68         int i;
    69        
    70         if(nl<=nh) {
    71                 // normal case
    72                 for(i=nl;   i< n0; i++) v[i] = 0;
    73                 for(i=n0;   i<=n1; i++) v[i] = k;
    74                 for(i=n1+1; i<=nh; i++) v[i] = 0;
    75         } else {
    76                 for(i=nl;   i< n1; i++) v[i] = k;
    77                 for(i=n1;   i<=n0; i++) v[i] = 0;
    78                 for(i=n1+1; i<=nh; i++) v[i] = k;
    79         }
    80 }
    81 /* --------------------------------------------------------------------------- */
    82 IMAGE_EXPORT(void) init_si16lut(sint16 *v, int nl, int nh, int n0, int n1, sint16 k)
    83 /* --------------------------------------------------------------------------- */
    84 {
    85         int i;
    86        
    87         if(nl<=nh) {
    88                 // normal case
    89                 for(i=nl;   i< n0; i++) v[i] = 0;
    90                 for(i=n0;   i<=n1; i++) v[i] = k;
    91                 for(i=n1+1; i<=nh; i++) v[i] = 0;
    92         } else {
    93                 for(i=nl;   i< n1; i++) v[i] = k;
    94                 for(i=n1;   i<=n0; i++) v[i] = 0;
    95                 for(i=n1+1; i<=nh; i++) v[i] = k;
    96         }
    97 }
    98 /* --------------------------------------------------------------------------- */
    99 IMAGE_EXPORT(void) init_ui32lut(uint32 *v, int nl, int nh, int n0, int n1, uint32 k)
    100 /* --------------------------------------------------------------------------- */
    101 {
    102         int i;
    103        
    104         if(nl<=nh) {
    105                 // normal case
    106                 for(i=nl;   i< n0; i++) v[i] = 0;
    107                 for(i=n0;   i<=n1; i++) v[i] = k;
    108                 for(i=n1+1; i<=nh; i++) v[i] = 0;
    109         } else {
    110                 for(i=nl;   i< n1; i++) v[i] = k;
    111                 for(i=n1;   i<=n0; i++) v[i] = 0;
    112                 for(i=n1+1; i<=nh; i++) v[i] = k;
    113         }
    114 }
    115 /* --------------------------------------------------------------------------- */
    116 IMAGE_EXPORT(void) init_i32lut(sint32 *v, int nl, int nh, int n0, int n1, sint32 k)
    117 /* --------------------------------------------------------------------------- */
    118 {
    119         int i;
    120        
    121         if(nl<=nh) {
    122                 // normal case
    123                 for(i=nl;   i< n0; i++) v[i] = 0;
    124                 for(i=n0;   i<=n1; i++) v[i] = k;
    125                 for(i=n1+1; i<=nh; i++) v[i] = 0;
    126         } else {
    127                 for(i=nl;   i< n1; i++) v[i] = k;
    128                 for(i=n1;   i<=n0; i++) v[i] = 0;
    129                 for(i=n1+1; i<=nh; i++) v[i] = k;
    130         }
    131 }
    132 /* -------------------------------------------------------------------------- */
    133 IMAGE_EXPORT(void) init_rgb8lut(rgb8 *v, int nl, int nh, int n0, int n1, rgb8 k)
    134 /* -------------------------------------------------------------------------- */
    135 {
    136         int i;
    137        
    138         if(nl<=nh) {
    139                 // normal case
    140                 for(i=nl;   i< n0; i++) { v[i].r = 0;   v[i].g = 0;   v[i].b = 0;}
    141                 for(i=n0;   i<=n1; i++) { v[i].r = k.r; v[i].g = k.g; v[i].b = k.b;}
    142                 for(i=n1+1; i<=nh; i++)  { v[i].r = 0;   v[i].g = 0;  v[i].b = 0;}
    143         } else {
    144                 for(i=nl;   i< n1; i++) { v[i].r = k.r; v[i].g = k.g; v[i].b = k.b;}
    145                 for(i=n1;   i<=n0; i++) { v[i].r = 0;   v[i].g = 0;   v[i].b = 0;}
    146                 for(i=n1+1; i<=nh; i++) { v[i].r = k.r; v[i].g = k.g; v[i].b = k.b;}
    147         }
    148 }
    149 /* ------------------------------------------------------------------------------------------- */
    150 IMAGE_EXPORT(void) lut_bmatrix(byte **S, long nrl,long nrh,long ncl, long nch, byte *L, byte **D)
    151 /* ------------------------------------------------------------------------------------------- */
    152 {
    153     int i, j;
    154 
    155     for(i=nrl; i<=nrh; i++) {
    156         for(j=ncl; j<=nch; j++) {
    157             D[i][j] = L[(int)S[i][j]];
    158         }
    159     }
    160 }
    161 /* -------------------------------------------------------------------------------------------- */
    162 IMAGE_EXPORT(void) lut_ui8matrix(uint8 **S, long nrl,long nrh,long ncl, long nch, uint8 *L, uint8 **D)
    163 /* -------------------------------------------------------------------------------------------- */
    164 {
    165     int i, j;
    166    
    167     for(i=nrl; i<=nrh; i++) {
    168         for(j=ncl; j<=nch; j++) {
    169             D[i][j] = L[(int)S[i][j]];
    170         }
    171     }
    172 }
    173 /* -------------------------------------------------------------------------------------------- */
    174 IMAGE_EXPORT(void) lut_si8matrix(sint8 **S, long nrl,long nrh,long ncl, long nch, sint8 *L, sint8 **D)
    175 /* -------------------------------------------------------------------------------------------- */
    176 {
    177     int i, j;
    178    
    179     for(i=nrl; i<=nrh; i++) {
    180         for(j=ncl; j<=nch; j++) {
    181             D[i][j] = L[(int)S[i][j]];
    182         }
    183     }
    184 }
    185 /* -------------------------------------------------------------------------------------------------- */
    186 IMAGE_EXPORT(void) lut_ui16matrix(uint16 **S, long nrl, long nrh, long ncl, long nch, uint16 *L, uint16 **D)
    187 /* -------------------------------------------------------------------------------------------------- */
    188 {
    189     int i, j;
    190    
    191     for(i=nrl; i<=nrh; i++) {
    192         for(j=ncl; j<=nch; j++) {
    193             D[i][j] = L[(int)S[i][j]];
    194         }
    195     }
    196 }
    197 /* -------------------------------------------------------------------------------------------------- */
    198 IMAGE_EXPORT(void) lut_si16matrix(sint16 **S, long nrl, long nrh, long ncl, long nch, sint16 *L, sint16 **D)
    199 /* -------------------------------------------------------------------------------------------------- */
    200 {
    201     int i, j;
    202    
    203     for(i=nrl; i<=nrh; i++) {
    204         for(j=ncl; j<=nch; j++) {
    205             D[i][j] = L[(int)S[i][j]];
    206         }
    207     }
    208 }
    209 /* -------------------------------------------------------------------------------------------------- */
    210 IMAGE_EXPORT(void) lut_ui32matrix(uint32 **S, long nrl, long nrh, long ncl, long nch, uint32 *L, uint32 **D)
    211 /* -------------------------------------------------------------------------------------------------- */
    212 {
    213     int i, j;
    214    
    215     for(i=nrl; i<=nrh; i++) {
    216         for(j=ncl; j<=nch; j++) {
    217             D[i][j] = L[(int)S[i][j]];
    218         }
    219     }
    220 }
    221 /* -------------------------------------------------------------------------------------------------- */
    222 IMAGE_EXPORT(void) lut_si32matrix(sint32 **S, long nrl, long nrh, long ncl, long nch, sint32 *L, sint32 **D)
    223 /* -------------------------------------------------------------------------------------------------- */
    224 {
    225     int i, j;
    226    
    227     for(i=nrl; i<=nrh; i++) {
    228         for(j=ncl; j<=nch; j++) {
    229             D[i][j] = L[(int)S[i][j]];
    230         }
    231     }
    232 }
    233 /* ------------------------------------------------------------------------------------------------ */
    234 IMAGE_EXPORT(void) lut_rgb8matrix(rgb8 **S, long nrl, long nrh, long ncl, long nch, rgb8 *L, rgb8 **D)
    235 /* ------------------------------------------------------------------------------------------------ */
    236 {
    237         int i, j;
    238        
    239         for(i=nrl; i<=nrh; i++) {
    240                 for(j=ncl; j<=nch; j++) {
    241                         D[i][j].r = L[S[i][j].r].r;
    242                         D[i][j].g = L[S[i][j].g].g;
    243                         D[i][j].b = L[S[i][j].b].b;
    244                 }
    245         }
    246 }
    247 /* --------------------------------------------------------------------------------------------------------- */
    248 IMAGE_EXPORT(void) lut_ui16matrix_ui8matrix(uint16 **S, long nrl, long nrh, long ncl, long nch, uint8 *L, uint8 **D)
    249 /* --------------------------------------------------------------------------------------------------------- */
    250 {
    251         int i, j;
    252        
    253         for(i=nrl; i<=nrh; i++) {
    254                 for(j=ncl; j<=nch; j++) {
    255                         D[i][j] = L[(int)S[i][j]];
    256                 }
    257         }
    258 }
    259 /* --------------------------------------------------------------------------------------------------------- */
    260 IMAGE_EXPORT(void) lut_ui32matrix_ui16matrix(uint32 **S, long nrl, long nrh, long ncl, long nch, uint16 *L, uint16 **D)
    261 /* --------------------------------------------------------------------------------------------------------- */
    262 {
    263         int i, j;
    264        
    265         for(i=nrl; i<=nrh; i++) {
    266                 for(j=ncl; j<=nch; j++) {
    267                         D[i][j] = L[(int)S[i][j]];
    268                 }
    269         }
    270 }
    271 /* ---------------------------------------------------------------------------- */
    272 IMAGE_EXPORT(void) histogram_bmatrix(byte **S, long nrl, long nrh, long ncl, long nch, int32 *H)
    273 /* ---------------------------------------------------------------------------- */
    274 {
    275         int i, j;
    276         byte *Si;
    277        
    278         for(i=nrl; i<=nrh; i++) {
    279                 Si = S[i];
    280                 for(j=ncl; j<=nch; j++) {
    281                         H[(int) Si[j]]++;
    282                 }
    283         }
    284 }
    285 /* --------------------------------------------------------------------------------- */
    286 IMAGE_EXPORT(void) histogram_ui16matrix(uint16 **S, long nrl, long nrh, long ncl, long nch, int32 *H)
    287 /* --------------------------------------------------------------------------------- */
    288 {
    289         int i, j;
    290         uint16 *Si;
    291        
    292         for(i=nrl; i<=nrh; i++) {
    293                 Si = S[i];
    294                 for(j=ncl; j<=nch; j++) {
    295                         H[Si[j]]++;
    296                 }
    297         }
    298 }
    299 /* ------------------------------------------------------------------------------- */
    300 IMAGE_EXPORT(void) histogram_rgb8matrix(rgb8 **S, long nrl, long nrh, long ncl, long nch, rgb32 *H)
    301 /* ------------------------------------------------------------------------------- */
    302 {
    303         int i, j;
    304         rgb8 *Si;
    305         int r, b, g;
     30
     31#undef init_type_lut
     32#define init_type_lut(t) \
     33void short_name(t,init_,lut)(t * v, int32_t nl, int32_t nh, int32_t n0, int32_t n1, t k) \
     34{                                                \
     35    if (nl <= nh) {                              \
     36        for (int32_t i = nl; i < n0; i++) {      \
     37            v[i] = 0;                            \
     38        }                                        \
     39        for (int32_t i = n0; i <= n1; i++) {     \
     40            v[i] = k;                            \
     41        }                                        \
     42        for (int32_t i = n1 + 1; i <= nh; i++) { \
     43            v[i] = 0;                            \
     44        }                                        \
     45    }                                            \
     46    else {                                       \
     47        for (int32_t i = nl; i < n1; i++) {      \
     48            v[i] = k;                            \
     49        }                                        \
     50        for (int32_t i = n1; i <= n0; i++) {     \
     51            v[i] = 0;                            \
     52        }                                        \
     53        for (int32_t i = n1 + 1; i <= nh; i++) { \
     54            v[i] = k;                            \
     55        }                                        \
     56    }                                            \
     57}
     58
     59
     60init_type_lut(int8_t);
     61init_type_lut(uint8_t);
     62init_type_lut(int16_t);
     63init_type_lut(uint16_t);
     64init_type_lut(int32_t);
     65init_type_lut(uint32_t);
     66
     67
     68
     69void init_rgb8lut(rgb8 * v, int32_t nl, int32_t nh, int32_t n0, int32_t n1, rgb8 k)
     70{
     71    if (nl <= nh) {
     72        // normal case
     73        for (int32_t i = nl; i < n0; i++) {
     74            v[i].r = 0;
     75            v[i].g = 0;
     76            v[i].b = 0;
     77        }
     78        for (int32_t i = n0; i <= n1; i++) {
     79            v[i].r = k.r;
     80            v[i].g = k.g;
     81            v[i].b = k.b;
     82        }
     83        for (int32_t i = n1 + 1; i <= nh; i++) {
     84            v[i].r = 0;
     85            v[i].g = 0;
     86            v[i].b = 0;
     87        }
     88    }
     89    else {
     90        for (int32_t i = nl; i < n1; i++) {
     91            v[i].r = k.r;
     92            v[i].g = k.g;
     93            v[i].b = k.b;
     94        }
     95        for (int32_t i = n1; i <= n0; i++) {
     96            v[i].r = 0;
     97            v[i].g = 0;
     98            v[i].b = 0;
     99        }
     100        for (int32_t i = n1 + 1; i <= nh; i++) {
     101            v[i].r = k.r;
     102            v[i].g = k.g;
     103            v[i].b = k.b;
     104        }
     105    }
     106}
     107
     108
     109#undef lut_type_matrix
     110#define lut_type_matrix(t) \
     111void short_name(t,lut_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t * L, t ** D) \
     112{                                              \
     113    for (int32_t i = nrl; i <= nrh; i++) {     \
     114        for (int32_t j = ncl; j <= nch; j++) { \
     115            D[i][j] = L[(int32_t) S[i][j]];    \
     116        }                                      \
     117    }                                          \
     118}
     119
     120lut_type_matrix(int8_t);
     121lut_type_matrix(uint8_t);
     122lut_type_matrix(int16_t);
     123lut_type_matrix(uint16_t);
     124lut_type_matrix(int32_t);
     125lut_type_matrix(uint32_t);
     126
     127
     128
     129void lut_rgb8matrix(rgb8 ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb8 * L, rgb8 ** D)
     130{
     131    for (int32_t i = nrl; i <= nrh; i++) {
     132        for (int32_t j = ncl; j <= nch; j++) {
     133            D[i][j].r = L[S[i][j].r].r;
     134            D[i][j].g = L[S[i][j].g].g;
     135            D[i][j].b = L[S[i][j].b].b;
     136        }
     137    }
     138}
     139
     140
     141void lut_ui16matrix_ui8matrix(uint16_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t * L, uint8_t ** D)
     142{
     143    for (int32_t i = nrl; i <= nrh; i++) {
     144        for (int32_t j = ncl; j <= nch; j++) {
     145            D[i][j] = L[(int32_t) S[i][j]];
     146        }
     147    }
     148}
     149
     150void lut_i16matrix_i8matrix(int16_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t * L, int8_t ** D)
     151{
     152    for (int32_t i = nrl; i <= nrh; i++) {
     153        for (int32_t j = ncl; j <= nch; j++) {
     154            D[i][j] = L[(int32_t) S[i][j]];
     155        }
     156    }
     157}
     158
     159void lut_ui32matrix_ui16matrix(uint32_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint16_t * L, uint16_t ** D)
     160{
     161    for (int32_t i = nrl; i <= nrh; i++) {
     162        for (int32_t j = ncl; j <= nch; j++) {
     163            D[i][j] = L[(int32_t) S[i][j]];
     164        }
     165    }
     166}
     167
     168void lut_i32matrix_i16matrix(int32_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint16_t * L, int16_t ** D)
     169{
     170    for (int32_t i = nrl; i <= nrh; i++) {
     171        for (int32_t j = ncl; j <= nch; j++) {
     172            D[i][j] = L[(int32_t) S[i][j]];
     173        }
     174    }
     175}
     176
     177
     178#undef histogram_type_matrix
     179#define histogram_type_matrix(t) \
     180void short_name(t,histogram_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t * H) \
     181{                                              \
     182    t * Si;                                    \
     183    for (int32_t i = nrl; i <= nrh; i++) {     \
     184        Si = S[i];                             \
     185        for (int32_t j = ncl; j <= nch; j++) { \
     186            H[(int32_t) Si[j]]++;              \
     187        }                                      \
     188    }                                          \
     189}
     190
     191histogram_type_matrix(int8_t);
     192histogram_type_matrix(uint8_t);
     193histogram_type_matrix(int16_t);
     194histogram_type_matrix(uint16_t);
     195histogram_type_matrix(int32_t);
     196histogram_type_matrix(uint32_t);
     197
     198
     199
     200void histogram_rgb8matrix(rgb8 ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb32 * H)
     201{
     202    rgb8 * Si;
     203    int r, b, g;
    306204    (void) Si;
    307        
    308         //FUNCTION_NAME("Histogram_rgbmatrix");
    309        
    310         for(i=nrl; i<=nrh; i++) {
    311                 Si = S[i];
    312                 //PROGRESS_INFO(function_name, i, nrl, nrh);
    313                 for(j=ncl; j<=nch; j++) {
    314                        
    315                         //H[Si[j].r].r++;
    316                         //H[Si[j].g].g++;
    317                         //H[Si[j].b].b++;
    318                        
    319                         r = S[i][j].r;
    320                         g = S[i][j].g;
    321                         b = S[i][j].b;
    322                        
    323                         H[r].r++;
    324                         H[g].g++;
    325                         H[b].b++;
    326                 }
    327         }
    328        
    329         //END;
    330         return;
    331 }
     205
     206
     207    for (int32_t i = nrl; i <= nrh; i++) {
     208        Si = S[i];
     209        for (int32_t j = ncl; j <= nch; j++) {
     210            r = S[i][j].r;
     211            g = S[i][j].g;
     212            b = S[i][j].b;
     213
     214            H[r].r++;
     215            H[g].g++;
     216            H[b].b++;
     217        }
     218    }
     219    return;
     220}
     221
     222// Local Variables:
     223// tab-width: 4
     224// c-basic-offset: 4
     225// c-file-offsets:((innamespace . 0)(inline-open . 0))
     226// indent-tabs-mode: nil
     227// End:
     228
     229// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     230
  • soft/giet_vm/applications/rosenfeld/nrc2/src/nrmem1.c

    r772 r823  
    3030 * -----------
    3131 */
    32 /* ---------------------------------------------------------------- */
    33 IMAGE_EXPORT(void) dup_si8vector(sint8 *X, long nl, long nh, sint8 *Y)
    34 /* ---------------------------------------------------------------- */
    35 {
    36     int i;
    37     for(i=nl; i<=nh; i++) {
    38         Y[i] = X[i];
    39     }
    40 }
    41 /* ---------------------------------------------------------------- */
    42 IMAGE_EXPORT(void) dup_ui8vector(uint8 *X, long nl, long nh, uint8 *Y)
    43 /* ---------------------------------------------------------------- */
    44 {
    45     int i;
    46     for(i=nl; i<=nh; i++) {
    47         Y[i] = X[i];
    48     }
    49 }
    50 /* ------------------------------------------------------------------- */
    51 IMAGE_EXPORT(void) dup_si16vector(sint16 *X, long nl, long nh, sint16 *Y)
    52 /* ------------------------------------------------------------------- */
    53 {
    54     int i;
    55     for(i=nl; i<=nh; i++) {
    56         Y[i] = X[i];
    57     }
    58 }
    59 /* ------------------------------------------------------------------- */
    60 IMAGE_EXPORT(void) dup_ui16vector(uint16 *X, long nl, long nh, uint16 *Y)
    61 /* ------------------------------------------------------------------- */
    62 {
    63     int i;
    64     for(i=nl; i<=nh; i++) {
    65         Y[i] = X[i];
    66     }
    67 }
    68 /* -------------------------------------------------------------------- */
    69 IMAGE_EXPORT(void) dup_si32vector(sint32 *X, long nl, long nh, sint32 *Y)
    70 /* -------------------------------------------------------------------- */
    71 {
    72     int i;
    73     for(i=nl; i<=nh; i++) {
    74         Y[i] = X[i];
    75     }
    76 }
    77 /* ------------------------------------------------------------------- */
    78 IMAGE_EXPORT(void) dup_ui32vector(uint32 *X, long nl, long nh, uint32 *Y)
    79 /* ------------------------------------------------------------------- */
    80 {
    81     int i;
    82     for(i=nl; i<=nh; i++) {
    83         Y[i] = X[i];
    84     }
    85 }
    86 /* -------------------------------------------------------------------- */
    87 IMAGE_EXPORT(void) dup_si64vector(sint64 *X, long nl, long nh, sint64 *Y)
    88 /* -------------------------------------------------------------------- */
    89 {
    90     int i;
    91     for(i=nl; i<=nh; i++) {
    92         Y[i] = X[i];
    93     }
    94 }
    95 /* ------------------------------------------------------------------- */
    96 IMAGE_EXPORT(void) dup_ui64vector(uint64 *X, long nl, long nh, uint64 *Y)
    97 /* ------------------------------------------------------------------- */
    98 {
    99     int i;
    100     for(i=nl; i<=nh; i++) {
    101         Y[i] = X[i];
    102     }
    103 }
    104 /* -------------------------------------------------------------------- */
    105 IMAGE_EXPORT(void) dup_f32vector(float32 *X, long nl, long nh, float32 *Y)
    106 /* -------------------------------------------------------------------- */
    107 {
    108     int i;
    109     for(i=nl; i<=nh; i++) {
    110         Y[i] = X[i];
    111     }
    112 }
    113 /* -------------------------------------------------------------------- */
    114 IMAGE_EXPORT(void) dup_f64vector(float64 *X, long nl, long nh, float64 *Y)
    115 /* -------------------------------------------------------------------- */
    116 {
    117     int i;
    118     for(i=nl; i<=nh; i++) {
    119         Y[i] = X[i];
    120     }
    121 }
    122 /* --------------------------------------------------------------- */
    123 IMAGE_EXPORT(void) dup_rgb8vector(rgb8 *X, long nl, long nh, rgb8 *Y)
    124 /* --------------------------------------------------------------- */
    125 {
    126     int i;
    127     for(i=nl; i<=nh; i++) {
    128         Y[i] = X[i];
    129     }
    130 }
    131 /* ------------------------------------------------------------------ */
    132 IMAGE_EXPORT(void) dup_rgbx8vector(rgbx8 *X, long nl, long nh, rgbx8 *Y)
    133 /* ------------------------------------------------------------------ */
    134 {
    135     int i;
    136     for(i=nl; i<=nh; i++) {
    137         Y[i] = X[i];
    138     }
    139 }
     32
     33
     34#undef dup_type_vector
     35#define dup_type_vector(t) \
     36void short_name(t,dup_,vector)(t * X, int32_t nl, int32_t nh, t * Y) \
     37{                                        \
     38    for (int32_t i = nl; i <= nh; i++) { \
     39        Y[i] = X[i];                     \
     40    }                                    \
     41}
     42
     43dup_type_vector(int8_t);
     44dup_type_vector(uint8_t);
     45dup_type_vector(int16_t);
     46dup_type_vector(uint16_t);
     47dup_type_vector(int32_t);
     48dup_type_vector(uint32_t);
     49dup_type_vector(int64_t);
     50dup_type_vector(uint64_t);
     51dup_type_vector(float);
     52dup_type_vector(double);
     53dup_type_vector(rgb8);
     54dup_type_vector(rgbx8);
     55
     56
    14057/*
    14158 * --------------------
     
    14360 * --------------------
    14461 */
    145 /* -------------------------------------------------------------------------------------- */
    146 IMAGE_EXPORT(void) split_rgb8vector(rgb8 *X, long nl, long nh, uint8 *R, uint8 *G, uint8 *B)
    147 /* -------------------------------------------------------------------------------------- */
    148 {
    149         long i;
    150         rgb8 x;
    151         for(i=nl; i<=nh; i++) {
    152                 x    = X[i];
    153                 R[i] = x.r;
    154                 G[i] = x.g;
    155                 B[i] = x.b;
    156         }
    157 }
    158 /* ------------------------------------------------------------------------------------------- */
    159 IMAGE_EXPORT(void) split_rgb32vector(rgb32 *X, long nl, long nh, uint32 *R, uint32 *G, uint32 *B)
    160 /* ------------------------------------------------------------------------------------------- */
    161 {
    162         long i;
    163         for(i=nl; i<=nh; i++) {
    164                 R[i] = X[i].r;
    165                 G[i] = X[i].g;
    166                 B[i] = X[i].b;
    167         }
    168 }
    169 /* -------------------------------------------------------------------------------------- */
    170 IMAGE_EXPORT(void) merge_rgb8vector(uint8 *R, uint8 *G, uint8 *B, long nl, long nh, rgb8 *X)
    171 /* -------------------------------------------------------------------------------------- */
    172 {
    173         long i;
    174         for(i=nl; i<=nh; i++) {
    175                 X[i].r = R[i];
    176                 X[i].g = G[i];
    177                 X[i].b = B[i];
    178         }
    179 }
    180 /* ------------------------------------------------------------------------------------------- */
    181 IMAGE_EXPORT(void) merge_rgb32vector(uint32 *R, uint32 *G, uint32 *B, long nl, long nh, rgb32 *X)
    182 /* ------------------------------------------------------------------------------------------- */
    183 {
    184         long i;
    185         for(i=nl; i<=nh; i++) {
    186                 X[i].r = R[i];
    187                 X[i].g = G[i];
    188                 X[i].b = B[i];
    189         }
    190 }
    191 
    192 /* ---------------- */
    193 /* -- Convertion -- */
    194 /* ---------------- */
    195 
    196 /* -------------------------------------------------------------------------------- */
    197 IMAGE_EXPORT(void) convert_si8vector_si16vector(sint8 *X, long nl, long nh, sint16 *Y)
    198 /* -------------------------------------------------------------------------------- */
    199 {
    200     long i;
    201     for(i=nl; i<=nh; i++)
    202         Y[i] = (sint16) X[i];
    203 }
    204 /* -------------------------------------------------------------------------------- */
    205 IMAGE_EXPORT(void) convert_si8vector_si32vector(sint8 *X, long nl, long nh, sint32 *Y)
    206 /* -------------------------------------------------------------------------------- */
    207 {
    208     long i;
    209     for(i=nl; i<=nh; i++)
    210         Y[i] = (sint32) X[i];
    211 }
    212 /* -------------------------------------------------------------------------------- */
    213 IMAGE_EXPORT(void) convert_si8vector_f32vector(sint8 *X, long nl, long nh, float32 *Y)
    214 /* -------------------------------------------------------------------------------- */
    215 {
    216     long i;
    217     for(i=nl; i<=nh; i++)
    218         Y[i] = (float32) X[i];
    219 }
    220 /* -------------------------------------------------------------------------------- */
    221 IMAGE_EXPORT(void) convert_si8vector_f64vector(sint8 *X, long nl, long nh, float64 *Y)
    222 /* -------------------------------------------------------------------------------- */
    223 {
    224     long i;
    225     for(i=nl; i<=nh; i++)
    226         Y[i] = (float64) X[i];
    227 }
    228 /* -------------------------------------------------------------------------------- */
    229 IMAGE_EXPORT(void) convert_ui8vector_ui16vector(uint8 *X, long nl, long nh, uint16 *Y)
    230 /* -------------------------------------------------------------------------------- */
    231 {
    232     long i;
    233     for(i=nl; i<=nh; i++)
    234         Y[i] = (uint16) X[i];
    235 }
    236 /* -------------------------------------------------------------------------------- */
    237 IMAGE_EXPORT(void) convert_ui8vector_ui32vector(uint8 *X, long nl, long nh, uint32 *Y)
    238 /* -------------------------------------------------------------------------------- */
    239 {
    240     long i;
    241     for(i=nl; i<=nh; i++)
    242         Y[i] = (uint32) X[i];
    243 }
    244 /* -------------------------------------------------------------------------------- */
    245 IMAGE_EXPORT(void) convert_ui8vector_f32vector(uint8 *X, long nl, long nh, float32 *Y)
    246 /* -------------------------------------------------------------------------------- */
    247 {
    248     long i;
    249     for(i=nl; i<=nh; i++)
    250         Y[i] = (float32) X[i];
    251 }
    252 /* -------------------------------------------------------------------------------- */
    253 IMAGE_EXPORT(void) convert_ui8vector_f64vector(uint8 *X, long nl, long nh, float64 *Y)
    254 /* -------------------------------------------------------------------------------- */
    255 {
    256     long i;
    257     for(i=nl; i<=nh; i++)
    258         Y[i] = (float64) X[i];
    259 }
    260 /* ------------------------------------------------------------------------------ */
    261 IMAGE_EXPORT(void) convert_ui8vector_rgb8vector(uint8 *X, long nl, long nh, rgb8 *Y)
    262 /* ------------------------------------------------------------------------------ */
    263 {
    264     long i;
    265     for(i=nl; i<=nh; i++) {
     62
     63
     64void split_rgb8vector(rgb8 * X, int32_t nl, int32_t nh, uint8_t * R, uint8_t * G, uint8_t * B)
     65{
     66    for (int32_t i = nl; i <= nh; i++) {
     67        R[i] = X[i].r;
     68        G[i] = X[i].g;
     69        B[i] = X[i].b;
     70    }
     71}
     72
     73void split_rgb32vector(rgb32 * X, int32_t nl, int32_t nh, uint32_t * R, uint32_t * G, uint32_t * B)
     74{
     75    for (int32_t i = nl; i <= nh; i++) {
     76        R[i] = X[i].r;
     77        G[i] = X[i].g;
     78        B[i] = X[i].b;
     79    }
     80}
     81
     82void merge_rgb8vector(uint8_t * R, uint8_t * G, uint8_t * B, int32_t nl, int32_t nh, rgb8 * X)
     83{
     84    for (int32_t i = nl; i <= nh; i++) {
     85        X[i].r = R[i];
     86        X[i].g = G[i];
     87        X[i].b = B[i];
     88    }
     89}
     90
     91
     92void merge_rgb32vector(uint32_t * R, uint32_t * G, uint32_t * B, int32_t nl, int32_t nh, rgb32 * X)
     93{
     94    for (int32_t i = nl; i <= nh; i++) {
     95        X[i].r = R[i];
     96        X[i].g = G[i];
     97        X[i].b = B[i];
     98    }
     99}
     100
     101/* ---------------- */
     102/* -- Conversion -- */
     103/* ---------------- */
     104
     105#undef convert_type1_vector_type2_vector
     106#define convert_type1_vector_type2_vector(t1, t2) \
     107void short_name(t1,convert_,short_name(t2,vector_,vector))(t1 * X, int32_t nl, int32_t nh, t2 * Y) \
     108{                                        \
     109    for (int32_t i = nl; i <= nh; i++) { \
     110        Y[i] = (t2) X[i];                \
     111    }                                    \
     112}
     113
     114convert_type1_vector_type2_vector(int8_t,int16_t);
     115convert_type1_vector_type2_vector(int8_t,int32_t);
     116convert_type1_vector_type2_vector(int8_t,float);
     117convert_type1_vector_type2_vector(int8_t,double);
     118convert_type1_vector_type2_vector(uint8_t,uint16_t);
     119convert_type1_vector_type2_vector(uint8_t,uint32_t);
     120convert_type1_vector_type2_vector(uint8_t,float);
     121convert_type1_vector_type2_vector(uint8_t,double);
     122convert_type1_vector_type2_vector(int16_t,int32_t);
     123convert_type1_vector_type2_vector(int16_t,float);
     124convert_type1_vector_type2_vector(int16_t,double);
     125convert_type1_vector_type2_vector(uint16_t,uint32_t);
     126convert_type1_vector_type2_vector(uint16_t,float);
     127convert_type1_vector_type2_vector(uint16_t,double);
     128convert_type1_vector_type2_vector(int32_t,float);
     129convert_type1_vector_type2_vector(int32_t,double);
     130convert_type1_vector_type2_vector(uint32_t,float);
     131convert_type1_vector_type2_vector(uint32_t,double);
     132convert_type1_vector_type2_vector(int16_t,int8_t);
     133convert_type1_vector_type2_vector(uint16_t,uint8_t);
     134convert_type1_vector_type2_vector(int32_t,int8_t);
     135convert_type1_vector_type2_vector(int32_t,int16_t);
     136convert_type1_vector_type2_vector(uint32_t,uint8_t);
     137convert_type1_vector_type2_vector(uint32_t,uint16_t);
     138convert_type1_vector_type2_vector(float,int8_t);
     139convert_type1_vector_type2_vector(float,uint8_t);
     140convert_type1_vector_type2_vector(float,int16_t);
     141convert_type1_vector_type2_vector(float,uint16_t);
     142convert_type1_vector_type2_vector(float,int32_t);
     143convert_type1_vector_type2_vector(float,uint32_t);
     144convert_type1_vector_type2_vector(double,int8_t);
     145convert_type1_vector_type2_vector(double,uint8_t);
     146convert_type1_vector_type2_vector(double,int16_t);
     147convert_type1_vector_type2_vector(double,uint16_t);
     148convert_type1_vector_type2_vector(double,int32_t);
     149convert_type1_vector_type2_vector(double,uint32_t);
     150convert_type1_vector_type2_vector(double,float);
     151
     152
     153
     154
     155
     156
     157
     158void convert_ui8vector_rgb8vector(uint8_t * X, int32_t nl, int32_t nh, rgb8 * Y)
     159{
     160    for (int32_t i = nl; i <= nh; i++) {
    266161        Y[i].r = X[i];
    267162        Y[i].g = X[i];
     
    269164    }
    270165}
    271 /* -------------------------------------------------------------------------------- */
    272 IMAGE_EXPORT(void) convert_ui8vector_rgbx8vector(uint8 *X, long nl, long nh, rgbx8 *Y)
    273 /* -------------------------------------------------------------------------------- */
    274 {
    275     long i;
    276     for(i=nl; i<=nh; i++) {
     166
     167void convert_ui8vector_rgbx8vector(uint8_t * X, int32_t nl, int32_t nh, rgbx8 * Y)
     168{
     169    for (int32_t i = nl; i <= nh; i++) {
    277170        Y[i].r = X[i];
    278171        Y[i].g = X[i];
     
    281174    }
    282175}
    283 /* ---------------------------------------------------------------------------------- */
    284 IMAGE_EXPORT(void) convert_si16vector_si32vector(sint16 *X, long nl, long nh, sint32 *Y)
    285 /* ---------------------------------------------------------------------------------- */
    286 {
    287     long i;
    288     for(i=nl; i<=nh; i++)
    289         Y[i] = (sint32) X[i];
    290 }
    291 /* ---------------------------------------------------------------------------------- */
    292 IMAGE_EXPORT(void) convert_si16vector_f32vector(sint16 *X, long nl, long nh, float32 *Y)
    293 /* ---------------------------------------------------------------------------------- */
    294 {
    295     long i;
    296     for(i=nl; i<=nh; i++)
    297         Y[i] = (float32) X[i];
    298 }
    299 /* ---------------------------------------------------------------------------------- */
    300 IMAGE_EXPORT(void) convert_si16vector_f64vector(sint16 *X, long nl, long nh, float64 *Y)
    301 /* ---------------------------------------------------------------------------------- */
    302 {
    303     long i;
    304     for(i=nl; i<=nh; i++)
    305         Y[i] = (float64) X[i];
    306 }
    307 
    308 /* ---------------------------------------------------------------------------------- */
    309 IMAGE_EXPORT(void) convert_ui16vector_ui32vector(uint16 *X, long nl, long nh, uint32 *Y)
    310 /* ---------------------------------------------------------------------------------- */
    311 {
    312     long i;
    313     for(i=nl; i<=nh; i++)
    314         Y[i] = (uint32) X[i];
    315 }
    316 /* ---------------------------------------------------------------------------------- */
    317 IMAGE_EXPORT(void) convert_ui16vector_f32vector(uint16 *X, long nl, long nh, float32 *Y)
    318 /* ---------------------------------------------------------------------------------- */
    319 {
    320     long i;
    321     for(i=nl; i<=nh; i++)
    322         Y[i] = (float32) X[i];
    323 }
    324 /* ---------------------------------------------------------------------------------- */
    325 IMAGE_EXPORT(void) convert_ui16vector_f64vector(uint16 *X, long nl, long nh, float64 *Y)
    326 /* ---------------------------------------------------------------------------------- */
    327 {
    328     long i;
    329     for(i=nl; i<=nh; i++)
    330         Y[i] = (float64) X[i];
    331 }
    332 /* ---------------------------------------------------------------------------------- */
    333 IMAGE_EXPORT(void) convert_si32vector_f32vector(sint32 *X, long nl, long nh, float32 *Y)
    334 /* ---------------------------------------------------------------------------------- */
    335 {
    336     long i;
    337     for(i=nl; i<=nh; i++)
    338         Y[i] = (float32) X[i];
    339 }
    340 /* ---------------------------------------------------------------------------------- */
    341 IMAGE_EXPORT(void) convert_si32vector_f64vector(sint32 *X, long nl, long nh, float64 *Y)
    342 /* ---------------------------------------------------------------------------------- */
    343 {
    344     long i;
    345     for(i=nl; i<=nh; i++)
    346         Y[i] = (float64) X[i];
    347 }
    348 /* ----------------------------------------------------------------------------------- */
    349 IMAGE_EXPORT(void) convert_ui32vector_f32vector(uint32 *X, long nl, long nh, float32 *Y)
    350 /* ----------------------------------------------------------------------------------- */
    351 {
    352     long i;
    353     for(i=nl; i<=nh; i++)
    354         Y[i] = (float32) X[i];
    355 }
    356 /* ----------------------------------------------------------------------------------- */
    357 IMAGE_EXPORT(void) convert_ui32vector_f64vector(uint32 *X, long nl, long nh, float64 *Y)
    358 /* ----------------------------------------------------------------------------------- */
    359 {
    360     long i;
    361     for(i=nl; i<=nh; i++)
    362         Y[i] = (float64) X[i];
    363 }
    364 // === Down === //
    365 /* ------------------------------------------------------------------------------- */
    366 IMAGE_EXPORT(void) convert_si16vector_si8vector(sint16 *X, long nl, long nh, sint8 *Y)
    367 /* ------------------------------------------------------------------------------- */
    368 {
    369     long i;
    370     for(i=nl; i<=nh; i++)
    371         Y[i] = (sint8) X[i];
    372 }
    373 /* ------------------------------------------------------------------------------- */
    374 IMAGE_EXPORT(void) convert_ui16vector_ui8vector(uint16 *X, long nl, long nh, uint8 *Y)
    375 /* ------------------------------------------------------------------------------- */
    376 {
    377     long i;
    378     for(i=nl; i<=nh; i++)
    379         Y[i] = (uint8) X[i];
    380 }
    381 /* -------------------------------------------------------------------------------- */
    382 IMAGE_EXPORT(void) convert_si32vector_si8vector(sint32 *X, long nl, long nh, sint8 *Y)
    383 /* -------------------------------------------------------------------------------- */
    384 {
    385     long i;
    386     for(i=nl; i<=nh; i++)
    387         Y[i] = (sint8) X[i];
    388 }
    389 /* ---------------------------------------------------------------------------------- */
    390 IMAGE_EXPORT(void) convert_si32vector_si16vector(sint32 *X, long nl, long nh, sint16 *Y)
    391 /* ---------------------------------------------------------------------------------- */
    392 {
    393     long i;
    394     for(i=nl; i<=nh; i++)
    395         Y[i] = (sint16) X[i];
    396 }
    397 /* -------------------------------------------------------------------------------- */
    398 IMAGE_EXPORT(void) convert_ui32vector_ui8vector(uint32 *X, long nl, long nh, uint8 *Y)
    399 /* -------------------------------------------------------------------------------- */
    400 {
    401     long i;
    402     for(i=nl; i<=nh; i++)
    403         Y[i] = (uint8) X[i];
    404 }
    405 /* ---------------------------------------------------------------------------------- */
    406 IMAGE_EXPORT(void) convert_ui32vector_ui16vector(uint32 *X, long nl, long nh, uint16 *Y)
    407 /* ---------------------------------------------------------------------------------- */
    408 {
    409     long i;
    410     for(i=nl; i<=nh; i++)
    411         Y[i] = (uint16) X[i];
    412 }
    413 /* -------------------------------------------------------------------------------- */
    414 IMAGE_EXPORT(void) convert_f32vector_si8vector(float32 *X, long nl, long nh, sint8 *Y)
    415 /* -------------------------------------------------------------------------------- */
    416 {
    417     long i;
    418     for(i=nl; i<=nh; i++)
    419         Y[i] = (sint8) X[i];
    420 }
    421 /* -------------------------------------------------------------------------------- */
    422 IMAGE_EXPORT(void) convert_f32vector_ui8vector(float32 *X, long nl, long nh, uint8 *Y)
    423 /* -------------------------------------------------------------------------------- */
    424 {
    425     long i;
    426     for(i=nl; i<=nh; i++)
    427         Y[i] = (uint8) X[i];
    428 }
    429 /* ---------------------------------------------------------------------------------- */
    430 IMAGE_EXPORT(void) convert_f32vector_si16vector(float32 *X, long nl, long nh, sint16 *Y)
    431 /* ---------------------------------------------------------------------------------- */
    432 {
    433     long i;
    434     for(i=nl; i<=nh; i++)
    435         Y[i] = (sint16) X[i];
    436 }
    437 /* ---------------------------------------------------------------------------------- */
    438 IMAGE_EXPORT(void) convert_f32vector_ui16vector(float32 *X, long nl, long nh, uint16 *Y)
    439 /* ---------------------------------------------------------------------------------- */
    440 {
    441     long i;
    442     for(i=nl; i<=nh; i++)
    443         Y[i] = (uint16) X[i];
    444 }
    445 /* ---------------------------------------------------------------------------------- */
    446 IMAGE_EXPORT(void) convert_f32vector_si32vector(float32 *X, long nl, long nh, sint32 *Y)
    447 /* ---------------------------------------------------------------------------------- */
    448 {
    449     long i;
    450     for(i=nl; i<=nh; i++)
    451         Y[i] = (sint32) X[i];
    452 }
    453 /* ---------------------------------------------------------------------------------- */
    454 IMAGE_EXPORT(void) convert_f32vector_ui32vector(float32 *X, long nl, long nh, uint32 *Y)
    455 /* ---------------------------------------------------------------------------------- */
    456 {
    457     long i;
    458     for(i=nl; i<=nh; i++)
    459         Y[i] = (uint32) X[i];
    460 }
    461 /* -------------------------------------------------------------------------------- */
    462 IMAGE_EXPORT(void) convert_f64vector_si8vector(float64 *X, long nl, long nh, sint8 *Y)
    463 /* -------------------------------------------------------------------------------- */
    464 {
    465     long i;
    466     for(i=nl; i<=nh; i++)
    467         Y[i] = (sint8) X[i];
    468 }
    469 /* -------------------------------------------------------------------------------- */
    470 IMAGE_EXPORT(void) convert_f64vector_ui8vector(float64 *X, long nl, long nh, uint8 *Y)
    471 /* -------------------------------------------------------------------------------- */
    472 {
    473     long i;
    474     for(i=nl; i<=nh; i++)
    475         Y[i] = (uint8) X[i];
    476 }
    477 /* ---------------------------------------------------------------------------------- */
    478 IMAGE_EXPORT(void) convert_f64vector_si16vector(float64 *X, long nl, long nh, sint16 *Y)
    479 /* ---------------------------------------------------------------------------------- */
    480 {
    481     long i;
    482     for(i=nl; i<=nh; i++)
    483         Y[i] = (sint16) X[i];
    484 }
    485 /* ---------------------------------------------------------------------------------- */
    486 IMAGE_EXPORT(void) convert_f64vector_ui16vector(float64 *X, long nl, long nh, uint16 *Y)
    487 /* ---------------------------------------------------------------------------------- */
    488 {
    489     long i;
    490     for(i=nl; i<=nh; i++)
    491         Y[i] = (uint16) X[i];
    492 }
    493 /* ---------------------------------------------------------------------------------- */
    494 IMAGE_EXPORT(void) convert_f64vector_si32vector(float64 *X, long nl, long nh, sint32 *Y)
    495 /* ---------------------------------------------------------------------------------- */
    496 {
    497     long i;
    498     for(i=nl; i<=nh; i++)
    499         Y[i] = (sint32) X[i];
    500 }
    501 /* ---------------------------------------------------------------------------------- */
    502 IMAGE_EXPORT(void) convert_f64vector_ui32vector(float64 *X, long nl, long nh, uint32 *Y)
    503 /* ---------------------------------------------------------------------------------- */
    504 {
    505     long i;
    506     for(i=nl; i<=nh; i++)
    507         Y[i] = (uint32) X[i];
    508 }
    509 /* ---------------------------------------------------------------------------------- */
    510 IMAGE_EXPORT(void) convert_f64vector_f32vector(float64 *X, long nl, long nh, float32 *Y)
    511 /* ---------------------------------------------------------------------------------- */
    512 {
    513     long i;
    514     for(i=nl; i<=nh; i++)
    515         Y[i] = (float32) X[i];
    516 }
    517 /* ------------------------------------------------------------------------------ */
    518 IMAGE_EXPORT(void) convert_rgb8vector_ui8vector(rgb8 *X, long nl, long nh, uint8 *Y)
    519 /* ------------------------------------------------------------------------------ */
    520 {
    521     long i;
    522     for(i=nl; i<=nh; i++) {
     176
     177
     178void convert_rgb8vector_ui8vector(rgb8 * X, int32_t nl, int32_t nh, uint8_t * Y)
     179{
     180    for (int32_t i = nl; i <= nh; i++) {
    523181        Y[i] = (X[i].r + X[i].g + X[i].b) / 3;
    524182    }
    525183}
    526 /* -------------------------------------------------------------------------------- */
    527 IMAGE_EXPORT(void) convert_rgbx8vector_ui8vector(rgbx8 *X, long nl, long nh, uint8 *Y)
    528 /* -------------------------------------------------------------------------------- */
    529 {
    530     long i;
    531     for(i=nl; i<=nh; i++) {
     184
     185void convert_rgbx8vector_ui8vector(rgbx8 * X, int32_t nl, int32_t nh, uint8_t * Y)
     186{
     187    for (int32_t i = nl; i <= nh; i++) {
    532188        Y[i] = (X[i].r + X[i].g + X[i].b) / 3;
    533189    }
    534190}
     191
    535192/*
    536193 * ---------------
     
    538195 * ---------------
    539196 */
    540 /* ------------------------------------------------------------------------------- */
    541 IMAGE_EXPORT(void) lowpart_ui16vector_ui8vector(uint16 *X, long nl,long nh, uint8 *Y)
    542 /* ------------------------------------------------------------------------------- */
    543 {
    544         int i;
    545         for(i=nl; i<=nh; i++) {
    546                 Y[i] = X[i] & 0xff;
    547         }
    548 }
    549 /* ------------------------------------------------------------------------------- */
    550 IMAGE_EXPORT(void) lowpart_ui32vector_ui8vector(uint32 *X, long nl,long nh, uint8 *Y)
    551 /* ------------------------------------------------------------------------------- */
    552 {
    553         int i;
    554         for(i=nl; i<=nh; i++) {
    555                 Y[i] = X[i] & 0xff;
    556         }
    557 }
    558 
    559 
     197
     198void lowpart_ui16vector_ui8vector(uint16_t * X, int32_t nl, int32_t nh, uint8_t * Y)
     199{
     200    for(int32_t i = nl; i <= nh; i++) {
     201        Y[i] = X[i] & 0xff;
     202    }
     203}
     204
     205void lowpart_ui32vector_ui8vector(uint32_t * X, int32_t nl, int32_t nh, uint8_t * Y)
     206{
     207    for (int32_t i = nl; i <= nh; i++) {
     208        Y[i] = X[i] & 0xff;
     209    }
     210}
     211
     212
Note: See TracChangeset for help on using the changeset viewer.