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

Function unary

gecode/int/unary.cpp:43–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41namespace Gecode {
42
43 void
44 unary(Home home, const IntVarArgs& s, const IntArgs& p, IntPropLevel ipl) {
45 using namespace Gecode::Int;
46 using namespace Gecode::Int::Unary;
47 if (same(s))
48 throw Int::ArgumentSame("Int::unary");
49 if (s.size() != p.size())
50 throw Int::ArgumentSizeMismatch("Int::unary");
51 for (int i=0; i<p.size(); i++) {
52 Int::Limits::nonnegative(p[i],"Int::unary");
53 Int::Limits::check(static_cast<long long int>(s[i].max()) + p[i],
54 "Int::unary");
55 }
56 GECODE_POST;
57 bool allOne = true;
58 for (int i=0; i<p.size(); i++) {
59 if (p[i] != 1) {
60 allOne = false;
61 break;
62 }
63 }
64 if (allOne) {
65 ViewArray<IntView> xv(home,s);
66 switch (vbd(ipl)) {
67 case IPL_BND:
68 GECODE_ES_FAIL(Distinct::Bnd<IntView>::post(home,xv));
69 break;
70 case IPL_DOM:
71 GECODE_ES_FAIL(Distinct::Dom<IntView>::post(home,xv));
72 break;
73 default:
74 GECODE_ES_FAIL(Distinct::Val<IntView>::post(home,xv));
75 }
76 } else {
77 TaskArray<ManFixPTask> t(home,s.size());
78 for (int i=0; i<s.size(); i++)
79 t[i].init(s[i],p[i]);
80 GECODE_ES_FAIL(manpost(home,t,ipl));
81 }
82 }
83
84 void
85 unary(Home home, const TaskTypeArgs& t,

Callers 15

postMethod · 0.85
postMethod · 0.85
postMethod · 0.85
postMethod · 0.85
costMethod · 0.85
costMethod · 0.85
costMethod · 0.85
nooverloadMethod · 0.85
p_cumulativesFunction · 0.85
p_schedule_unaryFunction · 0.85
costMethod · 0.85

Calls 10

sameFunction · 0.50
checkFunction · 0.50
postFunction · 0.50
sizeMethod · 0.45
maxMethod · 0.45
initMethod · 0.45
oneMethod · 0.45
gqMethod · 0.45
assignedMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected