function price=CrkeuCall(S0,K,r,T,sigma,Smax,dS,dt)
M=round(Smax/dS);dS=Smax/M;
N=round(T/dt);dt=T/N;
matval=zeros(M+1,N+1);

vetS=linspace(0,Smax,M+1)';
veti=0:M;
vetj=0:N;
%boundary
matval(:,N+1)=max(K-vetS,0);
matval(1,:) = 0;
matval(M+1,:) = M*dS-(K*exp(-r*dt*(N-vetj)));
%公式系数
alpha=0.25*dt*(sigma^2*(veti.^2)-r*veti);
beta=-dt*0.5*(sigma^2*(veti.^2)+r);
gamma=0.25*dt*(sigma^2*(veti.^2)+r*veti);
M1=-diag(alpha(3:M),-1)+diag(1-beta(2:M))-diag(gamma(2:M-1),1);
[L,U]=lu(M1);  
M2=diag(alpha(3:M),-1)+diag(1+beta(2:M))+diag(gamma(2:M-1),1);
  

for j=N:-1:1
    matval(2:M,j)=U\(L\(M2*matval(2:M,j+1)));
   
    
   
end
price=interp1(vetS,matval(:,1),S0);
