comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Code optimization
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Code optimization [message #75143 is a reply to message #75142] Wed, 16 February 2011 12:51 Go to previous messageGo to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
On Feb 16, 3:38 pm, kisCA <ki...@hotmail.com> wrote:
> Hi there,
>
> I am trying, if it's possible to write thes lines in matrix formalism
> but it seems a bit tricky for me.
>
> FOR I=1,NUM DO BEGIN
>         SUMI=0.
>         FOR K=1,M1 DO BEGIN
>                 FOR J=1,M1 DO BEGIN
>                      SUMI=SUMI+COV(J-1,K-1)*CS(J-1,I-1)*CS(K-1,I-1)
>                 ENDFOR
>          ENDFOR
>          VAR_ALPHA(I-1)=SUMI*VAR_FACTOR(I-1)
>  ENDFOR
>
> Is anyone got an idea it will be welcome
>
> Cheers

Yeah, it looks like that doesn't really need loops...

First you want to replace the inner loop with a matrix
multiplication of COV and CS - call the result R (make
sure you get the row and columns in the proper order).
Then you want to replace the K loop with total(R*CS,1).
Then you want to replace the I loop with a multiplication
of the last result by var_factor.

Something along those lines should work...

Ciao,
Paolo



Ciao,
Paolo
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Resizeable Graphics Windows for Traditional Commands
Next Topic: make strsplit not skip null between patterns

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 19:34:04 PDT 2025

Total time taken to generate the page: 0.32351 seconds