An algorithm for minimization of the density-functional energy is desc
ribed that replaces the diagonalization of the Kohn-Sham Hamiltonian w
ith block diagonalization into explicit occupied and partially occupie
d (in metals) subspaces and an implicit unoccupied subspace. The progr
ess reported here represents an important step toward the simultaneous
goals of linear scaling, controlled accuracy, efficiency, and transfe
rability. The method is specifically designed to deal with localized,
nonorthogonal basis sets to maximize transferability and state-by-stat
e iteration to minimize any charge-sloshing instabilities. It allows t
he treatment of metals, which is important in itself, and also because
the dynamics of ''semiconducting'' systems can result in metallic pha
ses. The computational demands of the algorithm scale as the particle
number, permitting applications to problems involving many inequivalen
t atoms.