source: soft/giet_vm/applications/rosenfeld/nrc2/src/nrio2x.c @ 823

Last change on this file since 823 was 823, checked in by meunier, 8 years ago
  • Improved scripts for simulations and graphes
  • Continued to clean up the lib nrc2 (from nrio2x.x to nrmem1.c)
  • Added a version (Fast - Parmerge - No stats)
File size: 8.9 KB
Line 
1/* ---------------- */
2/* --- nrio2x.c --- */
3/* ---------------- */
4
5/*
6 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved
7 * Univ Paris Sud XI, CNRS
8 */
9
10#include <stdio.h>
11#include <stddef.h>
12#include <stdlib.h>
13
14#include "nrc_os_config.h"
15#include "mypredef.h"
16#include "nrtype.h"
17#include "nrdef.h"
18#include "nrmacro.h"
19#include "nrkernel.h"
20
21#include "nrio0.h"
22#include "nralloc1.h"
23#include "nralloc2.h"
24#include "nrio1.h"
25#include "nrio2.h"
26#include "nrio2x.h"
27
28
29
30/* ------------------------------ */
31/* --- display_matrix_endline --- */
32/* ------------------------------ */
33
34#undef display_type_matrix_endline
35#define display_type_matrix_endline(t) \
36void short_name(t,display_,matrix_endline)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
37{                                                \
38    int32_t n = (i1 - i0 + 1) * (j1 - j0 + 1);   \
39    t * p = &m[i0][j0];                          \
40                                                 \
41    if (name != NULL) {                          \
42        printf(name);                            \
43    }                                            \
44                                                 \
45    for (int32_t i = i0; i <= i1; i++) {         \
46        for (int32_t j = j0; j <= j0 + n; j++) { \
47            printf(format, *p++);                \
48        }                                        \
49        printf("\n");                            \
50    }                                            \
51    printf("\n");                                \
52}
53
54display_type_matrix_endline(int8_t);
55display_type_matrix_endline(uint8_t);
56display_type_matrix_endline(int16_t);
57display_type_matrix_endline(uint16_t);
58display_type_matrix_endline(int32_t);
59display_type_matrix_endline(uint32_t);
60display_type_matrix_endline(int64_t);
61display_type_matrix_endline(uint64_t);
62
63
64/* ------------------------------- */
65/* --- display_matrix_endline0 --- */
66/* ------------------------------- */
67
68#undef display_type_matrix_endline0
69#define display_type_matrix_endline0(t) \
70void short_name(t,display_,matrix_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
71{                                                \
72    if (name != NULL) {                          \
73        printf(name);                            \
74    }                                            \
75                                                 \
76    for (int32_t i = i0; i <= i1; i++) {         \
77        int32_t n = (int32_t) m[i][j0];          \
78        for (int32_t j = j0; j <= j0 + n; j++) { \
79            printf(format, m[i][j]);             \
80        }                                        \
81        printf("\n");                            \
82    }                                            \
83    printf("\n");                                \
84}
85
86display_type_matrix_endline0(int8_t);
87display_type_matrix_endline0(uint8_t);
88display_type_matrix_endline0(int16_t);
89display_type_matrix_endline0(uint16_t);
90display_type_matrix_endline0(int32_t);
91display_type_matrix_endline0(uint32_t);
92display_type_matrix_endline0(int64_t);
93display_type_matrix_endline0(uint64_t);
94
95
96/* ------------------------------- */
97/* --- display_matrix_endline1 --- */
98/* ------------------------------- */
99
100#undef display_type_matrix_endline1
101#define display_type_matrix_endline1(t) \
102void short_name(t,display_,matrix_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
103{                                                    \
104    if (name != NULL) {                              \
105        printf(name);                                \
106    }                                                \
107                                                     \
108    for (int32_t i = i0; i <= i1; i++) {             \
109        int32_t n = (int32_t) m[i][j0 - 1];          \
110        for (int32_t j = j0; j <= j0 + n - 1; j++) { \
111            printf(format, m[i][j]);                 \
112        }                                            \
113        printf("\n");                                \
114    }                                                \
115    printf("\n");                                    \
116}
117
118display_type_matrix_endline1(int8_t);
119display_type_matrix_endline1(uint8_t);
120display_type_matrix_endline1(int16_t);
121display_type_matrix_endline1(uint16_t);
122display_type_matrix_endline1(int32_t);
123display_type_matrix_endline1(uint32_t);
124display_type_matrix_endline1(int64_t);
125display_type_matrix_endline1(uint64_t);
126
127
128/* -------------------------------------- */
129/* --- display_matrix_number_endline0 --- */
130/* -------------------------------------- */
131
132#undef display_type_matrix_number_endline0
133#define display_type_matrix_number_endline0(t) \
134void short_name(t,display_,matrix_number_endline0)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
135{                                                    \
136    if (name != NULL) {                              \
137        printf(name);                                \
138    }                                                \
139                                                     \
140    for (int32_t i = i0; i <= i1; i++) {             \
141        printf("[%3d] ", i);                         \
142        int32_t n = (int32_t) m[i][j0];              \
143        for (int32_t j = j0; j <= j0 + n; j++) {     \
144            printf(format, m[i][j]);                 \
145        }                                            \
146        printf("\n");                                \
147    }                                                \
148    printf("\n");                                    \
149}
150
151display_type_matrix_number_endline0(int8_t);
152display_type_matrix_number_endline0(uint8_t);
153display_type_matrix_number_endline0(int16_t);
154display_type_matrix_number_endline0(uint16_t);
155display_type_matrix_number_endline0(int32_t);
156display_type_matrix_number_endline0(uint32_t);
157display_type_matrix_number_endline0(int64_t);
158display_type_matrix_number_endline0(uint64_t);
159
160
161/* -------------------------------------- */
162/* --- display_matrix_number_endline1 --- */
163/* -------------------------------------- */
164
165#undef display_type_matrix_number_endline1
166#define display_type_matrix_number_endline1(t) \
167void short_name(t,display_,matrix_number_endline1)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, char * format, char * name) \
168{                                                    \
169    if (name != NULL) {                              \
170        printf(name);                                \
171    }                                                \
172                                                     \
173    for (int32_t i = i0; i <= i1; i++) {             \
174        printf("[%3d] ", i);                         \
175        int32_t n = (int32_t) m[i][j0 - 1];          \
176        for (int32_t j = j0; j <= j0 + n - 1; j++) { \
177            printf(format, m[i][j]);                 \
178        }                                            \
179        printf("\n");                                \
180    }                                                \
181    printf("\n");                                    \
182}
183
184display_type_matrix_number_endline1(int8_t);
185display_type_matrix_number_endline1(uint8_t);
186display_type_matrix_number_endline1(int16_t);
187display_type_matrix_number_endline1(uint16_t);
188display_type_matrix_number_endline1(int32_t);
189display_type_matrix_number_endline1(uint32_t);
190display_type_matrix_number_endline1(int64_t);
191display_type_matrix_number_endline1(uint64_t);
192
193
194/* ------------------------- */
195/* --- display_trimatrix --- */
196/* ------------------------- */
197
198#undef display_type_trimatrix
199#define display_type_trimatrix(t) \
200void short_name(t,display_,trimatrix)(t ** m, int32_t i0, int32_t i1, int32_t j0, int32_t j1, int32_t step, char * format, char * name) \
201{                                                    \
202    if (name != NULL) {                              \
203        printf(name);                                \
204    }                                                \
205                                                     \
206    for (int32_t i = i0; i <= i1; i++) {             \
207        for (int32_t j = j0; j <= j1; j++) {         \
208            printf(format, m[i][j]);                 \
209        }                                            \
210        printf("\n");                                \
211        j1 += step;                                  \
212    }                                                \
213    printf("\n");                                    \
214}
215
216display_type_trimatrix(int8_t);
217display_type_trimatrix(uint8_t);
218display_type_trimatrix(int16_t);
219display_type_trimatrix(uint16_t);
220display_type_trimatrix(int32_t);
221display_type_trimatrix(uint32_t);
222display_type_trimatrix(int64_t);
223display_type_trimatrix(uint64_t);
224display_type_trimatrix(float);
225display_type_trimatrix(double);
226
227
228// Local Variables:
229// tab-width: 4
230// c-basic-offset: 4
231// c-file-offsets:((innamespace . 0)(inline-open . 0))
232// indent-tabs-mode: nil
233// End:
234
235// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
236
Note: See TracBrowser for help on using the repository browser.