本文整理汇总了C++中FloatVal::assign方法的典型用法代码示例。如果您正苦于以下问题:C++ FloatVal::assign方法的具体用法?C++ FloatVal::assign怎么用?C++ FloatVal::assign使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FloatVal
的用法示例。
在下文中一共展示了FloatVal::assign方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}