本文整理汇总了C++中SymEngine::rational方法的典型用法代码示例。如果您正苦于以下问题:C++ SymEngine::rational方法的具体用法?C++ SymEngine::rational怎么用?C++ SymEngine::rational使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymEngine
的用法示例。
在下文中一共展示了SymEngine::rational方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: integer
using SymEngine::integer;
using SymEngine::Rational;
using SymEngine::rational;
using SymEngine::Number;
using SymEngine::is_a;
TEST_CASE("Rational", "[rational]")
{
RCP<const Integer> i2 = integer(2);
RCP<const Integer> i5 = integer(5);
RCP<const Integer> i10 = integer(10);
RCP<const Integer> i25 = integer(25);
RCP<const Number> q10_25 = Rational::from_two_ints(*i10, *i25);
RCP<const Number> q2_5 = Rational::from_two_ints(*i2, *i5);
RCP<const Number> q = rational(2, 5);
REQUIRE(q10_25->__eq__(*q2_5));
REQUIRE(q10_25->__eq__(*q));
RCP<const Number> r1 = rational(2, 1);
CHECK(is_a<Integer>(*r1));
CHECK(r1->__eq__(*integer(2)));
r1 = rational(9, 3);
CHECK(is_a<Integer>(*r1));
CHECK(r1->__eq__(*integer(3)));
}
TEST_CASE("Rational compare", "[rational compare]")
{
示例2: rational
using SymEngine::NotImplementedError;
using SymEngine::SymEngineException;
using SymEngine::DomainError;
using SymEngine::pi;
using SymEngine::gamma;
using SymEngine::I;
using SymEngine::Nan;
using SymEngine::erf;
using SymEngine::erfc;
using SymEngine::I;
using SymEngine::make_rcp;
using SymEngine::complex_double;
TEST_CASE("Constructors for Infinity", "[Infinity]")
{
RCP<const Number> r1 = rational(1, 1);
RCP<const Number> rm1 = rational(-1, 1);
RCP<const Number> r0 = rational(0, 1);
RCP<const Integer> im1 = integer(-1);
RCP<const Integer> i0 = integer(0);
RCP<const Infty> a = Infty::from_direction(r1);
RCP<const Infty> b = Infty::from_direction(rm1);
RCP<const Infty> c = Infty::from_direction(r0);
REQUIRE(eq(*a, *Inf));
REQUIRE(eq(*b, *NegInf));
REQUIRE(eq(*c, *ComplexInf));
CHECK_THROWS_AS(a->is_canonical(complex_double(std::complex<double>(2, 3))),