PIPS
vvs.c File Reference
#include <stdio.h>
#include "genC.h"
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "sc.h"
#include "polyedre.h"
#include "union.h"
#include "matrice.h"
#include "matrix.h"
#include "ri.h"
#include "constants.h"
#include "ri-util.h"
#include "misc.h"
#include "graph.h"
#include "paf_ri.h"
#include "text.h"
#include "text-util.h"
#include "paf-util.h"
#include "prgm_mapping.h"
+ Include dependency graph for vvs.c:

Go to the source code of this file.

Macros

#define VV_VAR(x)   var_val_variable(x)
 Name : substitution.c Package : prgm_mapping Author : Platonoff Alexis Date : 4 october 1993 Historic : Documents: Comments : This file contains the functions for manipulating substitutions. More...
 
#define VV_COEFF(x)   expression_to_int(var_val_value(x))
 
#define VV_VAL_(x)   normalized_linear_(expression_normalized(var_val_value(x)))
 
#define VV_VAL(x)   normalized_linear(expression_normalized(var_val_value(x)))
 
#define MAKE_VV(var, coeff, val)
 

Typedefs

typedef bool(* argh) (Pvecteur *, Pvecteur *)
 

Functions

Ppolynome my_vecteur_to_polynome (Pvecteur pv)
 Global variables
More...
 
list make_vvs (entity var, int coeff, Pvecteur val)
 ======================================================================== More...
 
var_val dup_vv (var_val vv)
 ======================================================================== More...
 
list dup_vvs (list vvs)
 ======================================================================== More...
 
void fprint_vvs (FILE *fp, list vvs)
 ======================================================================== More...
 
void fprint_vv (FILE *fp, var_val vv)
 ======================================================================== More...
 
list vvs_on_vvs (list vv1, list vv2)
 ======================================================================== More...
 
list compose_vvs (list vv1, list vv2)
 ======================================================================== More...
 
list sc_to_vvs (Psysteme sc, list var_l)
 ======================================================================== More...
 
Psysteme vvs_to_sc (list vvs)
 ======================================================================== More...
 
bool vvs_faisabilite (list vvs)
 ======================================================================== More...
 
Ppolynome vvs_on_polynome (list vvs, Ppolynome pp)
 ======================================================================== More...
 
Pvecteur vvs_on_vecteur (list vvs, Pvecteur pv)
 ======================================================================== More...
 
Psysteme vvs_on_systeme (list vvs, Psysteme ps)
 ======================================================================== More...
 
list make_vvs_from_sc (Psysteme ps_aux, list var_l)
 ======================================================================== More...
 
list plc_make_vvs_with_vector (Pvecteur v)
 ======================================================================== More...
 

Macro Definition Documentation

◆ MAKE_VV

#define MAKE_VV (   var,
  coeff,
  val 
)
Value:
make_var_val(var, \
NIL)), \
var_val make_var_val(entity a1, expression a2)
Definition: paf_ri.c:697
call make_call(entity a1, list a2)
Definition: ri.c:269
normalized make_normalized(enum normalized_utype tag, void *val)
Definition: ri.c:1447
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
entity make_integer_constant_entity(_int)
entity make_integer_constant_entity(int c) make entity for integer constant c
Definition: variable.c:1345
@ is_syntax_call
Definition: ri.h:2693
@ is_normalized_linear
Definition: ri.h:1760

Definition at line 75 of file vvs.c.

◆ VV_COEFF

#define VV_COEFF (   x)    expression_to_int(var_val_value(x))

Definition at line 72 of file vvs.c.

◆ VV_VAL

#define VV_VAL (   x)    normalized_linear(expression_normalized(var_val_value(x)))

Definition at line 74 of file vvs.c.

◆ VV_VAL_

#define VV_VAL_ (   x)    normalized_linear_(expression_normalized(var_val_value(x)))

Definition at line 73 of file vvs.c.

◆ VV_VAR

#define VV_VAR (   x)    var_val_variable(x)

Name : substitution.c Package : prgm_mapping Author : Platonoff Alexis Date : 4 october 1993 Historic : Documents: Comments : This file contains the functions for manipulating substitutions.

Ansi includes
Newgen includes
C3 includes
Pips includes
Macro functions

Definition at line 71 of file vvs.c.

Typedef Documentation

◆ argh

typedef bool(* argh) (Pvecteur *, Pvecteur *)

Definition at line 457 of file vvs.c.

Function Documentation

◆ compose_vvs()

list compose_vvs ( list  vv1,
list  vv2 
)

========================================================================

