An algebraic method for linear dynamical systems with stationary excitations