search for: cos_ij

Displaying 1 result from an estimated 1 matches for "cos_ij".

2007 Jul 23
1
code optimization tips
...s)), > nrow = 2, byrow = TRUE) > } > rj<-positions(N)*spacing # all positions in the 2N x 2N array > rj<-rj[1:2,-((dim(rj)[2]-1)/2+1)] # remove rj=(0,0) > > mod<-function(x){sqrt(x[1]^2+x[2]^2)} # modulus > > sij <-function(rj){ > rij=mod(rj-ri) > cos_ij=rj[1]/rij > sin_ij=rj[2]/rij > > A<-(1-1i*k*rij)*(3*cos_ij^2-1)*exp(1i*k*rij)/(rij^3) > B<-k^2*sin_ij^2*exp(1i*k*rij)/rij > > sij<-A+B > } > > s_ij<-apply(rj,2,sij) > S<-sum(s_ij) > alpha_s/(1-alpha_s*S) > } > alpha_c() This function is to be...