Skip to content

Commit

Permalink
CodeGenKranc.m: Avoid generating ToReal in unvectorised code
Browse files Browse the repository at this point in the history
  • Loading branch information
ianhinder committed Mar 17, 2014
1 parent 4c13d78 commit a25b71b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Tools/CodeGen/CodeGenKranc.m
Expand Up @@ -116,14 +116,14 @@
{"cctkLbnd1", "ptrdiff_t", "cctk_lbnd[0]"},
{"cctkLbnd2", "ptrdiff_t", "cctk_lbnd[1]"},
{"cctkLbnd3", "ptrdiff_t", "cctk_lbnd[2]"},
{"t", DataType[], "ToReal(cctk_time)"},
{"cctkOriginSpace1", DataType[], "ToReal(CCTK_ORIGIN_SPACE(0))"},
{"cctkOriginSpace2", DataType[], "ToReal(CCTK_ORIGIN_SPACE(1))"},
{"cctkOriginSpace3", DataType[], "ToReal(CCTK_ORIGIN_SPACE(2))"},
{"dt", DataType[], "ToReal(CCTK_DELTA_TIME)"},
{"dx", DataType[], "ToReal(CCTK_DELTA_SPACE(0))"},
{"dy", DataType[], "ToReal(CCTK_DELTA_SPACE(1))"},
{"dz", DataType[], "ToReal(CCTK_DELTA_SPACE(2))"},
{"t", DataType[], ToReal["cctk_time"]},
{"cctkOriginSpace1", DataType[], ToReal["CCTK_ORIGIN_SPACE(0)"]},
{"cctkOriginSpace2", DataType[], ToReal["CCTK_ORIGIN_SPACE(1)"]},
{"cctkOriginSpace3", DataType[], ToReal["CCTK_ORIGIN_SPACE(2)"]},
{"dt", DataType[], ToReal["CCTK_DELTA_TIME"]},
{"dx", DataType[], ToReal["CCTK_DELTA_SPACE(0)"]},
{"dy", DataType[], ToReal["CCTK_DELTA_SPACE(1)"]},
{"dz", DataType[], ToReal["CCTK_DELTA_SPACE(2)"]},

(* Note that dx is already a vector, so should not be wrapped in ToReal *)
{"dxi", DataType[], 1/dx},
Expand Down Expand Up @@ -271,7 +271,8 @@
rhs = rhs //. IntAbs[x_] -> abs[x];

If[vectorise === True,
rhs = VectoriseExpression[rhs]];
rhs = VectoriseExpression[rhs],
rhs = rhs /. ToReal[x_] ->x];

rhs = rhs //. {Parameter[xx_] -> xx};
rhs]];
Expand Down

0 comments on commit a25b71b

Please sign in to comment.