If "pv" is not NULL and "aux_vvs" is NULL, it means that elim_var_with_eg() did not work.

"v1 == v2", so "v2" is remove from "cvv2"

Definition at line 274 of file vvs.c.

276 {
277  list l1, l2, p2, cvv1, cvv2;
278 
279  cvv1 = dup_vvs(vv1);
280  cvv2 = dup_vvs(vv2);
281 
282  if(cvv1 == NIL) {
283  if(cvv2 == NIL)
284  return(NIL);
285  else
286  return(cvv2);
287  }
288  if(cvv2 == NIL)
289  return(cvv1);
290 
291  for(l1 = cvv1; !ENDP(l1); POP(l1)) {
292  var_val v1 = VAR_VAL(CAR(l1));
293  entity e1 = VV_VAR(v1);
294  int c1 = VV_COEFF(v1);
295  Pvecteur pv1 = (Pvecteur) VV_VAL(v1);
296 
297  p2 = NIL;
298  for(l2 = cvv2; !ENDP(l2); POP(l2)) {
299  var_val v2 = VAR_VAL(CAR(l2));
300  entity e2 = VV_VAR(v2);
301  int c2 = VV_COEFF(v2);
302  Pvecteur pv2 = (Pvecteur) VV_VAL(v2);
303 
304  if(same_entity_p(e1, e2)) {
305  list il, el, aux_vvs;
306  Psysteme aps1 = sc_new(), aps2;
307  Pvecteur pv;
308  int p;
309 
310  p = ppcm(c1,c2);
311  pv = vect_cl2_ofl_ctrl((p/c1), pv1, -(p/c2), pv2, NO_OFL_CTRL);
312 
313  il = vecteur_to_list(pv);
314  sc_add_egalite(aps1, contrainte_make(pv));
315 
316  aps2 = elim_var_with_eg(aps1, &il, &el);
317  aux_vvs = sc_to_vvs(aps2, el);
318 
319  /* If "pv" is not NULL and "aux_vvs" is NULL, it means that
320  * elim_var_with_eg() did not work.
321  */
322  if(ENDP(aux_vvs)) {
323  /* "v1 == v2", so "v2" is remove from "cvv2" */
324  if(p2 == NIL)
325  cvv2 = CDR(l2);
326  else
327  CDR(p2) = CDR(l2);
328  }
329  else if(!ENDP(CDR(aux_vvs)))
330  user_error("compose_vvs", "There are more than one vv\n");
331  else {
332  VAR_VAL(CAR(l2)) = VAR_VAL(CAR(aux_vvs));
333  p2 = l2;
334  }
335  }
336  else {
337  int cc2;
338  if( (cc2 = vect_coeff((Variable) e1, pv2)) != 0 ) {
339  int g = pgcd(cc2, c1);
340  vect_erase_var(&pv2, (Variable) e1);
342  (vect_cl2_ofl_ctrl((c1/g), pv2, (cc2/g), pv1, NO_OFL_CTRL));
343  }
344  p2 = l2;
345  }
346  }
347  }
348  for(l1 = cvv2; !ENDP(l1); POP(l1)) {
349  var_val v1 = VAR_VAL(CAR(l1));
350  entity e1 = VV_VAR(v1);
351  int c1 = VV_COEFF(v1);
352  Pvecteur pv1 = (Pvecteur) VV_VAL(v1);
353  for(l2 = cvv1; !ENDP(l2); POP(l2)) {
354  var_val v2 = VAR_VAL(CAR(l2));
355  entity e2 = VV_VAR(v2);
356  Pvecteur pv2 = (Pvecteur) VV_VAL(v2);
357 
358  if(same_entity_p(e1, e2)) {
359  user_error("compose_vvs", "Entities should be different\n");
360  }
361  else {
362  int cc2;
363  if( (cc2 = vect_coeff((Variable) e1, pv2)) != 0 ) {
364  int g = pgcd(cc2, c1);
365  vect_erase_var(&pv2, (Variable) e1);
367  (vect_cl2_ofl_ctrl((c1/g), pv2, (cc2/g), pv1, NO_OFL_CTRL));
368  }
369  }
370  }
371  }
372  return(gen_nconc(cvv1, cvv2));
373 }
#define pgcd(a, b)
Pour la recherche de performance, selection d'une implementation particuliere des fonctions.
Value ppcm(Value, Value)
ppcm.c
Definition: ppcm.c:42
#define newgen_Pvecteur(p)
Definition: compsec.h:26
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define user_error(fn,...)
Definition: misc-local.h:265
Psysteme elim_var_with_eg(Psysteme, list *, list *)
===========================================================================
Definition: utils.c:1361
list vecteur_to_list(Pvecteur)
===========================================================================
Definition: utils.c:1626
#define VAR_VAL(x)
VAR_VAL.
Definition: paf_ri.h:763
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
void sc_add_egalite(Psysteme p, Pcontrainte e)
void sc_add_egalite(Psysteme p, Pcontrainte e): macro ajoutant une egalite e a un systeme p; la base ...
Definition: sc_alloc.c:389
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define NO_OFL_CTRL
struct Svecteur * Pvecteur
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
Pvecteur vect_cl2_ofl_ctrl(Value x1, Pvecteur v1, Value x2, Pvecteur v2, int ofl_ctrl)
Pvecteur vect_cl2_ofl(Value x1, Pvecteur v1, Value x2, Pvecteur v2): allocation d'un vecteur v dont l...
Definition: binaires.c:204
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
Definition: unaires.c:106
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
#define VV_VAL_(x)
Definition: vvs.c:73
#define VV_VAR(x)
Name : substitution.c Package : prgm_mapping Author : Platonoff Alexis Date : 4 october 1993 Historic...
Definition: vvs.c:71
list dup_vvs(list vvs)
========================================================================
Definition: vvs.c:131
list sc_to_vvs(Psysteme sc, list var_l)
========================================================================
Definition: vvs.c:382
#define VV_VAL(x)
Definition: vvs.c:74
#define VV_COEFF(x)
Definition: vvs.c:72

