Skip to content

Commit

Permalink
reuse ExpressionToString function from TreeMasses` module
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Oct 4, 2015
1 parent 9533ee0 commit ff267dd
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions meta/GMuonMinus2.m
Expand Up @@ -518,21 +518,10 @@ If you add new kinds of vertices (e.g for new diagram types):
(* Converts an expression to a valid C++ string. The result of the
expression will be stored in `result'.
*)
ExpressionToString[expr_, result_String] :=
Module[{type, exprNoDep, exprStr},
VertexExpressionToString[expr_, result_String] :=
Module[{exprNoDep},
exprNoDep = TreeMasses`ReplaceDependenciesReverse[expr];
If[FreeQ[exprNoDep,SARAH`sum] && FreeQ[exprNoDep,SARAH`ThetaStep],
exprStr = result <> " = " <>
CConversion`RValueToCFormString[
Simplify[Parameters`DecreaseIndexLiterals[exprNoDep]]] <> ";\n";
,
type = CConversion`ScalarType[CConversion`complexScalarCType];
exprStr = CConversion`ExpandSums[
Parameters`DecreaseIndexLiterals[
Parameters`DecreaseSumIdices[exprNoDep]],
result, type, ""];
];
exprStr
TreeMasses`ExpressionToString[exprNoDep, result]
];

(* ParsedVertex structure:
Expand Down Expand Up @@ -566,7 +555,7 @@ If you add new kinds of vertices (e.g for new diagram types):
expr = (SARAH`Cp @@ indexedParticles) /. vertexRules;
"double result = 0.;\n\n" <>
Parameters`CreateLocalConstRefs[expr] <> "\n" <>
ExpressionToString[expr, "result"] <> "\n" <>
VertexExpressionToString[expr, "result"] <> "\n" <>
"return vertex_type(result);",

"LeftAndRightComponentedVertex",
Expand All @@ -575,8 +564,8 @@ If you add new kinds of vertices (e.g for new diagram types):
"std::complex<double> left = 0.0;\n" <>
"std::complex<double> right = 0.0;\n\n" <>
Parameters`CreateLocalConstRefs[exprL + exprR] <> "\n" <>
ExpressionToString[exprL, "left"] <> "\n" <>
ExpressionToString[exprR, "right"] <> "\n" <>
VertexExpressionToString[exprL, "left"] <> "\n" <>
VertexExpressionToString[exprR, "right"] <> "\n" <>
"return vertex_type(left, right);"];

sarahParticles = SARAH`getParticleName /@ particles;
Expand Down

0 comments on commit ff267dd

Please sign in to comment.