diff options
author | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-06-10 18:09:08 +0200 |
---|---|---|
committer | Ian Hinder <ian.hinder@aei.mpg.de> | 2011-06-11 03:47:29 +0200 |
commit | 25d10c9c3c8133a9caefbe1e6ecbd4b5e234105d (patch) | |
tree | f597f74b9fc693330576b14d8c74045098e1fe1f /Tools/CodeGen/CodeGen.m | |
parent | 66668c409754acc1f76ed50118d8831fc3992c59 (diff) |
Improve handling of ToReal and parameters in conditionals
Diffstat (limited to 'Tools/CodeGen/CodeGen.m')
-rw-r--r-- | Tools/CodeGen/CodeGen.m | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/Tools/CodeGen/CodeGen.m b/Tools/CodeGen/CodeGen.m index 4afd995..a1f0896 100644 --- a/Tools/CodeGen/CodeGen.m +++ b/Tools/CodeGen/CodeGen.m @@ -774,24 +774,12 @@ BoundaryWithGhostsLoop[block_] := ]} ]]]}; -(* Remove call to ToReal from condtion. This should really instead be - done much earlier. Sometimes Conditional is called with a - conditional that is an expression, sometimes it is a list of - strings, so we need to handle both cases. *) -(* One approach to remove calls to ToReal is to wrap the condition - into a function call, such as e.g. Cond[x], which is then handled by - the vectorisation code in the same way the IfThen[x,y,z] expression - is handled there. *) -removeToRealFunc[condition_] := Replace[condition, {ToReal[x_] -> x}] -removeToRealString[condition_] := If[StringQ[condition], StringReplace[condition, "ToReal(" ~~ x__ ~~ ")" :> x], condition] -removeToReal[condition_] := Map[removeToRealString, removeToRealFunc[condition]] - Conditional[condition_, block_] := - {"if (", removeToReal[condition], ")\n", + {"if (", condition, ")\n", CBlock[block]}; Conditional[condition_, block1_, block2_] := - {"if (", removeToReal[condition], ")\n", + {"if (", condition, ")\n", CBlock[block1], "else\n", CBlock[block2]}; onceInGridLoop[block_] := |