Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creation of mxArray *without* memory allocation/initialization

I often optimize some matlab routines by implementing them in mex. This works fine so far - but whenever creating the return mxArray, it gets preinitialized as I build it with mxCreateNumericArray.
In most of my work, I do not need the memory to be preallocated (zeroed). So sad - I can not find a matching command for that purpose (allocating memory without zeroing).

So my question could be answered in two ways:

  1. Which command do I have to call for creating a mxArray without zeroing the contents?
  2. How can I build a mxArray without allocating memory for Pr (and Pi)-field, which I would later allocate by mxMalloc.

One idea is building the Array with size (0,0) - but is this the ultimate solution?

like image 295
Bastian Ebeling Avatar asked Feb 14 '26 11:02

Bastian Ebeling


1 Answers

I guess, building a size (0,0) matrix is as close as it gets to a kind of "empty" constructor. Afterwards you'll have to resize the array using mxMalloc or mxRealloc.

I doubt this will result in a noticable performance gain though, unless you're handling really large arrays.

like image 183
sebastian Avatar answered Feb 16 '26 13:02

sebastian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!