From ff1a8ff9ad5ff7b62c6ad9e964caf53aa33faf27 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Tue, 30 Aug 2011 21:02:38 -0400 Subject: Support multi-argument Max/Min Support multi-argument Max and Min calls in Kranc. --- Tools/CodeGen/CodeGen.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Tools/CodeGen/CodeGen.m') 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]; -- cgit v1.2.3