Skip to content

Commit

Permalink
create local variables with correct type
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt committed Mar 26, 2015
1 parent 2f9dd0b commit c1588b7
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions meta/EWSB.m
Expand Up @@ -466,7 +466,8 @@

CreateTreeLevelEwsbSolver[solution_List] :=
Module[{result = "", body = "",
i, par, expr, parStr, oldParStr, reducedSolution},
i, par, expr, parStr, oldParStr, reducedSolution,
type},
reducedSolution = solution;
If[reducedSolution =!= {},
(* create local const refs to input parameters appearing
Expand All @@ -480,10 +481,11 @@
For[i = 1, i <= Length[reducedSolution], i++,
par = reducedSolution[[i,1]];
expr = reducedSolution[[i,2]];
type = CConversion`CreateCType[Parameters`GetType[par]];
parStr = CConversion`RValueToCFormString[par];
oldParStr = "old_" <> CConversion`ToValidCSymbolString[par];
result = result <>
"const double " <> oldParStr <> " = " <> parStr <> ";\n";
"const " <> type <>" " <> oldParStr <> " = " <> parStr <> ";\n";
];
result = result <> "\n";
(* write solution *)
Expand Down Expand Up @@ -525,7 +527,7 @@
];

SolveTreeLevelEwsbVia[equations_List, parameters_List] :=
Module[{result = "", simplifiedEqs, solution, i, par, expr, parStr},
Module[{result = "", simplifiedEqs, solution, i, par, expr, parStr, type},
If[Length[equations] =!= Length[parameters],
Print["Error: SolveTreeLevelEwsbVia: trying to solve ",
Length[equations], " equations for ", Length[parameters],
Expand All @@ -549,9 +551,10 @@
For[i = 1, i <= Length[solution], i++,
par = solution[[i,1]];
expr = solution[[i,2]];
type = CConversion`CreateCType[Parameters`GetType[par]];
parStr = "new_" <> CConversion`ToValidCSymbolString[par];
result = result <>
"const double " <> parStr <> " = " <>
"const " <> type <> " " <> parStr <> " = " <>
CConversion`RValueToCFormString[expr] <> ";\n";
];
result = result <> "\n";
Expand Down Expand Up @@ -645,7 +648,7 @@
];

CreateEwsbSolverWithTadpoles[solution_List, softHiggsMassToTadpoleAssociation_List] :=
Module[{result = "", i, par, expr, parStr, reducedSolution, rules},
Module[{result = "", i, par, expr, parStr, reducedSolution, rules, type},
reducedSolution = solution /.
FlexibleSUSY`tadpole[p_] :> CConversion`ReleaseHoldAt[HoldForm[FlexibleSUSY`tadpole[[p-1]]], {1,2}];
If[reducedSolution =!= {},
Expand All @@ -660,8 +663,9 @@
For[i = 1, i <= Length[reducedSolution], i++,
par = reducedSolution[[i,1]];
expr = reducedSolution[[i,2]];
type = CConversion`CreateCType[Parameters`GetType[par]];
parStr = CConversion`ToValidCSymbolString[par];
result = result <> "double " <> parStr <> ";\n";
result = result <> type <> " " <> parStr <> ";\n";
];
result = result <> "\n";
(* write solution *)
Expand Down

0 comments on commit c1588b7

Please sign in to comment.