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: How can you enlarge a matrix by adding zeroes
Replies: 20   Last Post: Jun 19, 2012 12:22 PM

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,538
Registered: 12/7/04
Re: How can you enlarge a matrix by adding zeroes
Posted: Jun 18, 2012 10:21 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"dpb" <none@non.net> wrote in message news:jrihne$ncn$1@speranza.aioe.org...
> On 6/16/2012 11:16 AM, Nasser M. Abbasi wrote:
> ...
>

>> We as users, we have to assume the Matlab engineers who added this
>> message to the code analyzer had a good reason to do it. They did
>> not add it just for for the fun of it.

> ...
>
> OK, I've done an extensive perusal of the online doc's for the last
> release and I can find no hints of TMW suggesting to write matrices w/o
> the brackets for performance in any situation.


Try this little experiment in the Command Window. You will receive warnings
from the DBSTOP calls, but that's to be expected.

http://www.mathworks.com/help/techdoc/ref/dbstop.html

"If file is not a MATLAB code file (for instance, it is a built-in or
MDL-file), then MATLAB issues a warning. MATLAB cannot stop in the file, so
it pauses before executing the file."

dbstop in horzcat
dbstop in vertcat
a = [5]

Note that MATLAB DOES call the built-in concatenation routine here, since
you're using []. Whether or not it calls the built-in concatenation routines
in a function file depends on how old a version of MATLAB you're using, I
think. The parser may be smart enough in later releases to avoid the
unnecessary call to the built-in concatenation routine since it can tell
that the built-in routine will be called. Code Analyzer does _static_
analysis of the code; the parser is not limited to static analysis when
running the code.

Granted, the concatenation routine doesn't have to DO much or anything in
this case, so it may not seem like a big deal. But consider doing this
inside a loop that iterates millions of times; the tiny overhead of calling
the built-in function may add up.

> The links to parentheses and brackets have essentially identical
> documentation as I have here--it says 'help paren' has more info on
> parentheses but I can't do that except locally.
>
> I suppose it's possible that there's where the guidance is hidden but I
> seriously doubt it says anything of the sort there, either.
>
> So, I think the recommendation is simply an artifact of the code analyzer
> nobody has ever questioned seriously as to the validity/reason for it.
> Otherwise one has to presume there's a real reason for special-casing the
> specific case and if so it's a significant oversight in the documentation
> that it isn't discussed.
>
> $0.025, imo, ymmv, etc., etc., etc., ...
>
> Maybe S Lord will stumble upon the argu^h^h^h^hdiscussion and can comment
> on the validity/significance of the analyzer and what applications it is
> intended to address.


If the parser has gotten smart enough, perhaps the particular message that
you and Bruno have been "discussing" is no longer necessary for functions or
classdef files. I'll ask the Code Analyzer developers to investigate and
determine if that message can be removed.

--
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.