diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2009-12-16 06:30:40 +0000 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2009-12-16 06:30:40 +0000 |
commit | 5f68e6a3823704d7c62fc128cf7d413e13de4ffd (patch) | |
tree | c215ca96ed95da43c54cd9c5728bd1e5c7c06fe2 /useful_functions.m | |
parent | 32648d980195e97da34668b49ce721f67463084e (diff) | |
download | multi_mode_eit-5f68e6a3823704d7c62fc128cf7d413e13de4ffd.tar.gz multi_mode_eit-5f68e6a3823704d7c62fc128cf7d413e13de4ffd.zip |
vectorization of unfold_density_matrix
Diffstat (limited to 'useful_functions.m')
-rw-r--r-- | useful_functions.m | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/useful_functions.m b/useful_functions.m index 10afb69..8e73ddf 100644 --- a/useful_functions.m +++ b/useful_functions.m @@ -26,22 +26,20 @@ function [N, rhoLiouville_w, rhoLiouville_r, rhoLiouville_c]=unfold_density_matr % unwrap density matrix to Liouville density vector and assign all possible % modulation frequencies as well % resulting vector should be Nlevels x Nlevels x length(modulation_freq) - N=Nfreq*Nlevels*Nlevels; + N = Nfreq*Nlevels*Nlevels; + rho_size = Nlevels*Nlevels; rhoLiouville_w=zeros(N,1); rhoLiouville_r=zeros(N,1); rhoLiouville_c=zeros(N,1); - i=0; - for w=1:Nfreq; - for r=1:Nlevels - for c=1:Nlevels - i+=1; - rhoLiouville(i)=0; - rhoLiouville_w(i)=w; % hold frequency modulation index - rhoLiouville_r(i)=r; % hold row value of rho_rc - rhoLiouville_c(i)=c; % hold column value of rho_rc - endfor - endfor - endfor + + w=1:Nfreq; + w_tmplate(:)=repmat(w,rho_size,1); + rhoLiouville_w=w_tmplate'; + r=1:Nlevels; + r_tmplate(:)=repmat(r,Nlevels,1); + rhoLiouville_r(:)=repmat(r_tmplate',Nfreq,1); + c=(1:Nlevels)';% hold column value of rho_rc + rhoLiouville_c=repmat(c,Nfreq*Nlevels,1); endfunction |