% Implicit 1-stage Padé

% Stabilization scheme
W   = 1/2;
w   = 1;

% tau = cinput('\nEnter stabilization parameter >> ',1.d-3);
tau = 1.d-3;

switch xDisc
    case 1; [fST,ST,ST2] = supgMethod(X,T,av,nu,sigma,s,tau,dt,elem,2,W,w);
    case 2; [fST,ST,ST2] = glsMethod (X,T,av,nu,sigma,s,tau,dt,elem,2,W,w);
    case 3; [fST,ST,ST2] = doNothing (X,2);
end

% Resolution of the system
S             = 1/dt*M+W*Ks+ST;
nBd           = length(aux);
A             = zeros(nBd,nPt);
A(:,aux(:,1)) = eye(nBd);
b             = aux(:,2)-aux(:,2);

u      = zeros(nPt,nTl);
Kss    = [S transpose(A);A zeros(nBd)];

u(:,1) = u0;

for n = 1:nStep
    wfs = w*fs;
    wKs = w*Ks*u(:,n);
    STs = ST2*u(:,n);
    
    fss      = [wfs+fST-wKs+STs;b];
    Du       = Kss\fss;
    u(:,n+1) = Du(1:nPt) + u(:,n);
end