References CAR, CDR, contrainte_make(), dup_vvs(), elim_var_with_eg(), ENDP, gen_nconc(), newgen_Pvecteur, NIL, NO_OFL_CTRL, pgcd, POP, ppcm(), same_entity_p(), sc_add_egalite(), sc_new(), sc_to_vvs(), user_error, VAR_VAL, vect_cl2_ofl_ctrl(), vect_coeff(), vect_erase_var(), vecteur_to_list(), VV_COEFF, VV_VAL, VV_VAL_, and VV_VAR.

Referenced by partial_broadcast_coefficients(), sc_to_vvs(), solve_system_by_succ_elim(), and valuer().

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

◆ dup_vv()

var_val dup_vv ( var_val  vv)

========================================================================

Definition at line 123 of file vvs.c.

125 {
126  return(MAKE_VV(VV_VAR(vv), VV_COEFF(vv), vect_dup((Pvecteur) VV_VAL(vv))));
127 }
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
#define MAKE_VV(var, coeff, val)
Definition: vvs.c:75

References MAKE_VV, vect_dup(), VV_COEFF, VV_VAL, and VV_VAR.

Referenced by dup_vvs().

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

◆ dup_vvs()

list dup_vvs ( list  vvs)

========================================================================

Definition at line 131 of file vvs.c.

133 {
134  list new_vvs = NIL, l;
135 
136  for(l = vvs; !ENDP(l); POP(l)) {
137  var_val v = VAR_VAL(CAR(l));
138 
139  new_vvs = gen_nconc(new_vvs, CONS(VAR_VAL, dup_vv(v), NIL));
140  }
141  return(new_vvs);
142 }
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
var_val dup_vv(var_val vv)
========================================================================
Definition: vvs.c:123

References CAR, CONS, dup_vv(), ENDP, gen_nconc(), NIL, POP, and VAR_VAL.

Referenced by compose_vvs().

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

◆ fprint_vv()

void fprint_vv ( FILE *  fp,
var_val  vv 
)

========================================================================

Definition at line 158 of file vvs.c.

161 {
163  fprintf(fp, "%s --> ", entity_local_name(VV_VAR(vv)));
164  else {
165  int coeff = VV_COEFF(vv);
166  if(coeff == 1)
167  fprintf(fp, "%s --> ", entity_local_name(VV_VAR(vv)));
168  else if(coeff == -1)
169  fprintf(fp, "-%s --> ", entity_local_name(VV_VAR(vv)));
170  else
171  fprintf(fp, "%d.%s --> ", coeff, entity_local_name(VV_VAR(vv)));
172  }
173 
174  pu_vect_fprint(fp, (Pvecteur) VV_VAL(vv));
175 }
void pu_vect_fprint(FILE *, Pvecteur)
===========================================================================
Definition: print.c:446
#define var_val_value(x)
Definition: paf_ri.h:795
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
#define syntax_undefined
Definition: ri.h:2676
#define expression_syntax(x)
Definition: ri.h:1247
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References entity_local_name(), expression_syntax, fprintf(), pu_vect_fprint(), syntax_undefined, var_val_value, VV_COEFF, VV_VAL, and VV_VAR.

