Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: mxCreateNumericArray maximal array size
Replies: 8   Last Post: Jun 6, 2012 10:16 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Steven Lord

Posts: 17,544
Registered: 12/7/04
Re: mxCreateNumericArray maximal array size
Posted: May 14, 2012 4:25 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.