On Jan 13, 2008 7:09 PM, Alan Bromborsky <[EMAIL PROTECTED]> wrote:
>
>
> Ondrej Certik wrote:
> > On Jan 13, 2008 5:58 PM, Alan Bromborsky <[EMAIL PROTECTED]> wrote:
> >
> >> The quickest way for me to get my geometric algebra module working with
> >> sympy is to override the +,-, and * operators in numpy so that they work
> >> with sypmy objects as array components.  However, I have not found any
> >> references on how to override operators in exisiting modules. Is there
> >> anyway to do this without modifying the code in the numpy module?
> >>
> >
> > Don't know about numpy. But I think the quickest way is to get rid
> > of the sequence protocol in sympy, i.e. don't use
> >
> > sin(x)[:] but sin(x).args[:]
> >
> > then numpy should start working with sympy like a charm. This is the issue:
> >
> > http://code.google.com/p/sympy/issues/detail?id=556
> >
> > And I submitted my first code yesterday:
> >
> > http://groups.google.com/group/sympy-patches/browse_thread/thread/bc52b09cea44893d
> >
> > now the whole sympy needs to be fixed to use .args[:] and that's it.
> >
> > Ondrej
> >
> > >
> >
> >
> How would you use this so that if X and Y are numpy arrays stuffed with
> sympy expressions and z is a sympy expression so that X+Y, X-Y, and z*X
> are correctly evaluated???????

I have a surprise for you: I just created patches for that in the issue:

http://code.google.com/p/sympy/issues/detail?id=556

before they get reviewed and pushed into our official repo, you can
try it like this:

$ hg clone http://hg.certik.cz/sympy-devel/
$ cd sympy-devel/
$ bin/isympy
[...]

In [1]: from numpy import array

In [2]: X = array([x, x**2, sin(x)])

In [3]: Y = array([y**3, 5, log(x)])

In [4]: X
Out[4]: array([x, x**2, sin(x)], dtype=object)

In [5]: Y
Out[5]: array([y**3, 5, log(x)], dtype=object)

In [6]: X+Y
Out[6]: array([x + y**3, 5 + x**2, log(x) + sin(x)], dtype=object)

In [7]: X-Y
Out[7]: array([x - y**3, (-5) + x**2, -log(x) + sin(x)], dtype=object)

In [8]: z*X
Out[8]: array([x*z, z*x**2, z*sin(x)], dtype=object)

So, what do you think now? :)

Ondrej

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
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