本文整理汇总了C++中SymEngine::sub方法的典型用法代码示例。如果您正苦于以下问题:C++ SymEngine::sub方法的具体用法?C++ SymEngine::sub怎么用?C++ SymEngine::sub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymEngine
的用法示例。
在下文中一共展示了SymEngine::sub方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expand
RCP<const Basic> hermite(RCP<const Integer> n, RCP<const Basic> y)
{
if (eq(*n, *one)) return mul(y, integer(2));
if (eq(*n, *zero)) return one;
return expand(sub(mul(mul(integer(2), y), hermite(n->subint(*one), y)),
mul(integer(2), mul(n->subint(*one), hermite(n->subint(*integer(2)), y)))));
}
示例2: 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.
// Value of `r` is a positive quantity with value 0.000000000149734291.....