## Singular Value decomposition
## system of equation solver
## Author: M. Turhan ÇOBAN
## Created: 2021-06-13
function [U,S,V] = SVD (A)
      B=A'
      ATA=B*A;
      [xx,y,zz]=eig(ATA);
      xx
      zz
      c=eig(ATA);
      c=flip(sort(c))
      n=length(A);
      n1=length(c);
      V =zeros(n,n);
      U =zeros(n,n);;
      x=zeros(1,n);
      S = zeros(n,n);
      SI = zeros(n,n);
      for i=1:n 
          x(i)=c(i,1)
          S(i,i)=sqrt(x(i))
          SI(i,i)=1.0/S(i,i) 
      end         
      L=zeros(1,n);
      for j=1:n
          for i=1:n            
             L(j)=L(j)+xx(i,j)*xx(i,j);
          endfor
      endfor   
      L  
      V=xx./L    
      V     
      VT=V';
      AV=A*VT
      U=AV*SI
      UT=U';
endfunction
