Changeset 823 for soft/giet_vm
- Timestamp:
- Jun 14, 2016, 5:23:56 PM (8 years ago)
- Location:
- soft/giet_vm/applications/rosenfeld
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/Makefile
r822 r823 6 6 7 7 TARGET ?= linux 8 IGNORE_ASSERT ?= false 9 8 10 # 9 11 # -- Config ---------- … … 11 13 ifeq ($(TARGET),giet-vm) 12 14 13 C_DEBUG_FLAGS = -O014 15 C_OPTIM_FLAGS = -std=c99 -O2 -fstrict-aliasing 15 16 C_OS_FLAGS = -DGTODay -DTARGET_OS=GIETVM 16 17 C_CONFIG_FLAGS = -DCLI 17 18 C_INC_FLAGS = -I$(INC_PATH) -Inrc2/include -I../.. -I../../giet_libs -I../../giet_xml/ 18 CFLAGSCPU := -mips32 -EL -G0 -mhard-float -fomit-frame-pointer -fno-builtin -ffreestanding19 CFLAGSCPU = -mips32 -EL -G0 -mhard-float -fomit-frame-pointer -fno-builtin -ffreestanding 19 20 20 LDFLAGS := -Lnrc2 -L../../build/libs -Trosenfeld.ld --start-group -lnrc2x -luser -lmath --end-group21 LDFLAGS = -Lnrc2 -L../../build/libs -Trosenfeld.ld --start-group -lnrc2x -luser -lmath --end-group 21 22 22 23 endif … … 28 29 29 30 # -- Config ---------- 30 C_DEBUG_FLAGS = -O031 31 C_OPTIM_FLAGS = -std=c99 -O2 -fstrict-aliasing 32 32 C_OS_FLAGS = -DGTODay -DTARGET_OS=LINUX -D_GNU_SOURCE … … 34 34 C_INC_FLAGS = -I$(INC_PATH) -Inrc2/include 35 35 CFLAGSCPU = 36 ifeq ($(IGNORE_ASSERT),true) 37 C_OPTIM_FLAGS := $(C_OPTIM_FLAGS) -DNDEBUG 38 endif 36 39 37 LDFLAGS := -Lnrc2 -Wl,--start-group -lnrc2x -lm -lpthread -Wl,--end-group40 LDFLAGS = -Lnrc2 -Wl,--start-group -lnrc2x -lm -lpthread -Wl,--end-group 38 41 39 42 endif … … 41 44 42 45 43 CFLAGSW := -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels -Wno-unused-function -Wno-unused-variable46 CFLAGSW = -Wredundant-decls -Wdisabled-optimization -Winline -Wpointer-arith -Wsign-compare -Wendif-labels -Wno-unused-function -Wno-unused-variable 44 47 45 48 # -- Flags ---------- 46 #CFLAGS = $(C_DEBUG_FLAGS) $(C_OS_FLAGS) $(C_INC_FLAGS) $(C_CONFIG_FLAGS)47 49 CFLAGS = $(C_OPTIM_FLAGS) $(C_OS_FLAGS) $(C_INC_FLAGS) $(C_CONFIG_FLAGS) -g -Wall $(CFLAGSW) $(CFLAGSCPU) 48 50 -
soft/giet_vm/applications/rosenfeld/include/clock.h
r822 r823 7 7 #include "nrc_os_config.h" 8 8 #if TARGET_OS == LINUX 9 #include <x86intrin.h> 9 10 #include <sys/time.h> 10 11 #endif … … 17 18 * - CLOCK_APP_CREATE; 18 19 * - CLOCK_THREAD_START(thread_id); 19 * - CLOCK_THREAD_COMPUTE_START(thread_id; 20 * - CLOCK_THREAD_START_STEP(thread_id, step_id) 21 * - CLOCK_THREAD_END_STEP(thread_id, step_id) 22 * - (repeat num_steps times) 23 * - CLOCK_THREAD_COMPUTE_END(thread_id); 20 * - Repeat num_runs times: 21 * - CLOCK_THREAD_COMPUTE_START(thread_id; 22 * - Repeat num_step times: 23 * - CLOCK_THREAD_START_STEP(thread_id, step_id) 24 * - CLOCK_THREAD_END_STEP(thread_id, step_id) 25 * - CLOCK_THREAD_COMPUTE_END(thread_id); 26 * - CLOCK_ACCUMULATE; 24 27 * - CLOCK_THREAD_END(thread_id) 25 28 * - CLOCK_APP_JOIN; … … 28 31 * - PRINT_CLOCK; 29 32 * - CLOCK_FREE; 33 * In case of several runs, the THREAD_COMPUTE and all the THREAD_STEP resulting times 34 * are averaged over all the runs. The other times are kind of irrelevant. 35 * TODO: make a struct gathering all variables and change macros to functions 30 36 */ 31 37 32 38 33 39 static void local_sort_asc(uint64_t tab[], int32_t size) { 34 int32_t tmp;40 uint64_t tmp; 35 41 int32_t i, j; 36 42 for (i = 0; i < size; i++) { … … 61 67 int32_t step_number; \ 62 68 int32_t clock_thread_num; \ 69 int32_t clock_num_runs; \ 63 70 uint64_t ** thread_start_step; \ 64 71 uint64_t ** thread_end_step; \ … … 67 74 uint64_t global_thread_compute_start; \ 68 75 uint64_t global_thread_compute_end; \ 76 uint64_t accumulated_thread_compute; \ 69 77 uint64_t * global_thread_start_step; \ 70 uint64_t * global_thread_end_step; 78 uint64_t * global_thread_end_step; \ 79 uint64_t * accumulated_thread_step; 71 80 72 81 #if TARGET_OS == GIETVM 73 82 #define CLOCK(x) ({ x = giet_proctime(); }) 74 83 #elif TARGET_OS == LINUX 75 #define CLOCK(x) ({ \84 /*#define CLOCK(x) ({ \ 76 85 struct timeval full_time; \ 77 86 gettimeofday(&full_time, NULL); \ 78 87 x = (uint64_t) ((full_time.tv_usec + full_time.tv_sec * 1000000)); \ 79 }) 88 }) */ 89 #define CLOCK(x) ({ x = __rdtsc(); }) 80 90 #endif 81 91 … … 84 94 clock_thread_num = (x); \ 85 95 step_number = (y); \ 96 clock_num_runs = 0; \ 86 97 global_thread_start = 0xFFFFFFFFFFFFFFFFLLU; \ 87 98 global_thread_end = 0; \ 88 99 global_thread_compute_start = 0xFFFFFFFFFFFFFFFFLLU; \ 89 100 global_thread_compute_end = 0; \ 101 accumulated_thread_compute = 0; \ 90 102 if ((x) > 0) { \ 91 103 thread_start = (uint64_t *) malloc(sizeof(uint64_t) * (x)); \ … … 98 110 thread_start_step = (uint64_t **) malloc(sizeof(uint64_t *) * (y)); \ 99 111 thread_end_step = (uint64_t **) malloc(sizeof(uint64_t *) * (y)); \ 112 accumulated_thread_step = (uint64_t *) malloc(sizeof(uint64_t) * (y)); \ 100 113 for (int32_t j = 0; j < (y); j++) { \ 101 global_thread_start_step[j] = 0xFFFFFFFFFFFFFFFFL U;\114 global_thread_start_step[j] = 0xFFFFFFFFFFFFFFFFLLU; \ 102 115 global_thread_end_step[j] = 0; \ 116 accumulated_thread_step[j] = 0; \ 103 117 thread_start_step[j] = (uint64_t *) malloc(sizeof(uint64_t) * (x)); \ 104 118 thread_end_step[j] = (uint64_t *) malloc(sizeof(uint64_t) * (x)); \ … … 120 134 #define CLOCK_THREAD_END_STEP(x, y) ({ CLOCK(thread_end_step[y][x]); }) 121 135 136 #define CLOCK_ACCUMULATE ({ \ 137 for (int32_t i = 0; i < clock_thread_num; i++) { \ 138 if (thread_compute_start[i] < global_thread_compute_start) { \ 139 global_thread_compute_start = thread_compute_start[i]; \ 140 } \ 141 if (thread_compute_end[i] > global_thread_compute_end) { \ 142 global_thread_compute_end = thread_compute_end[i]; \ 143 } \ 144 for (int32_t j = 0; j < step_number; j++) { \ 145 if (thread_start_step[j][i] < global_thread_start_step[j]) { \ 146 global_thread_start_step[j] = thread_start_step[j][i]; \ 147 } \ 148 if (thread_end_step[j][i] > global_thread_end_step[j]) { \ 149 global_thread_end_step[j] = thread_end_step[j][i]; \ 150 } \ 151 } \ 152 } \ 153 for (int32_t j = 0; j < step_number; j++) { \ 154 accumulated_thread_step[j] += (global_thread_end_step[j] - global_thread_start_step[j]); \ 155 global_thread_start_step[j] = 0xFFFFFFFFFFFFFFFFLLU; \ 156 global_thread_end_step[j] = 0; \ 157 } \ 158 accumulated_thread_compute += (global_thread_compute_end - global_thread_compute_start); \ 159 global_thread_compute_start = 0xFFFFFFFFFFFFFFFFLLU; \ 160 global_thread_compute_end = 0; \ 161 clock_num_runs++; \ 162 }) 163 122 164 123 165 #define CLOCK_FINALIZE ({ \ 166 if (clock_num_runs == 0) { \ 167 CLOCK_ACCUMULATE; \ 168 } \ 124 169 for (int32_t i = 0; i < clock_thread_num; i++) { \ 125 170 if (thread_start[i] < global_thread_start) { \ … … 146 191 }) 147 192 148 #define PRINT_CLOCK ({ \ 149 MCA_VERBOSE1(printf("Timestamps:\n")); \ 150 MCA_VERBOSE1(printf("[APP_START] : %llu\n", app_start)); \ 151 MCA_VERBOSE1(printf("[APP_CREATE] : %llu\n", app_create)); \ 152 MCA_VERBOSE1(printf("[THREAD_START] : %llu\n", global_thread_start)); \ 153 MCA_VERBOSE1(printf("[THREAD_COMPUTE_START] : %llu\n", global_thread_compute_start)); \ 154 for (int32_t j = 0; j < step_number; j++) { \ 155 MCA_VERBOSE1(printf("[THREAD_START_STEP_%d] : %llu\n", j, global_thread_start_step[j])); \ 156 MCA_VERBOSE1(printf("[THREAD_END_STEP_%d] : %llu\n", j, global_thread_end_step[j])); \ 157 } \ 158 MCA_VERBOSE1(printf("[THREAD_COMPUTE_END] : %llu\n", global_thread_compute_end)); \ 159 MCA_VERBOSE1(printf("[THREAD_END] : %llu\n", global_thread_end)); \ 160 MCA_VERBOSE1(printf("[APP_JOIN] : %llu\n", app_join)); \ 161 MCA_VERBOSE1(printf("[APP_END] : %llu\n", app_end)); \ 162 MCA_VERBOSE1(printf("Durations (in cycles):\n")); \ 163 MCA_VERBOSE1(printf("[TOTAL] : %llu\n", app_end - app_start)); \ 164 MCA_VERBOSE1(printf("[THREAD] : %llu\n", app_join - app_create)); \ 165 MCA_VERBOSE1(printf("[PARALLEL] : %llu\n", global_thread_end - global_thread_start)); \ 166 MCA_VERBOSE1(printf("[PARALLEL_COMPUTE] : %llu\n", global_thread_compute_end - global_thread_compute_start)); \ 167 for (int32_t j = 0; j < step_number; j++) { \ 168 MCA_VERBOSE1(printf("[THREAD_STEP_%d] : %llu\n", j, global_thread_end_step[j] - global_thread_start_step[j])); \ 169 } \ 170 MCA_VERBOSE1(printf("\n")); \ 171 MCA_VERBOSE1(printf("*** All threads times output in a gnuplot data-style ***\n")); \ 172 local_sort_asc(thread_start, clock_thread_num); \ 173 local_sort_asc(thread_compute_start, clock_thread_num); \ 174 local_sort_asc(thread_compute_end, clock_thread_num); \ 175 local_sort_asc(thread_end, clock_thread_num); \ 176 for (int32_t j = 0; j < step_number; j++) { \ 177 local_sort_asc(thread_start_step[j], clock_thread_num); \ 178 local_sort_asc(thread_end_step[j], clock_thread_num); \ 179 } \ 180 MCA_VERBOSE1(printf("# cycle thread_id\n")); \ 181 for (int32_t i = 0; i < clock_thread_num; i++) { \ 182 MCA_VERBOSE1(printf("%llu\t%d\n", thread_start[i], i)); \ 183 MCA_VERBOSE1(printf("%llu\t%d\n", thread_compute_start[i], i)); \ 184 for (int32_t j = 0; j < step_number; j++) { \ 185 MCA_VERBOSE1(printf("%llu\t%d\n", thread_start_step[j][i], i)); \ 186 MCA_VERBOSE1(printf("%llu\t%d\n", thread_end_step[j][i], i)); \ 187 } \ 188 MCA_VERBOSE1(printf("%llu\t%d\n", thread_compute_end[i], i)); \ 189 MCA_VERBOSE1(printf("%llu\t%d\n", thread_end[i], i)); \ 190 } \ 193 194 #define PRINT_CLOCK ({ \ 195 MCA_VERBOSE1(printf("Timestamps:\n")); \ 196 if (clock_num_runs > 1) { \ 197 MCA_VERBOSE1(printf("(THREAD_COMPUTE_START, THREAD_COMPUTE_END, THREAD_START_STEPs and THREAD_END_STEPs)\n")); \ 198 MCA_VERBOSE1(printf("(are those of the last run)\n")); \ 199 } \ 200 MCA_VERBOSE1(printf("[APP_START] : %llu\n", app_start)); \ 201 MCA_VERBOSE1(printf("[APP_CREATE] : %llu\n", app_create)); \ 202 MCA_VERBOSE1(printf("[THREAD_START] : %llu\n", global_thread_start)); \ 203 MCA_VERBOSE1(printf("[THREAD_COMPUTE_START] : %llu\n", global_thread_compute_start)); \ 204 for (int32_t j = 0; j < step_number; j++) { \ 205 MCA_VERBOSE1(printf("[THREAD_START_STEP_%d] : %llu\n", j, global_thread_start_step[j])); \ 206 MCA_VERBOSE1(printf("[THREAD_END_STEP_%d] : %llu\n", j, global_thread_end_step[j])); \ 207 } \ 208 MCA_VERBOSE1(printf("[THREAD_COMPUTE_END] : %llu\n", global_thread_compute_end)); \ 209 MCA_VERBOSE1(printf("[THREAD_END] : %llu\n", global_thread_end)); \ 210 MCA_VERBOSE1(printf("[APP_JOIN] : %llu\n", app_join)); \ 211 MCA_VERBOSE1(printf("[APP_END] : %llu\n", app_end)); \ 212 MCA_VERBOSE1(printf("Durations (in cycles):\n")); \ 213 if (clock_num_runs > 1) { \ 214 MCA_VERBOSE1(printf("(PARALLEL_COMPUTE and THREAD_STEPs are averaged over %d runs)\n", clock_num_runs)); \ 215 } \ 216 MCA_VERBOSE1(printf("[TOTAL] : %llu\n", app_end - app_start)); \ 217 MCA_VERBOSE1(printf("[THREAD] : %llu\n", app_join - app_create)); \ 218 MCA_VERBOSE1(printf("[PARALLEL] : %llu\n", global_thread_end - global_thread_start)); \ 219 MCA_VERBOSE1(printf("[PARALLEL_COMPUTE] : %llu\n", accumulated_thread_compute / clock_num_runs)); \ 220 for (int32_t j = 0; j < step_number; j++) { \ 221 MCA_VERBOSE1(printf("[THREAD_STEP_%d] : %llu\n", j, accumulated_thread_step[j] / clock_num_runs)); \ 222 } \ 223 MCA_VERBOSE1(printf("\n")); \ 224 MCA_VERBOSE1(printf("*** All threads times output in a gnuplot data-style ***\n")); \ 225 local_sort_asc(thread_start, clock_thread_num); \ 226 local_sort_asc(thread_compute_start, clock_thread_num); \ 227 local_sort_asc(thread_compute_end, clock_thread_num); \ 228 local_sort_asc(thread_end, clock_thread_num); \ 229 for (int32_t j = 0; j < step_number; j++) { \ 230 local_sort_asc(thread_start_step[j], clock_thread_num); \ 231 local_sort_asc(thread_end_step[j], clock_thread_num); \ 232 } \ 233 MCA_VERBOSE1(printf("# cycle thread_id\n")); \ 234 for (int32_t i = 0; i < clock_thread_num; i++) { \ 235 MCA_VERBOSE1(printf("%llu\t%d\n", thread_start[i] - app_start, i)); \ 236 MCA_VERBOSE1(printf("%llu\t%d\n", thread_compute_start[i] - app_start, i)); \ 237 for (int32_t j = 0; j < step_number; j++) { \ 238 MCA_VERBOSE1(printf("%llu\t%d\n", thread_start_step[j][i] - app_start, i)); \ 239 MCA_VERBOSE1(printf("%llu\t%d\n", thread_end_step[j][i] - app_start, i)); \ 240 } \ 241 MCA_VERBOSE1(printf("%llu\t%d\n", thread_compute_end[i] - app_start, i)); \ 242 MCA_VERBOSE1(printf("%llu\t%d\n", thread_end[i] - app_start, i)); \ 243 } \ 191 244 }) 192 245 … … 205 258 free(global_thread_start_step); \ 206 259 free(global_thread_end_step); \ 260 free(accumulated_thread_step); \ 207 261 for (int32_t j = 0; j < step_number; j++) { \ 208 262 free(thread_start_step[j]); \ -
soft/giet_vm/applications/rosenfeld/include/config.h
r822 r823 4 4 5 5 #define SLOW 0 6 #define FEATURES 16 #define FEATURES 0 7 7 #define FAST 1 8 8 #define PYR_BARRIERS 0 9 #define PARMERGE 09 #define PARMERGE 1 10 10 #define ARSP 0 11 11 … … 21 21 #if FAST 22 22 #if !FEATURES && !PARMERGE && !ARSP 23 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Rosenfeld_Dist(e, f, T, D, alpha)24 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Rosenfeld_Dist(e, f, g, T, D, alpha)23 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Rosenfeld_Dist(e, f, T, D, alpha) 24 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Rosenfeld_Dist(e, f, g, T, D, alpha) 25 25 #elif !FEATURES && !PARMERGE && ARSP 26 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Arsp_Rosenfeld_Dist(e, f, T, D, alpha)27 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha)26 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Arsp_Rosenfeld_Dist(e, f, T, D, alpha) 27 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha) 28 28 #error "Configuration Not implemented" 29 29 #elif !FEATURES && PARMERGE && !ARSP 30 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Rosenfeld_Dist(e, f, T, D, alpha, F)31 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Rosenfeld_Dist(e, f, g, T, D, alpha, F)32 # error "Configuration Not implemented"30 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Rosenfeld_Dist(e, f, T, D, alpha, F) 31 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 32 #define SetRoot_Parallel_FNF(D, rl, rd, alpha, F) SetRoot_Parallel_Rosenfeld_Dist(D, rl, rd, alpha, F) 33 33 #elif !FEATURES && PARMERGE && ARSP 34 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Arsp_Rosenfeld_Dist(e, f, T, D, alpha, F)35 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha, F)34 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Arsp_Rosenfeld_Dist(e, f, T, D, alpha, F) 35 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 36 36 #elif FEATURES && !PARMERGE && !ARSP 37 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Features_Rosenfeld_Dist(e, f, T, D, alpha, F)38 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Features_Rosenfeld_Dist(e, f, g, T, D, alpha, F)37 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Features_Rosenfeld_Dist(e, f, T, D, alpha, F) 38 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Features_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 39 39 #elif FEATURES && !PARMERGE && ARSP 40 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Features_Arsp_Rosenfeld_Dist(e, f, T, D, alpha, F)41 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Features_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha, F)40 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Features_Arsp_Rosenfeld_Dist(e, f, T, D, alpha, F) 41 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Features_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 42 42 #error "Configuration Not implemented" 43 43 #elif FEATURES && PARMERGE && !ARSP 44 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Features_Rosenfeld_Dist(e, f, T, D, alpha, F) 45 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Features_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 44 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Rosenfeld_Dist(e, f, T, D, alpha, F) 45 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 46 #define SetRoot_Parallel_FNF(D, rl, rd, alpha, F) SetRoot_Parallel_Features_Rosenfeld_Dist(D, rl, rd, alpha, F) 46 47 #elif FEATURES && PARMERGE && ARSP 47 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Features_Arsp_Rosenfeld_Dist(e, f, T, D, alpha, F)48 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Features_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha, F)48 #define vuse2_Rosenfeld(e, f, T, D, alpha, F) vuse2_Parallel_Features_Arsp_Rosenfeld_Dist(e, f, T, D, alpha, F) 49 #define vuse3_Rosenfeld(e, f, g, T, D, alpha, F) vuse3_Parallel_Features_Arsp_Rosenfeld_Dist(e, f, g, T, D, alpha, F) 49 50 #error "Configuration Not implemented" 50 51 #endif … … 72 73 // 2 : Standard level 73 74 // 3 : Maximum (debug) level 74 #define MCA_VERBOSE_LEVEL 2 75 76 #endif // __CONFIG_H__ 75 #define MCA_VERBOSE_LEVEL 1 77 76 78 77 78 #endif 79 -
soft/giet_vm/applications/rosenfeld/include/mca.h
r822 r823 67 67 68 68 typedef struct sMCA { 69 int p, np; // numero du processeur et nb total de processeurs 69 int p, np; // numero du processeur et nb total de processeurs 70 int nr; // nombre de runs successifs à mesurer 70 71 71 72 uint8 ** X; // image source … … 78 79 int j0, j1; 79 80 80 uint32 e0, e1; // indice pour chaque bande 81 uint32 ne; // indice max d'etiquettes utilise par bande 81 uint32 e0, e1; // indice pour chaque bande 82 uint32 ne; // indice max d'etiquettes utilise par bande 83 uint32 ne_prev; // ne de l'image précédente (pour le reset de T) 82 84 83 int alpha; // puissance de 2 >= a la taille d'un bloc84 uint32 * T; // table d'quivalence table (Rosenfeld) ou d'indices (Warp)85 uint32 ** D; // distributed table (instanciee dans chaque worker)85 int alpha; // puissance de 2 >= a la taille d'un bloc 86 uint32 * T; // table d'quivalence table (Rosenfeld) ou d'indices (Warp) 87 uint32 ** D; // distributed table (instanciee dans chaque worker) 86 88 87 89 RegionStats * stats; … … 106 108 void MCA_Set_Size(MCA * mca, int width, int height); 107 109 void MCA_Set_NP(MCA * mca, int np); 110 void MCA_Set_NR(MCA * mca, int nr); 108 111 109 112 uint32 MCA_CalcMaxLabels(int connection, uint32 height, uint32 width); -
soft/giet_vm/applications/rosenfeld/nrc2/Makefile
r822 r823 8 8 # -- File list ---------- 9 9 FILE = 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 giet10 FILE := $(FILE), nrio1f.c, nrio1xf.c, nrio2f.c nrio2x.c nrio2xf.c nrio3.c # comment if giet 11 11 12 12 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrio2x.h
r772 r823 11 11 #define __NRIO2X_H__ 12 12 13 #ifdef __cplusplus14 #pragma message ("C++")15 extern "C" {16 #endif17 18 #ifdef VERBOSE_PRAGMA19 //#pragma message ("- *** include nrio2x.h ***")20 #endif21 13 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 /* ------------------------------ */ 29 21 30 /* ------------------------------- */ 31 /* --- display_matrix_endline0 --- */ 22 #define display_type_matrix_endline(t) \ 23 void short_name(t,display_,matrix_endline)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name); \ 24 void short_name(t,display_,matrix_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name); \ 25 void short_name(t,display_,matrix_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name); \ 26 void 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); \ 27 void 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); 32 28 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); 29 display_type_matrix_endline(int8_t); 30 display_type_matrix_endline(uint8_t); 31 display_type_matrix_endline(int16_t); 32 display_type_matrix_endline(uint16_t); 33 display_type_matrix_endline(int32_t); 34 display_type_matrix_endline(uint32_t); 35 display_type_matrix_endline(int64_t); 36 display_type_matrix_endline(uint64_t); 40 37 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);75 38 76 39 /* ------------------------- */ … … 78 41 /* ------------------------- */ 79 42 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) \ 44 void 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 46 display_type_trimatrix(int8_t); 47 display_type_trimatrix(uint8_t); 48 display_type_trimatrix(int16_t); 49 display_type_trimatrix(uint16_t); 50 display_type_trimatrix(int32_t); 51 display_type_trimatrix(uint32_t); 52 display_type_trimatrix(int64_t); 53 display_type_trimatrix(uint64_t); 54 display_type_trimatrix(float); 55 display_type_trimatrix(double); 56 57 58 87 59 88 60 /* ----------------------- */ 89 61 /* --- 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 -- */ 90 69 /* ----------------------- */ 91 70 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) \ 72 void 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); \ 73 void short_name(t,write_,matrix_endline)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename); \ 74 void short_name(t,write_,matrix_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename); \ 75 void short_name(t,write_,matrix_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * filename); \ 76 void 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); \ 77 void 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); \ 78 void short_name(t,fwrite_,trimatrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step, char * filename); \ 79 void short_name(t,fread_,trimatrix)(char * filename, t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step); 99 80 100 /* ---------------------------- */ 101 /* --- write_matrix_endline --- */ 102 /* ---------------------------- */ 81 write_type_trimatrix(int8_t); 82 write_type_trimatrix(uint8_t); 83 write_type_trimatrix(int16_t); 84 write_type_trimatrix(uint16_t); 85 write_type_trimatrix(int32_t); 86 write_type_trimatrix(uint32_t); 87 write_type_trimatrix(int64_t); 88 write_type_trimatrix(uint64_t); 89 write_type_trimatrix(float); 90 write_type_trimatrix(double); 103 91 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);111 92 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 __cplusplus184 }185 #endif186 93 187 94 #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 7 7 * Univ Paris Sud XI, CNRS 8 8 */ 9 10 #ifndef _NR_IO3_H_ 11 #define _NR_IO3_H_ 12 9 13 /* -------------------- */ 10 14 /* --- display_cube --- */ 15 /* -- write_cube -- */ 16 /* -- fread_cube -- */ 17 /* -- fwrite_cube -- */ 11 18 /* -------------------- */ 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);19 19 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) \ 21 void 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); \ 22 void 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); \ 23 void 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); \ 24 void 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); 30 25 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); 26 display_type_cube(int8_t); 27 display_type_cube(uint8_t); 28 display_type_cube(int16_t); 29 display_type_cube(uint16_t); 30 display_type_cube(int32_t); 31 display_type_cube(uint32_t); 32 display_type_cube(int64_t); 33 display_type_cube(uint64_t); 34 display_type_cube(float); 35 display_type_cube(double); 38 36 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 11 11 #define __NRLINALG_H__ 12 12 13 # ifdef __cplusplus14 extern "C" { 15 #endif 13 #define transpose_type_matrix(t) \ 14 void short_name(t,transpose_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t ** D); \ 15 void short_name(t,transpose1_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch); 16 16 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); 17 transpose_type_matrix(int8_t); 18 transpose_type_matrix(uint8_t); 19 transpose_type_matrix(int16_t); 20 transpose_type_matrix(uint16_t); 21 transpose_type_matrix(int32_t); 22 transpose_type_matrix(uint32_t); 23 transpose_type_matrix(int64_t); 24 transpose_type_matrix(uint64_t); 25 transpose_type_matrix(float); 26 transpose_type_matrix(double); 27 transpose_type_matrix(rgb8); 28 transpose_type_matrix(rgbx8); 33 29 34 #ifdef __cplusplus35 }36 #endif37 30 38 31 #endif // __NRLINALG_H__ 32 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrlut.h
r772 r823 5 5 /* 6 6 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved 7 * Univ Paris Sud XI, CNRS8 */7 * Univ Paris Sud XI, CNRS 8 */ 9 9 10 10 #ifndef _NRLUT_H_ 11 11 #define _NRLUT_H_ 12 12 13 #ifdef __cplusplus 14 #ifdef PRAGMA_VERBOSE 15 #pragma message ("C++") 16 #endif 17 extern "C" { 18 #endif 13 #define init_type_lut(t) \ 14 void short_name(t,init_,lut)(t * v, int32_t nl, int32_t nh, int32_t n0, int32_t n1, t k); \ 15 void short_name(t,lut_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t * L, t ** D); 19 16 20 #ifdef PRAGMA_VERBOSE 21 #pragma message("- include nrlut.h") 22 #endif 17 init_type_lut(int8_t); 18 init_type_lut(uint8_t); 19 init_type_lut(int16_t); 20 init_type_lut(uint16_t); 21 init_type_lut(int32_t); 22 init_type_lut(uint32_t); 23 init_type_lut(rgb8); 23 24 24 25 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); 26 void lut_si16matrix_si8matrix(int16_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int8_t * L, int8_t ** D); 27 void lut_ui16matrix_ui8matrix(uint16_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint8_t * L, uint8_t ** D); 28 void lut_si32matrix_si16matrix(int32_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, int16_t * L, int16_t ** D); 29 void lut_ui32matrix_ui16matrix(uint32_t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, uint16_t * L, uint16_t ** D); 31 30 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);40 31 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) \ 33 void short_name(t,histogram_,matrix)(t ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, t * H); 49 34 50 #ifdef __cplusplus 51 } 52 #endif 35 histogram_type_matrix(int8_t); 36 histogram_type_matrix(uint8_t); 37 histogram_type_matrix(int16_t); 38 histogram_type_matrix(uint16_t); 39 histogram_type_matrix(int32_t); 40 histogram_type_matrix(uint32_t); 41 void histogram_rgb8matrix(rgb8 ** S, int32_t nrl, int32_t nrh, int32_t ncl, int32_t nch, rgb32 * H); 42 53 43 54 44 #endif /* _NRLUT_H_ */ 45 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrmem1.h
r772 r823 12 12 #define __NRMEM1_H__ 13 13 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) \ 16 void short_name(t,dup_,vector)(t * X, int32_t nl, int32_t nh, t * Y); 17 18 dup_type_vector(int8_t); 19 dup_type_vector(uint8_t); 20 dup_type_vector(int16_t); 21 dup_type_vector(uint16_t); 22 dup_type_vector(int32_t); 23 dup_type_vector(uint32_t); 24 dup_type_vector(int64_t); 25 dup_type_vector(uint64_t); 26 dup_type_vector(float); 27 dup_type_vector(double); 28 dup_type_vector(rgb8); 29 dup_type_vector(rgbx8); 30 31 /* --------------------- */ 32 /* --- split & merge --- */ 33 /* --------------------- */ 34 35 void split_rgb8vector(rgb8 * X, int32_t nl, int32_t nh, uint8_t * R, uint8_t * G, uint8_t * B); 36 void split_rgb32vector(rgb32 * X, int32_t nl, int32_t nh, uint32_t * R, uint32_t * G, uint32_t * B); 37 38 void merge_rgb8vector(uint8_t * R, uint8_t * G, uint8_t * B, int32_t nl, int32_t nh, rgb8 * X); 39 void merge_rgb32vector(uint32_t * R, uint32_t * G, uint32_t * B, int32_t nl, int32_t nh, rgb32 * X); 22 40 23 41 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);36 42 37 43 /* ---------------- */ 38 /* -- Conver tion -- */44 /* -- Conversion -- */ 39 45 /* ---------------- */ 40 46 41 // UP 47 #define convert_type1_vector_type2_vector(t1, t2) \ 48 void short_name(t1,convert_,short_name(t2,vector_,vector))(t1 * X, int32_t nl, int32_t nh, t2 * Y); 42 49 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); 50 convert_type1_vector_type2_vector(int8_t,int16_t); 51 convert_type1_vector_type2_vector(int8_t,int32_t); 52 convert_type1_vector_type2_vector(int8_t,float); 53 convert_type1_vector_type2_vector(int8_t,double); 54 convert_type1_vector_type2_vector(uint8_t,uint16_t); 55 convert_type1_vector_type2_vector(uint8_t,uint32_t); 56 convert_type1_vector_type2_vector(uint8_t,float); 57 convert_type1_vector_type2_vector(uint8_t,double); 58 convert_type1_vector_type2_vector(int16_t,int32_t); 59 convert_type1_vector_type2_vector(int16_t,float); 60 convert_type1_vector_type2_vector(int16_t,double); 61 convert_type1_vector_type2_vector(uint16_t,uint32_t); 62 convert_type1_vector_type2_vector(uint16_t,float); 63 convert_type1_vector_type2_vector(uint16_t,double); 64 convert_type1_vector_type2_vector(int32_t,float); 65 convert_type1_vector_type2_vector(int32_t,double); 66 convert_type1_vector_type2_vector(uint32_t,float); 67 convert_type1_vector_type2_vector(uint32_t,double); 68 convert_type1_vector_type2_vector(int16_t,int8_t); 69 convert_type1_vector_type2_vector(uint16_t,uint8_t); 70 convert_type1_vector_type2_vector(int32_t,int8_t); 71 convert_type1_vector_type2_vector(int32_t,int16_t); 72 convert_type1_vector_type2_vector(uint32_t,uint8_t); 73 convert_type1_vector_type2_vector(uint32_t,uint16_t); 74 convert_type1_vector_type2_vector(float,int8_t); 75 convert_type1_vector_type2_vector(float,uint8_t); 76 convert_type1_vector_type2_vector(float,int16_t); 77 convert_type1_vector_type2_vector(float,uint16_t); 78 convert_type1_vector_type2_vector(float,int32_t); 79 convert_type1_vector_type2_vector(float,uint32_t); 80 convert_type1_vector_type2_vector(double,int8_t); 81 convert_type1_vector_type2_vector(double,uint8_t); 82 convert_type1_vector_type2_vector(double,int16_t); 83 convert_type1_vector_type2_vector(double,uint16_t); 84 convert_type1_vector_type2_vector(double,int32_t); 85 convert_type1_vector_type2_vector(double,uint32_t); 86 convert_type1_vector_type2_vector(double,float); 87 convert_type1_vector_type2_vector(uint8_t,rgb8); 88 convert_type1_vector_type2_vector(uint8_t,rgbx8); 89 convert_type1_vector_type2_vector(rgb8,uint8_t); 90 convert_type1_vector_type2_vector(rgbx8,uint8_t); 47 91 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 // DOWN72 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);100 92 101 93 /* … … 105 97 */ 106 98 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 99 void lowpart_ui16vector_ui8vector(uint16_t * X, int32_t nl, int32_t nh, uint8_t * Y); 100 void lowpart_ui32vector_ui8vector(uint32_t * X, int32_t nl, int32_t nh, uint8_t * Y); 123 101 124 102 #endif /* __NRMEM1_H__ */ 103 -
soft/giet_vm/applications/rosenfeld/nrc2/include/nrtype.h
r822 r823 24 24 // Short names 25 25 26 #define sn_int8_t(p,s) p## i8##s27 #define sn_int16_t(p,s) p## i16##s28 #define sn_int32_t(p,s) p## i32##s29 #define sn_int64_t(p,s) p## i64##s26 #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 30 30 #define sn_uint8_t(p,s) p##ui8##s 31 31 #define sn_uint16_t(p,s) p##ui16##s -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2x.c
r772 r823 26 26 #include "nrio2x.h" 27 27 28 29 28 30 /* ------------------------------ */ 29 31 /* --- display_matrix_endline --- */ 30 32 /* ------------------------------ */ 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) \ 36 void 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 54 display_type_matrix_endline(int8_t); 55 display_type_matrix_endline(uint8_t); 56 display_type_matrix_endline(int16_t); 57 display_type_matrix_endline(uint16_t); 58 display_type_matrix_endline(int32_t); 59 display_type_matrix_endline(uint32_t); 60 display_type_matrix_endline(int64_t); 61 display_type_matrix_endline(uint64_t); 62 63 157 64 /* ------------------------------- */ 158 65 /* --- display_matrix_endline0 --- */ 159 66 /* ------------------------------- */ 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) \ 70 void 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 86 display_type_matrix_endline0(int8_t); 87 display_type_matrix_endline0(uint8_t); 88 display_type_matrix_endline0(int16_t); 89 display_type_matrix_endline0(uint16_t); 90 display_type_matrix_endline0(int32_t); 91 display_type_matrix_endline0(uint32_t); 92 display_type_matrix_endline0(int64_t); 93 display_type_matrix_endline0(uint64_t); 94 95 389 96 /* ------------------------------- */ 390 97 /* --- display_matrix_endline1 --- */ 391 98 /* ------------------------------- */ 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) \ 102 void 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 118 display_type_matrix_endline1(int8_t); 119 display_type_matrix_endline1(uint8_t); 120 display_type_matrix_endline1(int16_t); 121 display_type_matrix_endline1(uint16_t); 122 display_type_matrix_endline1(int32_t); 123 display_type_matrix_endline1(uint32_t); 124 display_type_matrix_endline1(int64_t); 125 display_type_matrix_endline1(uint64_t); 126 127 512 128 /* -------------------------------------- */ 513 129 /* --- display_matrix_number_endline0 --- */ 514 130 /* -------------------------------------- */ 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) \ 134 void 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 151 display_type_matrix_number_endline0(int8_t); 152 display_type_matrix_number_endline0(uint8_t); 153 display_type_matrix_number_endline0(int16_t); 154 display_type_matrix_number_endline0(uint16_t); 155 display_type_matrix_number_endline0(int32_t); 156 display_type_matrix_number_endline0(uint32_t); 157 display_type_matrix_number_endline0(int64_t); 158 display_type_matrix_number_endline0(uint64_t); 159 160 642 161 /* -------------------------------------- */ 643 162 /* --- display_matrix_number_endline1 --- */ 644 163 /* -------------------------------------- */ 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) \ 167 void 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 184 display_type_matrix_number_endline1(int8_t); 185 display_type_matrix_number_endline1(uint8_t); 186 display_type_matrix_number_endline1(int16_t); 187 display_type_matrix_number_endline1(uint16_t); 188 display_type_matrix_number_endline1(int32_t); 189 display_type_matrix_number_endline1(uint32_t); 190 display_type_matrix_number_endline1(int64_t); 191 display_type_matrix_number_endline1(uint64_t); 192 193 772 194 /* ------------------------- */ 773 195 /* --- display_trimatrix --- */ 774 196 /* ------------------------- */ 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) \ 200 void 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 216 display_type_trimatrix(int8_t); 217 display_type_trimatrix(uint8_t); 218 display_type_trimatrix(int16_t); 219 display_type_trimatrix(uint16_t); 220 display_type_trimatrix(int32_t); 221 display_type_trimatrix(uint32_t); 222 display_type_trimatrix(int64_t); 223 display_type_trimatrix(uint64_t); 224 display_type_trimatrix(float); 225 display_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 25 25 #include "nrio2x.h" 26 26 27 /* ------------------------------ */28 /* --- display_matrix_endline --- */29 /* ------------------------------ */30 27 /* ----------------------- */ 31 28 /* --- write_trimatrix --- */ 32 29 /* ----------------------- */ 33 30 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) \ 33 void 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 50 write_type_trimatrix(int8_t); 51 write_type_trimatrix(uint8_t); 52 write_type_trimatrix(int16_t); 53 write_type_trimatrix(uint16_t); 54 write_type_trimatrix(int32_t); 55 write_type_trimatrix(uint32_t); 56 write_type_trimatrix(int64_t); 57 write_type_trimatrix(uint64_t); 58 write_type_trimatrix(float); 59 write_type_trimatrix(double); 60 61 203 62 /* ---------------------------- */ 204 63 /* --- write_matrix_endline --- */ 205 64 /* ---------------------------- */ 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) \ 68 void 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 85 write_type_matrix_endline(int8_t); 86 write_type_matrix_endline(uint8_t); 87 write_type_matrix_endline(int16_t); 88 write_type_matrix_endline(uint16_t); 89 write_type_matrix_endline(int32_t); 90 write_type_matrix_endline(uint32_t); 91 write_type_matrix_endline(int64_t); 92 write_type_matrix_endline(uint64_t); 93 write_type_matrix_endline(float); 94 write_type_matrix_endline(double); 95 96 367 97 /* ------------------------------ */ 368 98 /* --- write_imatrix_endline0 --- */ 369 99 /* ------------------------------ */ 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) \ 103 void 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 120 write_type_matrix_endline0(int8_t); 121 write_type_matrix_endline0(uint8_t); 122 write_type_matrix_endline0(int16_t); 123 write_type_matrix_endline0(uint16_t); 124 write_type_matrix_endline0(int32_t); 125 write_type_matrix_endline0(uint32_t); 126 write_type_matrix_endline0(int64_t); 127 write_type_matrix_endline0(uint64_t); 128 write_type_matrix_endline0(float); 129 write_type_matrix_endline0(double); 130 131 132 525 133 /* ------------------------------ */ 526 134 /* --- write_imatrix_endline1 --- */ 527 135 /* ------------------------------ */ 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) \ 139 void 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 156 write_type_matrix_endline1(int8_t); 157 write_type_matrix_endline1(uint8_t); 158 write_type_matrix_endline1(int16_t); 159 write_type_matrix_endline1(uint16_t); 160 write_type_matrix_endline1(int32_t); 161 write_type_matrix_endline1(uint32_t); 162 write_type_matrix_endline1(int64_t); 163 write_type_matrix_endline1(uint64_t); 164 write_type_matrix_endline1(float); 165 write_type_matrix_endline1(double); 166 167 683 168 /* ------------------------------------- */ 684 169 /* --- write_imatrix_number_endline0 --- */ 685 170 /* ------------------------------------- */ 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) \ 174 void 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 192 write_type_matrix_number_endline0(int8_t); 193 write_type_matrix_number_endline0(uint8_t); 194 write_type_matrix_number_endline0(int16_t); 195 write_type_matrix_number_endline0(uint16_t); 196 write_type_matrix_number_endline0(int32_t); 197 write_type_matrix_number_endline0(uint32_t); 198 write_type_matrix_number_endline0(int64_t); 199 write_type_matrix_number_endline0(uint64_t); 200 write_type_matrix_number_endline0(float); 201 write_type_matrix_number_endline0(double); 202 203 848 204 /* ------------------------------------- */ 849 205 /* --- write_imatrix_number_endline1 --- */ 850 206 /* ------------------------------------- */ 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) \ 210 void 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 228 write_type_matrix_number_endline1(int8_t); 229 write_type_matrix_number_endline1(uint8_t); 230 write_type_matrix_number_endline1(int16_t); 231 write_type_matrix_number_endline1(uint16_t); 232 write_type_matrix_number_endline1(int32_t); 233 write_type_matrix_number_endline1(uint32_t); 234 write_type_matrix_number_endline1(int64_t); 235 write_type_matrix_number_endline1(uint64_t); 236 write_type_matrix_number_endline1(float); 237 write_type_matrix_number_endline1(double); 238 239 1013 240 /* ---------------------- */ 1014 241 /* -- fwrite_trimatrix -- */ 1015 242 /* ---------------------- */ 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) \ 246 void 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 260 fwrite_type_trimatrix(int8_t); 261 fwrite_type_trimatrix(uint8_t); 262 fwrite_type_trimatrix(int16_t); 263 fwrite_type_trimatrix(uint16_t); 264 fwrite_type_trimatrix(int32_t); 265 fwrite_type_trimatrix(uint32_t); 266 fwrite_type_trimatrix(int64_t); 267 fwrite_type_trimatrix(uint64_t); 268 fwrite_type_trimatrix(float); 269 fwrite_type_trimatrix(double); 270 271 272 1111 273 1112 274 /* --------------------- */ 1113 275 /* -- fread_trimatrix -- */ 1114 276 /* --------------------- */ 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) \ 280 void 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 294 fread_type_trimatrix(int8_t); 295 fread_type_trimatrix(uint8_t); 296 fread_type_trimatrix(int16_t); 297 fread_type_trimatrix(uint16_t); 298 fread_type_trimatrix(int32_t); 299 fread_type_trimatrix(uint32_t); 300 fread_type_trimatrix(int64_t); 301 fread_type_trimatrix(uint64_t); 302 fread_type_trimatrix(float); 303 fread_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 30 30 /* --- display_cube --- */ 31 31 /* -------------------- */ 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;37 32 38 if(name != NULL) puts(name); 33 #undef display_type_cube 34 #define display_type_cube(t) \ 35 void 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 } 39 50 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; 51 display_type_cube(int8_t); 52 display_type_cube(uint8_t); 53 display_type_cube(int16_t); 54 display_type_cube(uint16_t); 55 display_type_cube(int32_t); 56 display_type_cube(uint32_t); 57 display_type_cube(int64_t); 58 display_type_cube(uint64_t); 59 display_type_cube(float); 60 display_type_cube(double); 55 61 56 if(name != NULL) puts(name);57 62 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 }158 63 159 64 /* ---------------- */ 160 65 /* -- write_cube -- */ 161 66 /* ---------------- */ 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;167 67 168 FILE *f; 68 #undef write_type_cube 69 #define write_type_cube(t) \ 70 void 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 } 169 87 170 f = fopen(filename, "wt"); 171 if(f == NULL) { 172 nrerror("Can't open file in write_i8cube"); 173 } 88 write_type_cube(int8_t); 89 write_type_cube(uint8_t); 90 write_type_cube(int16_t); 91 write_type_cube(uint16_t); 92 write_type_cube(int32_t); 93 write_type_cube(uint32_t); 94 write_type_cube(int64_t); 95 write_type_cube(uint64_t); 96 write_type_cube(float); 97 write_type_cube(double); 174 98 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 }184 99 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 }337 100 338 101 /* ---------------- */ 339 102 /* -- fread_cube -- */ 340 103 /* ---------------- */ 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;348 104 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) \ 107 void 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 125 fread_type_cube(int8_t); 126 fread_type_cube(uint8_t); 127 fread_type_cube(int16_t); 128 fread_type_cube(uint16_t); 129 fread_type_cube(int32_t); 130 fread_type_cube(uint32_t); 131 fread_type_cube(int64_t); 132 fread_type_cube(uint64_t); 133 fread_type_cube(float); 134 fread_type_cube(double); 352 135 353 136 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");393 137 394 138 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");414 139 415 140 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: 427 147 428 #ifndef __NRIO3_H__ 429 #define __NRIO3_H__ 148 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 430 149 431 #ifdef __cplusplus432 #pragma message ("C++")433 extern "C" {434 #endif435 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 __cplusplus456 }457 #endif458 459 #endif /* __NRIO3_H__ */ -
soft/giet_vm/applications/rosenfeld/nrc2/src/nrlinalg.c
r772 r823 24 24 #include "nrlinalg.h" 25 25 26 #undef transpose_type_matrix 27 #define transpose_type_matrix(t) \ 28 void 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 } 26 36 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 } 37 transpose_type_matrix(int8_t); 38 transpose_type_matrix(uint8_t); 39 transpose_type_matrix(int16_t); 40 transpose_type_matrix(uint16_t); 41 transpose_type_matrix(int32_t); 42 transpose_type_matrix(uint32_t); 43 transpose_type_matrix(int64_t); 44 transpose_type_matrix(uint64_t); 45 transpose_type_matrix(float); 46 transpose_type_matrix(double); 47 transpose_type_matrix(rgb8); 48 transpose_type_matrix(rgbx8); 49 50 51 #undef transpose1_type_matrix 52 #define transpose1_type_matrix(t) \ 53 void 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 } \ 38 63 } 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 65 transpose1_type_matrix(int8_t); 66 transpose1_type_matrix(uint8_t); 67 transpose1_type_matrix(int16_t); 68 transpose1_type_matrix(uint16_t); 69 transpose1_type_matrix(int32_t); 70 transpose1_type_matrix(uint32_t); 71 transpose1_type_matrix(int64_t); 72 transpose1_type_matrix(uint64_t); 73 transpose1_type_matrix(float); 74 transpose1_type_matrix(double); 75 transpose1_type_matrix(rgb8); 76 transpose1_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 13 13 14 14 /* 15 * 2002/06/11 ajout des fonctions endline16 */15 * 2002/06/11 ajout des fonctions endline 16 */ 17 17 #include <stdio.h> 18 18 #include <stddef.h> … … 28 28 #include "nrlut.h" 29 29 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) \ 33 void 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 60 init_type_lut(int8_t); 61 init_type_lut(uint8_t); 62 init_type_lut(int16_t); 63 init_type_lut(uint16_t); 64 init_type_lut(int32_t); 65 init_type_lut(uint32_t); 66 67 68 69 void 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) \ 111 void 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 120 lut_type_matrix(int8_t); 121 lut_type_matrix(uint8_t); 122 lut_type_matrix(int16_t); 123 lut_type_matrix(uint16_t); 124 lut_type_matrix(int32_t); 125 lut_type_matrix(uint32_t); 126 127 128 129 void 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 141 void 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 150 void 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 159 void 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 168 void 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) \ 180 void 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 191 histogram_type_matrix(int8_t); 192 histogram_type_matrix(uint8_t); 193 histogram_type_matrix(int16_t); 194 histogram_type_matrix(uint16_t); 195 histogram_type_matrix(int32_t); 196 histogram_type_matrix(uint32_t); 197 198 199 200 void 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; 306 204 (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 30 30 * ----------- 31 31 */ 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) \ 36 void 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 43 dup_type_vector(int8_t); 44 dup_type_vector(uint8_t); 45 dup_type_vector(int16_t); 46 dup_type_vector(uint16_t); 47 dup_type_vector(int32_t); 48 dup_type_vector(uint32_t); 49 dup_type_vector(int64_t); 50 dup_type_vector(uint64_t); 51 dup_type_vector(float); 52 dup_type_vector(double); 53 dup_type_vector(rgb8); 54 dup_type_vector(rgbx8); 55 56 140 57 /* 141 58 * -------------------- … … 143 60 * -------------------- 144 61 */ 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 64 void 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 73 void 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 82 void 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 92 void 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) \ 107 void 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 114 convert_type1_vector_type2_vector(int8_t,int16_t); 115 convert_type1_vector_type2_vector(int8_t,int32_t); 116 convert_type1_vector_type2_vector(int8_t,float); 117 convert_type1_vector_type2_vector(int8_t,double); 118 convert_type1_vector_type2_vector(uint8_t,uint16_t); 119 convert_type1_vector_type2_vector(uint8_t,uint32_t); 120 convert_type1_vector_type2_vector(uint8_t,float); 121 convert_type1_vector_type2_vector(uint8_t,double); 122 convert_type1_vector_type2_vector(int16_t,int32_t); 123 convert_type1_vector_type2_vector(int16_t,float); 124 convert_type1_vector_type2_vector(int16_t,double); 125 convert_type1_vector_type2_vector(uint16_t,uint32_t); 126 convert_type1_vector_type2_vector(uint16_t,float); 127 convert_type1_vector_type2_vector(uint16_t,double); 128 convert_type1_vector_type2_vector(int32_t,float); 129 convert_type1_vector_type2_vector(int32_t,double); 130 convert_type1_vector_type2_vector(uint32_t,float); 131 convert_type1_vector_type2_vector(uint32_t,double); 132 convert_type1_vector_type2_vector(int16_t,int8_t); 133 convert_type1_vector_type2_vector(uint16_t,uint8_t); 134 convert_type1_vector_type2_vector(int32_t,int8_t); 135 convert_type1_vector_type2_vector(int32_t,int16_t); 136 convert_type1_vector_type2_vector(uint32_t,uint8_t); 137 convert_type1_vector_type2_vector(uint32_t,uint16_t); 138 convert_type1_vector_type2_vector(float,int8_t); 139 convert_type1_vector_type2_vector(float,uint8_t); 140 convert_type1_vector_type2_vector(float,int16_t); 141 convert_type1_vector_type2_vector(float,uint16_t); 142 convert_type1_vector_type2_vector(float,int32_t); 143 convert_type1_vector_type2_vector(float,uint32_t); 144 convert_type1_vector_type2_vector(double,int8_t); 145 convert_type1_vector_type2_vector(double,uint8_t); 146 convert_type1_vector_type2_vector(double,int16_t); 147 convert_type1_vector_type2_vector(double,uint16_t); 148 convert_type1_vector_type2_vector(double,int32_t); 149 convert_type1_vector_type2_vector(double,uint32_t); 150 convert_type1_vector_type2_vector(double,float); 151 152 153 154 155 156 157 158 void convert_ui8vector_rgb8vector(uint8_t * X, int32_t nl, int32_t nh, rgb8 * Y) 159 { 160 for (int32_t i = nl; i <= nh; i++) { 266 161 Y[i].r = X[i]; 267 162 Y[i].g = X[i]; … … 269 164 } 270 165 } 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 167 void convert_ui8vector_rgbx8vector(uint8_t * X, int32_t nl, int32_t nh, rgbx8 * Y) 168 { 169 for (int32_t i = nl; i <= nh; i++) { 277 170 Y[i].r = X[i]; 278 171 Y[i].g = X[i]; … … 281 174 } 282 175 } 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 178 void convert_rgb8vector_ui8vector(rgb8 * X, int32_t nl, int32_t nh, uint8_t * Y) 179 { 180 for (int32_t i = nl; i <= nh; i++) { 523 181 Y[i] = (X[i].r + X[i].g + X[i].b) / 3; 524 182 } 525 183 } 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 185 void convert_rgbx8vector_ui8vector(rgbx8 * X, int32_t nl, int32_t nh, uint8_t * Y) 186 { 187 for (int32_t i = nl; i <= nh; i++) { 532 188 Y[i] = (X[i].r + X[i].g + X[i].b) / 3; 533 189 } 534 190 } 191 535 192 /* 536 193 * --------------- … … 538 195 * --------------- 539 196 */ 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 198 void 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 205 void 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 -
soft/giet_vm/applications/rosenfeld/scripts/create_graph.py
r822 r823 16 16 import filecmp 17 17 import random 18 import math 18 19 19 20 from stack import Stack … … 23 24 24 25 use_rand_images = True 25 with_features = True26 with_features = False 26 27 27 threads = [1, 2, 4] 28 nb_step = 0 28 threads = [1, 2, 4, 8, 16, 32, 64] 29 29 use_dsk = True 30 img_size = 102430 img_size = 2048 31 31 granularity = 1 32 32 rand_seed = 7 … … 42 42 # Each of these configuration must have been run with both features activated and deactivated 43 43 configs = [ 44 {'SLOW':'1', 'FAST':'0', 'PARMERGE':'0', 'ARSP':'0'},45 {'SLOW':'0', 'FAST':'1', 'PARMERGE':'0', 'ARSP':'0'},46 44 #{'SLOW':'1', 'FAST':'0', 'PARMERGE':'0', 'ARSP':'0'}, 47 45 #{'SLOW':'0', 'FAST':'1', 'PARMERGE':'0', 'ARSP':'0'}, 48 46 #{'SLOW':'0', 'FAST':'1', 'PARMERGE':'1', 'ARSP':'0'}, 49 #{'SLOW':'0', 'FAST':'1', 'PARMERGE':'1', 'ARSP':'1'},47 {'SLOW':'0', 'FAST':'1', 'PARMERGE':'1', 'ARSP':'1'}, 50 48 ] 51 49 … … 55 53 code = compile(f.read(), pyconf_file, 'exec') 56 54 exec(code) 55 56 nb_step = 0 57 57 58 58 if use_dsk: … … 125 125 plotter.add_x(X) 126 126 assert(nb_step == 4) 127 YPAR1 = [float( exec_time[fconfig][thread]["NF"][density][0]) for density in range(0, 101)] # Parallel Labeling128 YPAR2 = [float( exec_time[fconfig][thread]["NF"][density][1]) for density in range(0, 101)] # Merging (Parallel or Pyramidal)129 YPTC2 = [float( exec_time[fconfig][thread]["NF"][density][2]) for density in range(0, 101)] # Parallel Transitive Closure130 YPAR3 = [float( exec_time[fconfig][thread]["NF"][density][3]) for density in range(0, 101)] # Parallel Relabeling127 YPAR1 = [float(int(exec_time[fconfig][thread]["NF"][density][0]) / math.pow(img_size, 2)) for density in range(0, 101)] # Parallel Labeling 128 YPAR2 = [float(int(exec_time[fconfig][thread]["NF"][density][1]) / math.pow(img_size, 2)) for density in range(0, 101)] # Merging (Parallel or Pyramidal) 129 YPTC2 = [float(int(exec_time[fconfig][thread]["NF"][density][2]) / math.pow(img_size, 2)) for density in range(0, 101)] # Parallel Transitive Closure 130 YPAR3 = [float(int(exec_time[fconfig][thread]["NF"][density][3]) / math.pow(img_size, 2)) for density in range(0, 101)] # Parallel Relabeling 131 131 132 132 plotter.add_y(YPAR1) … … 136 136 137 137 if with_features: 138 YPAR1f = [float( exec_time[fconfig][thread]["FT"][density][0]) for density in range(0, 101)] # Parallel Labeling139 YPAR2f = [float( exec_time[fconfig][thread]["FT"][density][1]) for density in range(0, 101)] # Merging (Parallel or Pyramidal)138 YPAR1f = [float(int(exec_time[fconfig][thread]["FT"][density][0]) / math.pow(img_size, 2)) for density in range(0, 101)] # Parallel Labeling 139 YPAR2f = [float(int(exec_time[fconfig][thread]["FT"][density][1]) / math.pow(img_size, 2)) for density in range(0, 101)] # Merging (Parallel or Pyramidal) 140 140 deltaYPAR1 = [max(0, x - y) for x, y in zip (YPAR1f, YPAR1)] 141 141 deltaYPAR2 = [max(0, x - y) for x, y in zip (YPAR2f, YPAR2)] -
soft/giet_vm/applications/rosenfeld/scripts/run_simus.py
r822 r823 5 5 # python 2 as it will execute on computation servers 6 6 7 # TODO: 8 # Can we do something about assert in perf eval? 7 9 8 10 from __future__ import print_function … … 37 39 38 40 # Parameters 39 num_runs = 10 41 # - with eval_perf, num_internal_runs should be used, as this allows to mitigate the cost of the extra 42 # run required to have the correct "ne" value (number of labels), and only the times from last application run are taken 43 # - With check_results, num_app_runs should be used, so as to have a number of checks equals to the number of runs, 44 # because only one check per application run is performed 45 num_app_runs = 1 # Number of times the application is launched per configuration 46 num_internal_runs = 20 # Number of times the image is processed inside the application 40 47 check_results = False 41 48 eval_perf = True 42 49 use_valgrind = False 43 50 use_rand_images = True 44 threads = [1, 2, 4] 51 threads = [1, 2, 4, 8, 16, 32, 64] 52 #threads = [1, 2] 45 53 use_dsk = True 46 54 # Using dsk will store generated random images, otherwise they are re-generated at each run to save disk space … … 48 56 # Configurations 49 57 configs = [ 50 {'SLOW':'1', 'FAST':'0', 'FEATURES':'0', 'PARMERGE':'0', 'ARSP':'0'}, 51 {'SLOW':'0', 'FAST':'1', 'FEATURES':'0', 'PARMERGE':'0', 'ARSP':'0'}, 52 {'SLOW':'1', 'FAST':'0', 'FEATURES':'1', 'PARMERGE':'0', 'ARSP':'0'}, 53 {'SLOW':'0', 'FAST':'1', 'FEATURES':'1', 'PARMERGE':'0', 'ARSP':'0'}, 58 #{'SLOW':'1', 'FAST':'0', 'FEATURES':'0', 'PARMERGE':'0', 'ARSP':'0'}, 59 #{'SLOW':'0', 'FAST':'1', 'FEATURES':'0', 'PARMERGE':'0', 'ARSP':'0'}, 60 #{'SLOW':'1', 'FAST':'0', 'FEATURES':'1', 'PARMERGE':'0', 'ARSP':'0'}, 61 #{'SLOW':'0', 'FAST':'1', 'FEATURES':'1', 'PARMERGE':'0', 'ARSP':'0'}, 62 {'SLOW':'0', 'FAST':'1', 'FEATURES':'0', 'PARMERGE':'1', 'ARSP':'0'}, 54 63 #{'SLOW':'0', 'FAST':'1', 'FEATURES':'1', 'PARMERGE':'1', 'ARSP':'0'}, 55 64 #{'SLOW':'0', 'FAST':'1', 'FEATURES':'0', 'PARMERGE':'1', 'ARSP':'1'}, … … 60 69 rand_seed = 7 61 70 granularity = 1 # constant for now 62 img_size = 102471 img_size = 2048 63 72 64 73 check_pyconf_file(pyconf_file) … … 93 102 94 103 104 if check_results and eval_perf: 105 print("*** Warning: check_results and eval_perf modes are both set\n") 106 if eval_perf and use_valgrind: 107 print("*** Warning: using valgrind while eval_perf mode is set\n") 108 if eval_perf and num_app_runs != 1: 109 print("*** Warning: using eval_perf with num_app_runs != 1\n") 110 if check_results and num_internal_runs != 1: 111 print("*** Warning: using check_results with num_internal_runs != 1\n") 112 113 95 114 96 115 def gen_random_image(filename, x, y, granularity, density, seed): … … 136 155 break 137 156 if not line_with_key: 138 f.write(line) 157 if "#define MCA_VERBOSE_LEVEL" in line: 158 if eval_perf: 159 verb_level = 1 160 else: 161 verb_level = 2 162 f.write("#define MCA_VERBOSE_LEVEL %d\n" % verb_level) 163 else: 164 f.write(line) 139 165 140 166 f.close() … … 179 205 my_chdir(top_path) 180 206 cmd = ['make'] 207 #if eval_perf: 208 # cmd.extend(['IGNORE_ASSERT=true']) 181 209 print_and_call(cmd) 182 210 my_chdir(scripts_path) … … 205 233 for nthreads in threads: 206 234 perf_array[fconfig][img_basename][nthreads] = {} 207 for run in range(num_ runs):235 for run in range(num_app_runs): 208 236 if not os.path.exists(ref_bmpfile): 209 237 bmpfile = ref_bmpfile … … 223 251 224 252 cmd.extend([short_path(binary_file), '-n', str(nthreads), '-i', short_path(image)]) 253 254 if num_internal_runs > 1: 255 cmd.extend(['-r', str(num_internal_runs)]) 225 256 226 257 if check_results: … … 236 267 237 268 # if performance evaluation, get timing measurements 269 # Only the last application run is considered 238 270 if eval_perf: 239 271 for line in outlines: … … 247 279 step = match.group(1) 248 280 value = tokens[len(tokens) - 1] 249 if step in perf_array[fconfig][img_basename][nthreads]: 250 # Accumulating times over the num_runs runs 251 perf_array[fconfig][img_basename][nthreads][step] += int(value) 252 else: 253 perf_array[fconfig][img_basename][nthreads][step] = int(value) 281 perf_array[fconfig][img_basename][nthreads][step] = int(value) 254 282 255 283 … … 315 343 for step in sorted(perf_array[fconfig][img_basename][nthreads].keys()): 316 344 # Average time for each step 317 file.write("[STEP_%s] %d\n" % (step, perf_array[fconfig][img_basename][nthreads][step] / num_runs))345 file.write("[STEP_%s] %d\n" % (step, perf_array[fconfig][img_basename][nthreads][step])) 318 346 319 347 img_idx += 1 -
soft/giet_vm/applications/rosenfeld/src-par/mca.c
r822 r823 98 98 99 99 100 // ----------------------------------------------- 100 // ------------------------------------------------ 101 101 void MCA_Set_Size(MCA * mca, int width, int height) 102 // ----------------------------------------------- 102 // ------------------------------------------------ 103 103 { 104 104 MCA_Set_Width(mca, width); … … 107 107 108 108 109 // ---------------------------------------------------- 109 // ----------------------------------------------------- 110 110 void MCA_Set_Dimension(MCA * mca, int width, int height) 111 // ---------------------------------------------------- 111 // ----------------------------------------------------- 112 112 { 113 113 MCA_Set_Width(mca, width); … … 116 116 117 117 118 // ------------------------------ 118 // ------------------------------- 119 119 void MCA_Set_NP(MCA * mca, int np) 120 // ------------------------------ 120 // ------------------------------- 121 121 { 122 122 mca->np = np; 123 123 } 124 125 126 // ------------------------------- 127 void MCA_Set_NR(MCA * mca, int nr) 128 // ------------------------------- 129 { 130 mca->nr = nr; 131 } 132 124 133 125 134 … … 146 155 // input 147 156 int np = mca->np; 157 int nr = mca->nr; 148 158 int width = mca->width; 149 159 int height = mca->height; … … 292 302 mca_par->e0 = e0_par; 293 303 mca_par->e1 = e1_par; 304 // à la premiÚre itération, on remet à 0 toute la table T 305 mca_par->ne_prev = e1_par; 294 306 mca_par->alpha = pw2; 295 307 mca_par->np = np; 308 mca_par->nr = nr; 296 309 // Pour les barriÚres pyramidales 297 310 mca_par->nb_level = nb_level; … … 311 324 mca_par->E = remote_dist_ui32matrix(i0_par, i1_par, 0, width - 1, x, y); // distributed matrix with border 312 325 313 if (p == 0) { 314 mca_par->T = remote_ui32vector(e0_par - 1, e1_par, x, y); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot 315 mca_par->stats = remote_RegionStatsVector(e0_par - 1, e1_par, x, y); 316 } 317 else { 318 mca_par->T = remote_ui32vector(e0_par, e1_par, x, y); 319 mca_par->stats = remote_RegionStatsVector(e0_par, e1_par, x, y); 320 } 326 mca_par->T = remote_ui32vector(e0_par, e1_par, x, y); 327 mca_par->stats = remote_RegionStatsVector(e0_par, e1_par, x, y); 321 328 322 329 mca_par->D = (uint32 **) remote_vvector(0, np - 1, x, y); … … 326 333 mca_par->E = dist_ui32matrix(i0_par, i1_par, 0, width - 1); // distributed matrix with border 327 334 328 if (p == 0) { 329 mca_par->T = ui32vector(e0_par - 1, e1_par); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot 330 mca_par->stats = RegionStatsVector(e0_par - 1, e1_par); 331 } 332 else { 333 mca_par->T = ui32vector(e0_par, e1_par); 334 mca_par->stats = RegionStatsVector(e0_par, e1_par); 335 } 335 mca_par->T = ui32vector(e0_par, e1_par); 336 mca_par->stats = RegionStatsVector(e0_par, e1_par); 336 337 337 338 mca_par->D = (uint32 **) vvector(0, np - 1); … … 353 354 354 355 MCA_VERBOSE3(printf("p = %d T[%d..%d]\n", p, e0, e1)); 355 if (p == 0) { 356 set_ui32vector_j(T, e0 - 1, e1); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot 357 } 358 else { 359 set_ui32vector_j(T, e0, e1); 360 } 361 MCA_VERBOSE3(printf("\n")); 356 set_ui32vector_j(T, e0, e1); 362 357 } 363 358 … … 371 366 372 367 MCA_VERBOSE3(printf("p = %d T[%d..%d]\n", p, e0, e1)); 373 if (p == 0) { 374 MCA_VERBOSE3(display_ui32vector_number(T, e0 - 1, e0 + 10, "%5d", "T")); 375 } 376 else { 377 MCA_VERBOSE3(display_ui32vector_number(T, e0, e0 + 10, "%5d", "T")); 378 } 368 MCA_VERBOSE3(display_ui32vector_number(T, e0, e0 + 10, "%5d", "T")); 379 369 MCA_VERBOSE3(printf("\n")); 380 370 } … … 506 496 free_dist_ui32matrix(mca_par->E, i0, i1, j0, j1); 507 497 508 if (p == 0) { 509 free_ui32vector(mca_par->T, e0 - 1, e1); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot 510 free_RegionStatsVector(mca_par->stats, e0 - 1, e1); 511 } 512 else { 513 free_ui32vector(mca_par->T, e0, e1); 514 free_RegionStatsVector(mca_par->stats, e0, e1); 515 } 498 free_ui32vector(mca_par->T, e0, e1); 499 free_RegionStatsVector(mca_par->stats, e0, e1); 516 500 517 501 free_vvector((void **) mca_par->D, 0, np - 1); -
soft/giet_vm/applications/rosenfeld/src-par/mca_main.c
r822 r823 43 43 #define MAX_THREADS 256 44 44 #define DEFAULT_NTHREADS 1 45 #define DEFAULT_NRUNS 1 45 46 #define DEFAULT_IN_FILENAME "/misc/cadastre.pgm" 46 47 #define DEFAULT_OUT_FILENAME "out.bmp" … … 233 234 234 235 235 // ----------------------------------------------------------- 236 void mca_test2(int num_threads, char * infile, char * outfile)237 // ----------------------------------------------------------- 236 // ------------------------------------------------------------------------- 237 void mca_test2(int num_threads, int num_runs, char * infile, char * outfile) 238 // ------------------------------------------------------------------------- 238 239 { 239 240 int i0, i1, j0, j1; … … 277 278 MCA_Set_ImageL(mca, E); 278 279 MCA_Set_NP(mca, num_threads); 280 MCA_Set_NR(mca, num_runs); 279 281 280 282 // -- MCA init … … 316 318 317 319 318 // -------------------------------------------------------------- 319 int main_test_mca(int num_threads, char * infile, char * outfile)320 // -------------------------------------------------------------- 320 // ---------------------------------------------------------------------------- 321 int main_test_mca(int num_threads, int num_runs, char * infile, char * outfile) 322 // ---------------------------------------------------------------------------- 321 323 { 322 324 CLOCK_INIT(num_threads, 4); // 4 = Number of steps in body 323 325 CLOCK_APP_START; 324 326 325 mca_test2(num_threads, infile, outfile);327 mca_test2(num_threads, num_runs, infile, outfile); 326 328 327 329 CLOCK_APP_END; … … 349 351 int ch; 350 352 int num_threads = DEFAULT_NTHREADS; 353 int num_runs = DEFAULT_NRUNS; 351 354 352 355 MCA_VERBOSE1(printf("*** Starting application Rosenfeld ***\n")); 353 356 354 357 #if TARGET_OS != GIETVM // @QM I think the giet has some random (uninitialized) values for argc and argv 355 while ((ch = getopt(argc, argv, "i:o:n: hdg")) != EOF) {358 while ((ch = getopt(argc, argv, "i:o:n:r:hdg")) != EOF) { 356 359 switch (ch) { 357 360 case 'i': … … 363 366 case 'n': 364 367 num_threads = atoi(optarg); 368 break; 369 case 'r': 370 num_runs = atoi(optarg); 365 371 break; 366 372 case 'h': … … 409 415 MCA_VERBOSE1(printf("Parameters:\n")); 410 416 MCA_VERBOSE1(printf("- Number of threads: %d\n", num_threads)); 417 MCA_VERBOSE1(printf("- Number of images processed: %d\n", num_runs)); 411 418 MCA_VERBOSE1(printf("- Input file: %s\n", infile)); 412 419 MCA_VERBOSE1(printf("- Output file: %s\n", outfile)); … … 450 457 451 458 pthread_mutex_init(&print_lock, PTHREAD_PROCESS_PRIVATE); 452 main_test_mca(num_threads, infile, outfile);459 main_test_mca(num_threads, num_runs, infile, outfile); 453 460 454 461 return 0; -
soft/giet_vm/applications/rosenfeld/src-par/mca_rosenfeld.c
r822 r823 142 142 } 143 143 #endif // FEATURES && !PARMERGE 144 145 146 #if !FEATURES && PARMERGE 147 // ----------------------------------------------------------------------------------------------------------- 148 static bool SetRoot_Parallel_Rosenfeld_Dist(uint32 ** D, uint32 root, uint32 eps, int shift, RegionStats ** F) 149 // ----------------------------------------------------------------------------------------------------------- 150 { 151 assert(root != 0 && eps != 0); 152 153 MCA_VERBOSE3(printf("F(%d) += F(%d)\n", eps, root)); 154 155 int mask = (1 << shift) - 1; 156 157 uint32 r1 = root >> shift; 158 uint32 r0 = root & mask; 159 160 uint32 e1 = eps >> shift; 161 uint32 e0 = eps & mask; 162 163 // Locking towards the root (first root, then eps) 164 pthread_spin_lock(&F[r1][r0].lock); 165 pthread_spin_lock(&F[e1][e0].lock); 166 if (D[e1][e0] != eps || D[r1][r0] != root) { 167 // Someone change the root of epsilon or "root", need to find the new root 168 pthread_spin_unlock(&F[e1][e0].lock); 169 pthread_spin_unlock(&F[r1][r0].lock); 170 return false; 171 } 172 173 D[r1][r0] = eps; 174 175 pthread_spin_unlock(&F[e1][e0].lock); 176 pthread_spin_unlock(&F[r1][r0].lock); 177 return true; 178 } 179 #endif // !FEATURES && PARMERGE 144 180 145 181 … … 585 621 586 622 587 #if FAST && FEATURES && PARMERGE && !ARSP623 #if FAST && PARMERGE && !ARSP // Valid for FEATURES and !FEATURES 588 624 // --------------------------------------------------------------------------------------------------------------------------- 589 static void vuse2_Parallel_ Features_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha, RegionStats ** F)625 static void vuse2_Parallel_Rosenfeld_Dist(uint32 ed, uint32 el, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 590 626 // --------------------------------------------------------------------------------------------------------------------------- 591 627 { … … 610 646 // qui a fait un test 611 647 if (rd < rl) { 612 ok = SetRoot_Parallel_Features_Rosenfeld_Dist(D, rl, rd, alpha, F); 648 // Features or No Features depending on config 649 ok = SetRoot_Parallel_FNF(D, rl, rd, alpha, F); 613 650 } 614 651 else { 615 ok = SetRoot_Parallel_F eatures_Rosenfeld_Dist(D, rd, rl, alpha, F);652 ok = SetRoot_Parallel_FNF(D, rd, rl, alpha, F); 616 653 } 617 654 } while (!ok); 618 655 } 619 656 620 // FAST && FEATURES &&PARMERGE && !ARSP657 // FAST && PARMERGE && !ARSP 621 658 622 659 // ----------------------------------------------------------------------------------------------------------------------------------------- 623 static void vuse3_Parallel_ Features_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha, RegionStats ** F)660 static void vuse3_Parallel_Rosenfeld_Dist(uint32 ed1, uint32 ed2, uint32 el3, uint32 * T, uint32 ** D, int alpha, RegionStats ** F) 624 661 // ----------------------------------------------------------------------------------------------------------------------------------------- 625 662 { … … 649 686 ok3 = true; 650 687 if (r1 > eps) { 651 ok1 = SetRoot_Parallel_F eatures_Rosenfeld_Dist(D, r1, eps, alpha, F);688 ok1 = SetRoot_Parallel_FNF(D, r1, eps, alpha, F); 652 689 } 653 690 if (r2 > eps && r2 != r1) { 654 ok2 = SetRoot_Parallel_F eatures_Rosenfeld_Dist(D, r2, eps, alpha, F);691 ok2 = SetRoot_Parallel_FNF(D, r2, eps, alpha, F); 655 692 } 656 693 if (r3 > eps && r3 != r2 && r3 != r1) { 657 ok3 = SetRoot_Parallel_F eatures_Rosenfeld_Dist(D, r3, eps, alpha, F);694 ok3 = SetRoot_Parallel_FNF(D, r3, eps, alpha, F); 658 695 } 659 696 } while (!(ok1 && ok2 && ok3)); 660 697 } 661 #endif // FAST && FEATURES &&PARMERGE && !ARSP698 #endif // FAST && PARMERGE && !ARSP 662 699 663 700 … … 1381 1418 uint32 e0 = mca->e0; 1382 1419 uint32 e1 = mca->e1; 1420 uint32 ne_prev = mca->ne_prev; 1383 1421 uint32 ne = e0 - 1; 1384 1422 uint32 nr = 0; … … 1390 1428 RegionStats * stats = mca->stats; 1391 1429 1392 // reset sous optimal (pour le moment = voir region32)1393 if (mca->p == 0) { 1394 set_ui32vector_j(T, e0 - 1, e1); // car e0 = 1, on a besoin que T[0] = 0 pour FindRoot1430 CLOCK_THREAD_START_STEP(mca->p, 0); 1431 1432 set_ui32vector_j(T, e0, ne_prev); 1395 1433 #if FEATURES 1396 zero_RegionStatsVector(stats, e0 - 1, e1);1434 zero_RegionStatsVector(stats, e0, ne_prev); 1397 1435 #endif 1398 }1399 else {1400 set_ui32vector_j(T, e0, e1);1401 #if FEATURES1402 zero_RegionStatsVector(stats, e0, e1);1403 #endif1404 }1405 1436 1406 1437 if (mca->p == 0) { … … 1411 1442 // -- Etiquetage d'une bande -- // 1412 1443 // ---------------------------- // 1413 1414 CLOCK_THREAD_START_STEP(mca->p, 0);1415 1444 1416 1445 ne = line0Labeling_Rosenfeld(X, i0, width, E, T, ne); … … 1644 1673 1645 1674 CLOCK_THREAD_START(mca->p); 1646 CLOCK_THREAD_COMPUTE_START(mca->p); 1647 1648 MCA_Scatter_ImageX(mca); 1649 pthread_barrier_wait(&main_barrier); 1650 1651 MCA_Label_Rosenfeld_PAR1(mca); 1652 pthread_barrier_wait(&main_barrier); 1653 1675 1676 int num_runs = mca->nr; 1677 1678 // We always perform one more run than the num_runs 1679 // value, so as to know "ne", i.e. the number of 1680 // elements to reset in the T and F tables (labels and stats) 1681 // After this first extra run, clock times are not accumulated 1682 // and thus are lost. 1683 // Note: the CLOCK_THREAD_START will still include this first run, 1684 // and in case of multiple runs, only averaged times should be 1685 // considered. 1686 for (int run = 0; run < num_runs + 1; run++) { 1687 1688 CLOCK_THREAD_COMPUTE_START(mca->p); 1689 1690 MCA_Scatter_ImageX(mca); 1691 pthread_barrier_wait(&main_barrier); 1692 1693 MCA_Label_Rosenfeld_PAR1(mca); 1694 pthread_barrier_wait(&main_barrier); 1695 1654 1696 #if PARMERGE 1655 MCA_Label_Rosenfeld_PAR2(mca);1697 MCA_Label_Rosenfeld_PAR2(mca); 1656 1698 #else 1657 MCA_Label_Rosenfeld_PYR2(mca);1699 MCA_Label_Rosenfeld_PYR2(mca); 1658 1700 #endif 1659 pthread_barrier_wait(&main_barrier); 1660 1661 MCA_Label_Rosenfeld_PAR3(mca); 1662 pthread_barrier_wait(&main_barrier); 1663 1664 MCA_Gather_ImageL(mca); 1665 pthread_barrier_wait(&main_barrier); 1666 1667 CLOCK_THREAD_COMPUTE_END(mca->p); 1701 pthread_barrier_wait(&main_barrier); 1702 1703 MCA_Label_Rosenfeld_PAR3(mca); 1704 pthread_barrier_wait(&main_barrier); 1705 1706 MCA_Gather_ImageL(mca); 1707 pthread_barrier_wait(&main_barrier); 1708 1709 CLOCK_THREAD_COMPUTE_END(mca->p); 1710 1711 if (run == 0) { 1712 // Mise à jour du ne_prev par chaque thread 1713 mca->ne_prev = mca->ne; 1714 mca->ne = 0; 1715 } 1716 else { 1717 // Accumulation du temps COMPUTE et de toutes les STEP 1718 if (mca->p == 0) { 1719 CLOCK_ACCUMULATE; 1720 } 1721 assert(mca->ne == mca->ne_prev); 1722 // Reinitialisation de "ne" s'il ne s'agit pas du dernier run 1723 if (run != num_runs) { 1724 mca->ne = 0; 1725 } 1726 } 1727 pthread_barrier_wait(&main_barrier); 1728 } 1729 1668 1730 1669 1731 #if FEATURES
Note: See TracChangeset
for help on using the changeset viewer.