/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./lib/tensors/Tensor_unary.h Copyright (C) 2015 Author: Azusa Yamaguchi Author: Peter Boyle Author: paboyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ #ifndef GRID_TENSOR_UNARY_H #define GRID_TENSOR_UNARY_H NAMESPACE_BEGIN(Grid); #define UNARY(func) \ template accelerator_inline auto func(const iScalar &z) -> iScalar \ { \ iScalar ret; \ ret._internal = func( (z._internal)); \ return ret; \ } \ template accelerator_inline auto func(const iVector &z) -> iVector \ { \ iVector ret; \ for(int c1=0;c1 accelerator_inline auto func(const iMatrix &z) -> iMatrix \ { \ iMatrix ret; \ for(int c1=0;c1 accelerator_inline iScalar func(const iScalar &z,scal y) \ { \ iScalar ret; \ ret._internal = func(z._internal,y); \ return ret; \ } \ template accelerator_inline iVector func(const iVector &z,scal y) \ { \ iVector ret; \ for(int c1=0;c1 accelerator_inline iMatrix func(const iMatrix &z, scal y) \ { \ iMatrix ret; \ for(int c1=0;c1 accelerator_inline auto toReal(const iScalar &z) -> typename iScalar::Realified { typename iScalar::Realified ret; ret._internal = toReal(z._internal); return ret; } template accelerator_inline auto toReal(const iVector &z) -> typename iVector::Realified { typename iVector::Realified ret; for(int c1=0;c1 accelerator_inline auto toReal(const iMatrix &z) -> typename iMatrix::Realified { typename iMatrix::Realified ret; for(int c1=0;c1 accelerator_inline auto toComplex(const iScalar &z) -> typename iScalar::Complexified { typename iScalar::Complexified ret; ret._internal = toComplex(z._internal); return ret; } template accelerator_inline auto toComplex(const iVector &z) -> typename iVector::Complexified { typename iVector::Complexified ret; for(int c1=0;c1 accelerator_inline auto toComplex(const iMatrix &z) -> typename iMatrix::Complexified { typename iMatrix::Complexified ret; for(int c1=0;c1