On Thu, Feb 17, 2011 at 11:34 AM, Ondrej Certik <[email protected]> wrote:
> On Thu, Feb 17, 2011 at 8:35 AM, Chris Smith <[email protected]> wrote:
>> Ronan Lamy wrote:
>>> Le mercredi 16 février 2011 à 22:24 -0800, Ondrej Certik a écrit :
>>>> 2) NumPy array()
>>>>
>>>> So that you can use syntax like:
>>>>
>>>> xdata = array([1, 2, 3, 4, 5])
>>>> ydata = xdata ** 2
>>>> data2 = array([xdata, 1.5 * ydata])
>>>>
>>>> which just works in Mathematica (it's in the core language).
>>>>
>>>
>>> I don't really see the point of having this in sympy. Which actual
>>> problems does it solve?
>>
>> It's just sugar, and I think that's what is meant by "it just works". I'm 
>> guessing the above means the following in python:
>>
>>    ydata = [xi**2 for xi in xdata]
>>    data2 = zip(xdata, [yi*1.5 for yi in ydata])
>
> Well, this is what it means:
>
> In [1]: from numpy import array
> In [2]: xdata = array([1, 2, 3, 4, 5])
> In [3]: ydata = xdata ** 2
> In [4]: data2 = array([xdata, 1.5 * ydata])
> In [5]: data2
> Out[5]:
> array([[  1. ,   2. ,   3. ,   4. ,   5. ],
>       [  1.5,   6. ,  13.5,  24. ,  37.5]])
>
> Btw, we already have a similar concept in SymPy: Matrix. But it
> represents a math matrix and that's it. I think we need an array
> concept as well.
>
> Ronan --- the actual problem that it solves is that in Mathematica,
> people do use the syntactic sugar for arrays. So I would like to use
> the same thing in SymPy. Which I can, using numpy, but as I said,
> sometimes numpy is not available, and I want this to always work.

Here is a preliminary implementation, so that you can comment on it:

https://github.com/certik/sympy/commit/00a77c35dd0d603826aa29fe1c9528e34d08142e

as you can see, it's very simple. So far it's only 1D arrays, I still
have to implement multidimensional arrays, and conversions from
Matrix.

Ondrej

-- 
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.

Reply via email to