function  F = sysmatrix(cv,th,rn)
%SYSMATRIX
%
%	F = SYSMATRIX(CV,TH,RN)
%
%    Returns the 2 x 2 paraxial system matrix given
%
%     CV   curvatures
%     TH   distance to following surface
%     RN   refractive index of following medium
%
%     first surface is a dummy to give index of incident medium
%
	m = length(th);
	if (nargin==2)
	   phi = cv;
	   td = th;
	else
	   phi(1) = 0;
	   td(1) = th(1)/rn(1);
	   for (i=2:m)
	      phi(i) = (rn(i)-rn(i-1))*cv(i);
	      td(i) = th(i)/rn(i);
	   end
	end
	F = eye(2,2);
	for (i=1:m)
	  F = F * [ 1 -phi(i); 0 1 ] * [ 1 0; td(i) 1];
	end