本文整理汇总了C++中FloatVal类的典型用法代码示例。如果您正苦于以下问题:C++ FloatVal类的具体用法?C++ FloatVal怎么用?C++ FloatVal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FloatVal类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
ExecStatus
ReLeFloat<View,CtrlView,rm>::post(Home home, View x, FloatVal c, CtrlView b) {
if (b.one()) {
if (rm != RM_PMI)
{
GECODE_ME_CHECK(x.lq(home,c.max()));
if (x.assigned() && (x.max() >= c.min()))
return ES_FAILED;
(void) new (home) ReLeFloat<View,CtrlView,rm>(home,x,c,b);
}
} else if (b.zero()) {
if (rm != RM_IMP)
GECODE_ME_CHECK(x.gq(home,c.min()));
} else {
switch (rtest_le(x,c)) {
case RT_TRUE:
if (rm != RM_IMP)
GECODE_ME_CHECK(b.one(home));
break;
case RT_FALSE:
if (rm != RM_PMI)
GECODE_ME_CHECK(b.zero(home));
break;
case RT_MAYBE:
(void) new (home) ReLeFloat<View,CtrlView,rm>(home,x,c,b);
break;
default: GECODE_NEVER;
}
}
return ES_OK;
}
示例2: GECODE_ME_CHECK
ExecStatus
Tan<A,B>::propagate(Space& home, const ModEventDelta&) {
GECODE_ME_CHECK(x1.eq(home,tan(x0.domain())));
FloatVal iv = fmod(x0.domain(),FloatVal::pi());
FloatNum offSet(Round.sub_down(x0.min(),iv.min()));
GECODE_ES_CHECK(aTanProject(x1,iv));
GECODE_ME_CHECK(x0.eq(home,iv + offSet));
return (x0.assigned() && x1.assigned()) ? home.ES_SUBSUMED(*this) : ES_FIX;
}
示例3: d
forceinline ModEvent
FloatVarImp::lq(Space& home, const FloatVal& n) {
if (n.max() >= dom.max()) return ME_FLOAT_NONE;
if (n.max() < dom.min()) return ME_FLOAT_FAILED;
FloatDelta d(n.min(),dom.max());
ModEvent me = ME_FLOAT_BND;
dom = intersect(dom,FloatVal(dom.min(),n.min()));
if (assigned()) me = ME_FLOAT_VAL;
GECODE_ASSUME((me == ME_FLOAT_VAL) |
(me == ME_FLOAT_BND));
return notify(home,me,d);
}
示例4: estimate
void
estimate(Term* t, int n, FloatVal c, FloatNum& l, FloatNum &u) {
FloatVal est = c;
for (int i=n; i--; )
est += t[i].a * t[i].x.domain();
FloatNum min = est.min();
FloatNum max = est.max();
if (min < Limits::min)
min = Limits::min;
if (min > Limits::max)
min = Limits::max;
l = min;
if (max < Limits::min)
max = Limits::min;
if (max > Limits::max)
max = Limits::max;
u = max;
}
示例5: aTanProject
ExecStatus aTanProject(const V& aTanIv, FloatVal& iv) {
#define I0__PI_2I FloatVal(0,pi_half_upper())
#define IPI_2__PII FloatVal(pi_half_lower(),pi_upper())
#define POS(X) ((I0__PI_2I.in(X))?0:1)
#define CASE(X,Y) case ((X << 2) | Y) :
#define SHIFTN_UP(N,X) Round.add_up(Round.mul_up(N,pi_upper()),X)
#define GROWING(I) Round.tan_down(iv.min()) <= Round.tan_up(iv.max())
#define ATANINF_DOWN Round.atan_down(aTanIv.min())
#define ATANSUP_UP Round.atan_up(aTanIv.max())
#define PI_UP pi_upper()
#define PI_DOWN pi_lower()
#define PI_TWICE_DOWN pi_twice_lower()
int n = iv.max() / pi_lower();
// 0 <=> in [0;PI/2]
// 1 <=> in [PI/2;PI]
switch ( (POS(iv.min()) << 2) | POS(Round.sub_up(iv.max(),Round.mul_up(n,PI_UP))) )
{
CASE(0,0)
if (GROWING(iv)) iv.assign(ATANINF_DOWN,SHIFTN_UP(n,ATANSUP_UP));
else if (Round.tan_down(iv.min()) <= aTanIv.max())
if (Round.tan_up(iv.max()) >= aTanIv.min()) break; // Nothing changed
else iv.assign(iv.min(),SHIFTN_UP(n-1, ATANSUP_UP));
else
if (Round.tan_up(iv.max()) >= aTanIv.min()) iv.assign(Round.add_down(PI_DOWN, ATANINF_DOWN), iv.max());
else { if (n <= 1) return ES_FAILED; else iv.assign(Round.add_down(PI_DOWN, ATANINF_DOWN), SHIFTN_UP(n-1, ATANSUP_UP)); }
break;
CASE(0,1)
if (Round.tan_down(iv.min()) <= aTanIv.max())
if (Round.tan_up(iv.max()) >= aTanIv.min()) break; // Nothing changed
else iv.assign(iv.min(), SHIFTN_UP(n,ATANSUP_UP));
else
if (Round.tan_up(iv.max()) >= aTanIv.min()) iv.assign(Round.add_down(PI_DOWN, ATANINF_DOWN), iv.max());
else { if (n <= 1) return ES_FAILED; else iv.assign(Round.add_down(PI_DOWN, ATANINF_DOWN), SHIFTN_UP(n,ATANSUP_UP)); }
break;
CASE(1,0)
iv.assign(Round.add_down(PI_DOWN, ATANINF_DOWN), SHIFTN_UP(n,ATANSUP_UP));
break;
CASE(1,1)
if (GROWING(iv)) iv.assign(Round.add_down(PI_DOWN, ATANINF_DOWN), SHIFTN_UP(n+1,ATANSUP_UP));
else if (Round.tan_down(iv.min()) <= aTanIv.max())
if (Round.tan_up(iv.max()) >= aTanIv.min()) break; // Nothing changed
else iv.assign(iv.min(), SHIFTN_UP(n,ATANSUP_UP));
else
if (Round.tan_up(iv.max()) >= aTanIv.min()) iv.assign(Round.add_down(PI_TWICE_DOWN, ATANINF_DOWN), iv.max());
else { if (n <= 1) return ES_FAILED; iv.assign(Round.add_down(PI_TWICE_DOWN, ATANINF_DOWN), SHIFTN_UP(n,ATANSUP_UP)); }
break;
default:
GECODE_NEVER;
break;
}
return ES_OK;
#undef PI_TWICE_DOWN
#undef PI_UP
#undef PI_DOWN
#undef ATANINF_DOWN
#undef ATANSUP_UP
#undef GROWING
#undef SHIFTN_UP
#undef CASE
#undef POS
#undef I0__PI_2I
#undef IPI_2__PII
}
示例6: dopost
void
dopost(Home home, Term* t, int n, FloatRelType frt, FloatVal c) {
Limits::check(c,"Float::linear");
for (int i=n; i--; )
if (t[i].x.assigned()) {
c -= t[i].a * t[i].x.val();
t[i]=t[--n];
}
if ((c < Limits::min) || (c > Limits::max))
throw OutOfLimits("Float::linear");
/*
* Join coefficients for aliased variables:
*
*/
{
// Group same variables
TermLess tl;
Support::quicksort<Term,TermLess>(t,n,tl);
// Join adjacent variables
int i = 0;
int j = 0;
while (i < n) {
Limits::check(t[i].a,"Float::linear");
FloatVal a = t[i].a;
FloatView x = t[i].x;
while ((++i < n) && same(t[i].x,x)) {
a += t[i].a;
Limits::check(a,"Float::linear");
}
if (a != 0.0) {
t[j].a = a; t[j].x = x; j++;
}
}
n = j;
}
Term *t_p, *t_n;
int n_p, n_n;
/*
* Partition into positive/negative coefficents
*
*/
if (n > 0) {
int i = 0;
int j = n-1;
while (true) {
while ((t[j].a < 0) && (--j >= 0)) ;
while ((t[i].a > 0) && (++i < n)) ;
if (j <= i) break;
std::swap(t[i],t[j]);
}
t_p = t; n_p = i;
t_n = t+n_p; n_n = n-n_p;
} else {
t_p = t; n_p = 0;
t_n = t; n_n = 0;
}
/*
* Make all coefficients positive
*
*/
for (int i=n_n; i--; )
t_n[i].a = -t_n[i].a;
if (frt == FRT_GQ) {
frt = FRT_LQ;
std::swap(n_p,n_n); std::swap(t_p,t_n); c = -c;
}
if (n == 0) {
switch (frt) {
case FRT_EQ: if (!c.in(0.0)) home.fail(); break;
case FRT_LQ: if (c.max() < 0.0) home.fail(); break;
default: GECODE_NEVER;
}
return;
}
/*
* Test for unit coefficients only
*
*/
bool is_unit = true;
for (int i=n; i--; )
if (t[i].a != 1.0) {
is_unit = false;
break;
}
if (is_unit) {
// Unit coefficients
ViewArray<FloatView> x(home,n_p);
for (int i = n_p; i--; )
x[i] = t_p[i].x;
//.........这里部分代码省略.........
示例7:
forceinline FloatNum
ScaleView::size(void) const {
FloatVal c = x.size(); c *= a; return c.max();
}
示例8: return
forceinline FloatNum
ScaleView::med(void) const {
FloatVal c = x.med(); c *= a; return (c.min()+c.max())/2;
}