MCPcopy Create free account
hub / github.com/Gecode/gecode / post

Function post

gecode/int/linear/int-post.cpp:218–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216 }
217
218 void
219 post(Home home, Term<IntView>* t, int n, IntRelType irt, int c,
220 IntPropLevel ipl) {
221
222 Limits::check(c,"Int::linear");
223
224 long long int d = c;
225
226 eliminate(t,n,d);
227
228 Term<IntView> *t_p, *t_n;
229 int n_p, n_n, gcd=1;
230 bool is_unit = normalize<IntView>(t,n,t_p,n_p,t_n,n_n,gcd);
231
232 rewrite(irt,d,t_p,n_p,t_n,n_n);
233
234 // Divide by gcd
235 if (gcd > 1) {
236 switch (irt) {
237 case IRT_EQ:
238 if ((d % gcd) != 0) {
239 home.fail();
240 return;
241 }
242 d /= gcd;
243 break;
244 case IRT_NQ:
245 if ((d % gcd) != 0)
246 return;
247 d /= gcd;
248 break;
249 case IRT_LQ:
250 d = floor_div_xp(d,static_cast<long long int>(gcd));
251 break;
252 default: GECODE_NEVER;
253 }
254 }
255
256 if (n == 0) {
257 switch (irt) {
258 case IRT_EQ: if (d != 0) home.fail(); break;
259 case IRT_NQ: if (d == 0) home.fail(); break;
260 case IRT_LQ: if (d < 0) home.fail(); break;
261 default: GECODE_NEVER;
262 }
263 return;
264 }
265
266 if (n == 1) {
267 if (n_p == 1) {
268 LLongScaleView y(t_p[0].a,t_p[0].x);
269 switch (irt) {
270 case IRT_EQ: GECODE_ME_FAIL(y.eq(home,d)); break;
271 case IRT_NQ: GECODE_ME_FAIL(y.nq(home,d)); break;
272 case IRT_LQ: GECODE_ME_FAIL(y.lq(home,d)); break;
273 default: GECODE_NEVER;
274 }
275 } else {

Callers 15

propagateMethod · 0.70
postMethod · 0.70
propagateMethod · 0.70
postMethod · 0.70
propagateMethod · 0.70
post_naryFunction · 0.70
propagateMethod · 0.70
relFunction · 0.50
clauseFunction · 0.50
iteFunction · 0.50
distinctFunction · 0.50
nooverlapFunction · 0.50

Calls 15

floor_div_xpFunction · 0.85
precisionFunction · 0.85
eliminateFunction · 0.70
rewriteFunction · 0.70
checkFunction · 0.50
BoolViewClass · 0.50
MinusViewClass · 0.50
failMethod · 0.45
eqMethod · 0.45
nqMethod · 0.45
lqMethod · 0.45
gqMethod · 0.45

Tested by

no test coverage detected