#ifndef GRID_MATH_TRANSPOSE_H #define GRID_MATH_TRANSPOSE_H namespace Grid { ///////////////////////////////////////////////////////////////// // Transpose all indices ///////////////////////////////////////////////////////////////// inline ComplexD transpose(ComplexD &rhs){ return rhs;} inline ComplexF transpose(ComplexF &rhs){ return rhs;} inline RealD transpose(RealD &rhs){ return rhs;} inline RealF transpose(RealF &rhs){ return rhs;} template inline typename std::enable_if::value, iMatrix >::type transpose(iMatrix arg) { iMatrix ret; for(int i=0;i inline typename std::enable_if::notvalue, iMatrix >::type transpose(iMatrix arg) { iMatrix ret; for(int i=0;i inline typename std::enable_if::value, iScalar >::type transpose(iScalar arg) { iScalar ret; ret._internal = transpose(arg._internal); // NB recurses return ret; } template inline typename std::enable_if::notvalue, iScalar >::type transpose(iScalar arg) { iScalar ret; ret._internal = arg._internal; // NB recursion stops return ret; } //////////////////////////////////////////////////////////////////////////////////////////// // Transpose a specific index; instructive to compare this style of recursion termination // to that of adj; which is easiers? //////////////////////////////////////////////////////////////////////////////////////////// #if 0 template inline typename std::enable_if,Level>::value, iMatrix >::type transposeIndex (const iMatrix &arg) { iMatrix ret; for(int i=0;i inline typename std::enable_if,Level>::notvalue, iMatrix >::type transposeIndex (const iMatrix &arg) { iMatrix ret; for(int i=0;i(arg._internal[i][j]); }} return ret; } template inline typename std::enable_if,Level>::notvalue, iScalar >::type transposeIndex (const iScalar &arg) { iScalar ret; ret._internal=transposeIndex(arg._internal); return ret; } template inline typename std::enable_if,Level>::value, iScalar >::type transposeIndex (const iScalar &arg) { return arg; } #endif } #endif