[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: loops vs vectorization

From: Joan Picanyol i Puig
Subject: Re: loops vs vectorization
Date: Fri, 7 Jul 2006 09:56:11 +0200
User-agent: Mutt/1.5.11

* Paul Kienzle <address@hidden> [20060707 04:22]:
> >    %XXX this shouldn't be hard to vectorize
> >    for lp = 1:lnechoes
> >        ltmp(lp,llags(lp):ln_t + llags(lp) - 1) = ltmps(lp,:) * 
> >lvalues(lp),
> >    end
> The right hand side is easy enough:
>    diag(lvalues)*ltmps
> The left hand side is harder:
>    ltmp(sub2ind(size(ltmp),i,j))
> where
>    i=repmat([1:lnechoes],ln_t,1)
>    j=repmat([1:ln_t]',1,lnechoes)+repmat(llags(:)',ln_t,1)

Thanks for the tip, I hope I remember it next time I'm scratching my

> If what you want is really an attenuated echo, though, then you should 
> be able to use filter.  E.g., the following is a lag 5 echo attenuated 
> by 40%:
>     x=zeros(1,40); x(1:2)=1; plot(filter(1,[1,0,0,0,-0.6],x))

Doh! That's what I get for sharing code: lessons on KISS. Surely filter
handles the complex case as well...

> >Any tips for this one? I have a harder one too, and this one is 
> >killing me:
> >The only reason I haven't rewritten it in C++ (besides the proverbial
> >lack of time) is that I believe most time is spent on the svd() call,
> >and thus there's not much to be gained.
> Check if repeating the svd doubles the amount of running time.  This 
> will confirm that it is the bottleneck, and that the only improvement 
> you will get is by changing your algorithm or using parallelism.

That sound like a plan, and easier than tic()/toc()'ing all over the

Many thanks for your insight.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]