Skip to content

Commit

Permalink
Don't convert small integers to reals during code generation
Browse files Browse the repository at this point in the history
Don't convert small integers to reals during code generation. Small integers may be used in if conditions, and converting these to real numbers creates less efficient code.
  • Loading branch information
eschnett committed Sep 13, 2012
1 parent 2c958c1 commit 0226c2f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Tools/CodeGen/CodeGenCactus.m
Expand Up @@ -666,8 +666,10 @@
undoVect[expr_] := expr //. {
ToReal[x_] -> x,

x_Integer -> 1.0*x, (* don't generate large integer constants *)
x_Ratio -> N[x,30],
(* don't generate large integer constants *)
x_Integer /; Abs[x]>10^9 :> 1.0*x,
(* generate sufficient precision *)
x_Ratio :> N[x,30],

kneg[x_] -> -x,

Expand Down

0 comments on commit 0226c2f

Please sign in to comment.