Passing numpy arrays to matlab

Josh Marshall josh.p.marshall at gmail.com
Wed Nov 8 22:18:54 CST 2006


Hi David,

Sorry for the late reply. Can you CC any reply to me as well, as I  
just get the digests and read them every few days.

On 08/11/2006, at 11:09 PM, David Cournapeau wrote:

> I didn't know that, thanks. Unfortunately, it is not really what I am
> trying to do: mlabwrap is just a python interface a bit more high  
> level
> than pymat, with many fancy tricks, but still do copies. What I would
> like is to avoid completely the copying by using proxy classes around
> data from numpy so that I can pass "automatically" numpy arrays to
> matlab C api, and a proxy class around data from matlab so that they
> look like numpy arrays.

I don't see how you are going to get around doing the copies. Matlab  
is in a separate process from the Python interpreter, and there is no  
shared memory. In what way do you want these proxy classes to "look  
like numpy arrays"?

Note that mlabwrap creates proxy arrays, and only copies the data if  
you actually request it to. (AFAIRemember) Otherwise you aren't  
losing any speed, because there aren't going to be any copies.

>     I don't care that much about the actual api from python point of
> view, because I intend to use this mainly to compare matlab vs numpy
> implementation, not as a way to use matlab inside python regularly.  
> And
> once the copy problem is solved, adding syntactic sugar using  
> python is
> easy anyway, I think (it should be easy to do something similar to
> mlabwrap at that point),

What could be possible to do is add an array interface to the  
mlabwrap proxy classes so they can be used as numpy arrays when  
required for passing to numpy functions (or PIL, etc). Thus we only  
copy when we want to use numpy functions. Then we could define the  
operators on the proxy class to perform their operations on the other  
side of the bridge.

Cheers,
Josh


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2433 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061109/fb34db35/attachment-0001.bin 
-------------- next part --------------
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
-------------- next part --------------
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


More information about the Numpy-discussion mailing list