Nonlinear matrix solution of the Kohn-Hohenberg-Sham equation for electrons in a jellium slab