From ac5b74c57addfd2b82c9a30d017c263b6d1cc911 Mon Sep 17 00:00:00 2001 From: Christian Zimmermann Date: Mon, 7 Dec 2020 13:46:01 +0100 Subject: [PATCH] arith + hl_ops: negate --- src/include/arith.h | 13 +++++++++++++ src/lib/mk_hl_op.sh | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/include/arith.h b/src/include/arith.h index fc8a712..db34d75 100644 --- a/src/include/arith.h +++ b/src/include/arith.h @@ -142,6 +142,19 @@ namespace MultiArrayTools }; + template + struct negate : public StaticFunctionBase, T> + { + static constexpr bool FISSTATIC = true; + using StaticFunctionBase, T>::apply; + + static inline T apply(T a) + { + return -a; + } + + }; + template using plus = plusx; diff --git a/src/lib/mk_hl_op.sh b/src/lib/mk_hl_op.sh index 27f6af5..f904f85 100755 --- a/src/lib/mk_hl_op.sh +++ b/src/lib/mk_hl_op.sh @@ -33,3 +33,16 @@ for fff in plus minus multiplies divides ; do echo " template class HighLevelOp,2>;" >> ${file} echo "}" >> ${file} done + +for fff in negate ; do + file=hl_ops/${fff}.cc + test -f ${file} && rm -f ${file} + echo "#include \"multi_array_header.h\"" >> ${file} + echo "#include \"high_level_operation.h\"" >> ${file} + echo "" >> ${file} + echo "namespace MultiArrayTools" >> ${file} + echo "{" >> ${file} + echo " template class HighLevelOp,1>;" >> ${file} + echo " template class HighLevelOp,1>;" >> ${file} + echo "}" >> ${file} +done