A new matrix theorem and its application for establishing independent coordinates for complex dynamical systems with constraints