Hi, On 2 June 2011 09:56, SherjilOzair <[email protected]> wrote:
> Well, if Domain.sum(...) is significantly faster than sum(elements of > Domain), then its pretty reasonable that it should be implemented. sum > is almost as important as +, -, * and /. sum is used in many > algorithms. Matrix algorithms particularly use sum for dot products. > > If you see my code for the cholesky and LDL decomposition in [1], I > have used the Add(*(...)) construct freely, as Matrix currently > converts its elements to Sympy objects. So Add works as a good > summation. > > But if I want to abstractify this, and make Matrix work for XYZ dtype, > then the sum has to be an abstract one. Python's builtin sum suffices > as an abstract sum, but is slow. If I have the 'domain' variable > storing the domain type in the Matrix object, I can use > domain.sum(...), and the appropriate sum would be called by the > algorithm, Add for Sympy, fsum for mpmath and so on. > > [1] https://github.com/sympy/sympy/pull/184/files (lines 534, 536, > 573, 575, 599, etc.) > This pull request is what is was I was asking for. From this it seems that implementing sum() method in appropriate domains will be beneficial. > > > On Jun 2, 9:55 am, Mateusz Paprocki <[email protected]> wrote: > > Hi, > > > > On 2 June 2011 06:37, SherjilOzair <[email protected]> wrote: > > > > > This hasn't been implemented yet. Should I go ahead and add it ? > > > sums for QQ, etc also needed. > > > > First it would be good to see where and why this is needed at all. Then > we > > can think about implementation (which is actually trivial). > > > > > > > > > > > > > > > > > > > > > > > > > See [1] for the types I need. > > > > > [1] > > >http://groups.google.com/group/sympy/browse_thread/thread/c793f703085. > .. > > > > > On May 31, 9:43 pm, Vinzent Steinberg > > > <[email protected]> wrote: > > > > On May 30, 9:52 pm, Mateusz Paprocki <[email protected]> wrote: > > > > > > > That could work: > > > > > > > ZZ.sum([1, 2, 3]) -> sum([1, 2, 3]) > > > > > RR.sum([1.0, 2.0]) -> mpmath.fsum([1.0, 2.0]) > > > > > EX.sum([x, y, z]) -> Add(*[x, y, z]) > > > > > > > etc. > > > > > > This is exactly what I have been thinking of. > > > > > > Vinzent > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "sympy" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]. > > > For more options, visit this group at > > >http://groups.google.com/group/sympy?hl=en. > > > > Mateusz > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > > Mateusz -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
