本文整理汇总了C++中SymEngine::expand方法的典型用法代码示例。如果您正苦于以下问题:C++ SymEngine::expand方法的具体用法?C++ SymEngine::expand怎么用?C++ SymEngine::expand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymEngine
的用法示例。
在下文中一共展示了SymEngine::expand方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: R1
double R1()
{
RCP<const Basic> g;
RCP<const Basic> h = div(I, integer(2));
auto t1 = std::chrono::high_resolution_clock::now();
g = expand(f(f(f(f(f(f(f(f(f(f(h)))))))))));
auto t2 = std::chrono::high_resolution_clock::now();
return std::chrono::duration_cast<std::chrono::nanoseconds>(t2-t1).count()/1000000000.0;
}
示例3: 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;
}
示例4: main
int main(int argc, char *argv[])
{
SymEngine::print_stack_on_segfault();
int N;
if (argc == 2) {
N = std::atoi(argv[1]);
} else {
N = 100;
}
RCP<const Basic> e, f, s, a0, a1;
a0 = symbol("a0");
a1 = symbol("a1");
e = add(a0, a1);
f = zero;
for (long long i = 2; i < N; i++) {
std::ostringstream o;
o << "a" << i;
s = symbol(o.str());
e = add(e, s);
f = add(f, s);
}
f = neg(f);
auto t1 = std::chrono::high_resolution_clock::now();
e = expand(pow(e, integer(2)));
e = e->subs({{a0, f}});
e = expand(e);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1)
.count()
<< "ms" << std::endl;
std::cout << e->__str__() << std::endl;
return 0;
}
示例5: 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;
}
示例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;
}