Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: matlab alternative to mtimesx for this problem ?
Date: Sun, 28 Aug 2011 23:24:09 +0000 (UTC)
Organization: University of Waterloo
Lines: 31
Message-ID: <j3eimp$op4$1@newscl01ah.mathworks.com>
References: <j3e342$dbb$1@newscl01ah.mathworks.com> <j3eb5j$52j$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1314573849 25380 172.30.248.35 (28 Aug 2011 23:24:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 28 Aug 2011 23:24:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1646679
Xref: news.mathworks.com comp.soft-sys.matlab:741518

Merci Bruno,

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message 
> > I want to integrate a function of w and t, wrt w, so the final answer should be a function of t. 

> Wait a minute, why you need to do thing so inefficiently? Sometime you just have to think harder than what you really computes.
> 
> The above results are equal to (at numerical precision)
> 
> > d = trapz(w,w)*t(:);


This is obviously not true for all functions of w and t, and the example I gave wasn't actually the function I'm integrating, but a simpler example.

> BTW: 
> repmat(w,length(t),1).*repmat(t',1,length(w)),
> bsxfun(@times,w,t')
> mtimesx(w,'T',t)
> 
> is simply:
> 
> >  t'*w
> 


Thank you.

But: 
tic;d=trapz(w,t'*w,2);toc

takes 4GB of RAM and 52 seconds. (same as REPMAT and BSXFUN)