function [x,nok,rA,VI,cI]=lae(A,B,eps);
%LAE solves A*x=B for any dimensions (m,n) of A with the accuracy eps
%x - solution
%nok - 0 if OK, otherwise nonzero describing how many dependent equations not fulfilled
%rA - rank of A computed by SVD with accuracy eps
%VI - enables to compute all solutions if many exists
% the solutions are x = x + VI*yI where yI is arbitrary vector of dimensions (n-rA,1)
%cI - cI=0 describes the fulfillment of dependent equations
%
[m,n]=size(A);
[U,S,V]=svd(A);
S=diag(S);
rA=sum(S>eps);
c=U'*B;
if m>rA,
   cI=c((rA+1):m,1);
   nok=sum(cI>eps);
else
   cI=[];
   nok=0;
end;
S=S(1:rA,1);
cD=c(1:rA,1);
yD=cD./S;
if n>rA,
   VI=V(:,(rA+1):n);
   yI=zeros(n-rA,1);
else
   VI=[];
   yI=[];
end;
y=[yD;yI];
x=V*y;
   