Referenced by fprint_vvs().

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

◆ fprint_vvs()

void fprint_vvs ( FILE *  fp,
list  vvs 
)

========================================================================

Definition at line 146 of file vvs.c.

149 {
150  if(vvs == NULL)
151  fprintf(fp, "Var_vals Empty\n");
152  for( ; !ENDP(vvs); POP(vvs))
153  fprint_vv(fp, VAR_VAL(CAR(vvs)));
154 }
void fprint_vv(FILE *fp, var_val vv)
========================================================================
Definition: vvs.c:158

References CAR, ENDP, fprint_vv(), fprintf(), POP, and VAR_VAL.

Referenced by broadcast_conditions(), is_not_trivial_p(), partial_broadcast_coefficients(), plc_make_distance(), plc_make_vvs_with_vector(), prgm_mapping(), solve_system_by_succ_elim(), and valuer().

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

◆ make_vvs()

list make_vvs ( entity  var,
int  coeff,
Pvecteur  val 
)

========================================================================

Definition at line 113 of file vvs.c.

117 {
118  return(CONS(VAR_VAL, MAKE_VV(var, coeff, val), NIL));
119 }

References CONS, MAKE_VV, NIL, and VAR_VAL.

Referenced by plc_make_vvs_with_vector(), and valuer().

+ Here is the caller graph for this function:

◆ make_vvs_from_sc()

list make_vvs_from_sc ( Psysteme  ps_aux,
list  var_l 
)

========================================================================

We remove "var" from "vec"

We have: val.var + new_vec == 0. So: abs(val).var = -sign(val).new_vec

Definition at line 610 of file vvs.c.

613 {
614  list new_vvs = NIL, l;
615  Pcontrainte pc = ps_aux->egalites;
616 
617  for(l = var_l; !ENDP(l); POP(l), pc = pc->succ) {
618  entity var = ENTITY(CAR(l));
619  Pvecteur vec = pc->vecteur, new_vec;
620  int val = vect_coeff((Variable) var, vec);
621  var_val vv;
622 
623  if(val == 0)
624  user_error("make_vvs_from_sc", "Value should not be equal to zero\n");
625 
626  /* We remove "var" from "vec" */
627  new_vec = vect_del_var(vec, (Variable) var);
628 
629  /* We have: val.var + new_vec == 0. So: abs(val).var = -sign(val).new_vec
630  */
631  if(val < 0)
632  val = 0-val;
633  else
634  vect_chg_sgn(new_vec);
635 
636 /*
637  vv_syn = syntax_undefined;
638  if(val != 1) {
639  vv_syn = make_syntax(is_syntax_call,
640  make_call(make_integer_constant_entity(val), NIL));
641  }
642  vv = make_var_val(var, make_expression(vv_syn,
643  make_normalized(is_normalized_linear,
644  new_vec)));
645 */
646  vv = MAKE_VV(var, val, new_vec);
647 
648  new_vvs = gen_nconc(new_vvs, CONS(VAR_VAL, vv, NIL));
649  }
650  return(new_vvs);
651 }
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
Pvecteur vecteur
struct Scontrainte * succ
Pcontrainte egalites
Definition: sc-local.h:70
Pvecteur vect_del_var(Pvecteur v_in, Variable var)
Pvecteur vect_del_var(Pvecteur v_in, Variable var): allocation d'un nouveau vecteur egal a la project...
Definition: unaires.c:206

References CAR, CONS, ENDP, ENTITY, gen_nconc(), MAKE_VV, NIL, POP, Scontrainte::succ, user_error, VAR_VAL, vect_chg_sgn(), vect_coeff(), vect_del_var(), and Scontrainte::vecteur.

Referenced by partial_broadcast_coefficients(), plc_make_distance(), valuer(), and vvs_on_vvs().

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

◆ my_vecteur_to_polynome()

Ppolynome my_vecteur_to_polynome ( Pvecteur  pv)

Global variables

Internal variables
========================================================================

Definition at line 86 of file vvs.c.

