I'm new to sympy (and *very *impressed with what I can do with it), but 
have been unable to figure something out about converting certain matrix 
expressions into their "lambda function" form for fast evaluation.

I have a sympy matrix containing symbols x, y, and z. If I invoke lambdify 
on this matrix for those symbols, I get a function that returns a numpy 
matrix (great!). Is it also possible to make it return a numpy array 
(rather than a matrix)? The reason I need this is because my matrix is 
actually a rank-3 tensor when the arguments x,y,z are supplied (which are 
vectors). In other words, I want to supply 3 equally sized vectors to my 
matrix to create an m-by-n-by-k numpy array where my original [sympy] 
matrix was m-by-n.

For example, I could do:
>>> fn = lambda x,y: np.array( [ [x+y, x-y], [x-y, y-x] ] )
>>> fn(1,2)
array([[ 3, -1],
       [-1,  1]]) # Gives back original array shape (2x2)
>>>
>>> arr1 = np.array([1,2,3])
>>> arr2 = np.array([4,5,6])
>>> fn(arr1, arr2)
array([[[ 5,  7,  9],
        [-3, -3, -3]],

       [[-3, -3, -3],
        [ 3,  3,  3]]])
>>> fn(arr1, arr2).shape # (2x2x3)
(2L, 2L, 3L)

I basically want to do the above with a sympy matrix rather than explicitly 
typing the lambda function.

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to