45#include "../../../traits/expressionTraits.hpp"
46#include "../traversalLogic.hpp"
47#include "forEachLeafLogic.hpp"
56 template<
typename Identifier>
65 template<
typename Node>
67 std::vector<std::string> topNodeRep;
72 if (topNodeRep[0].find(
"(") == 0) {
73 topNodeRep[0] = topNodeRep[0].substr(1, topNodeRep[0].size() - 2);
76 mathRep = topNodeRep[0];
84 template<
typename Node>
86 std::vector<std::string> linkRep;
87 std::string stmtOperator =
node.getMathRep();
91 if (linkRep.size() == 2) {
94 if (stmtOperator.find(
"()") != std::string::npos) {
96 stmtOperator.pop_back();
97 nodeRep.push_back(stmtOperator + linkRep[0] +
", " + linkRep[1] +
")");
99 nodeRep.push_back(
"(" + linkRep[0] +
" " + stmtOperator +
" " + linkRep[1] +
")");
102 nodeRep.push_back(stmtOperator +
"(" + linkRep[0] +
")");
107 template<
typename Node>
111 linkRep.push_back(
"p(" + std::to_string(
node.getValue()) +
")");
113 linkRep.push_back(
"x" + std::to_string(
node.getIdentifier()));
118 template<
typename Node>
120 linkRep.push_back(
"c(" + convert_value(
node.getValue()) +
")");
126 std::string convert_value(T
const& v) {
127 return std::to_string(v);
131 std::string convert_value(std::complex<T>
const& v) {
132 return "(" + std::to_string(std::real(v)) +
" + " + std::to_string(std::imag(v)) +
")";
136 std::string convert_value(T*
const& v) {
137 return "p" + std::to_string(
reinterpret_cast<size_t>(v));
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
CoDiPack - Code Differentiation Package.
Definition codi.hpp:94
Implement logic for leaf nodes only.
Definition forEachLeafLogic.hpp:60
Identifier passiveThreshold
The identifiers that are allocated for passive values.
Definition mathStatementGenLogic.hpp:59
inlinevoid node(Node const &node, std::vector< std::string > &nodeRep)
Links two nodes with a math operation.
Definition mathStatementGenLogic.hpp:85
inlinevoid eval(NodeInterface< Node > const &node, std::string &mathRep)
Produces a math representation string for a given statement.
Definition mathStatementGenLogic.hpp:66
void handleConstant(Node const &node, std::vector< std::string > &linkRep)
Called for leaf nodes which implement ConstantExpression.
Definition mathStatementGenLogic.hpp:119
MathStatementGenLogic(Identifier passiveThreshold=0)
Constructor.
Definition mathStatementGenLogic.hpp:62
void handleActive(Node const &node, std::vector< std::string > &linkRep)
Called for leaf nodes which implement LhsExpressionInterface.
Definition mathStatementGenLogic.hpp:108
Node side interface for the traversal of expressions.
Definition nodeInterface.hpp:56
inlineImpl const & cast() const
Cast to the implementation.
Definition nodeInterface.hpp:62
inlinevoid toLinks(Node const &node, Args &&... args)
Definition traversalLogic.hpp:149
inlinevoid toNode(Node const &node, Args &&... args)
Definition traversalLogic.hpp:143