#ifndef GRID_MATH_EXP_H #define GRID_MATH_EXP_H #define DEFAULT_MAT_EXP 12 namespace Grid { /////////////////////////////////////////////// // Exponentiate function for scalar, vector, matrix /////////////////////////////////////////////// template inline iScalar Exponentiate(const iScalar&r, ComplexD alpha , Integer Nexp = DEFAULT_MAT_EXP) { iScalar ret; ret._internal = Exponentiate(r._internal, alpha, Nexp); return ret; } template::TensorLevel == 0 >::type * =nullptr> inline iMatrix Exponentiate(const iMatrix &arg, ComplexD alpha , Integer Nexp = DEFAULT_MAT_EXP ) { iMatrix unit(1.0); iMatrix temp(unit); for(int i=Nexp; i>=1;--i){ temp *= alpha/ComplexD(i); temp = unit + temp*arg; } return ProjectOnGroup(temp);//maybe not strictly necessary } } #endif