PIPS
io.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "linear_assert.h"
#include <string.h>
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
+ Include dependency graph for io.c:

Go to the source code of this file.

Functions

Pvecteur vect_read (Pbase *b)
 INTLIBRARY. More...
 
void vect_fprint (FILE *f, Pvecteur v, get_variable_name_t variable_name)
 void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v sur le fichier f; le nom de chaque coordonnee est donne par la fonction variable_name() More...
 
void vect_fprint_as_dense (FILE *f, Pvecteur v, Pbase b)
 void vect_fprint_as_dense(FILE * f, Pvecteur v, Pbase b): More...
 
void vect_fprint_as_monome (FILE *f, Pvecteur v, Pbase b, get_variable_name_t variable_name, char *mult_symbol)
 void vect_fprint_as_monome(FILE * f, Pvecteur v, Pbase b, char * (*variable_name)(), char *mult_symbol): impression d'un vecteur creux considere comme un monome sans coefficient. More...
 
char * vect_sprint_as_monome (Pvecteur v, Pbase b, get_variable_name_t variable_name, char *mult_symbol)
 char *vect_sprint_as_monome(Pvecteur v, Pbase b, char * (*variable_name)(), char *mult_symbol): Retourne dans une chaine le Pvecteur considere comme un monome sans coefficient. More...
 
void vect_dump (Pvecteur v)
 void vect_dump(Pvecteur v): print sparse vector v on stderr. More...
 
