#ifndef GRID_MATH_TA_H #define GRID_MATH_TA_H namespace Grid { /////////////////////////////////////////////// // Ta function for scalar, vector, matrix /////////////////////////////////////////////// inline ComplexF Ta( const ComplexF &arg){ return arg;} inline ComplexD Ta( const ComplexD &arg){ return arg;} inline RealF Ta( const RealF &arg){ return arg;} inline RealD Ta( const RealD &arg){ return arg;} template inline iScalar Ta(const iScalar&r) { iScalar ret; ret._internal = Ta(r._internal); return ret; } template inline iVector Ta(const iVector&r) { iVector ret; for(int i=0;i inline iMatrix Ta(const iMatrix &arg) { iMatrix ret(arg); double factor = (1/(double)N); ret = (ret - adj(arg))*0.5; ret -= trace(ret)*factor; return ret; } /////////////////////////////////////////////// // ProjectOnGroup function for scalar, vector, matrix /////////////////////////////////////////////// template inline iScalar ProjectOnGroup(const iScalar&r) { iScalar ret; ret._internal = ProjectOnGroup(r._internal); return ret; } template inline iVector ProjectOnGroup(const iVector&r) { iVector ret; for(int i=0;i::TensorLevel == 0 >::type * =nullptr> inline iMatrix ProjectOnGroup(const iMatrix &arg) { // need a check for the group type? iMatrix ret(arg); double nrm; for(int c1=0;c1 inline auto Determinant(const iScalar&r) -> iScalar { iScalar ret; ret._internal = Determinant(r._internal); return ret; } template::TensorLevel == 0 >::type * =nullptr> inline auto Determinant(const iMatrix &arg)-> iScalar { iMatrix ret(arg); iScalar det = 1.0; /* Conversion of matrix to upper triangular */ for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(j>i){ vtype ratio = ret._internal[j][i]/ret._internal[i][i]; for(int k = 0; k < N; k++){ ret._internal[j][k] -= ratio * ret._internal[i][k]; } } } } for(int i = 0; i < N; i++) det *= ret._internal[i][i]; return det; } /////////////////////////////////////////////// // Exponentiate function for scalar, vector, matrix /////////////////////////////////////////////// template inline iScalar Exponentiate(const iScalar&r, double alpha, int Nexp) { iScalar ret; ret._internal = Exponentiate(r._internal, alpha, Nexp); return ret; } template::TensorLevel == 0 >::type * =nullptr> inline iMatrix Exponentiate(const iMatrix &arg, double alpha, int Nexp) { iMatrix unit(1.0); iMatrix temp(unit); for(int i=Nexp; i>=1;--i){ temp *= alpha/double(i); temp = unit + temp*arg; } return ProjectOnGroup(temp); } } #endif