function  q = mldivide(k,b)

% ofact/mldivide

%	Etienne Balmes
%       Copyright (c) 2001-2004 by INRIA and SDTools,All Rights Reserved.
%       Use under OpenFEM trademark.html license and LGPL.txt library license
%       $Revision: 1.6 $  $Date: 2005/09/30 16:02:58 $

switch k.ty(1)
case 6.1
   if size(b,2)==1; b=b.*k.dinv;
   else
     for j1=1:size(b,2);  b(:,j1)=b(:,j1).*k.dinv; end
   end
   q=b;

case 6
   for j1=1:size(b,2);  b(ind,j1)=b(ind,j1).*k.dinv; end
   q=b;
case 0
 if ischar(b); sp_util('sky_dec',k);end;q=[];
case 2
 if ischar(b); q=[]; else; q = k.u \ (k.l \ b);end
case 3
 if ischar(b); q=[]; else; q = k.u \ (k.l \ b);end
case 5

 if ischar(b) q='done';
 elseif ~isempty(k.method.Solve); eval(k.method.Solve)
 else
  if strcmp(k.ind,'spfmex')  
    q=spfmex('solve',k.ty(2),full(b));
  elseif strcmp(k.ind,'psldlt')
    q=zeros(size(b));
    for j1=1:size(b,2);  q(:,j1)=psldlt('solve',full(b(:,j1)),k.ty(2));  end
  end
 end
otherwise
 if isempty(b)|ischar(b) q=b;
 elseif ~isempty(k.method.Solve); eval(k.method.Solve)
 else
  if issparse(b); b=full(b);end
  if k.ty(1)==0;  sp_util('sky_dec',k); end
  if isreal(b); q = sp_util('sky_inv',k,b);
  else q = sp_util('sky_inv',k,real(b))+i*sp_util('sky_inv',k,imag(b));end
 end
end 
