Exemplo n.º 1
1
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)))));
}
Exemplo n.º 2
1
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;
}
Exemplo n.º 3
1
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
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;
}