An eigenvalue decomposition method to construct absorbing boundary conditions for acoustic and elastic wave equations