本文整理汇总了C++中SymEngine::integer_class方法的典型用法代码示例。如果您正苦于以下问题:C++ SymEngine::integer_class方法的具体用法?C++ SymEngine::integer_class怎么用?C++ SymEngine::integer_class使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymEngine
的用法示例。
在下文中一共展示了SymEngine::integer_class方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mul
using SymEngine::mul;
using SymEngine::erf;
using SymEngine::sub;
using SymEngine::eval_mpfr;
using SymEngine::integer_class;
using SymEngine::print_stack_on_segfault;
using SymEngine::max;
using SymEngine::min;
using SymEngine::loggamma;
TEST_CASE("precision: eval_mpfr", "[eval_mpfr]")
{
mpfr_t a;
mpfr_init2(a, 53);
RCP<const Basic> s = mul(pi, integer(1963319607));
RCP<const Basic> t = integer(integer_class("6167950454"));
RCP<const Basic> r = sub(s, t);
// value of `r` is approximately 0.000000000149734291
eval_mpfr(a, *r, MPFR_RNDN);
// `eval_mpfr` was done with a precision of 53 bits (precision of `a`) and
// rounding mode `MPFR_RNDN`
// With 53 bit precision, `s` and `t` have the same value.
// Hence value of `r` was rounded down to `0.000000000000000`
REQUIRE(mpfr_cmp_si(a, 0) == 0);
mpfr_set_prec(a, 100);
eval_mpfr(a, *r, MPFR_RNDN);
// `eval_mpfr` was done with a precision of 100 bits (precision of `a`) and
// rounding mode `MPFR_RNDN`
// With 100 bit precision, `s` and `t` are not equal in value.
示例2: REQUIRE
// undefined behaviour for C++ standard
/*REQUIRE((integer_class(-1024) << 3) == -8192);
REQUIRE((integer_class(-1024) >> 3) == -128);
REQUIRE((integer_class(-768) << 5) == -24576);
REQUIRE((integer_class(-768) >> 5) == -24);
REQUIRE((integer_class(-500) << 3) == -4000);
REQUIRE((integer_class(-500) >> 3) == -63);
REQUIRE((integer_class(-5) << 1) == -10);
REQUIRE((integer_class(-5) >> 1) == -3);
REQUIRE((integer_class(-4) << 0) == -4);
REQUIRE((integer_class(-4) >> 0) == -4);
REQUIRE((integer_class(-2) << 10) == -2048);
REQUIRE((integer_class(-2) >> 10) == -1);
REQUIRE((integer_class(-1) << 4) == -16);
REQUIRE((integer_class(-1) >> 4) == -1);*/
REQUIRE((integer_class(0) << 5) == 0);
REQUIRE((integer_class(0) >> 5) == 0);
REQUIRE((integer_class(1) << 2) == 4);
REQUIRE((integer_class(1) >> 2) == 0);
REQUIRE((integer_class(2) << 4) == 32);
REQUIRE((integer_class(2) >> 4) == 0);
REQUIRE((integer_class(4) << 1) == 8);
REQUIRE((integer_class(4) >> 1) == 2);
REQUIRE((integer_class(5) << 6) == 320);
REQUIRE((integer_class(5) >> 6) == 0);
REQUIRE((integer_class(500) << 1) == 1000);
REQUIRE((integer_class(500) >> 1) == 250);
REQUIRE((integer_class(768) << 2) == 3072);
REQUIRE((integer_class(768) >> 2) == 192);
REQUIRE((integer_class(1024) << 3) == 8192);
REQUIRE((integer_class(1024) >> 3) == 128);
示例3: integer_set_mpz
CWRAPPER_OUTPUT_TYPE integer_set_mpz(basic s, const mpz_t i)
{
CWRAPPER_BEGIN
s->m = SymEngine::integer(integer_class(i));
CWRAPPER_END
}
示例4: integer_set_str
CWRAPPER_OUTPUT_TYPE integer_set_str(basic s, const char *c)
{
CWRAPPER_BEGIN
s->m = SymEngine::integer(integer_class(c));
CWRAPPER_END
}
示例5: integer_set_ui
CWRAPPER_OUTPUT_TYPE integer_set_ui(basic s, unsigned long i)
{
CWRAPPER_BEGIN
s->m = SymEngine::integer(integer_class(i));
CWRAPPER_END
}