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:
Jun 6, 2012 10:16 AM
|
|
"shlomi golubev" <e271p314@yahoo.com> wrote in message news:jqndkr$d3m$1@newscl01ah.mathworks.com... > "Steven_Lord" <slord@mathworks.com> wrote in message > <jpg77r$cqn$1@newscl01ah.mathworks.com>... >> >> >> Don't use int _or_ long. Use mwSize and/or mwIndex and let the compiler >> figure it out for you. >> >> http://www.mathworks.com/help/techdoc/apiref/mwsize.html >> >> http://www.mathworks.com/help/techdoc/apiref/mwindex.html >> >> >> http://www.mathworks.com/help/techdoc/matlab_external/brb25_6-1.html >> >> -- >> Steve Lord >> slord@mathworks.com >> To contact Technical Support use the Contact Us link on >> http://www.mathworks.com > > How can it be done during compile time? the array size depends on user > input, if the input is less than 2^31 a simple int would do the job but if > the input is more than that I'll need to use long type for index to avoid > overflow, in any case this decision can be made only during runtime after > the user input was received, am I missing something?
Don't worry about it; let the _compiler_ worry about it. The type defined to be mwIndex will be large enough to contain the largest index into the largest matrix that can theoretically be created on that architecture (see the help for the COMPUTER function, in particular the second output, for that value) and mwSize is similar but for sizes instead of indices.
-- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
|
|
|