diff --git a/lib/tensors/Tensor_logical.h b/lib/tensors/Tensor_logical.h new file mode 100644 index 00000000..5ded9f9c --- /dev/null +++ b/lib/tensors/Tensor_logical.h @@ -0,0 +1,32 @@ +#ifndef GRID_TENSOR_LOGICAL_H +#define GRID_TENSOR_LOGICAL_H + +namespace Grid { + +#define LOGICAL_BINOP(Op)\ +template strong_inline iScalar operator Op (const iScalar& lhs,const iScalar& rhs) \ +{\ + iScalar ret;\ + ret._internal = lhs._internal Op rhs._internal ;\ + return ret;\ +}\ +template strong_inline iScalar operator Op (const iScalar& lhs,Integer rhs) \ +{\ + typename iScalar::scalar_type t; t=rhs;\ + typename iScalar::tensor_reduced srhs; srhs=t;\ + return lhs Op srhs;\ +}\ +template strong_inline iScalar operator Op (Integer lhs,const iScalar& rhs) \ +{\ + typename iScalar::scalar_type t;t=lhs;\ + typename iScalar::tensor_reduced slhs;slhs=t;\ + return slhs Op rhs;\ +} + +LOGICAL_BINOP(|); +LOGICAL_BINOP(&); +LOGICAL_BINOP(||); +LOGICAL_BINOP(&&); + +} +#endif