Ab initio simulation of optical properties of noble-metal clusters