Skip to content

Univariate Series expansion benchmarks

Iris Lui edited this page May 30, 2016 · 4 revisions

Developed as part of UC Davis Series Expansion project by Charles and Iris.

This compares the benchmarks between UnivariateSeries, UPSeriesPiranha, and URatPSeriesFlint. The benchmark was using the function series to build the series expansion from polynomial

N = 1000;
auto arg = add(x, pow(x, integer(2)));
auto ex = mul(sin(arg), cos(arg));
auto res = SymEngine::UnivariateSeries::series(ex, "x", N);

With the same function series, performance of UPSeriesPiranha is currently 33802 ms and URatPSeriesFlint is 3962 ms.

With the initial implementation, the performance of UnivariateSeries is 61686 ms, which is much too large.

As of May 16 (#940 merged) the series function for UnivariateSeries runs for 54555 ms.

##UExprDict and UExprPoly Operation Performance Thanks to a suggestion from Isuru, UExprDict holds the dictionary, and UExprPoly holds a UExprDict. This way all arithmetic operations are done in UExprDict and some operations can be mutable. The benchmarks we used is:

RCP<const Symbol> x = symbol("x");
map_int_Expr p, q;
int N = 100000;
int N2 = 1000;
for (int i = 0; i < N; ++i) {
    Expression coef(pow(x, integer(i)));
    p[i] = coef;
}
for (int j = 0; j < N2; ++j) {
    Expression coef(pow(x, integer(j)));
    q[j] = coef;
}

UExprDict ep(p), epq(q);
UExprDict e({{0, Expression(7)}});
Expression coeff(7);

###Results The change in UExprDict and UExprPoly increased the performance of all the operations with the exception of multiplication. This because the multiplication between 2 polynomials containing more than 1 term, which is done with a naive implementation.

Operation Original times Modified times
ep + ep 241ms 155ms
ep += ep 232ms 126ms
ep - ep 311ms 257ms
ep -= ep 313ms 247ms
-ep 238ms 114ms
epq * epq 2185ms 2117ms
epq *= epq 2192ms 2188ms
ep * e 303ms 84ms
ep *= e 313ms 66ms
ep / coeff 318ms 150ms
ep /= coeff 314ms 133ms