Andrew Straw wrote:
> David Cournapeau wrote:
>   
>> Andrew Straw wrote:
>>   
>>     
>>> David Cournapeau wrote:
>>>   
>>>     
>>>       
>>>>     - To send data from the calling process to matlab, you first have to 
>>>> create a mxArray, which is the basic matlab handler of a matlab array, 
>>>> and populating it. Using mxArray is very ackward : you cannot create 
>>>> mxArray from existing data, you have to copy data to them, etc... 
>>>>     
>>>>       
>>>>         
>>> My understanding, never having done it, but from reading the docs, is
>>> that you can create a "hybrid array" where you manage the memory. Thus,
>>> you can create an mxArray from existing data. However, the docs
>>> basically say that this is too hard for most mortals (and they may well
>>> be right -- too painful for me, anyway)!
>>>   
>>>     
>>>       
>> Would you mind telling me where you found that information ? Because 
>> right now, I am wasting a lot of cycles because of memory copy in both 
>> directions, and it is sometimes slow enough so that it is annoying,
>>   
>>     
> I found it reading through the in-program help (the C-API section,
> whatever it's called) on a Matlab installation at my university. I guess
> this was Matlab 2006A. A quick Google search turns this up:
>
> http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/index.html?/access/helpdesk/help/techdoc/matlab_external/f25255.html
>
> They give the following example, which seems to create a Matlab array
> "pArray" with data owned by the C variable "data":
>
> mxArray *pArray = mxCreateDoubleMatrix(0, 0, mxREAL);
> double data[10];
>
> mxSetPr(pArray, data);
> mxSetM(pArray, 1);
> mxSetN(pArray, 10);
>   
Thank you very much, I think this added documentation is pretty recent; 
I have never seen it before, and I did a lot a mex programming at some 
point... This whole mxarray nonsense reminds me why I gave up on matlab :),

cheers,

David

-------------------------------------------------------------------------
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
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to