density of states: speed optimization; TODO: see function arguments...