44#include "../../../traits/expressionTraits.hpp"
45#include "../traversalLogic.hpp"
46#include "forEachLeafLogic.hpp"
55 template<
typename Identifier>
64 template<
typename Node>
66 std::vector<std::string> topNodeRep;
71 if (topNodeRep[0].find(
"(") == 0) {
72 topNodeRep[0] = topNodeRep[0].substr(1, topNodeRep[0].size() - 2);
75 mathRep = topNodeRep[0];
83 template<
typename Node>
85 std::vector<std::string> linkRep;
86 std::string stmtOperator =
node.getMathRep();
90 if (linkRep.size() == 2) {
93 if (stmtOperator.find(
"()") != std::string::npos) {
95 stmtOperator.pop_back();
96 nodeRep.push_back(stmtOperator + linkRep[0] +
", " + linkRep[1] +
")");
98 nodeRep.push_back(
"(" + linkRep[0] +
" " + stmtOperator +
" " + linkRep[1] +
")");
101 nodeRep.push_back(stmtOperator +
"(" + linkRep[0] +
")");
106 template<
typename Node>
110 linkRep.push_back(
"p(" + std::to_string(
node.getValue()) +
")");
112 linkRep.push_back(
"x" + std::to_string(
node.getIdentifier()));
117 template<
typename Node>
119 linkRep.push_back(
"c(" + convert_value(
node.getValue()) +
")");
125 std::string convert_value(T
const& v) {
126 return std::to_string(v);
131 std::string convert_value(T*
const& v) {
132 return "p" + std::to_string(
reinterpret_cast<size_t>(v));
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
CoDiPack - Code Differentiation Package.
Definition codi.hpp:91
Implement logic for leaf nodes only.
Definition forEachLeafLogic.hpp:60
Creates a math representation from a given rhs in the form of a string.
Definition mathStatementGenLogic.hpp:56
Identifier passiveThreshold
The identifiers that are allocated for passive values.
Definition mathStatementGenLogic.hpp:58
void eval(NodeInterface< Node > const &node, std::string &mathRep)
Produces a math representation string for a given statement.
Definition mathStatementGenLogic.hpp:65
void node(Node const &node, std::vector< std::string > &nodeRep)
Links two nodes with a math operation.
Definition mathStatementGenLogic.hpp:84
void handleConstant(Node const &node, std::vector< std::string > &linkRep)
Called for leaf nodes which implement ConstantExpression.
Definition mathStatementGenLogic.hpp:118
MathStatementGenLogic(Identifier passiveThreshold=0)
Constructor.
Definition mathStatementGenLogic.hpp:61
void handleActive(Node const &node, std::vector< std::string > &linkRep)
Called for leaf nodes which implement LhsExpressionInterface.
Definition mathStatementGenLogic.hpp:107
Node side interface for the traversal of expressions.
Definition nodeInterface.hpp:56
Impl const & cast() const
Cast to the implementation.
Definition nodeInterface.hpp:62
void toNode(Node const &node, Args &&... args)
Helper method to distinguish between leaf nodes and normal nodes.
Definition traversalLogic.hpp:142
void toLinks(Node const &node, Args &&... args)
Helper method which calls forEachLink on the node.
Definition traversalLogic.hpp:148