mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
d9d4c5916a
Now need to construct pseudofermion two flavour, ratio, one flavour, ratio action fragments.
47 lines
1.3 KiB
C++
47 lines
1.3 KiB
C++
#ifndef GRID_MATH_TRACE_H
|
|
#define GRID_MATH_TRACE_H
|
|
namespace Grid {
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
// Traces: both all indices and a specific index. Indices must be
|
|
// either scalar or matrix
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
inline ComplexF trace( const ComplexF &arg){ return arg;}
|
|
inline ComplexD trace( const ComplexD &arg){ return arg;}
|
|
inline RealF trace( const RealF &arg){ return arg;}
|
|
inline RealD trace( const RealD &arg){ return arg;}
|
|
|
|
template<class vtype,int N>
|
|
inline auto trace(const iMatrix<vtype,N> &arg) -> iScalar<decltype(trace(arg._internal[0][0]))>
|
|
{
|
|
iScalar<decltype( trace(arg._internal[0][0] )) > ret;
|
|
zeroit(ret._internal);
|
|
for(int i=0;i<N;i++){
|
|
ret._internal=ret._internal+trace(arg._internal[i][i]);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
template<class vtype>
|
|
inline auto trace(const iScalar<vtype> &arg) -> iScalar<decltype(trace(arg._internal))>
|
|
{
|
|
iScalar<decltype(trace(arg._internal))> ret;
|
|
ret._internal=trace(arg._internal);
|
|
return ret;
|
|
}
|
|
|
|
template<class vtype,int N>
|
|
inline auto trace(const iVector<vtype,N> &arg) -> iVector<decltype(trace(arg._internal[0])),N>
|
|
{
|
|
iVector<decltype(trace(arg._internal[0])),N> ret;
|
|
for(int i=0;i<N;i++){
|
|
ret._internal[i]=trace(arg._internal[i]);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
|
|
}
|
|
#endif
|