本文整理汇总了C++中SymEngine::pow方法的典型用法代码示例。如果您正苦于以下问题:C++ SymEngine::pow方法的具体用法?C++ SymEngine::pow怎么用?C++ SymEngine::pow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymEngine
的用法示例。
在下文中一共展示了SymEngine::pow方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: C
double C()
{
RCP<const Integer> x = integer(13*17*31);
RCP<const Integer> y = integer(13*19*29);
auto t1 = std::chrono::high_resolution_clock::now();
for (int i = 1; i <= 200; i++) {
gcd(*rcp_static_cast<const Integer>(pow(x, integer(300 + i%181))),
*rcp_static_cast<const Integer>(pow(y, integer(200 + i%183))));
}
auto t2 = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count()/1000000000.0;
}
示例2: S2
double S2()
{
RCP<const Basic> x = symbol("x");
RCP<const Basic> y = symbol("y");
RCP<const Basic> z = symbol("z");
RCP<const Basic> e;
RCP<const Basic> f;
e = pow(add(pow(x, sin(x)), add(pow(y, cos(y)), pow(z, add(x, y)))), integer(100));
auto t1 = std::chrono::high_resolution_clock::now();
f = expand(e);
auto t2 = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count()/1000000000.0;
}
示例3: E
double E()
{
RCP<const Basic> s = integer(0);
RCP<const Basic> y = symbol("y");
RCP<const Basic> t = symbol("t");
auto t1 = std::chrono::high_resolution_clock::now();
for (int i = 1; i <= 10; i++) {
s = add(s, div(mul(integer(i), mul(y, pow(t, integer(i)))),
pow(add(y, mul(integer(abs(5 - i)), t)), integer(i))));
}
auto t2 = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count()/1000000000.0;
}
示例4: S3a
double S3a()
{
RCP<const Basic> x = symbol("x");
RCP<const Basic> y = symbol("y");
RCP<const Basic> z = symbol("z");
RCP<const Basic> e;
RCP<const Basic> f;
e = pow(add(pow(x, y), add(pow(y, z), pow(z, x))), integer(500));
e = expand(e);
auto t1 = std::chrono::high_resolution_clock::now();
f = e->diff(rcp_static_cast<const Symbol>(x));
auto t2 = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count()/1000000000.0;
}
示例5: R8
double R8()
{
RCP<const Basic> x = symbol("x");
auto t1 = std::chrono::high_resolution_clock::now();
x = right(pow(x, integer(2)), integer(0), integer(5), x, 10000);
auto t2 = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count()/1000000000.0;
}
示例6: S1
double S1()
{
RCP<const Basic> x = symbol("x");
RCP<const Basic> y = symbol("y");
RCP<const Basic> z = symbol("z");
RCP<const Basic> e;
RCP<const Basic> f;
e = pow(add(x, add(y, add(z, one))), integer(7));
f = mul(e, add(e, one));
auto t1 = std::chrono::high_resolution_clock::now();
f = expand(f);
auto t2 = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count()/1000000000.0;
}
示例7: R7
double R7()
{
RCP<const Basic> x = symbol("x");
RCP<const Basic> f = add(pow(x, integer(24)),
add(mul(integer(34), pow(x, integer(12))),
add(mul(integer(45), pow(x, integer(3))),
add(mul(integer(9), pow(x, integer(18))),
add(mul(integer(34), pow(x, integer(10))),
mul(integer(32), pow(x, integer(21))))))));
vec_basic v;
auto t1 = std::chrono::high_resolution_clock::now();
for (int i = 0; i < 10000; ++i) {
v.push_back(f->subs({{x, real_double(0.5)}}));
}
auto t2 = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count()/1000000000.0;
}
示例8: add
RCP<const Basic> f(RCP<const Basic> z) {
return add(mul(sqrt(div(one, integer(3))), pow(z, integer(2))), div(I, integer(3)));
}
示例9: integer
using SymEngine::Subs;
using SymEngine::Derivative;
using SymEngine::function_symbol;
using SymEngine::I;
using SymEngine::real_double;
using SymEngine::complex_double;
TEST_CASE("test_printing(): printing", "[printing]")
{
RCP<const Basic> r, r1, r2;
RCP<const Integer> i = integer(-1);
RCP<const Symbol> x = symbol("x");
RCP<const Symbol> y = symbol("y");
RCP<const Symbol> z = symbol("z");
r = div(integer(12), pow(integer(196), div(integer(1), integer(2))));
REQUIRE(r->__str__() == "(3/49)*196**(1/2)");
r = mul(integer(12), pow(integer(196), div(integer(1), integer(2))));
REQUIRE(r->__str__() == "12*196**(1/2)");
r = mul(integer(23), mul(pow(integer(5), div(integer(1), integer(2))),
pow(integer(7), div(integer(1), integer(2)))));
REQUIRE(r->__str__() == "23*5**(1/2)*7**(1/2)");
r = mul(integer(2), pow(symbol("x"), integer(2)));
REQUIRE(r->__str__() == "2*x**2");
r = mul(integer(23), mul(pow(div(integer(5), integer(2)), div(integer(1), integer(2))),
pow(div(integer(7), integer(3)), div(integer(1), integer(2)))));
REQUIRE(r->__str__() == "23*(7/3)**(1/2)*(5/2)**(1/2)");
示例10: mul
r2 = mul(mul(i3, x), y);
REQUIRE(eq(*r1, *r2));
r1 = add(add(x, x), x);
r2 = mul(i3, x);
REQUIRE(eq(*r1, *r2));
r1 = add(add(x, x), x);
r2 = mul(x, i3);
REQUIRE(eq(*r1, *r2));
r1 = add(x, one);
r2 = add(one, x);
REQUIRE(eq(*r1, *r2));
r1 = add(pow(x, y), z);
r2 = add(z, pow(x, y));
REQUIRE(eq(*r1, *r2));
r1 = add(x, I);
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(mpq_class(1, 2));
示例11: a
r4 = integer(5);
#ifdef HAVE_SYMENGINE_MPFR
SymEngine::mpfr_class a(100);
SymEngine::eval_mpfr(a.get_mpfr_t(), *r1, MPFR_RNDN);
r5 = SymEngine::real_mpfr(std::move(a));
#else
r5 = SymEngine::real_double(SymEngine::eval_double(*r1));
#endif
std::vector<std::pair<RCP<const Basic>, double>> vec = {
{r1, 0.841470984808},
{r2, 0.479425538604},
{add(r1, r2), 1.320896523412},
{mul(r1, r2), 0.403422680111},
{pow(r1, r2), 0.920580670898},
{tan(pow(r1, r2)), 1.314847038576},
{erf(E), 0.9998790689599},
{erfc(E), 0.0001209310401},
{add(sin(r3), add(cos(r4), add(tan(r3), add(sec(integer(6)),
add(csc(r4), cot(r4)))))),
0.387875350057},
{add(asin(r3),
add(acos(r3), add(atan(r3), add(asec(integer(6)),
add(acsc(r4), acot(r4)))))),
3.570293614860},
{add(add(sinh(one), add(cosh(one), add(tanh(one), coth(one)))),
csch(r3)),
9.759732838729},
{add(add(add(asinh(r4), add(acosh(r4), add(atanh(r3), acoth(r4)))),
csch(r4)),
示例12: parse
s = "4^2/2+2";
res = parse(s);
REQUIRE(eq(*res, *integer(10)));
s = "(1+2*(3+1)-5/(2+2))";
res = parse(s);
REQUIRE(eq(*res, *add(integer(9), div(integer(-5), integer(4)))));
s = "2 + -3";
res = parse(s);
REQUIRE(eq(*res, *integer(-1)));
s = "10000000000000000000000000";
res = parse(s);
REQUIRE(eq(*res, *pow(integer(10), integer(25))));
// Make sure that parsing and printing works correctly
s = "0.123123123e-10";
res = parse(s);
REQUIRE(eq(*res, *parse(res->__str__())));
s = "123123123123123.";
res = parse(s);
REQUIRE(eq(*res, *parse(res->__str__())));
#ifdef HAVE_SYMENGINE_MPFR
s = "1.231231232123123123123123123123e8";
res = parse(s);
REQUIRE(eq(*res, *parse(res->__str__())));
#endif
示例13: symbol
using SymEngine::LambdaComplexDoubleVisitor;
using SymEngine::max;
using SymEngine::E;
using SymEngine::gamma;
using SymEngine::loggamma;
using SymEngine::min;
TEST_CASE("Evaluate to double", "[lambda_double]")
{
RCP<const Basic> x, y, z, r;
double d;
x = symbol("x");
y = symbol("y");
z = symbol("z");
r = add(x, add(mul(y, z), pow(x, integer(2))));
LambdaRealDoubleVisitor v;
v.init({x, y, z}, *r);
d = v.call({1.5, 2.0, 3.0});
REQUIRE(::fabs(d - 9.75) < 1e-12);
d = v.call({1.5, -1.0, 2.0});
REQUIRE(::fabs(d - 1.75) < 1e-12);
r = max({x, add(mul(y, z), integer(3))});
v.init({x, y, z}, *r);
d = v.call({4.0, 1.0, 2.5});
REQUIRE(::fabs(d - 5.5) < 1e-12);
示例14: sin
using SymEngine::vec_basic;
TEST_CASE("eval_double: eval_double", "[eval_double]")
{
RCP<const Basic> r1, r2, r3, r4;
r1 = sin(integer(1));
r2 = sin(div(integer(1), integer(2)));
r3 = div(one, integer(5));
r4 = integer(5);
std::vector<std::pair<RCP<const Basic>, double>> vec = {
{ r1, 0.841470984808 },
{ r2, 0.479425538604 },
{ add(r1, r2), 1.320896523412 },
{ mul(r1, r2), 0.403422680111 },
{ pow(r1, r2), 0.920580670898 },
{ tan(pow(r1, r2)), 1.314847038576 },
{ add(sin(r3), add(cos(r4), add(tan(r3), add(sec(integer(6)), add(csc(r4), cot(r4)))))), 0.387875350057 },
{ add(asin(r3), add(acos(r3), add(atan(r3), add(asec(integer(6)), add(acsc(r4), acot(r4)))))), 3.570293614860 },
{ add(sinh(one), add(cosh(one), add(tanh(one), coth(one)))), 4.792911269914 },
{ add(asinh(r4), add(acosh(r4), add(atanh(r3), acoth(r4)))), 5.010335118942 },
{ SymEngine::abs(log(div(pi, mul(E, integer(2))))), 0.548417294710 },
{ SymEngine::atan2(r1, neg(r2)), 2.08867384922582 }
};
for (unsigned i = 0; i < vec.size(); i++) {
double val = eval_double(*vec[i].first);
std::cout.precision(12);
std::cout << vec[i].first->__str__() << " ~ " << val << std::endl;
REQUIRE(::fabs(val - vec[i].second) < 1e-12);
}