An Efficient Method For Approximating Products of Functions of Matrices With Vectors