From 28d6be2a4e87ee419e35e7878ed5944b13ecbce2 Mon Sep 17 00:00:00 2001 From: Peter Boyle Date: Thu, 22 Aug 2019 18:56:37 +0100 Subject: [PATCH] Fix GCC complaint --- Grid/tensors/Tensor_arith_scalar.h | 179 +++++++++++++++++++++-------- 1 file changed, 133 insertions(+), 46 deletions(-) diff --git a/Grid/tensors/Tensor_arith_scalar.h b/Grid/tensors/Tensor_arith_scalar.h index a9bb0310..3ee0900a 100644 --- a/Grid/tensors/Tensor_arith_scalar.h +++ b/Grid/tensors/Tensor_arith_scalar.h @@ -60,166 +60,245 @@ template accelerator_inline iMatrix operator * (const typena //////////////////////////////////////////////////////////////////// // Double support; cast to "scalar_type" through constructor //////////////////////////////////////////////////////////////////// -template accelerator_inline iScalar operator * (const iScalar& lhs,double rhs) + +template::scalar_type,double> = 0> +accelerator_inline iScalar operator * (const iScalar& lhs,double rhs) { + // typename std::enable_if::scalar_type,double>::value,int>::type i=0; typename iScalar::scalar_type t; t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs*srhs; } -template accelerator_inline iScalar operator * (double lhs,const iScalar& rhs) { return rhs*lhs; } +template::scalar_type,double> = 0> +accelerator_inline iScalar operator * (double lhs,const iScalar& rhs) +{ + // typename std::enable_if::scalar_type,double>::value,int>::type i=0; + return rhs*lhs; +} -template accelerator_inline iVector operator * (const iVector& lhs,double rhs) +template::scalar_type,double> = 0> +accelerator_inline iVector operator * (const iVector& lhs,double rhs) { + // typename std::enable_if::scalar_type,double>::value,int>::type i=0; typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs*srhs; } -template accelerator_inline iVector operator * (double lhs,const iVector& rhs) { return rhs*lhs; } +template::scalar_type,double> = 0> +accelerator_inline iVector operator * (double lhs,const iVector& rhs) +{ + // typename std::enable_if::scalar_type,double>::value,int>::type i=0; + return rhs*lhs; +} -template accelerator_inline iMatrix operator * (const iMatrix& lhs,double rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator * (const iMatrix& lhs,double rhs) { + // typename std::enable_if::scalar_type,double>::value,int>::type i=0; typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs*srhs; } -template accelerator_inline iMatrix operator * (double lhs,const iMatrix& rhs) { return rhs*lhs; } +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator * (double lhs,const iMatrix& rhs) +{ + // typename std::enable_if::scalar_type,double>::value,int>::type i=0; + return rhs*lhs; +} //////////////////////////////////////////////////////////////////// // Complex support; cast to "scalar_type" through constructor //////////////////////////////////////////////////////////////////// -template accelerator_inline iScalar operator * (const iScalar& lhs,ComplexD rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator * (const iScalar& lhs,ComplexD rhs) { + // typename std::enable_if::scalar_type,ComplexD>::value,int>::type i=0; typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; - return lhs*srhs; } -template accelerator_inline iScalar operator * (ComplexD lhs,const iScalar& rhs) { return rhs*lhs; } - -template accelerator_inline iVector operator * (const iVector& lhs,ComplexD rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator * (ComplexD lhs,const iScalar& rhs) { + // typename std::enable_if::scalar_type,ComplexD>::value,int>::type i=0; + return rhs*lhs; +} + +template::scalar_type,double> = 0> +accelerator_inline iVector operator * (const iVector& lhs,ComplexD rhs) +{ + // typename std::enable_if::scalar_type,ComplexD>::value,int>::type i=0; typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs*srhs; } -template accelerator_inline iVector operator * (ComplexD lhs,const iVector& rhs) { return rhs*lhs; } - -template accelerator_inline iMatrix operator * (const iMatrix& lhs,ComplexD rhs) +template::scalar_type,double> = 0> +accelerator_inline iVector operator * (ComplexD lhs,const iVector& rhs) { + // typename std::enable_if::scalar_type,ComplexD>::value,int>::type i=0; + return rhs*lhs; +} + +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator * (const iMatrix& lhs,ComplexD rhs) +{ + // typename std::enable_if::scalar_type,ComplexD>::value,int>::type i=0; typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs*srhs; } -template accelerator_inline iMatrix operator * (ComplexD lhs,const iMatrix& rhs) { return rhs*lhs; } +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator * (ComplexD lhs,const iMatrix& rhs) +{ + // typename std::enable_if::scalar_type,ComplexD>::value,int>::type i=0; + return rhs*lhs; +} //////////////////////////////////////////////////////////////////// // Integer support; cast to "scalar_type" through constructor //////////////////////////////////////////////////////////////////// -template accelerator_inline iScalar operator * (const iScalar& lhs,Integer rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator * (const iScalar& lhs,Integer rhs) { + // typename std::enable_if::scalar_type,ComplexD>::value,int>::type i=0; typename iScalar::scalar_type t; t=rhs; typename iScalar::tensor_reduced srhs; srhs=t; return lhs*srhs; } -template accelerator_inline iScalar operator * (Integer lhs,const iScalar& rhs) { return rhs*lhs; } +template::scalar_type,double> = 0> +accelerator_inline iScalar operator * (Integer lhs,const iScalar& rhs) +{ + // typename std::enable_if::scalar_type,Integer>::value,int>::type i=0; + return rhs*lhs; +} -template accelerator_inline iVector operator * (const iVector& lhs,Integer rhs) +template::scalar_type,double> = 0> +accelerator_inline iVector operator * (const iVector& lhs,Integer rhs) { + // typename std::enable_if::scalar_type,Integer>::value,int>::type i=0; typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs*srhs; } -template accelerator_inline iVector operator * (Integer lhs,const iVector& rhs) { return rhs*lhs; } - -template accelerator_inline iMatrix operator * (const iMatrix& lhs,Integer rhs) +template::scalar_type,double> = 0> +accelerator_inline iVector operator * (Integer lhs,const iVector& rhs) { + // typename std::enable_if::scalar_type,Integer>::value,int>::type i=0; + return rhs*lhs; +} + +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator * (const iMatrix& lhs,Integer rhs) +{ + // typename std::enable_if::scalar_type,Integer>::value,int>::type i=0; typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs*srhs; } -template accelerator_inline iMatrix operator * (Integer lhs,const iMatrix& rhs) { return rhs*lhs; } +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator * (Integer lhs,const iMatrix& rhs) +{ + // typename std::enable_if::scalar_type,Integer>::value,int>::type i=0; + return rhs*lhs; +} /////////////////////////////////////////////////////////////////////////////////////////////// // addition by fundamental scalar type applies to matrix(down diag) and scalar /////////////////////////////////////////////////////////////////////////////////////////////// -template accelerator_inline iScalar operator + (const iScalar& lhs,const typename iScalar::scalar_type rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator + (const iScalar& lhs,const typename iScalar::scalar_type rhs) { typename iScalar::tensor_reduced srhs; srhs=rhs; return lhs+srhs; } -template accelerator_inline iScalar operator + (const typename iScalar::scalar_type lhs,const iScalar& rhs) { return rhs+lhs; } +template::scalar_type,double> = 0> +accelerator_inline iScalar operator + (const typename iScalar::scalar_type lhs,const iScalar& rhs) { return rhs+lhs; } -template accelerator_inline iMatrix operator + (const iMatrix& lhs,const typename iScalar::scalar_type rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator + (const iMatrix& lhs,const typename iScalar::scalar_type rhs) { typename iMatrix::tensor_reduced srhs; srhs=rhs; return lhs+srhs; } -template accelerator_inline iMatrix operator + (const typename iScalar::scalar_type lhs,const iMatrix& rhs) { return rhs+lhs; } +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator + (const typename iScalar::scalar_type lhs,const iMatrix& rhs) { return rhs+lhs; } //////////////////////////////////////////////////////////////////// // Double support; cast to "scalar_type" through constructor //////////////////////////////////////////////////////////////////// -template accelerator_inline iScalar operator + (const iScalar& lhs,double rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator + (const iScalar& lhs,double rhs) { typename iScalar::scalar_type t; t=rhs; typename iScalar::tensor_reduced srhs; srhs=t; return lhs+srhs; } -template accelerator_inline iScalar operator + (double lhs,const iScalar& rhs) { return rhs+lhs; } +template::scalar_type,double> = 0> +accelerator_inline iScalar operator + (double lhs,const iScalar& rhs) { return rhs+lhs; } -template accelerator_inline iMatrix operator + (const iMatrix& lhs,double rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator + (const iMatrix& lhs,double rhs) { typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs+srhs; } -template accelerator_inline iMatrix operator + (double lhs,const iMatrix& rhs) { return rhs+lhs; } +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator + (double lhs,const iMatrix& rhs) { return rhs+lhs; } // Integer support cast to scalar type through constructor -template accelerator_inline iScalar operator + (const iScalar& lhs,Integer rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator + (const iScalar& lhs,Integer rhs) { typename iScalar::scalar_type t; t=rhs; typename iScalar::tensor_reduced srhs; srhs=t; return lhs+srhs; } -template accelerator_inline iScalar operator + (Integer lhs,const iScalar& rhs) { return rhs+lhs; } +template::scalar_type,double> = 0> +accelerator_inline iScalar operator + (Integer lhs,const iScalar& rhs) { return rhs+lhs; } -template accelerator_inline iMatrix operator + (const iMatrix& lhs,Integer rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator + (const iMatrix& lhs,Integer rhs) { typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs+srhs; } -template accelerator_inline iMatrix operator + (Integer lhs,const iMatrix& rhs) { return rhs+lhs; } +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator + (Integer lhs,const iMatrix& rhs) { return rhs+lhs; } /////////////////////////////////////////////////////////////////////////////////////////////// // subtraction of fundamental scalar type applies to matrix(down diag) and scalar /////////////////////////////////////////////////////////////////////////////////////////////// -template accelerator_inline iScalar operator - (const iScalar& lhs,const typename iScalar::scalar_type rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator - (const iScalar& lhs,const typename iScalar::scalar_type rhs) { typename iScalar::tensor_reduced srhs; srhs=rhs; return lhs-srhs; } -template accelerator_inline iScalar operator - (const typename iScalar::scalar_type lhs,const iScalar& rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator - (const typename iScalar::scalar_type lhs,const iScalar& rhs) { typename iScalar::tensor_reduced slhs;slhs=lhs; return slhs-rhs; } -template accelerator_inline iMatrix operator - (const iMatrix& lhs,const typename iScalar::scalar_type rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator - (const iMatrix& lhs,const typename iScalar::scalar_type rhs) { typename iScalar::tensor_reduced srhs; srhs=rhs; return lhs-srhs; } -template accelerator_inline iMatrix operator - (const typename iScalar::scalar_type lhs,const iMatrix& rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator - (const typename iScalar::scalar_type lhs,const iMatrix& rhs) { typename iScalar::tensor_reduced slhs;slhs=lhs; return slhs-rhs; @@ -228,26 +307,30 @@ template accelerator_inline iMatrix operator - (const typena //////////////////////////////////////////////////////////////////// // Double support; cast to "scalar_type" through constructor //////////////////////////////////////////////////////////////////// -template accelerator_inline iScalar operator - (const iScalar& lhs,double rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator - (const iScalar& lhs,double rhs) { typename iScalar::scalar_type t; t=rhs; typename iScalar::tensor_reduced srhs; srhs=t; return lhs-srhs; } -template accelerator_inline iScalar operator - (double lhs,const iScalar& rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator - (double lhs,const iScalar& rhs) { typename iScalar::scalar_type t(lhs); typename iScalar::tensor_reduced slhs;slhs=t; return slhs-rhs; } -template accelerator_inline iMatrix operator - (const iMatrix& lhs,double rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator - (const iMatrix& lhs,double rhs) { typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs-srhs; } -template accelerator_inline iMatrix operator - (double lhs,const iMatrix& rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator - (double lhs,const iMatrix& rhs) { typename iScalar::scalar_type t(lhs); typename iScalar::tensor_reduced slhs;slhs=t; @@ -257,25 +340,29 @@ template accelerator_inline iMatrix operator - (double lhs,c //////////////////////////////////////////////////////////////////// // Integer support; cast to "scalar_type" through constructor //////////////////////////////////////////////////////////////////// -template accelerator_inline iScalar operator - (const iScalar& lhs,Integer rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator - (const iScalar& lhs,Integer rhs) { typename iScalar::scalar_type t; t=rhs; typename iScalar::tensor_reduced srhs; srhs=t; return lhs-srhs; } -template accelerator_inline iScalar operator - (Integer lhs,const iScalar& rhs) +template::scalar_type,double> = 0> +accelerator_inline iScalar operator - (Integer lhs,const iScalar& rhs) { typename iScalar::scalar_type t;t=lhs; typename iScalar::tensor_reduced slhs;slhs=t; return slhs-rhs; } -template accelerator_inline iMatrix operator - (const iMatrix& lhs,Integer rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator - (const iMatrix& lhs,Integer rhs) { typename iScalar::scalar_type t;t=rhs; typename iScalar::tensor_reduced srhs;srhs=t; return lhs-srhs; } -template accelerator_inline iMatrix operator - (Integer lhs,const iMatrix& rhs) +template::scalar_type,double> = 0> +accelerator_inline iMatrix operator - (Integer lhs,const iMatrix& rhs) { typename iScalar::scalar_type t;t=lhs; typename iScalar::tensor_reduced slhs;slhs=t;