Home > atphysics > LinearOptics > amat.m

amat

PURPOSE ^

find A matrix from one turn map matrix T such that:

SYNOPSIS ^

function a=amat(transmat)

DESCRIPTION ^

find A matrix from one turn map matrix T such that:

           [Rotx  0    0  ]
inv(A)*T*A=[ 0   Rotz  0  ]
           [ 0    0   Rots]

Order it so that it is close to the order of x,y,z
also ensure that positive modes are before negative so that
one has proper symplecticity
B. Nash July 18, 2013
we order and normalize the vectors via
 v_j' jmat(3) v_k = i sgn(j) delta(j,k)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function a=amat(transmat)
0002 %find A matrix from one turn map matrix T such that:
0003 %
0004 %           [Rotx  0    0  ]
0005 %inv(A)*T*A=[ 0   Rotz  0  ]
0006 %           [ 0    0   Rots]
0007 %
0008 %Order it so that it is close to the order of x,y,z
0009 %also ensure that positive modes are before negative so that
0010 %one has proper symplecticity
0011 %B. Nash July 18, 2013
0012 %we order and normalize the vectors via
0013 % v_j' jmat(3) v_k = i sgn(j) delta(j,k)
0014 
0015 persistent Vxyz jm
0016 if isempty(Vxyz)
0017     Vxyz={...
0018         1/sqrt(2)*[-1i -1;1 1i;],...
0019         1/sqrt(2)*[-1i -1 0 0;1 1i 0 0;0 0 -1i -1;0 0 1 1i;],...
0020         1/sqrt(2)*[-1i -1 0 0 0 0;1 1i 0 0 0 0;0 0 -1i -1 0 0;...
0021         0 0 1 1i 0 0; 0 0 0 0 -1i -1;0 0 0 0 1 1i;]...
0022         };
0023     jm={jmat(1),jmat(2),jmat(3)};
0024 end
0025 
0026 nv=size(transmat,1);
0027 dms=nv/2;
0028 idx=reshape(1:nv,2,dms);
0029 select=idx(1,:);
0030 
0031 [V,~]=eig(transmat);
0032 
0033 %compute norms of each:
0034 Vp=V'*jm{dms};
0035 n=-0.5i*sum(Vp.'.*V);
0036 
0037 %put positive modes before negative modes (swap columns if first n in pair
0038 %is negative)
0039 order=reshape(idx([1 1],:),1,nv) + (n<0);
0040 V=V(:,order);
0041 n=n(order);
0042 
0043 %now normalize each vector
0044 Vn=V./repmat(sqrt(abs(n)),nv,1);
0045 
0046 %find the vecs that project most onto x,y,z, and reorder
0047 %nn will have structure
0048 % n1x n1y n1z
0049 % n2x n2y n2z
0050 % n3x n3y n3z
0051 nn=0.5*abs(sqrt(-1i*Vn'*jm{dms}*Vxyz{dms}));
0052 [~,ind]=max(nn(select,select));
0053 
0054 indS=ind;
0055 %sort ind for the case of repeated indices
0056 %[~,indS]=sort(ind,2);
0057 %logic still not quite correct- should find best projector on x then y then
0058 %z.  Can the one vector project best on both x and y?  Is this projection
0059 %definition correct?
0060 %14 Oct, 2014- more testing needed before using this additional sort.
0061 %B. Nash
0062 
0063 %reorder pairs
0064 V_ordered=Vn(:,2*indS-1);
0065 
0066 %build a matrix
0067 a=reshape([real(V_ordered);imag(V_ordered)],nv,nv);
0068 
0069 end
0070 
0071

Generated on Thu 24-Aug-2017 18:47:33 by m2html © 2005