当前位置: 首页>>代码示例>>C++>>正文


C++ SymEngine::sub方法代码示例

本文整理汇总了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)))));
}
开发者ID:SHIVAPRASAD96,项目名称:symengine,代码行数:7,代码来源:symbench.cpp

示例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.....
开发者ID:altairpearl,项目名称:symengine,代码行数:31,代码来源:test_eval_mpfr.cpp


注:本文中的SymEngine::sub方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。