source: soft/giet_vm/applications/rosenfeld/nrc2/src/nrio1x.c @ 772

Last change on this file since 772 was 772, checked in by meunier, 8 years ago
  • Ajout de l'application rosenfeld
  • Changement du nom du flag O_CREATE en O_CREAT
File size: 7.8 KB
Line 
1/* ---------------- */
2/* --- nrio1x.c --- */
3/* ---------------- */
4
5/*
6 * Copyright (c) 2000-2014, Lionel Lacassagne, All rights reserved
7 * Univ Paris Sud XI, CNRS
8 */
9
10#include <stdlib.h>
11#include <stdio.h>
12
13#include "nrc_os_config.h"
14#include "mypredef.h"
15#include "nrtype.h"
16#include "nrdef.h"
17#include "nrkernel.h"
18#include "nrmacro.h"
19
20#include "nralloc1.h"
21#include "nrio1x.h"
22
23/* ---------------------------------------------------------------------------------------------------------- */
24IMAGE_EXPORT(void) display_bvector_circular(byte *v,long nl,long nh, long c0, long c1, char *format, char *name)
25/* ---------------------------------------------------------------------------------------------------------- */
26{
27  long i, n=nh-nl+1;
28
29  if(name != NULL) puts(name);
30
31  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
32}
33/* ----------------------------------------------------------------------------------------------------------- */
34IMAGE_EXPORT(void) display_si16vector_circular(sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name)
35/* ----------------------------------------------------------------------------------------------------------- */
36{
37  long i, n=nh-nl+1;
38
39  if(name != NULL) puts(name); 
40
41  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
42}
43/* --------------------------------------------------------------------------------------------------------- */
44IMAGE_EXPORT(void) display_ui32vector_circular(uint32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
45/* --------------------------------------------------------------------------------------------------------- */
46{
47  long i, n=nh-nl+1;
48
49  if(name != NULL) puts(name);
50
51  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
52}
53/* ---------------------------------------------------------------------------------------------------------- */
54IMAGE_EXPORT(void) display_f32vector_circular(float32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
55/* ---------------------------------------------------------------------------------------------------------- */
56{
57  long i, n=nh-nl+1;
58
59  if(name != NULL) puts(name);
60
61  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
62}
63/* ------------------------------------------------------------------------------------------------------------ */
64IMAGE_EXPORT(void) display_f64vector_circular(float64 *v,long nl,long nh, long c0, long c1, char *format, char *name)
65/* ------------------------------------------------------------------------------------------------------------ */
66{
67  long i, n=nh-nl+1;
68
69  if(name != NULL) puts(name);
70
71  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
72}
73/* ----------------------------------------------------------------------------------------------------------------- */
74IMAGE_EXPORT(void) display_bvector_circular_number(byte *v,long nl,long nh, long c0, long c1, char *format, char *name)
75/* ----------------------------------------------------------------------------------------------------------------- */
76{
77  long i, n=nh-nl+1;
78
79  if(name != NULL) puts(name);
80
81  putchar('#');
82  for(i=c0; i<=c1; i++) {
83    printf(format,   i%n+nl);
84  }
85  putchar('\n');
86  putchar(' ');
87  for(i=c0; i<=c1; i++) {
88    printf(format, v[i%n+nl]);
89  }
90  putchar('\n');
91}
92/* ------------------------------------------------------------------------------------------------------------------ */
93IMAGE_EXPORT(void) display_si16vector_circular_number(sint16 *v,long nl,long nh, long c0, long c1, char *format, char *name)
94/* ------------------------------------------------------------------------------------------------------------------ */
95{
96  long i, n=nh-nl+1;
97
98  if(name != NULL) puts(name);
99
100  putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
101  putchar(' ');  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
102}
103/* ---------------------------------------------------------------------------------------------------------------- */
104IMAGE_EXPORT(void) display_ui32vector_circular_number(uint32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
105/* ---------------------------------------------------------------------------------------------------------------- */
106{
107  long i, n=nh-nl+1;
108
109  if(name != NULL) puts(name);
110
111  putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
112  putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
113}
114/* ----------------------------------------------------------------------------------------------------------------- */
115IMAGE_EXPORT(void) display_f32vector_circular_number(float32 *v,long nl,long nh, long c0, long c1, char *format, char *name)
116/* ----------------------------------------------------------------------------------------------------------------- */
117{
118  long i, n=nh-nl+1;
119
120  if(name != NULL) puts(name);
121
122  putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
123  putchar(' ');  for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
124}
125/* ------------------------------------------------------------------------------------------------------------------- */
126IMAGE_EXPORT(void) display_dvector_circular_number(float64 *v,long nl,long nh, long c0, long c1, char *format, char *name)
127/* ------------------------------------------------------------------------------------------------------------------- */
128{
129  long i, n=nh-nl+1;
130
131  if(name != NULL) puts(name);
132
133  putchar('#'); for(i=c0; i<=c1; i++) { printf(format,   i%n+nl); } putchar('\n');
134  putchar(' '); for(i=c0; i<=c1; i++) { printf(format, v[i%n+nl]);} putchar('\n');
135}
136
137/* ------------------------------------------------------------------------------------- */
138IMAGE_EXPORT(void) display_bvector_cycle(byte *v,long nl,long nh, char *format, char *name)
139/* ------------------------------------------------------------------------------------- */
140{
141  long i;
142  uint8 first, next;
143  uint8 *displayed;
144
145  if(name != NULL) printf("%s", name);
146
147  displayed = ui8vector0(nl, nh);
148 
149  for(i=nl; i<=nh; i++) {
150    if(!displayed[i]) {
151      displayed[i] = 1;
152      printf(format, i);
153      first = (byte) i;
154      next = v[i];
155      while(first != next) {
156        displayed[next] = 1;
157        printf(format, next);
158        next = v[next];
159      }
160      putchar('\n');
161    }
162  }
163  putchar('\n');
164  free_ui8vector(displayed, nl, nh);
165}
166/* -------------------------------------------------------------------------------------- */
167IMAGE_EXPORT(void) display_si16vector_cycle(sint16 *v,long nl,long nh, char *format, char *name)
168/* -------------------------------------------------------------------------------------- */
169{
170  long i;
171  uint16 first, next;
172  uint8 *displayed;
173
174  if(name != NULL) printf("%s", name);
175
176  displayed = ui8vector0(nl, nh);
177 
178  for(i=nl; i<=nh; i++) {
179    if(!displayed[i]) {
180      displayed[i] = 1;
181      printf(format, i);
182      first = (sint16) i;
183      next = v[i];
184      while(first != next) {
185        displayed[next] = 1;
186        printf(format, next);
187        next = v[next];
188      }
189      putchar('\n');
190    }
191  }
192  putchar('\n');
193  free_ui8vector(displayed, nl, nh);
194}
195/* ---------------------------------------------------------------------------------------- */
196IMAGE_EXPORT(void) display_ui16vector_cycle(uint16 *v,long nl,long nh, char *format, char *name)
197/* ---------------------------------------------------------------------------------------- */
198{
199  long i;
200  uint16 first, next;
201  uint8 *displayed;
202
203  if(name != NULL) printf("%s", name);
204
205  displayed = ui8vector0(nl, nh);
206 
207  for(i=nl; i<=nh; i++) {
208    if(!displayed[i]) {
209      displayed[i] = 1;
210      printf(format, i);
211      first = (uint16) i;
212      next = v[i];
213      while(first != next) {
214        displayed[next] = 1;
215        printf(format, next);
216        next = v[next];
217      }
218      putchar('\n');
219    }
220  }
221  putchar('\n');
222  free_ui8vector(displayed, nl, nh);
223}
Note: See TracBrowser for help on using the repository browser.