Efficient approximation of functions of some large matrices by partial fraction expansions