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


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

本文整理汇总了C++中SymEngine::rational_class方法的典型用法代码示例。如果您正苦于以下问题:C++ SymEngine::rational_class方法的具体用法?C++ SymEngine::rational_class怎么用?C++ SymEngine::rational_class使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SymEngine的用法示例。


在下文中一共展示了SymEngine::rational_class方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: m

    REQUIRE((integer_class(100) % integer_class(17)) == 15);

    // compound modulus operator
    j = -9;
    i = 7;
    j %= i;
    REQUIRE(j == -2);

    // move constructor and move assignment
    integer_class n = 5;
    integer_class m(std::move(n));
    i = std::move(m);

    // construction of rational_class
    // r = rational_class(integer_class(2),3);  fails!
    r = rational_class(integer_class(2), integer_class(3));

    // truncated division
    j = integer_class(12) / integer_class(5);
    REQUIRE(j == 2);
    j = integer_class(-12) / integer_class(5);
    REQUIRE(j == -2);
}

TEST_CASE("powers and roots: integer_class", "[integer_class]")
{
    integer_class res, i;

    // mp_pow_ui
    mp_pow_ui(res, -1, 0);
    REQUIRE(res == 1);
开发者ID:Piruzzolo,项目名称:symengine,代码行数:31,代码来源:test_integer_class.cpp

示例2: complex_set_mpq

CWRAPPER_OUTPUT_TYPE complex_set_mpq(basic s, const mpq_t re, const mpq_t im)
{
    CWRAPPER_BEGIN
    s->m = SymEngine::Complex::from_mpq(rational_class(re), rational_class(im));
    CWRAPPER_END
}
开发者ID:bjodah,项目名称:symengine,代码行数:6,代码来源:cwrapper.cpp

示例3: rational_set_ui

CWRAPPER_OUTPUT_TYPE rational_set_ui(basic s, unsigned long a, unsigned long b)
{
    CWRAPPER_BEGIN
    s->m = SymEngine::Rational::from_mpq(rational_class(a, b));
    CWRAPPER_END
}
开发者ID:bjodah,项目名称:symengine,代码行数:6,代码来源:cwrapper.cpp

示例4: rational_set_mpq

CWRAPPER_OUTPUT_TYPE rational_set_mpq(basic s, const mpq_t i)
{
    CWRAPPER_BEGIN
    s->m = SymEngine::Rational::from_mpq(rational_class(i));
    CWRAPPER_END
}
开发者ID:bjodah,项目名称:symengine,代码行数:6,代码来源:cwrapper.cpp

示例5: REQUIRE

    REQUIRE(eq(*r1, *r2));

    r1 = add(x, I);
    r2 = add(I, x);
    REQUIRE(eq(*r1, *r2));
    r2 = add({I, x});
    REQUIRE(eq(*r1, *r2));

    r1 = mul(x, I);
    r2 = mul(mul(I, i2), x);
    r3 = mul(mul(I, i3), x);
    r2 = add(r1, r2);
    REQUIRE(eq(*r3, *r2));

    r1 = real_double(0.1);
    r2 = Rational::from_mpq(rational_class(1, 2));
    r3 = add(add(add(r1, r2), integer(1)), real_double(0.2));
    REQUIRE(is_a<RealDouble>(*r3));
    REQUIRE(std::abs(rcp_static_cast<const RealDouble>(r3)->i - 1.8) < 1e-12);
    r3 = add({r1, r2, integer(1), real_double(0.2)});
    REQUIRE(std::abs(rcp_static_cast<const RealDouble>(r3)->i - 1.8) < 1e-12);

    r1 = complex_double(std::complex<double>(0.1, 0.2));
    r2 = Complex::from_two_nums(*Rational::from_mpq(rational_class(1, 2)),
                                *Rational::from_mpq(rational_class(7, 5)));
    r3 = add(add(add(r1, r2), integer(1)), real_double(0.4));
    REQUIRE(is_a<ComplexDouble>(*r3));
    REQUIRE(std::abs(rcp_static_cast<const ComplexDouble>(r3)->i.real() - 2.0)
            < 1e-12);
    REQUIRE(std::abs(rcp_static_cast<const ComplexDouble>(r3)->i.imag() - 1.6)
            < 1e-12);
开发者ID:chenchfort,项目名称:symengine,代码行数:31,代码来源:test_arit.cpp


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