PIPS
integrer.c File Reference
#include <stdio.h>
#include "pip__type.h"
#include "pip__tab.h"
+ Include dependency graph for integrer.c:

Go to the source code of this file.

Functions

Entier sol_mod (Entier x, Entier y)
 
int non_borne (Tableau *tp, int nvar, Entier D, int bigparm)
 
Tableauexpanser ()
 
int integrer (Tableau **ptp, Tableau **pcontext, int D, int *pnvar, int *pnparm, int *pni, int *pnc)
 

Function Documentation

◆ expanser()

Tableau* expanser ( )

Referenced by integrer(), pip_solve(), and pip_solve_min_with_big().

+ Here is the caller graph for this function:

◆ integrer()

int integrer ( Tableau **  ptp,
Tableau **  pcontext,
int  D,
int pnvar,
int pnparm,
int pni,
int pnc 
)

attention, en cas de succes, nligne augmente l'echec ne peut donc etre marque par une valeur superieure a nligne

y a t'il de la place ?

Definition at line 56 of file integrer.c.

60 {int ncol = *pnvar+*pnparm+1;
61  int nligne = *pnvar + *pni;
62  Entier coupure[MAXCOL];
63  int i, j, k, ff;
64  Entier x, d;
65  int ok_var, ok_const, ok_parm;
66  if(D == 1) return(-1); /* attention, en cas de succes, nligne augmente
67  l'echec ne peut donc etre marque par une valeur
68  superieure a nligne */
69  if(ncol >= MAXCOL) {
70  fprintf(stderr, "Trop de colonnes : %d\n", ncol);
71  exit(3);
72  }
73  for(i = 0; i<*pnvar; i++)
74  {
75  ff = Flag(*ptp, i);
76  if(ff & Unit)continue;
77  ok_var = False;
78  for(j = 0; j<*pnvar; j++)
79  {x = coupure[j] = sol_mod(Index(*ptp, i, j), D);
80  if(x > 0) ok_var = True;
81  }
82  if(! ok_var) continue;
83  x = coupure[*pnvar] = - sol_mod(-Index(*ptp, i, *pnvar), D);
84  ok_const = (x != 0);
85  d = x;
86  ok_parm = False;
87  for(j = (*pnvar)+1; j<ncol; j++)
88  {
89  x = coupure[j] = - sol_mod(- Index(*ptp, i, j), D);
90  d = sol_pgcd(d, x);
91  if(x != 0) ok_parm = True;
92  }
93 #if (DEBUG > 2)
94  Q{printf("%ld/cut : %d %d #[", cross_product, *pnvar, *pnparm);
95  for(j = 0; j<ncol; j++)printf(" %d",coupure[j]);
96  printf("]/ %d\n", D);
97  }
98 #endif
99  if(ok_parm)
100  {
101  Entier discrp[MAXPARM], discrm[MAXPARM];
102  if(*pnparm >= MAXPARM) {
103  fprintf(stderr, "Trop de parametres : %d\n", *pnparm);
104  exit(4);
105  }
106  d = sol_pgcd(d, D);
107  sol_new(*pnparm);
108  sol_div();
109  sol_forme(*pnparm+1);
110  for(j = 0; j<*pnparm; j++)sol_val(-coupure[j+*pnvar+1]/d, 1);
111  sol_val(-coupure[*pnvar]/d, 1);
112  sol_val(D/d, 1);
113  for(j = 0; j<*pnparm; j++)
114  {x = coupure[j+*pnvar+1];
115  discrp[j] = -x;
116  discrm[j] = x;
117  }
118  discrp[*pnparm] = -D;
119  discrm[*pnparm] = D;
120  x = coupure[*pnvar];
121  discrp[(*pnparm)+1] = -x;
122  discrm[(*pnparm)+1] = -x + D -1;
123  if((*pnc) +2 > (*pcontext)->height ||
124  (*pnparm) + 2 > (*pcontext)->width)
125  {int dcw, dch;
126  dcw = llog(D);
127  dch = 2 * dcw + *pni;
128  Flag(*pcontext, *pnc) = 0;
129  *pcontext = expanser(*pcontext, 0, *pnc, *pnparm+1, 0,
130  dch, dcw);
131  }
132  (*pnparm)++;
133  for(k = 0; k < *pnc; k++)
134  {Index(*pcontext, k, *pnparm) =
135  Index(*pcontext, k, (*pnparm)-1);
136  Index(*pcontext, k, (*pnparm)-1) = 0;
137  }
138  for(j = 0; j <= *pnparm; j++)
139  {Index(*pcontext, *pnc, j) = discrp[j];
140  Index(*pcontext, *pnc + 1, j) = discrm[j];
141  }
142  Flag(*pcontext, *pnc) = Unknown;
143  Flag(*pcontext, *pnc+1) = Unknown;
144  (*pnc) += 2;
145  coupure[ncol] = D;
146  break;
147  }
148  else if(ok_const)break;
149  }
150  if(i >= *pnvar)return(-1);
151  if(i < *pnvar)
152  {/* y a t'il de la place ? */
153  if(nligne >= (*ptp)->height || ncol >= (*ptp)->width)
154  {int d, dth, dtw;
155  int llog();
156  d = llog(D);
157  dth = d + (*pnparm? *pni : 0);
158  dtw = (*pnparm ? d : 0);
159  *ptp = expanser(*ptp, *pnvar, *pni, ncol, 0, dth, dtw);
160  }
161  ncol = *pnvar + *pnparm + 1;
162  Flag(*ptp, nligne) = Minus;
163  for(j = 0; j<ncol; j++) Index(*ptp, nligne, j) = coupure[j];
164  for(j = ncol; j < (*ptp)->width; j++) Index(*ptp, nligne, j) =0;
165  (*pni)++;
166  }
167  return(nligne);
168 }
#define D(A)
Definition: iabrev.h:56
Entier sol_mod(Entier x, Entier y)
Definition: integrer.c:31
Tableau * expanser()
long int cross_product
Definition: pip.c:91
#define exit(code)
Definition: misc-local.h:54
void sol_new()
int sol_pgcd()
void sol_div()
Definition: sol.c:151
void sol_val()
#define Index(p, i, j)
Definition: pip__tab.h:45
#define Unknown
Definition: pip__tab.h:41
#define Flag(p, i)
Definition: pip__tab.h:46
#define Unit
Definition: pip__tab.h:36
#define Minus
Definition: pip__tab.h:38
#define Entier
Definition: pip__type.h:24
#define MAXPARM
Definition: pip__type.h:42
#define False
Definition: pip__type.h:33
#define Q
Definition: pip__type.h:39
#define True
Definition: pip__type.h:32
#define MAXCOL
Definition: pip__type.h:41
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
int printf()
void sol_forme(int l)
Definition: sol.c:133
static char * x
Definition: split_file.c:159
int llog(Entier x)
Definition: traiter.c:39

References cross_product, D, Entier, exit, expanser(), False, Flag, fprintf(), Index, llog(), MAXCOL, MAXPARM, Minus, printf(), Q, sol_div(), sol_forme(), sol_mod(), sol_new(), sol_pgcd(), sol_val(), True, Unit, Unknown, and x.

Referenced by traiter().

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

◆ non_borne()

int non_borne ( Tableau tp,
int  nvar,
Entier  D,
int  bigparm 
)

Definition at line 39 of file integrer.c.

43 {int i, ff;
44  for(i = 0; i<nvar; i++)
45  {ff = Flag(tp, i);
46  if(bigparm > 0)
47  {if(ff & Unit)return(True);
48  if(Index(tp, i, bigparm) != D) return(True);
49  }
50  }
51  return(False);
52 }

References D, False, Flag, Index, True, and Unit.

Referenced by primal_pivot().

+ Here is the caller graph for this function:

◆ sol_mod()

Entier sol_mod ( Entier  x,
Entier  y 
)

Definition at line 31 of file integrer.c.

33 {Entier r;
34  r = x % y;
35  if(r<0) r += y;
36  return(r);
37 }

References Entier, and x.

Referenced by integrer().

+ Here is the caller graph for this function: