aboutsummaryrefslogtreecommitdiff
path: root/Tools/CodeGen/CodeGen.m
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2011-08-30 21:02:38 -0400
committerErik Schnetter <schnetter@gmail.com>2011-08-30 21:02:38 -0400
commitff1a8ff9ad5ff7b62c6ad9e964caf53aa33faf27 (patch)
tree26d452bda1cd3a11c57d73112c8d515d2a8df0b9 /Tools/CodeGen/CodeGen.m
parentf00977a223262f57c08eb9f73eea8e24205f9c04 (diff)
Support multi-argument Max/Min
Support multi-argument Max and Min calls in Kranc.
Diffstat (limited to 'Tools/CodeGen/CodeGen.m')
-rw-r--r--Tools/CodeGen/CodeGen.m5
1 files changed, 3 insertions, 2 deletions
diff --git a/Tools/CodeGen/CodeGen.m b/Tools/CodeGen/CodeGen.m
index 93b1740..2eaaf70 100644
--- a/Tools/CodeGen/CodeGen.m
+++ b/Tools/CodeGen/CodeGen.m
@@ -961,8 +961,9 @@ ReplacePowers[expr_, vectorise_] :=
(* there have been some problems doing the Max/Min
replacement via the preprocessor for C, so we do it
here *)
- rhs = rhs /. Max[xx_, yy_] -> fmax[xx, yy];
- rhs = rhs /. Min[xx_, yy_] -> fmin[xx, yy];
+ (* Note: Mathematica simplifies Max[xx_] -> xx automatically *)
+ rhs = rhs //. Max[xx_, yy__] -> fmax[xx, Max[yy]];
+ rhs = rhs //. Min[xx_, yy__] -> fmin[xx, Min[yy]];
rhs = rhs /. Power[xx_, power_] -> pow[xx, power];