[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 00:16:46 +0200
User-agent: Mutt/1.5.11

'k, so let's turn this into "I wish I'd know how to vectorize this".

* Robert A.Macy <address@hidden> [20060706 01:11]:
> for example, the simple act of replacing every item that is
> less than negative with the value zero.  

Indexing with find should fit your needs.

I just found this in some code of mine:

    %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),

Any tips for this one? I have a harder one too, and this one is killing me:

    for i = 1:ln_t
        [u,s,v] = svd(Rx(:,:,i)),
        w = 1./diag(s + 1000*eps),
        m = (abs(u.'*conj(a_s))).^2,
        pow_density = 1 ./ (sum(diag(w)*m)),
        k = find(pow_density == max(pow_density)),

        %check for aliasing
        if (length(k) ~= 1) 
            msg = sprintf('capon_doa_est found %d out of %d possible DoAs\n',...
                k, length(theta_s))
            k = k(1)

        ldoa(i) = theta_s(k),

For those in signal processing, this is supposed to be a Capon DoA
estimator.  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. It is also svd()
that I wouldn't know how to vectorize.


reply via email to

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