Integrated Hai's SVD code