function  [K1,K2,K3]=ckdf(x,xl,a,alph,bet,gam,delt)
%function  [K1,K2,K3]=ckdf(x,xl,a,alph,bet,gam,delt)
C=exp(x(1,:));K=exp(x(2,:));CL=exp(xl(1,:));KL=exp(xl(2,:));
ncol=size(x,2);
K1=zeros(2,2,ncol);K2=zeros(2,2,ncol);K3=zeros(2,1,ncol);
K1(1,:,:)=ones(1,2,ncol);
K1(2,1,:)=gam*bet*(alph*exp(a).*KL.^(alph-1)+delt)./C.^(gam+1);
K1(2,2,:)= zeros(1,ncol);
K2(1,1,:)=zeros(1,ncol);
K2(1,2,:)=-alph*exp(a).*KL.^(alph-1)-delt;
K2(2,1,:)=-gam./CL.^(gam+1);
K2(2,2,:)= bet*alph*(1-alph)*exp(a).*KL.^(alph-2)./C.^gam;
K3=[-exp(a).*KL.^alph;-exp(a).*KL.^(alph-1)*bet*alph./C.^gam];
%to here, have df/dexp(x) (except for K3).  To get df/dx, mult by exp(x):
K1=K1.*rrepmat(exp(x),2,[]);
K2=K2.*rrepmat(exp(xl),2,[]);
