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

Go to the source code of this file.

Functions

bool sc_belongs_p (Psysteme ps, Pvecteur v)
 package sc More...
 
bool sc_internal_p (Psysteme ps, Pvecteur v)
 Check if the integer point defined by vector v is stricly inside the set defined by the constraints of ps. More...
 

Function Documentation

◆ sc_belongs_p()

bool sc_belongs_p ( Psysteme  ps,
Pvecteur  v 
)

package sc

Check if the integer point defined by vector v belongs to the set defined by the constraints of ps. The point is defined according to the basis b of ps. Any non-zero coefficient in pv is ignored if the corresponding variable does not appear in the basis of ps. An variable/dimension of ps that does not appear in pv has value 0. In other word, v is projected onto the space defined by b.

This function is primarily defined to be called from the debugger gdb or in debugging code.

Definition at line 51 of file sc_belong.c.

52 {
54  bool belongs_p = true;
55 
56  for (eq = ps->egalites;
57  !CONTRAINTE_UNDEFINED_P(eq) && belongs_p;
58  eq = eq->succ) {
60  belongs_p = equality_eval_p(c, v);
61  }
62 
63  for (eq = ps->inegalites;
64  !CONTRAINTE_UNDEFINED_P(eq) && belongs_p;
65  eq = eq->succ) {
67  belongs_p = inequality_eval_p(c, v);
68  }
69 
70  return belongs_p;
71 }
#define CONTRAINTE_UNDEFINED_P(c)
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
bool equality_eval_p(Pvecteur, Pvecteur)
Definition: predicats.c:369
bool inequality_eval_p(Pvecteur, Pvecteur)
Definition: predicats.c:374
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89

References CONTRAINTE_UNDEFINED_P, contrainte_vecteur, Ssysteme::egalites, eq, equality_eval_p(), Ssysteme::inegalites, inequality_eval_p(), and Scontrainte::succ.

Referenced by build_sc_nredund_2pass_ofl_ctrl().

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

◆ sc_internal_p()

bool sc_internal_p ( Psysteme  ps,
Pvecteur  v 
)

Check if the integer point defined by vector v is stricly inside the set defined by the constraints of ps.

The point is defined according to the basis b of ps. Any non-zero coefficient in pv is ignored if the corresponding variable does not appear in the basis of ps. An variable/dimension of ps that does not appear in pv has value 0. In other word, v is projected onto the space defined by b.

This function is defined to be called in the debugger gdb or in debugging code. But it may also be useful to check if a vertex of a generating system is significant or not with respect to ps. If it is found internal, it is not significant.

The equations must be met exactly

For the convex set defined by ps to have some kind of inside, ps must contain at least one inequality.

Definition at line 85 of file sc_belong.c.

86 {
88  bool internal_p = true;
89  bool belongs_p = true;
90 
91  /* The equations must be met exactly */
92  for (eq = ps->egalites;
93  CONTRAINTE_UNDEFINED_P(eq) && belongs_p;
94  eq = eq->succ) {
96  belongs_p = equality_eval_p(c, v);
97  }
98 
99  /* For the convex set defined by ps to have some kind of inside, ps
100  must contain at least one inequality. */
101  if(CONTRAINTE_UNDEFINED_P(sc_inegalites(ps)))
102  internal_p = false;
103 
104  for (eq = ps->inegalites;
105  CONTRAINTE_UNDEFINED_P(eq) && belongs_p && internal_p;
106  eq = eq->succ) {
108  Value r = contrainte_eval(c, v);
109  internal_p = value_neg_p(r);
110  // belongs_p = value_negz_p(r); seems redundant with internal_p, a
111  // stronger condition
112  }
113 
114  return internal_p;
115 }
int Value
#define value_neg_p(val)
Value contrainte_eval(Pvecteur, Pvecteur)
Evaluate constraint c according to values in v and return the constant obtained.
Definition: predicats.c:331

References contrainte_eval(), CONTRAINTE_UNDEFINED_P, contrainte_vecteur, Ssysteme::egalites, eq, equality_eval_p(), Ssysteme::inegalites, Scontrainte::succ, and value_neg_p.

+ Here is the call graph for this function: