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,526
Registered: 12/7/04
Re: mxCreateNumericArray maximal array size
Posted: Jun 6, 2012 10:16 AM
  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: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




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.