Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: making an evaluation of a VERY long expression much faster
Date: Fri, 3 Jul 2009 21:09:01 +0000 (UTC)
Organization: Boeing
Lines: 26
Message-ID: <h2ls1d$b1i$1@fred.mathworks.com>
References: <64605448-23d8-4aab-946f-a66103ac62b6@n11g2000yqb.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1246655341 11314 172.30.248.37 (3 Jul 2009 21:09:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 3 Jul 2009 21:09:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:552730


kem <kemelmi@gmail.com> wrote in message <64605448-23d8-4aab-946f-a66103ac62b6@n11g2000yqb.googlegroups.com>...
> Hello,
> How can an evaluation of a very very long expression can be made
> faster.
> My expression has terms with the operation .* between matrices and
> then those terms  are summed together
> for example:
> 
> A.*B + B.*C.^2.*D+ A.*C + .....
> 
> where A B C D .. are matrices
> this can be a sum of  100 terms like these
> 
> will programming it in MEX help here?
> 
> Can something else be done?
> 
> 
> I am using it inside an optimization so it is crucial that it will run
> as fast as possible
> 
> Thanks!

From what you have shown so far, I don't see anything that could be executed significantly faster in a mex routine. The matrix * and .* operators in MATLAB are already optimized pretty well. The only thing that a mex could do for you would be to eliminate some temporary variables (i.e., do the entire expression inside the mex and only create one variable to hold the final output), but I doubt that would speed things up much.

James Tursa