Synthesis of Inhomogeneous Waves Using the Least-Squares Method