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 #75142 is a reply to message #75141] Wed, 16 February 2011 12:57 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
Are cov, cs and var_factor functions or variables? If variables, it would be a lot clearer to subscript them with [] instead of (). (also, why start those for loops at 1 and have -1 scattered throughout the code? it would be clearer to loop from 0 to num-1 or m-1 respectively and just index with i, j and k)

Assuming they're variables:

; calculate the matrix sum
sum = matrix_multiply(matrix_multiply(cov, cs), cs, /atranspose)
; pick out the diagonals, which are the ones with the same i in both cs multiplications
diags = (num+1) * lindgen(num)
; multiply by var_factor
var_alpha = sum[diags] * var_factor

-Jeremy.
[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 13:42:19 PDT 2025

Total time taken to generate the page: 0.80303 seconds