本文整理汇总了C++中SymEngine::expr2poly方法的典型用法代码示例。如果您正苦于以下问题:C++ SymEngine::expr2poly方法的具体用法?C++ SymEngine::expr2poly怎么用?C++ SymEngine::expr2poly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SymEngine
的用法示例。
在下文中一共展示了SymEngine::expr2poly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
print_stack_on_segfault();
RCP<const Basic> x = symbol("x");
RCP<const Basic> y = symbol("y");
RCP<const Basic> z = symbol("z");
RCP<const Basic> w = symbol("w");
RCP<const Basic> i15 = integer(15);
RCP<const Basic> e, f1, f2, r;
e = pow(add(add(add(x, y), z), w), i15);
f1 = expand(e);
f2 = expand(add(e, w));
umap_basic_num syms;
insert(syms, x, integer(0));
insert(syms, y, integer(1));
insert(syms, z, integer(2));
insert(syms, w, integer(3));
umap_vec_mpz P1, P2, C;
expr2poly(f1, syms, P1);
expr2poly(f2, syms, P2);
std::cout << "poly_mul start" << std::endl;
auto t1 = std::chrono::high_resolution_clock::now();
poly_mul(P1, P2, C);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout << "poly_mul stop" << std::endl;
/*
std::cout << *e << std::endl;
std::cout << *f1 << std::endl;
std::cout << P1 << std::endl;
std::cout << *f2 << std::endl;
std::cout << P2 << std::endl;
std::cout << "RESULT:" << std::endl;
std::cout << C << std::endl;
*/
std::cout
<< std::chrono::duration_cast<std::chrono::milliseconds>(t2-t1).count()
<< "ms" << std::endl;
std::cout << "number of terms: "
<< C.size() << std::endl;
return 0;
}
示例2: test_expand
void test_expand()
{
RCP<const Basic> x = symbol("x");
RCP<const Basic> y = symbol("y");
RCP<const Basic> z = symbol("z");
RCP<const Basic> w = symbol("w");
RCP<const Basic> i4 = integer(2);
RCP<const Basic> e, f1, f2, r;
e = pow(add(add(add(x, y), z), w), i4);
f1 = expand(e);
f2 = expand(add(e, w));
umap_basic_num syms;
insert(syms, x, integer(0));
insert(syms, y, integer(1));
insert(syms, z, integer(2));
insert(syms, w, integer(3));
umap_vec_mpz P1, P2, C;
expr2poly(f1, syms, P1);
expr2poly(f2, syms, P2);
std::cout << "poly_mul start" << std::endl;
auto t1 = std::chrono::high_resolution_clock::now();
poly_mul(P1, P2, C);
auto t2 = std::chrono::high_resolution_clock::now();
std::cout << "poly_mul stop" << std::endl;
/*
std::cout << *e << std::endl;
std::cout << *f1 << std::endl;
std::cout << P1 << std::endl;
std::cout << *f2 << std::endl;
std::cout << P2 << std::endl;
std::cout << "RESULT:" << std::endl;
std::cout << C << std::endl;
*/
std::cout
<< std::chrono::duration_cast<std::chrono::milliseconds>(t2-t1).count()
<< "ms" << std::endl;
}