本文整理汇总了C++中rational类的典型用法代码示例。如果您正苦于以下问题:C++ rational类的具体用法?C++ rational怎么用?C++ rational使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rational类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: assign
void assign(contains_app & x,expr * fml,const rational & v) {
SASSERT(v.is_unsigned());
eq_atoms& eqs = get_eqs(x.x(), fml);
unsigned uv = v.get_unsigned();
uint64 domain_size;
if (is_small_domain(x, eqs, domain_size)) {
SASSERT(v < rational(domain_size, rational::ui64()));
assign_small_domain(x, eqs, uv);
}
else {
assign_large_domain(x, eqs, uv);
}
}
开发者ID:AleksandarZeljic,项目名称:z3,代码行数:13,代码来源:qe_dl_plugin.cpp
示例2: is_target_core
bool is_target_core(expr * n, rational & u) {
if (!is_uninterp_const(n))
return false;
rational l; bool s;
if (m_bm.has_lower(n, l, s) &&
m_bm.has_upper(n, u, s) &&
l.is_zero() &&
!u.is_neg() &&
u.get_num_bits() <= m_max_bits) {
return true;
}
return false;
}
开发者ID:killbug2004,项目名称:Snippets,代码行数:14,代码来源:lia2pb_tactic.cpp
示例3: subst
void subst(contains_app & x,const rational & v,expr_ref & fml, expr_ref* def) {
SASSERT(v.is_unsigned());
eq_atoms& eqs = get_eqs(x.x(), fml);
unsigned uv = v.get_unsigned();
uint64 domain_size;
if (is_small_domain(x, eqs, domain_size)) {
SASSERT(uv < domain_size);
subst_small_domain(x, eqs, uv, fml);
}
else {
subst_large_domain(x, eqs, uv, fml);
}
if (def) {
*def = 0; // TBD
}
}
开发者ID:AleksandarZeljic,项目名称:z3,代码行数:16,代码来源:qe_dl_plugin.cpp
示例4: is_target
bool is_target(expr * var, rational & val) {
bool strict;
return
is_uninterp_const(var) &&
(!m_normalize_int_only || m_util.is_int(var)) &&
m_bm.has_lower(var, val, strict) &&
!val.is_zero();
}
开发者ID:jawline,项目名称:z3,代码行数:8,代码来源:normalize_bounds_tactic.cpp
示例5: squareRoot
// **** 1.Add a square root function to the rational class. ****
rational squareRoot(const rational &r)
{
assert(r.numerator()>0);
double top = r.numerator();
double bot = r.denominator();
double topSqrt = sqrt(top);
double botSqrt = sqrt(bot);
// Estimate if not a perfect square
if ((fmod(topSqrt,1)!=0) ||(fmod(botSqrt,1)!=0))
{
topSqrt = sqrt(100*top);
botSqrt = sqrt(100*bot);
}
return rational((int)topSqrt, (int)botSqrt);
}
开发者ID:rbirky1,项目名称:cmsc331-proj1,代码行数:19,代码来源:rational.cpp
示例6: is_diff_term
bool static_features::is_diff_term(expr const * e, rational & r) const {
// lhs can be 'x' or '(+ k x)'
if (!is_arith_expr(e)) {
r.reset();
return true;
}
if (is_numeral(e, r))
return true;
return m_autil.is_add(e) && to_app(e)->get_num_args() == 2 && is_numeral(to_app(e)->get_arg(0), r) && !is_arith_expr(to_app(e)->get_arg(1));
}
开发者ID:sukwon0709,项目名称:byterun,代码行数:10,代码来源:static_features.cpp
示例7: print
void print(rational a){
if(a.get_chisl()==0)std::cout<<"\n 0 ";else{
if(a.get_chisl()==a.get_znam())std::cout<<"\n 1";else{
if(a.get_znam()==1)std::cout<<"\n "<<a.get_chisl();else{
std::cout<<"\n "<<a.get_chisl()<<"/"<<a.get_znam();
}
}
}
}
开发者ID:Melancholic,项目名称:Rational,代码行数:9,代码来源:main.cpp
示例8: default_exception
unsigned context::scoped_state::add(expr* f, rational const& w, symbol const& id) {
if (w.is_neg()) {
throw default_exception("Negative weight supplied. Weight should be positive");
}
if (w.is_zero()) {
throw default_exception("Zero weight supplied. Weight should be positive");
}
if (!m.is_bool(f)) {
throw default_exception("Soft constraint should be Boolean");
}
if (!m_indices.contains(id)) {
m_objectives.push_back(objective(m, id));
m_indices.insert(id, m_objectives.size() - 1);
}
SASSERT(m_indices.contains(id));
unsigned idx = m_indices[id];
m_objectives[idx].m_terms.push_back(f);
m_objectives[idx].m_weights.push_back(w);
m_objectives_term_trail.push_back(idx);
return idx;
}
开发者ID:killbug2004,项目名称:Snippets,代码行数:21,代码来源:opt_context.cpp
示例9: result
rational operator - (const rational &left, const rational &right)
{
rational result(
left.numerator() * right.denominator() -
right.numerator() * left.denominator(),
left.denominator() * right.denominator());
return result;
}
开发者ID:rbirky1,项目名称:cmsc331-proj1,代码行数:8,代码来源:rational.cpp
示例10: main
int main()
{
int shift = 20;
hashset hset;
hashset::iterator iter;
i64 mup = (1LL<<(2*shift))-1;
i64 mdown = (1LL<<shift)-1;
mup -= mdown;
vector<rational> vr;
for(int di = 2; di <= 35; ++di)
for(int ni = 1; ni < di; ++ni){
int common = gcd(ni, di);
if(common> 1) continue;
vr.push_back(rational(ni, di));
}
sort(vr.begin(), vr.end());
for(unsigned int i = 0; i < vr.size(); ++i){
for(unsigned int j = i; j < vr.size(); ++j){
rational& r1 = vr[i];
rational& r2 = vr[j];
const rational xr = r1 + r2;
//x+y=z
if(xr.pnum() >= xr.pden()) break;
if(xr.pden() <= 35){
rational xr2 = xr + xr;
i64 value = (xr2.pden()<<shift)+(xr2.pnum());
assert(((value & mup)>>shift) == xr2.pden());
assert((value & mdown) == xr2.pnum());
iter = hset.find(value);
if(iter == hset.end()){
hset.insert(value);
//printf("a %lld %lld %lld %lld %lld %lld %lld %lld\n", r1.pnum(), r1.pden(),
// r2.pnum(), r2.pden(), xr.pnum(), xr.pden(), xr2.pnum(), xr2.pden());
}
}
}
}
开发者ID:lld2006,项目名称:my-c---practice-project,代码行数:38,代码来源:180.cpp
示例11: pow
sym pow(const sym &s,const rational &q) {
if(typeid(*s.expr)==typeid(sym::sym_num))
return sym(pow(((sym::sym_num *)s.expr)->value,q.eval()));
sym snew;
snew.context=s.check_context();
delete snew.expr;
snew.expr=s.expr->clone();
snew.expr=snew.expr->pow(q)->reduce();
return snew;
}
开发者ID:rieutord,项目名称:ester,代码行数:14,代码来源:sym.cpp
示例12: rational
BOOST_CONSTEXPR explicit
rational(rational<NewType> const &r)
: num(r.numerator()), den(is_normalized(int_type(r.numerator()),
int_type(r.denominator())) ? r.denominator() :
(BOOST_THROW_EXCEPTION(bad_rational("bad rational: denormalized conversion")), 0)){}
开发者ID:SamSaffron,项目名称:DiscourseMobile,代码行数:5,代码来源:rational.hpp
示例13:
bool operator==(const rational<T2> &f) const
{
return ((this->_numerator == f.numerator()) &&
(this->_denominator == f.denominator()));
}
开发者ID:julien-f,项目名称:jfcpp,代码行数:5,代码来源:rational.hpp
示例14:
sym::sym(const rational &q) {
context=NULL;
expr=new sym::sym_num(q.eval());
}
开发者ID:rieutord,项目名称:ester,代码行数:4,代码来源:sym.cpp
示例15: rational
rational rational::operator /(const rational& second) const {
return rational(getNum() * second.getDenom(), getDenom() * second.getNum());
}
开发者ID:RinesThaix,项目名称:ifmocpp,代码行数:3,代码来源:rational.cpp
示例16: eval
bool rational::operator>(const rational &q) const {
return eval()>q.eval();
}
开发者ID:ester-project,项目名称:ester,代码行数:3,代码来源:rational.cpp
示例17: return
bool operator == (const rational &left, const rational &right)
{
return (left.numerator() * right.denominator() ==
left.denominator() * right.numerator());
}
开发者ID:rbirky1,项目名称:cmsc331-proj1,代码行数:5,代码来源:rational.cpp
示例18:
// Assignments
void rational::operator = (const rational &right)
{
top = right.numerator();
bottom = right.denominator();
}
开发者ID:rbirky1,项目名称:cmsc331-proj1,代码行数:6,代码来源:rational.cpp
示例19:
inline SPROUT_CONSTEXPR sprout::rational<IntType>
operator-(rational<IntType> const& r) {
return sprout::detail::rational_construct_access<IntType>::raw_construct(
-r.numerator(), r.denominator()
);
}
开发者ID:EzoeRyou,项目名称:Sprout,代码行数:6,代码来源:arithmetic.hpp
示例20: print_point
out << "(" << a.x << ", " << a.y << ")";
return out;
}
std::ostream& tangents::print_tangent_domain(const point &a, const point &b, std::ostream& out) const {
out << "("; print_point(a, out); out << ", "; print_point(b, out); out << ")";
return out;
}
void tangents::generate_simple_tangent_lemma(const rooted_mon* rm) {
if (rm->size() != 2)
return;
TRACE("nla_solver", tout << "rm:"; m_core->print_rooted_monomial_with_vars(*rm, tout) << std::endl;);
m_core->add_empty_lemma();
unsigned i_mon = rm->orig_index();
const monomial & m = c().m_monomials[i_mon];
const rational v = c().product_value(m);
const rational& mv = vvr(m);
SASSERT(mv != v);
SASSERT(!mv.is_zero() && !v.is_zero());
rational sign = rational(nla::rat_sign(mv));
if (sign != nla::rat_sign(v)) {
c().generate_simple_sign_lemma(-sign, m);
return;
}
bool gt = abs(mv) > abs(v);
if (gt) {
for (lpvar j : m) {
const rational & jv = vvr(j);
rational js = rational(nla::rat_sign(jv));
c().mk_ineq(js, j, llc::LT);
c().mk_ineq(js, j, llc::GT, jv);
开发者ID:levnach,项目名称:z3,代码行数:31,代码来源:nla_tangent_lemmas.cpp
注:本文中的rational类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论