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

Go to the source code of this file.

Macros

#define MALLOC(s, t, f)   malloc(s)
 package sc More...
 
#define FREE(p, t, f)   free(p)
 

Functions

Variable creat_new_var (Psysteme ps)
 char * noms_var(int i): cette fonction convertit un numero de variable en chaine de caracteres More...
 
bool var_in_lcontrainte_p (Pcontrainte pc, Variable var)
 Check if variable var appears in at least on of the constraints in constraint list pc with a non-zero coefficient. More...
 
bool var_in_sc_p (Psysteme sc, Variable var)
 bool var_in_sc_p(Psysteme sc, Variable var) Cette fonction teste si la variable est contrainte par les egalites ou les inegalites More...
 

Macro Definition Documentation

◆ FREE

#define FREE (   p,
  t,
  f 
)    free(p)

Definition at line 44 of file sc_var.c.

◆ MALLOC

#define MALLOC (   s,
  t,
  f 
)    malloc(s)

package sc

Definition at line 43 of file sc_var.c.

Function Documentation

◆ creat_new_var()

Variable creat_new_var ( Psysteme  ps)

char * noms_var(int i): cette fonction convertit un numero de variable en chaine de caracteres

resultat retourne par la fonction :

char * : chaine de caracteres associee au numero de variable

Les parametres de la fonction :

int i : numero de variable du systeme

FI: a regarder et a commenter et a transferer dans base.dir; pourrait-etre un variable_default_name()? Ou integer_default_name()?

FI: suppression avec le passage a char * du type Variable Variable creat_new_var(Psysteme ps): creation d'une nouvelle variable v pour le systeme ps; les champs "base" et "dimension" sont mis a jour et la nouvelle variable est renvoyee.

Le nom de la nouvelle variable v est de la forme "Xnnn" ou nnn represente son rang dans la base "ps->base"

Auteur: Corinne Ancourt

Modifications:

  • remplacement du champ num_var par le champ base

Definition at line 102 of file sc_var.c.

104 {
105  Variable v;
106  int d;
107  static char name[4];
108 
109  assert(ps != NULL);
110 
111  d = ps->dimension++;
112  assert(0 <= d && d <= 99);
113  name[0] = 'X';
114  (void) sprintf(&name[1],"%d",d);
115  v = variable_make(name);
116  return v;
117 }
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 dimension
Definition: sc-local.h:74
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

References assert, and variable_make().

Referenced by add_var_sup(), loop_index_domaine_to_contrainte(), mat_sys_conv(), matrices_to_loop_sc(), matrices_to_sc(), var_ecart_sup(), and var_posit().

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

◆ var_in_lcontrainte_p()

bool var_in_lcontrainte_p ( Pcontrainte  pc,
Variable  var 
)

Check if variable var appears in at least on of the constraints in constraint list pc with a non-zero coefficient.

Definition at line 122 of file sc_var.c.

125 {
126  bool find = false;
127  Pcontrainte pc1;
128 
129  for (pc1 = pc; !CONTRAINTE_UNDEFINED_P(pc1) && !find; pc1=pc1->succ)
130  find = find || vect_coeff(var,pc1->vecteur);
131 
132  return (find);
133 }
#define CONTRAINTE_UNDEFINED_P(c)
Pvecteur vecteur
struct Scontrainte * succ
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 CONTRAINTE_UNDEFINED_P, Scontrainte::succ, vect_coeff(), and Scontrainte::vecteur.

Referenced by var_in_sc_p().

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

◆ var_in_sc_p()

bool var_in_sc_p ( Psysteme  sc,
Variable  var 
)

bool var_in_sc_p(Psysteme sc, Variable var) Cette fonction teste si la variable est contrainte par les egalites ou les inegalites

Definition at line 139 of file sc_var.c.

142 {
143 
144  bool find = false;
145 
146  find = find || var_in_lcontrainte_p(sc->egalites,var)
147  || var_in_lcontrainte_p(sc->inegalites,var);
148 
149  return(find);
150 }
bool var_in_lcontrainte_p(Pcontrainte pc, Variable var)
Check if variable var appears in at least on of the constraints in constraint list pc with a non-zero...
Definition: sc_var.c:122
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70

References var_in_lcontrainte_p().

Referenced by var_with_unity_coeff_p().

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