From 00ea4f7ef1631a0e7e52320cc9780607f5678722 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Mon, 21 Dec 2009 20:31:15 +0000 Subject: vectorization of susceptibility calculations --- useful_functions.m | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'useful_functions.m') diff --git a/useful_functions.m b/useful_functions.m index ce17071..34f1155 100644 --- a/useful_functions.m +++ b/useful_functions.m @@ -199,13 +199,10 @@ function kappa=susceptibility(wi, rhoLiouville, dipole_elements) kappa.linear=0; kappa.left=0; kappa.right=0; - for i=1:Nlevels - for j=1:Nlevels - kappa.linear += dipole_elements.linear(j,i) * rho(i,j); - kappa.left += dipole_elements.left(j,i) * rho(i,j); - kappa.right += dipole_elements.right(j,i) * rho(i,j); - endfor - endfor + + kappa.linear = sum( sum( transpose(dipole_elements.linear) .* rho ) ); + kappa.left = sum( sum( transpose(dipole_elements.left) .* rho ) ); + kappa.right = sum( sum( transpose(dipole_elements.right) .* rho ) ); endfunction function index=freq2index(freq, modulation_freq) -- cgit v1.2.3