added matrix exponentiation template