Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.25 KB | None | 0 0
  1. function [V,G_inv] = soliton2(V,z,eigs,c,x,t)
  2.  
  3. % eigs = [1i; 2 + 3i]; c = [2.3; 5.7];
  4. c = c.*exp(2i*eigs*x);
  5. N = numel(eigs);
  6.  
  7. A = 1./(eigs - eigs'); B = -A.';
  8.  
  9. u = (eye(N) - B*A)\(-conj(c));
  10. v = (eye(N) - B*A)\(B*c);
  11. s = (eye(N) - A*B)\c;
  12. r = (eye(N) - A*B)\(-A*conj(c));
  13.  
  14. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  15.  
  16. % z0 = 2-3i;
  17. %
  18. % R = .01;
  19. % N = 100; h = 2*pi/N;
  20. %
  21. % t = (0:h:2*pi-h).';
  22. %
  23. % z = z0 + R*exp(1i*t);
  24. % dz = R*1i*exp(1i*t);
  25. %
  26. % f = zeros(N,1);
  27.  
  28. G = zeros(numel(z),2,2); G_inv = zeros(numel(z),2,2);
  29.  
  30. for i = 1:numel(z)
  31.     z1 = 1./(z(i)-eigs); z2 = 1./(z(i)-conj(eigs));
  32.     G(i,1,1) = 1 + dot(r,z1);
  33.     G(i,2,1) = dot(s,z1);
  34.     G(i,1,2) = dot(u,z2);
  35.     G(i,2,2) = 1 + dot(v,z2);    
  36.     G_inv(i,:,:) = inv(squeeze(G(i,:,:)));
  37. end
  38.  
  39. % compute f = G * V
  40. f11 = G(:,1,1).*V(:,1,1) + G(:,1,2).*V(:,2,1);
  41. f12 = G(:,1,1).*V(:,1,2) + G(:,1,2).*V(:,2,2);
  42. f21 = G(:,2,1).*V(:,1,1) + G(:,2,2).*V(:,2,1);
  43. f22 = G(:,2,1).*V(:,1,2) + G(:,2,2).*V(:,2,2);
  44.  
  45. % compute f * G^-1 = G*V*G^-1
  46. V(:,1,1) = f11.*G_inv(:,1,1) + f12.*G_inv(:,2,1);
  47. V(:,1,2) = f11.*G_inv(:,1,2) + f12.*G_inv(:,2,2);
  48. V(:,2,1) = f21.*G_inv(:,1,1) + f22.*G_inv(:,2,1);
  49. V(:,2,2) = f21.*G_inv(:,1,2) + f22.*G_inv(:,2,2);
  50. %
  51. % residue = 1/(2i*pi)*sum(f.*dz*h)
  52.  
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement