function drdp = drhs_dparam(x,dxdp,param)
%
% Caswell, Demographic Research, vol 18 (2009)
% Example 1, page 67
%

xdim=length(x);
kdim=length(param);
drdp=zeros(xdim,kdim+xdim);

% Calculate dgdx
dgdx=dgvec_dxvec(x,param);

%Calculate dgdparam
dgdp=dgvec_dparam(x,param);

% Construct derivative of rhs wrt parameters
for i=1:xdim
    for k=1:kdim+xdim
        for m=1:xdim
           drdp(i,k)=drdp(i,k)+dgdx(i,m)*dxdp(m,k);
        end
        drdp(i,k)=drdp(i,k)+dgdp(i,k);
    end
end

%[V,D]=eig(dgdx)

end
