Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: mxCreateNumericArray maximal array size
Posted:
May 14, 2012 4:25 PM
|
|
"shlomi golubev" <e271p314@yahoo.com> wrote in message news:jorop9$p5g$1@newscl01ah.mathworks.com... > I have this mex code > ... > dims[0]=2*(2*n-1); dims[1]=2*(2*n-1); dims[2]=2*(2*n-1); > plhs[0]=mxCreateNumericArray(3,dims,mxSINGLE_CLASS,complexFlag); > ... > for n <= 323 it works fine, but for n >= 324 matlab crashes with an ugly > core dump. > > I checked what is so special about these numbers and it appears that this > is exactly the point where (2*(2*n-1))^3 becomes bigger than 2^31. > > so I run another test like this > > ... > dims[0]=2*(2*n-1); dims[1]=2*(2*n-1); > plhs[0]=mxCreateNumericArray(2,dims,mxSINGLE_CLASS,complexFlag); > ... > > again same result only this time for n <= 23170 it works fine, but for n > >= 23171 matlab crashes with an ugly core dump > > so the problem is obvious, any chances to fix it soon or to provide some > work around?
Do you check to make sure that plhs[0] is not NULL before trying to use it? See the Returns section of:
http://www.mathworks.com/help/techdoc/apiref/mxcreatenumericarray.html
My guess is that you're on a 32-bit OS, in which case you should check the second output of the COMPUTER function in MATLAB. It may look familiar.
The "workaround" is to test the output of mxCreateNumericArray before using it and do something appropriate if it's NULL. Another possibility is to consider a 64-bit OS if you want to create very large arrays.
-- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
|
|
|