diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-11-17 11:45:59 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2020-09-21 16:33:21 -0400 |
commit | 5473989610e4a8a9fad67f742b34f749074b9788 (patch) | |
tree | 7a45ca7fea1531fbeeae284b79975368d88d4601 | |
parent | 776725153e8e86dc327e1a3d401f529aff94e39c (diff) | |
download | multi_mode_eit-5473989610e4a8a9fad67f742b34f749074b9788.tar.gz multi_mode_eit-5473989610e4a8a9fad67f742b34f749074b9788.zip |
Further speed up by splitting expressions in parts
-rw-r--r-- | useful_functions.m | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/useful_functions.m b/useful_functions.m index 5492609..0cc4952 100644 --- a/useful_functions.m +++ b/useful_functions.m @@ -79,22 +79,37 @@ function [L0m, polarizability_m]=L0_and_polarization_submatrices( ... m=rhoLiouville_r(s); n=rhoLiouville_c(s); - decay_part_m(p,s)= ... - ( ... - decay_total(g_decay,k)/2 ... - + decay_total(g_decay,j)/2 ... - + g_dephasing(j,k) ... - )* kron_delta_m(j,m)*kron_delta_m(k,n) ... - - kron_delta_m(m,n)*kron_delta_m(j,k)*g_decay(m,j) ; + % speed up avoiding guaranteed to be zero calculations + if ( kron_delta_m(k,n) && kron_delta_m(j,m) ) + decay_part_m(p,s)= ... + ( ... + decay_total(g_decay,k)/2 ... + + decay_total(g_decay,j)/2 ... + + g_dephasing(j,k) ... + ); + endif + if ( kron_delta_m(m,n) && kron_delta_m(j,k) ) + decay_part_m(p,s) += - g_decay(m,j) ; + endif + + % speed up avoiding guaranteed to be zero calculations + if ( kron_delta_m(k,n) ) + % calculate unperturbed part (Hamiltonian without EM field) + L0m(p,s)=H0(j,m); + + polarizability_m.linear(p,s) = dipole_elements.linear(j,m); + polarizability_m.left(p,s) = dipole_elements.left(j,m) ; + polarizability_m.right(p,s) = dipole_elements.right(j,m) ; + endif % speed up avoiding guaranteed to be zero calculations - if ( kron_delta_m(k,n) || kron_delta_m(j,m) ) + if ( kron_delta_m(j,m) ) % calculate unperturbed part (Hamiltonian without EM field) - L0m(p,s)=H0(j,m)*kron_delta_m(k,n)-H0(n,k)*kron_delta_m(j,m); + L0m(p,s)+=-H0(n,k)*kron_delta_m(j,m); - polarizability_m.linear(p,s)= ( dipole_elements.linear(j,m)*kron_delta_m(k,n)-dipole_elements.linear(n,k)*kron_delta_m(j,m) ); - polarizability_m.left(p,s)= ( dipole_elements.left(j,m)*kron_delta_m(k,n)-dipole_elements.left(n,k)*kron_delta_m(j,m) ); - polarizability_m.right(p,s)= ( dipole_elements.right(j,m)*kron_delta_m(k,n)-dipole_elements.right(n,k)*kron_delta_m(j,m) ); + polarizability_m.linear(p,s) +=-dipole_elements.linear(n,k); + polarizability_m.left(p,s) +=-dipole_elements.left(n,k); + polarizability_m.right(p,s) +=-dipole_elements.right(n,k); endif endfor endfor |