A generalized horner algorithm for computing integrals involving the matrix exponential