Hi Shivam,
On Sun, Mar 8, 2015 at 5:13 AM, Shivam Vats <
shiv...@gmail.com> wrote:
> Hi
>
> Sympy currently lacks a class based representation for series expansions.
> Though the current approach works well, it has its problems, like- all types
> of
> series are lumped under one name, issues with infinite series, etc.
And it is slow.
> Moreover, such
> an implementation, if successful, can also be ported to C++, which will be
> much
> faster.
It should be done in SymPy first, it will speed it up a lot, as well
as allow us to figure out the best design. Then we should translate to
C++ to get additional speed.
It's a little bit faster, but I think that's just because I sort the
dictionaries first:
https://github.com/certik/sympy/blob/59492520b443ea5f0ef31fc018e9bc700b93b818/a.py#L114
This can be done easily in ring_series as well. The two approaches are
equivalent, as far as I can tell.
How fast is that approach?
>
> How do the two approaches compare? What are the expectations from such a
> class
> based representation?
I think we should use ring_series in a new Series class, and implement
any missing features in ring_series as needed. See the other thread
you cited above.
I think this is the most optimal way to represent and implement series
expansion. It's what Piranha uses (except that Piranha does some
clever optimizations in C++, but the overall structure, i.e. a
hashtable is the same). The only other way that I know of is to use
some kind of a dense representation (polys can do dense representation
too, but overall the sparse representation seems about as fast or
faster for most problems). So I would however use sparse
representation, i.e. ring_series. So just doing the above will provide
a very fast implementation, and it seems to me that any other
datastructure/design will only provide minor algorithmic speedup. Once
this is done, we should implement this in C++ and use some of the
tricks from Piranha, that will provide a good constant speedup.
You can try to implement the Kronecker trick with packing the
exponents in Python as well. That provides good speedup, but it's an
additional complexity.
Ondrej