! Performs normalization of X
! Replaces X(n, m) by an orthonormal matrix U(n, m)
! "m" vectors with "n" coordinates
subroutine Normalize(n, m, X, tol)
complex X(n,m)
complex z(n)


! Normalize each vector (column) of X:
DO j =1,m

z =X(:,j)

if(vNorm2(n,z) >=TOL) then
X(:, j) =z/vNorm2(n,z)
else
X(:, j) =z		!(0.,0.)
endif

ENDDO

!write(1,*) 'X-normalized:'
!do i =1,n
!write(1,*) X(i,1:m)
!enddo
END subroutine Normalize
