Generalized Phase Retrieval and a Nonconvex Formulation