diff --git a/AMDiS/src/expressions/functorN_expr.hpp b/AMDiS/src/expressions/functorN_expr.hpp index e60ba4d2e1431e22df1fd4a80d83239f7f351605..f7a1e31bd66d67048ec69352cdfb341c224e059c 100644 --- a/AMDiS/src/expressions/functorN_expr.hpp +++ b/AMDiS/src/expressions/functorN_expr.hpp @@ -109,13 +109,13 @@ namespace AMDiS template struct Function { - typedef R result_type; + typedef R type; }; template struct Function { - typedef R type; + typedef R type; }; template @@ -128,11 +128,6 @@ namespace AMDiS typedef decltype(function_helper(&F::operator())) type; }; - template - struct Functor > - { - typedef R type; - }; template struct Functor::type> diff --git a/AMDiS/src/expressions/simplify_expr.hpp b/AMDiS/src/expressions/simplify_expr.hpp index 2e659b8c364d0be1de80802904c04b62521ba148..5d154895c15accdc9b9ce92c7fe2812dd11cd70d 100644 --- a/AMDiS/src/expressions/simplify_expr.hpp +++ b/AMDiS/src/expressions/simplify_expr.hpp @@ -74,6 +74,16 @@ namespace AMDiS static type eval(RValue const& t) { return t; } }; + /// -(n) -> (-n) + template + struct Simplify< Negative > > + { + typedef RValue type; + + static type eval(Negative > const& t) + { return RValue(-t.term.value); } + }; + /// -(N) -> (-N) template struct Simplify< Negative > > @@ -82,7 +92,6 @@ namespace AMDiS static type eval(Negative > const& t) { return CValue<-N>(); } - }; /// -0 -> 0 @@ -439,14 +448,23 @@ namespace AMDiS /// (X + (-Y)) -> X - Y template - struct Simplify< Negative > > > + struct Simplify< Add > > { typedef Subtract type; - static type eval(Negative > > const& t) + static type eval(Add > const& t) { return t.term1 - t.term2.term; } }; + template + struct Simplify< Add, Negative > > + { + typedef Negative type; + + static type eval(Add, Negative > const& t) + { return t.term2; } + }; + /// -(X - Y) -> Y - X template struct Simplify< Negative > >