The quantum canonical ensemble