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

Home » Public Forums » archive » Help optimizing the nested for loops
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Help optimizing the nested for loops [message #42774] Thu, 24 February 2005 12:46
Messon Gbah is currently offline  Messon Gbah
Messages: 4
Registered: September 2000
Junior Member
Could some one help get rid of nested for loops in the following statements?
The original code was written in C and I'm trying to port it to IDL.

indx = indgen(n)
indx[0] = 3
index[3] = 0
array = dblarr(n,n)
alpha = dblarr(n,n)
beta = dblarr(n)

;Loop 1
trace = double(0.0)
for j=0, n-1 do begin
vj = indx[j]
trace += alpha[vj,vj]
alpha[vj,vj] += flamda ;flamda = a constant
for k=0,j do alpha[vj,indx[k]] = alpha[indx[k],vj]
endfor

;Loop 2
for j=0, n-1 do begin
vj = indx[j]
for k=0,n-1 do array[indx[k],j] =
alpha[indx[k],vj]/sqrt(alpha[vj,vj]*alpha[indx[k],indx[k]])
endfor

;Loop 3
for j=0, n-1 do begin
vj = indx[j]
b[vj] = T[vj] ;T is some init value
for k=0, n-1 do begin
vk = indx[k]
b[vj] += beta[vk]*array[k,j]/sqrt(alpha[vj,vj]*alpha[vk,vk])
endfor
endfor
[Message index]
 
Read Message
Previous Topic: ENVI Error: Negative position argument not allowed
Next Topic: file_basename(): bug or feature?

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

Current Time: Fri Oct 10 15:22:57 PDT 2025

Total time taken to generate the page: 1.43873 seconds