void vect_print (Pvecteur v, get_variable_name_t variable_name)
 void vect_print(Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v sur stdout; le nom de chaque coordonnee est donne par la fonction variable_name(); voir vect_fprint() More...
 
void vect_fdump (FILE *f, Pvecteur v)
 void vect_fdump(FILE * f, Pvecteur v): impression d'un vecteur creux par vect_fprint() avec passage de la fonction variable_debug_name() More...
 
void base_fprint (FILE *f, Pbase b, get_variable_name_t variable_name)
 void base_fprint(FILE * f, Pbase b, char * (*variable_name)()): impression d'une base sur le fichier f; le nom de chaque coordonnee est donne par la fonction variable_name() More...
 

Function Documentation

◆ base_fprint()

void base_fprint ( FILE *  f,
Pbase  b,
get_variable_name_t  variable_name 
)

void base_fprint(FILE * f, Pbase b, char * (*variable_name)()): impression d'une base sur le fichier f; le nom de chaque coordonnee est donne par la fonction variable_name()

Par exemple, la base b -> -> -> -> b == ( i j k ) est imprime sous la forme i j k LF ou les symboles i, j et k sont obtenus via la fonction pointee par variable_name()

Le base vide est represente par base vide LF

Note: attention au linefeed final il n'existe pas de fonction relisant une base sous cette forme

Parameters
variable_nameariable_name

Definition at line 342 of file io.c.

344  {
345  if(VECTEUR_NUL_P(b))
346  (void) fprintf(f,"base vide\n");
347  else
348  for ( ; !VECTEUR_NUL_P(b); b = b->succ) {
349  (void) fprintf(f,"%s", variable_name(b->var));
350  if (!VECTEUR_NUL_P(b->succ)) {
351  (void) fprintf(f,", ");
352  }
353  }
354  (void) fprintf(f," \n");
355 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * variable_name(Variable v)
polynome_ri.c
Definition: polynome_ri.c:73
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
#define VECTEUR_NUL_P(v)

References f(), fprintf(), Svecteur::succ, Svecteur::var, variable_name(), and VECTEUR_NUL_P.

Referenced by build_transfer_equations(), create_tile_basis(), hyperplane(), loop_nest_to_wp65_code(), print_dependence_cone(), print_loopnest_dependence_cone(), sc_default_dump(), sc_default_dump_to_files(), sc_dump(), sc_fprint_for_sc_fscan(), and sc_image_computation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_dump()

void vect_dump ( Pvecteur  v)

void vect_dump(Pvecteur v): print sparse vector v on stderr.

By default, each dimension/variable is represented by an X followed by its hexadeximal address.

Intended for debug purposes. Its behavior depends on the setting of pointer variable_debug_name by init_variable_debug_name(). Different names can be returned for each variable, more useful than a pointer value.

Definition at line 304 of file io.c.

304  {
305  vect_fprint(stderr, v, variable_debug_name);
306 }
void vect_fprint(FILE *f, Pvecteur v, get_variable_name_t variable_name)
void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v su...
Definition: io.c:124
char *(* variable_debug_name)(Variable)
Debug support: pointer to the function used by debug print outs.
Definition: variable.c:114

References variable_debug_name, and vect_fprint().

Referenced by affine_to_transformer(), check_coefficient_reduction(), compute_x_and_y_bounds(), find_first_integer_point_in_between(), make_loop_indice_equation(), new_constraint_for_coefficient_reduction_with_bounding_box(), sc_bounded_normalization(), sc_consistent_p(), sc_projection_optim_along_vecteur_ofl(), simple_affine_to_transformer(), simplify_constraint_with_bounding_box(), and Tiling_buffer_allocation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_fdump()

void vect_fdump ( FILE *  f,
Pvecteur  v 
)

void vect_fdump(FILE * f, Pvecteur v): impression d'un vecteur creux par vect_fprint() avec passage de la fonction variable_debug_name()

Definition at line 320 of file io.c.

320  {
322 }

References f(), variable_debug_name, and vect_fprint().

+ Here is the call graph for this function:

◆ vect_fprint()

void vect_fprint ( FILE *  f,
Pvecteur  v,
get_variable_name_t  variable_name 
)

void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v sur le fichier f; le nom de chaque coordonnee est donne par la fonction variable_name()

Par exemple, le vecteur v -> -> -> -> v == 2 i - 3 j + k est imprime sous la forme 2 * i - 3 * j + k LF ou les symboles i, j et k sont obtenus via la fonction pointee par variable_name()

Le vecteur nul est represente par vecteur nul LF

Note: attention au linefeed final il n'existe pas de fonction relisant des vecteurs sous cette forme (pour le moment...)

Modifications:

  • suppression du cas special du terme constant Resultat : core dump (FC, 28/11/94) Fixed, (BC, 6/12/94)
Parameters
variable_nameariable_name

Definition at line 124 of file io.c.

124  {
125  Pvecteur p;
126 
127  if(v==NULL)
128  (void) fprintf(f,"nul vector\n");
129  else
130  for (p = v; p != NULL; p = p->succ)
131  {
132  if (p->var != TCST) {
133  fprint_Value(f, p->val);
134  (void) fprintf(f," * %s ", variable_name(p->var));
135  }
136  else {
137  (void) fprint_Value(f, p->val);
138  fprintf(f, " ");
139  }
140 
141  if (p->succ != NULL) {
142  (void) fprintf(f,"+ ");}
143  else {
144  (void) fprintf(f,"\n");}
145  }
146 }
void fprint_Value(FILE *f, Value v)
Definition: io.c:42
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Value val
Definition: vecteur-local.h:91
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.

References f(), fprint_Value(), fprintf(), Svecteur::succ, TCST, Svecteur::val, Svecteur::var, and variable_name().

Referenced by add_loop_skip_condition(), chose_variable_to_project_for_feasability(), compute_iteration_domain(), create_tile_basis(), dbg_ray_dte_rm(), dj_variable_substitution_with_eqs_ofl_ctrl(), eval_var(), find_iteration_domain(), fprint_message(), invariant_vector_p(), loop_iteration_domaine_to_sc(), loop_nest_to_wp65_code(), module_to_wp65_modules(), movement_computation(), new_system_with_only_live_variable(), pa_path_to_few_disjunct_ofl_ctrl(), parallel_tiling(), pvecteur_to_polynome(), ray_dte_fprint(), reduce_coefficients_with_bounding_box(), reg_v_debug(), sc_elim_redund_with_first_ofl_ctrl(), small_positive_slope_reduce_coefficients_with_bounding_box(), sommet_fprint(), tiling_transformation(), transformer_pattern_fix_point(), vect_debug(), vect_dump(), vect_fdump(), and vect_print().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_fprint_as_dense()

void vect_fprint_as_dense ( FILE *  f,
Pvecteur  v,
Pbase  b 
)

void vect_fprint_as_dense(FILE * f, Pvecteur v, Pbase b):

Par exemple, le vecteur v -> -> -> -> v == 2 i - 3 j + k est imprime sous la forme ( 2 -3 1) dans la base (i j k)

No constant term TCST is expected.

I do not know what should be done for constant terms...

Definition at line 159 of file io.c.

163 {
164  if(vect_in_basis_p(v, b)) {
165  Pvecteur coord;
166 
167  fputc('(', f);
168 
169  for(coord = b; !VECTEUR_NUL_P(coord); coord = coord->succ) {
170  Variable var = vecteur_var(coord);
171 
172  if(VARIABLE_DEFINED_P(var)) {
173  fprint_Value(f, vect_coeff(var, v));
174  if(VECTEUR_NUL_P(coord->succ)) {
175  fputc(')', f);
176  }
177  else {
178  fputc(',', f);
179  }
180  }
181  else {
182  /* I do not know what should be done for constant terms... */
183  abort();
184  }
185  }
186  }
187  else
188  abort();
189 }
bool vect_in_basis_p(Pvecteur v, Pbase b)
Pvecteur vect_in_basis_p(Pvecteur v, Pbase b): check that all coordinates in v are in b,...
Definition: base.c:342
#define abort()
Definition: misc-local.h:53
#define VARIABLE_DEFINED_P(v)
Definition: vecteur-local.h:66
#define vecteur_var(v)
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References abort, f(), fprint_Value(), Svecteur::succ, VARIABLE_DEFINED_P, vect_coeff(), vect_in_basis_p(), VECTEUR_NUL_P, and vecteur_var.

Referenced by ray_dte_fprint_as_dense(), and sommet_fprint_as_dense().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_fprint_as_monome()

void vect_fprint_as_monome ( FILE *  f,
Pvecteur  v,
Pbase  b,
get_variable_name_t  variable_name,
char *  mult_symbol 
)

void vect_fprint_as_monome(FILE * f, Pvecteur v, Pbase b, char * (*variable_name)(), char *mult_symbol): impression d'un vecteur creux considere comme un monome sans coefficient.

Par ex.: le vecteur 2 * i - 3 * j + k est ecrit: "i^2 * j^(-3) * k". Le nom de chaque variable est donne par la fonction variable_name(). L'ordre dans lequel sont ecrites les inconnues du monome est fixe par la base b. Le symbole "multiplication" est passe dans (char *) mult_symbol: " * ", ".", "x", "", ... le vecteur de base special TCST n'est pas affiche: seulement son coefficient. Pas de
a la fin de l'affichage.

Parameters
variable_nameariable_name
mult_symbolult_symbol

Definition at line 201 of file io.c.

205  {
206  char *s = vect_sprint_as_monome(v, b, variable_name, mult_symbol);
207 
208  fprintf(f, "%s", s);
209  free(s);
210 }
void free(void *)
char * vect_sprint_as_monome(Pvecteur v, Pbase b, get_variable_name_t variable_name, char *mult_symbol)
char *vect_sprint_as_monome(Pvecteur v, Pbase b, char * (*variable_name)(), char *mult_symbol): Retou...
Definition: io.c:217

References f(), fprintf(), free(), variable_name(), and vect_sprint_as_monome().

Referenced by prv().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ vect_print()

void vect_print ( Pvecteur  v,
get_variable_name_t  variable_name 
)

void vect_print(Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v sur stdout; le nom de chaque coordonnee est donne par la fonction variable_name(); voir vect_fprint()

Parameters
variable_nameariable_name

Definition at line 312 of file io.c.

313 {
314  vect_fprint(stdout, v, variable_name);
315 }

References variable_name(), and vect_fprint().

+ Here is the call graph for this function:

◆ vect_read()

Pvecteur vect_read ( Pbase b)

INTLIBRARY.

io.c

Pvecteur vect_read(Pbase * b): lecture interactive d'un vecteur sur stdin; la base b est modifiee de maniere a ce que chaque composante y figure bien;

La representation d'un vecteur dont la troisieme composante vaut 2, la dixieme 6 et les autres 0 peut etre: 3 2 1 10 6 0 ou x3 2 1 x10 6 0 Le 1 veut dire qu'il faut continuer les lectures, le zero, qu'il faut arreter

Ce format est malheureusement incompatible avec celui de vect_fprint()

Definition at line 65 of file io.c.

66 {
67  Pvecteur v1, v = VECTEUR_NUL;
68  // Let's assume that no variable name will be longer than 9 characters
69  char buffer[10];
70  int c; // flag de continuation
71 
72  c = 1;
73  while (c == 1) {
74  Variable var;
75  Value val;
76  // vect_chain() n'est pas utilise pour conserver l'ordre des couples
77  (void) printf ("valeur de variable :");
78  int n = scanf("%9s",buffer);
79  assert(n==1);
80  (void) printf ("valeur du coefficient de la variable :");
81  (void) scan_Value(&val);
83  var = variable_make(buffer);
84  *b = vect_add_variable(*b,var);
85  }
86  else {
87  var = base_find_variable(*b, (Variable) buffer);
88  }
89  v1 = vect_new(var, val);
90  v1->succ = v;
91  v = v1;
92  (void) printf ("'1' -->rentrer d'autres valeurs,(0-2..9)"
93  "sinon. votre choix:");
94  n = scanf("%d", &c);
95  assert(n==1);
96  }
97  return v;
98 }
int Value
Variable base_find_variable(Pbase b, Variable v)
Variable base_find_variable(Pbase b, Variable v): returns variable v if variable v is one of b's elem...
Definition: base.c:155
bool base_contains_variable_p(Pbase b, Variable v)
bool base_contains_variable_p(Pbase b, Variable v): returns true if variable v is one of b's elements...
Definition: base.c:136
Pbase vect_add_variable(Pbase b, Variable v)
package vecteur - routines sur les bases
Definition: base.c:61
int scan_Value(Value *pv)
Definition: io.c:63
Variable variable_make(char *name)
Variable variable_make(char * name): defines a new variable of a given name.
Definition: variable.c:129
#define assert(ex)
Definition: newgen_assert.h:41
int printf()
static string buffer
Definition: string.c:113
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110

References assert, base_contains_variable_p(), base_find_variable(), buffer, printf(), scan_Value(), Svecteur::succ, variable_make(), vect_add_variable(), vect_new(), and VECTEUR_NUL.

+ Here is the call graph for this function:

◆ vect_sprint_as_monome()

char* vect_sprint_as_monome ( Pvecteur  v,
Pbase  b,
get_variable_name_t  variable_name,
char *  mult_symbol 
)

char *vect_sprint_as_monome(Pvecteur v, Pbase b, char * (*variable_name)(), char *mult_symbol): Retourne dans une chaine le Pvecteur considere comme un monome sans coefficient.

(voir ci-dessus)

si la base est vide: affiche comme ca vient

si la base n'est pas vide, affiche selon l'ordre qu'elle definit

exp < 0

inutile pour les polynomes

(un peu tard:-)

Parameters
variable_nameariable_name
mult_symbolult_symbol

Definition at line 217 of file io.c.

220  {
221  Pvecteur p;
222  char t[99];
223  char *r = t;
224  char *s = NULL;
225 
226  if (VECTEUR_NUL_P(v))
227  strcpy (&t[0], "0");
228  else if (VECTEUR_NUL_P(b)) {
229  /* si la base est vide: affiche comme ca vient */
230  for (p = v; p != NULL; p = p->succ) {
231  if (value_one_p(p->val)) {
232  (void) sprintf(r, "%s", variable_name(p->var));
233  r = strchr(r, '\0');
234  }
235  else {
236  (void) sprintf(r, "%s^", variable_name(p->var));
237  r = strchr(r, '\0');
238  sprint_Value(r, p->val);
239  r = strchr(r, '\0');
240  }
241  if (p->succ != NULL) {
242  (void) sprintf(r, "%s", mult_symbol);
243  r = strchr(r, '\0');
244  }
245  }
246  }
247  else {
248  /* si la base n'est pas vide, affiche selon l'ordre
249  * qu'elle definit */
250  bool first_var = true;
251  Value exp;
252  for ( ; !VECTEUR_NUL_P(b); b = b->succ) {
253  exp = vect_coeff(b->var, v);
254  if(exp!=0) {
255 
256  if (!first_var) {
257  (void) sprintf(r, "%s", mult_symbol);
258  r = strchr(r, '\0');
259  }
260  else
261  first_var = false;
262 
263  if (value_pos_p(exp)) {
264  if (value_one_p(exp)) {
265  (void) sprintf(r, "%s", variable_name(b->var));
266  r = strchr(r, '\0');
267  }
268  else {
269  (void) sprintf(r,"%s^", variable_name(b->var));
270  r = strchr(r, '\0');
271  sprint_Value(r, exp);
272  r = strchr(r, '\0');
273  }
274  }
275  else /* exp < 0 */ {
276  /* inutile pour les polynomes */
277  first_var = false;
278 
279  (void) sprintf(r, "%s^(", variable_name(b->var));
280  r = strchr(r, '\0');
281  sprint_Value(r, exp);
282  r = strchr(r, '\0');
283  (void) sprintf(r, ")");
284  r = strchr(r, '\0');
285  }
286  }
287  }
288  }
289  s = (char*) strdup(t);
290  assert(strlen(s)<99); /* (un peu tard:-) */
291  return s;
292 }
#define value_pos_p(val)
#define value_one_p(val)
void sprint_Value(char *s, Value v)
Definition: io.c:53
char * strdup()
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References assert, exp, sprint_Value(), strdup(), Svecteur::succ, Svecteur::val, value_one_p, value_pos_p, Svecteur::var, variable_name(), vect_coeff(), and VECTEUR_NUL_P.

Referenced by monome_sprint(), and vect_fprint_as_monome().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: