PIPS
sc_belong.c
Go to the documentation of this file.
1 /*
2 
3  $Id: sc_belong.c 1641 2016-03-02 08:20:19Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of Linear/C3 Library.
8 
9  Linear/C3 Library is free software: you can redistribute it and/or modify it
10  under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  Linear/C3 Library is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with Linear/C3 Library. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 
25  /* package sc */
26 
27 #ifdef HAVE_CONFIG_H
28  #include "config.h"
29 #endif
30 
31 #include <stdio.h>
32 #include <string.h>
33 #include <stdlib.h>
34 
35 #include "boolean.h"
36 #include "arithmetique.h"
37 #include "vecteur.h"
38 #include "contrainte.h"
39 #include "sc.h"
40 
41 /* Check if the integer point defined by vector v belongs to the set
42  defined by the constraints of ps. The point is defined according to
43  the basis b of ps. Any non-zero coefficient in pv is ignored if the
44  corresponding variable does not appear in the basis of ps. An
45  variable/dimension of ps that does not appear in pv has value 0. In
46  other word, v is projected onto the space defined by b.
47 
48  This function is primarily defined to be called from the debugger
49  gdb or in debugging code.
50  */
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 }
72 
73 /* Check if the integer point defined by vector v is stricly inside
74  the set defined by the constraints of ps. The point is defined
75  according to the basis b of ps. Any non-zero coefficient in pv is
76  ignored if the corresponding variable does not appear in the basis
77  of ps. An variable/dimension of ps that does not appear in pv has
78  value 0. In other word, v is projected onto the space defined by b.
79 
80  This function is defined to be called in the debugger gdb or in
81  debugging code. But it may also be useful to check if a vertex of a
82  generating system is significant or not with respect to ps. If it
83  is found internal, it is not significant.
84  */
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)
#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
Value contrainte_eval(Pvecteur, Pvecteur)
Evaluate constraint c according to values in v and return the constant obtained.
Definition: predicats.c:331
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 o...
Definition: sc_belong.c:85
bool sc_belongs_p(Psysteme ps, Pvecteur v)
package sc
Definition: sc_belong.c:51
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