autowrap a matrix expression

80 views
Skip to first unread message

Gustavo

unread,
Jan 21, 2012, 3:07:42 AM1/21/12
to sympy
How can I autowrap a matrix expression without making an autofunction
from each of the elements

Matthew

unread,
Jan 21, 2012, 7:51:39 PM1/21/12
to sympy
Hi Gustavo,

Can you say more about what you want? I don't understand. It might be
helpful to give an example of what you want to work.

-Matt

Gustavo

unread,
Jan 23, 2012, 1:49:59 AM1/23/12
to sympy
Sorry for the vagueness. This is what I'd like:

import sympy
from sympy.utilities.autowrap import autowrap

x = sympy.symbol.symbols('x')
m = sympy.Matrix([x,sympy.cos(x)])
f = autowrap(m)

CodeGenError: Fortran only supports a single or no return value.

It's possible to autowrap each element of "m" separately, but then I
might miss out on some optimization opportunities, like common
subexpression elimination.

Aaron Meurer

unread,
Jan 23, 2012, 12:57:39 PM1/23/12
to sy...@googlegroups.com
But what kind of object would you expect to be used for the Matrox?

Aaron Meurer

> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
>

Gustavo

unread,
Jan 23, 2012, 2:20:50 PM1/23/12
to sympy
Right now it returns a <float>. I'd like an NumPy array, so maybe I
can create the NumPy array with the correct size and row/column
ordering and pass it as an "out parameter" to the code generator.

On Jan 23, 12:57 pm, Aaron Meurer <asmeu...@gmail.com> wrote:
> But what kind of object would you expect to be used for the Matrox?
>
> Aaron Meurer
>

Gustavo

unread,
Jul 6, 2012, 11:22:05 AM7/6/12
to sy...@googlegroups.com
Is it possible to accomplish this using an out parameter? This would still be useful to me.
> > To unsubscribe from this group, send email to sympy+unsubscribe@googlegroups.com.

Matthew Rocklin

unread,
Jul 6, 2012, 11:45:13 AM7/6/12
to sy...@googlegroups.com
It would be nice if SymPy could do this. I'm unfortunately not very familiar with the code generation module. If it's not possible now then we should make an issue for it. 

Alternatively you could take a look at the theano project. They optimize and generate code for symbolic expressions. They're tightly integrated with NumPy as well. They tend to specialize more in array expressions but I'm sure that what you're proposing in your example is possible. They are pretty responsive on their e-mail list groups.google.com/group/theano-users

-Matt

To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/mCUBg_bgcjgJ.

To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.

Matthew Rocklin

unread,
Jul 6, 2012, 11:51:21 AM7/6/12
to sy...@googlegroups.com, theano-dev
On a semi-related note I think it'd be awesome if SymPy created a Theano code generator. Our two projects are related and I think that there is something to be gained by cooperation. We optimize and simplify expressions in semi-orthogonal ways. 

Frédéric Bastien

unread,
Jul 6, 2012, 1:50:01 PM7/6/12
to sympy
Hi,

I agree that more cooperation would be great. Up to now the problem on
our side is time to look at SymPy.

I'm going to SciPy in ~1 week in Texas. I was under the impression
there was a tutorial/talk about SimPy There, but I don't find it
anymore. Is it a sprint? The sprints list is not on the web site of
the conference.

I'll try to read the SymPy tutorial in the plane going to the
conference. If there is people that would like to talk about way to
cooperate, I'll be more then happy to discuss that.

Fred

Aaron Meurer

unread,
Jul 6, 2012, 2:46:29 PM7/6/12
to sy...@googlegroups.com
On Jul 6, 2012, at 12:41 PM, "Frédéric Bastien" <no...@nouiz.org> wrote:

> Hi,
>
> I agree that more cooperation would be great. Up to now the problem on
> our side is time to look at SymPy.
>
> I'm going to SciPy in ~1 week in Texas. I was under the impression
> there was a tutorial/talk about SimPy There, but I don't find it
> anymore.

You were probably looking at last year's page. As far as I know there
isn't one this year.

Aaron Meurer
Reply all
Reply to author
Forward
0 new messages