This function obtains a unitary matrix Q such that: d=diag(Q *diag(lmd)*Q). In other words, it gives a way to generate a matrix with given eigenvalues and diagonal elements. By Daniel Perez Palomar (last revision: May 10, 2004). Feel free to distribute this file as it is (without including any modifications).