diff --git a/lib/tensors/Tensor_unary.h b/lib/tensors/Tensor_unary.h index 2a546701..045097a3 100644 --- a/lib/tensors/Tensor_unary.h +++ b/lib/tensors/Tensor_unary.h @@ -2,7 +2,7 @@ #define GRID_TENSOR_UNARY_H namespace Grid { -#define UNARY_REAL(func)\ +#define UNARY(func)\ template inline auto func(const iScalar &z) -> iScalar\ {\ iScalar ret;\ @@ -53,14 +53,71 @@ template inline iScalar func(const iScalar &z,scal y) \ return ret;\ } -UNARY_REAL(sqrt); -UNARY_REAL(rsqrt); -UNARY_REAL(sin); -UNARY_REAL(cos); +UNARY(sqrt); +UNARY(rsqrt); +UNARY(sin); +UNARY(cos); +UNARY(log); +UNARY(exp); +UNARY(abs); +UNARY(Not); + + +template inline auto toReal(const iScalar &z) -> typename iScalar::Realified +{ + typename iScalar::Realified ret; + ret._internal = toReal(z._internal); + return ret; +} + template inline auto toReal(const iVector &z) -> typename iVector::Realified +{ + typename iVector::Realified ret; + for(int c1=0;c1 inline auto toReal(const iMatrix &z) -> typename iMatrix::Realified +{ + typename iMatrix::Realified ret; + for(int c1=0;c1 inline auto toComplex(const iScalar &z) -> typename iScalar::Complexified +{ + typename iScalar::Complexified ret; + ret._internal = toComplex(z._internal); + return ret; +} + template inline auto toComplex(const iVector &z) -> typename iVector::Complexified +{ + typename iVector::Complexified ret; + for(int c1=0;c1 inline auto toComplex(const iMatrix &z) -> typename iMatrix::Complexified +{ + typename iMatrix::Complexified ret; + for(int c1=0;c1