function [senmat, emat] = sensitivity(a)
% [s,e] = sensitivity(a)
%
% Given Leslie matrix a, finds the corresponding
% sensitivity matrix, s, and the elasticity matrix, e.
%

[w,d] = eig(a);
d = diag(d);
v = conj(inv(w));
imax = find(d==max(d));
w =  w(:,imax);
v = real(v(imax,:)).';
senmat=v*w';

%elasticity = (1/imax)*senmat.*a;
emat = senmat.*a/max(eig(a));

