aboutsummaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
Diffstat (limited to 'Tools')
-rw-r--r--Tools/CodeGen/CodeGenCactus.m10
1 files changed, 10 insertions, 0 deletions
diff --git a/Tools/CodeGen/CodeGenCactus.m b/Tools/CodeGen/CodeGenCactus.m
index 33b1c6b..9c85bd4 100644
--- a/Tools/CodeGen/CodeGenCactus.m
+++ b/Tools/CodeGen/CodeGenCactus.m
@@ -741,6 +741,16 @@ DefFn[
rhs = rhs /. 8/3 -> keightthird;
rhs = rhs /. -8/3 -> -keightthird;
*)
+
+ (* Handle Piecewise function *)
+ (* TODO: This does not work with vectorisation, since IfThen
+ there expects a constant condition *)
+ rhs = rhs /. Piecewise -> piecewise1
+ //. piecewise1[pairs_List, val_:0] :>
+ If[pairs==={}, val,
+ IfThen[First[pairs][[2]],
+ First[pairs][[1]],
+ piecewise1[Rest[pairs], val]]];
(* Remove parentheses *)
rhs = rhs //. Parenthesis[xx_] -> xx;