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

Method post

gecode/float/arithmetic/pow-nroot.hpp:48–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47 template<class A, class B>
48 ExecStatus
49 Pow<A,B>::post(Home home, A x0, B x1, int n) {
50 if (n == 0) {
51 if ((x0.min() == 0.0) && (x0.max() == 0.0)) return ES_FAILED;
52 GECODE_ME_CHECK(x1.eq(home,1.0));
53 return ES_OK;
54 }
55
56 GECODE_ME_CHECK(x1.eq(home,pow(x0.domain(),n)));
57 if ((x1.min() == 0.0) && (x1.max() == 0.0)) {
58 GECODE_ME_CHECK(x1.eq(home,0.0));
59 return ES_OK;
60 }
61
62 if ((n % 2) == 0) {
63 if (x0.min() >= 0)
64 GECODE_ME_CHECK(x0.eq(home,nroot(x1.domain(),n)));
65 else if (x0.max() <= 0)
66 GECODE_ME_CHECK(x0.eq(home,-nroot(x1.domain(),n)));
67 else
68 GECODE_ME_CHECK(x0.eq(home,
69 hull(
70 nroot(x1.domain(),n),
71 -nroot(x1.domain(),n)
72 )
73 ));
74 } else {
75 GECODE_ME_CHECK(x0.eq(home,nroot(x1.domain(),n)));
76 }
77
78 if (!x0.assigned()) (void) new (home) Pow<A,B>(home,x0,x1,n);
79 return ES_OK;
80 }
81
82 template<class A, class B>
83 forceinline

Callers

nothing calls this directly

Calls 9

powFunction · 0.50
nrootFunction · 0.50
hullFunction · 0.50
minMethod · 0.45
maxMethod · 0.45
eqMethod · 0.45
domainMethod · 0.45
assignedMethod · 0.45
gqMethod · 0.45

Tested by

no test coverage detected