88 {
89  Ppolynome pp;
90 
91  if(VECTEUR_NUL_P(pv))
92  pp = POLYNOME_NUL;
93  else {
94  Pvecteur vec;
95 
96  pp = NULL;
97  for(vec = pv; vec != NULL; vec = vec->succ) {
98  Variable var = vecteur_var(vec);
99  float val = (float) vecteur_val(vec);
100  Ppolynome newpp;
101 
102  newpp = make_polynome(val, var, 1);
103  polynome_succ(newpp) = pp;
104  pp = newpp;
105  }
106  }
107 
108  return(pp);
109 }
Ppolynome make_polynome(float coeff, Variable var, Value expo)
Ppolynome make_polynome(float coeff, Variable var, Value expo) PRIVATE allocates space for,...
Definition: pnome-alloc.c:100
#define POLYNOME_NUL
#define polynome_succ(pp)
struct Svecteur * succ
Definition: vecteur-local.h:92
#define vecteur_val(v)
#define vecteur_var(v)
#define VECTEUR_NUL_P(v)

References make_polynome(), POLYNOME_NUL, polynome_succ, Svecteur::succ, VECTEUR_NUL_P, vecteur_val, and vecteur_var.

+ Here is the call graph for this function:

◆ plc_make_vvs_with_vector()

list plc_make_vvs_with_vector ( Pvecteur  v)

========================================================================

list plc_make_vvs_with_vector(Pvecteur v): computes a substitution from a vector representing the following equality: v = 0

We do a Gauss-Jordan elimination on "v", the equation is transformed into a substitution.

For example, with the equation: C1 - C2 = 0

we can eliminate one of the two variables C1 or C2), the substitution may be: C2 <– C1

we sort the variables of this vector in order to try the elimination in the following order: first the CONST_COEFF, second the PARAM_COEFF, third the INDEX_COEFF, last the MU_COEFF.

We look, in lc, for a variable that we can eliminate in v, i.e. with a coefficient equal to 1 or -1.

Definition at line 668 of file vvs.c.

670 {
671  list vvs = NIL, lc;
672  bool var_not_found;
673  entity crt_var = entity_undefined;
674  int crt_val = 0;
675  Pvecteur pv_elim;
676 
677  /* we sort the variables of this vector in order to try the elimination in
678  * the following order: first the CONST_COEFF, second the PARAM_COEFF,
679  * third the INDEX_COEFF, last the MU_COEFF.
680  */
681 
683 
684  /* We look, in lc, for a variable that we can eliminate in v, i.e. with a
685  * coefficient equal to 1 or -1.
686  */
687  var_not_found = true;
688  for(; (lc != NIL) && var_not_found; lc = CDR(lc)) {
689  crt_var = ENTITY(CAR(lc));
690  crt_val = (int) vect_coeff((Variable) crt_var, v);
691  if((crt_val == 1) || (crt_val == -1))
692  var_not_found = false;
693  }
694  if(! var_not_found) {
695  pv_elim = vect_cl2_ofl_ctrl((crt_val)*(-1), v, 1,
696  vect_new((Variable) crt_var, 1),
697  NO_OFL_CTRL);
698  vvs = make_vvs(crt_var, 1, pv_elim);
699  }
700 
701  if(get_debug_level() > 5) {
702  fprintf(stderr, "[plc_make_vvs_with_dist] \t\t\tDist vvs:\n");
703  fprint_vvs(stderr, vvs);
704  fprintf(stderr, "\n");
705  }
706 
707  return(vvs);
708 }
void const char const char const int
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
list general_merge_sort(list, bool(*)(void))
bool compare_coeff(chunk *c1, chunk *c2)
========================================================================
Definition: utils.c:161
#define entity_undefined
Definition: ri.h:2761
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
void fprint_vvs(FILE *fp, list vvs)
========================================================================
Definition: vvs.c:146
list make_vvs(entity var, int coeff, Pvecteur val)
========================================================================
Definition: vvs.c:113

References CAR, CDR, compare_coeff(), ENTITY, entity_undefined, fprint_vvs(), fprintf(), general_merge_sort(), get_debug_level(), int, make_vvs(), NIL, NO_OFL_CTRL, vect_cl2_ofl_ctrl(), vect_coeff(), vect_new(), and vecteur_to_list().

Referenced by solve_system_by_succ_elim().

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

◆ sc_to_vvs()

list sc_to_vvs ( Psysteme  sc,
list  var_l 
)

========================================================================

list sc_to_vvs(sc, var_l): returns the substitution equivalent to the system given in argument knowing that the substituted variables are contained in "var_l", in the same order. Then, their must be as many var in "var_l" as there are equalities in "sc".

We have: val.var + v = 0 => var = -val.v, with val in {1, -1} however: V = val.var + v => v = V - val.var so: var = -val(V - val.var) => var = -val.V + (val)^2.var => var = -val.V + var

Definition at line 382 of file vvs.c.

385 {
386  list vvs = NIL;
387 
388  Pcontrainte pc;
389  Pvecteur pv_elim;
390 
391  for(pc = sc->egalites ; pc != NULL; pc = pc->succ, var_l = CDR(var_l))
392  {
393  bool var_not_found = true;
394  Pvecteur pv = pc->vecteur;
395  entity var = ENTITY(CAR(var_l));
396 
397  for( ; !VECTEUR_NUL_P(pv) && var_not_found; )
398  {
399  if( ((pv->val == 1) || (pv->val == -1)) && (pv->var != TCST) )
400  {
401  if(same_entity_p((entity) pv->var, var))
402  var_not_found = false;
403  else
404  pv = pv->succ;
405  }
406  else
407  pv = pv->succ;
408  }
409  if(! var_not_found)
410  {
411  /* We have: val.var + v = 0 => var = -val.v, with val in {1, -1}
412  * however: V = val.var + v => v = V - val.var
413  * so: var = -val(V - val.var) => var = -val.V + (val)^2.var => var = -val.V + var
414  */
415  pv_elim = vect_cl2_ofl_ctrl((pv->val)*(-1), pc->vecteur, 1,
416  vect_new(pv->var, 1),
417  NO_OFL_CTRL);
418 
419  vvs = compose_vvs(vvs, CONS(VAR_VAL, MAKE_VV(var, 1, pv_elim), NIL));
420  }
421  else
422  user_error("sc_to_vvs", "The var must in the equality\n");
423  }
424  return(vvs);
425 }
Value val
Definition: vecteur-local.h:91
Variable var
Definition: vecteur-local.h:90
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
list compose_vvs(list vv1, list vv2)
========================================================================
Definition: vvs.c:274

References CAR, CDR, compose_vvs(), CONS, ENTITY, MAKE_VV, NIL, NO_OFL_CTRL, same_entity_p(), Scontrainte::succ, Svecteur::succ, TCST, user_error, Svecteur::val, Svecteur::var, VAR_VAL, vect_cl2_ofl_ctrl(), vect_new(), Scontrainte::vecteur, and VECTEUR_NUL_P.

Referenced by compose_vvs().

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

◆ vvs_faisabilite()

bool vvs_faisabilite ( list  vvs)

========================================================================

Definition at line 449 of file vvs.c.

451 {
452  Psysteme ps;
453  ps = vvs_to_sc(vvs);
455 }
bool sc_rational_feasibility_ofl_ctrl(Psysteme sc, int ofl_ctrl, bool ofl_res)
Psysteme vvs_to_sc(list vvs)
========================================================================
Definition: vvs.c:429

References NO_OFL_CTRL, sc_rational_feasibility_ofl_ctrl(), and vvs_to_sc().

+ Here is the call graph for this function:

◆ vvs_on_polynome()

Ppolynome vvs_on_polynome ( list  vvs,
Ppolynome  pp 
)

========================================================================

Special treatment if there is only one sub

Definition at line 465 of file vvs.c.

468 {
469  list avvs, used_vars;
470 
471  if(vvs == NIL)
472  return(pp);
473 
474  /* Special treatment if there is only one sub */
475  if(CDR(vvs) == NIL) {
476  var_val vv = VAR_VAL(CAR(vvs));
477  Variable var = (Variable) var_val_variable(vv);
478  int c = VV_COEFF(vv);
479  Pvecteur pv = (Pvecteur) VV_VAL(vv);
480  Ppolynome ppv = vecteur_to_polynome(pv);
481 
482  if(c != 1)
483  user_error("vvs_on_polynome", "Coeff is not 1\n");
484  else
485  pp = prototype_var_subst(pp, var, ppv);
486 
487  return(pp);
488  }
489 
491 
492  for(avvs = vvs; !ENDP(avvs) && !ENDP(used_vars); POP(avvs)) {
493  var_val vv = VAR_VAL(CAR(avvs));
494  entity var = VV_VAR(vv);
495  int c = VV_COEFF(vv);
496  list prec, curr;
497  bool found = false;
498 
499  if(c != 1)
500  user_error("vvs_on_polynome", "Coeff is not 1\n");
501 
502  for(curr = used_vars, prec = NIL; !ENDP(curr) && (!found); POP(curr)) {
503  if(same_entity_p(var, ENTITY(CAR(curr)))) {
504  found = true;
505  if(prec == NIL)
506  used_vars = CDR(used_vars);
507  else
508  CDR(prec) = CDR(curr);
509  }
510  prec = curr;
511  }
512 
513  if(found) {
514  Pvecteur pv = (Pvecteur) VV_VAL(vv);
515  Ppolynome ppv = vecteur_to_polynome(pv);
516 
517  pp = prototype_var_subst(pp, (Variable) var, ppv);
518  }
519  }
520 
521  return(pp);
522 }
list base_to_list(Pbase base)
Most includes are centralized here.
bool pu_is_inferior_var(Variable, Variable)
Ppolynome prototype_var_subst(Ppolynome, Variable, Ppolynome)
=================================================================
Definition: utils.c:1978
#define var_val_variable(x)
Definition: paf_ri.h:793
Ppolynome vecteur_to_polynome(Pvecteur pv)
===========================================================================
Definition: pnome-bin.c:406
Pbase polynome_used_var(Ppolynome pp, int *is_inferior_var)
Pbase polynome_used_var(Ppolynome pp, bool *is_inferior_var()) PRIVATE Returns, in a Pbase,...
Definition: pnome-reduc.c:204
bool(* argh)(Pvecteur *, Pvecteur *)
Definition: vvs.c:457

References base_to_list(), CAR, CDR, ENDP, ENTITY, NIL, polynome_used_var(), POP, prototype_var_subst(), pu_is_inferior_var(), same_entity_p(), user_error, VAR_VAL, var_val_variable, vecteur_to_polynome(), VV_COEFF, VV_VAL, and VV_VAR.

Referenced by is_not_trivial_p(), plc_make_distance(), prgm_mapping(), valuer(), and vvs_on_prototypes().

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

◆ vvs_on_systeme()

Psysteme vvs_on_systeme ( list  vvs,
Psysteme  ps 
)

========================================================================

Psysteme vvs_on_systeme(list vvs, Psysteme ps): applies the substitution "s" on the system "ps". The substitution is done directly on "ps" ; so, it is modified and is the returned value.

We substitute "pv" to "c.e" in ps.

Definition at line 567 of file vvs.c.

570 {
571  Psysteme new_ps = ps;
572  list avvs;
573 
574  if(ENDP(vvs))
575  return(ps);
576 
577  for(avvs = vvs; !ENDP(avvs) ; POP(avvs)) {
578  var_val vv = VAR_VAL(CAR(avvs));
579  entity e = VV_VAR(vv);
580  int c = VV_COEFF(vv);
581  Pvecteur pv = (Pvecteur) VV_VAL(vv);
582 
583  /* We substitute "pv" to "c.e" in ps. */
584  substitute_var_with_vec(new_ps, e, c, pv);
585  }
586 
587  return(new_ps);
588 }
void substitute_var_with_vec(Psysteme, entity, Value, Pvecteur)
===========================================================================
Definition: utils.c:1210

References CAR, ENDP, POP, substitute_var_with_vec(), VAR_VAL, VV_COEFF, VV_VAL, and VV_VAR.

Referenced by valuer().

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

◆ vvs_on_vecteur()

Pvecteur vvs_on_vecteur ( list  vvs,
Pvecteur  pv 
)

========================================================================

Pvecteur vvs_on_vecteur(list vvs, Pvecteur pv): applies the substitution "s" on the vecteur "pv". The substitution is done directly on "pv" ; so, it is modified and is the returned value.

We substitute "vvpv" to "vve" in "pv".

We delete the occurence of "vve"...

... and we add "val*vvpv" to "pv".

Definition at line 530 of file vvs.c.

533 {
534  list avvs;
535 
536  if(ENDP(vvs))
537  return(pv);
538 
539  for(avvs = vvs; !ENDP(avvs) ; POP(avvs)) {
540  var_val vv = VAR_VAL(CAR(avvs));
541  entity vve = VV_VAR(vv);
542  int vvc = VV_COEFF(vv);
543  Pvecteur vvpv = (Pvecteur) VV_VAL(vv);
544  Value val = vect_coeff((Variable) vve, pv);
545 
546  if(vvc != 1)
547  user_error("vvs_on_vecteur", "Coeff is not 1\n");
548 
549  /* We substitute "vvpv" to "vve" in "pv". */
550  if(val != 0) {
551  /* We delete the occurence of "vve"... */
552  vect_erase_var(&pv, (Variable) vve);
553 
554  /* ... and we add "val*vvpv" to "pv". */
555  pv = vect_cl_ofl_ctrl(pv, val, vvpv, NO_OFL_CTRL);
556  }
557  }
558  return(pv);
559 }
int Value
Pvecteur vect_cl_ofl_ctrl(Pvecteur v, Value lambda, Pvecteur u, int ofl_ctrl)
Pvecteur vect_cl_ofl_ctrl(Pvecteur v, Value lambda, Pvecteur u, int ofl_ctrl): etape d'acculumulation...
Definition: binaires.c:128

References CAR, ENDP, NO_OFL_CTRL, POP, user_error, VAR_VAL, vect_cl_ofl_ctrl(), vect_coeff(), vect_erase_var(), VV_COEFF, VV_VAL, and VV_VAR.

Referenced by solve_system_by_succ_elim().

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

◆ vvs_on_vvs()

list vvs_on_vvs ( list  vv1,
list  vv2 
)

========================================================================

Definition at line 198 of file vvs.c.

200 {
201  list l1, l2, new_vvs = gen_concatenate(vv2, NIL);
202 
203  for(l1 = vv1; !ENDP(l1); POP(l1)) {
204  var_val v1 = VAR_VAL(CAR(l1));
205  entity e1 = VV_VAR(v1);
206  int c1 = VV_COEFF(v1);
207  Pvecteur pv1 = (Pvecteur) VV_VAL(v1);
208 
209  for(l2 = new_vvs; !ENDP(l2); POP(l2)) {
210  var_val v2 = VAR_VAL(CAR(l2));
211  entity e2 = VV_VAR(v2);
212  int c2 = VV_COEFF(v2);
213  Pvecteur pv2 = (Pvecteur) VV_VAL(v2);
214 
215  if(same_entity_p(e1, e2)) {
216  list il, el, aux_vvs;
217  Psysteme aps1 = sc_new(), aps2;
218  Pvecteur pv;
219  int p;
220 
221  p = ppcm(c1, c2);
222  pv = vect_cl2_ofl_ctrl((p/c1), pv1, -(p/c2), pv2, NO_OFL_CTRL);
223 
224  il = vecteur_to_list(pv);
225  sc_add_egalite(aps1, contrainte_make(pv));
226 
227  aps2 = elim_var_with_eg(aps1, &il, &el);
228  aux_vvs = make_vvs_from_sc(aps2, el);
229 
230  if(ENDP(aux_vvs))
231  return(NIL);
232  if(!ENDP(CDR(aux_vvs)))
233  user_error("vvs_on_vvs", "There are more than one vv\n");
234 
235  CDR(aux_vvs) = CDR(l2);
236  CDR(l2) = aux_vvs;
237  }
238  else {
239  int cc2, g;
240  if( (cc2 = vect_coeff((Variable) e1, pv2)) != 0 ) {
241  g = pgcd(cc2, c1);
242  vect_erase_var(&pv2, (Variable) e1);
244  (vect_cl2_ofl_ctrl((c1/g), pv2, (cc2/g), pv1, NO_OFL_CTRL));
245  }
246  }
247  }
248  }
249  return(new_vvs);
250 }
list gen_concatenate(const list l1x, const list l2x)
concatenate two lists.
Definition: list.c:436
list make_vvs_from_sc(Psysteme ps_aux, list var_l)
========================================================================
Definition: vvs.c:610

References CAR, CDR, contrainte_make(), elim_var_with_eg(), ENDP, gen_concatenate(), make_vvs_from_sc(), newgen_Pvecteur, NIL, NO_OFL_CTRL, pgcd, POP, ppcm(), same_entity_p(), sc_add_egalite(), sc_new(), user_error, VAR_VAL, vect_cl2_ofl_ctrl(), vect_coeff(), vect_erase_var(), vecteur_to_list(), VV_COEFF, VV_VAL, VV_VAL_, and VV_VAR.

Referenced by valuer().

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

◆ vvs_to_sc()

Psysteme vvs_to_sc ( list  vvs)

========================================================================

Definition at line 429 of file vvs.c.

431 {
432  Psysteme ps = sc_new();
433 
434  for( ; !ENDP(vvs) ; POP(vvs)) {
435  var_val vv = VAR_VAL(CAR(vvs));
436  entity v = VV_VAR(vv);
437  int c = VV_COEFF(vv);
438  Pvecteur pv = (Pvecteur) VV_VAL(vv);
439 
440  vect_add_elem(&pv, (Variable) v, -c);
442  }
443  sc_creer_base(ps);
444  return(ps);
445 }
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72

References CAR, contrainte_make(), ENDP, POP, sc_add_egalite(), sc_creer_base(), sc_new(), VAR_VAL, vect_add_elem(), VV_COEFF, VV_VAL, and VV_VAR.

Referenced by vvs_faisabilite().

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