CppADCodeGen  2.3.0
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::LanguageDot< Base > Class Template Reference
Inheritance diagram for CppAD::cg::LanguageDot< Base >:
Inheritance graph
Collaboration diagram for CppAD::cg::LanguageDot< Base >:
Collaboration graph

Public Types

using Node = OperationNode< Base >
 

Public Member Functions

 LanguageDot ()
 
bool isIgnoreZeroDepAssign () const
 
void setIgnoreZeroDepAssign (bool ignore)
 
void setFilename (const std::string &name)
 
virtual size_t getParameterPrecision () const
 
virtual void setParameterPrecision (size_t p)
 
void setIndepNodeStyle (const std::string &indepNodeStyle)
 
const std::string & getIndepNodeStyle () const
 
void setDepNodeStyle (const std::string &depNodeStyle)
 
const std::string & getDepNodeStyle () const
 
void setCombineParameterNodes (bool combineParameterNodes)
 
bool isCombineParameterNodes () const
 
void printStaticIndexArray (std::ostringstream &os, const std::string &name, const std::vector< size_t > &values)
 
void printStaticIndexMatrix (std::ostringstream &os, const std::string &name, const std::map< size_t, std::map< size_t, size_t > > &values)
 
void printRandomIndexPatternDeclaration (std::ostringstream &os, const std::set< RandomIndexPattern *> &randomPatterns)
 

Static Public Member Functions

static void printIndexCondExpr (std::ostringstream &out, const std::vector< size_t > &info, const std::string &index)
 
static void generateNames4RandomIndexPatterns (const std::set< RandomIndexPattern *> &randomPatterns)
 
static void indexPattern2String (std::ostream &os, const IndexPattern &ip, const OperationNode< Base > &index)
 
static void indexPattern2String (std::ostream &os, const IndexPattern &ip, const std::vector< const OperationNode< Base > *> &indexes)
 
static void linearIndexPattern2String (std::ostream &os, const LinearIndexPattern &lip, const OperationNode< Base > &index)
 

Protected Member Functions

virtual void generateSourceCode (std::ostream &out, const std::unique_ptr< LanguageGenerationData< Base > > &info) override
 
size_t getVariableID (const OperationNode< Base > &node) const
 
virtual bool createsNewVariable (const OperationNode< Base > &var, size_t totalUseCount) const override
 
virtual bool requiresVariableName (const OperationNode< Base > &var) const
 
virtual bool directlyAssignsVariable (const OperationNode< Base > &var) const
 
virtual bool requiresVariableArgument (enum CGOpCode op, size_t argIndex) const override
 
const std::string & createVariableName (OperationNode< Base > &var)
 
virtual bool requiresVariableDependencies () const override
 
virtual std::string print (const Argument< Base > &arg)
 
virtual std::string printExpression (OperationNode< Base > &node)
 
virtual std::string printParameter (const Base &value)
 
virtual std::string makeNodeName (const OperationNode< Base > &node)
 
std::string makeNodeName (const Argument< Base > &arg)
 
virtual std::string makeNodeName (const Base &value)
 
std::string printNodeDeclaration (const OperationNode< Base > &op, const std::ostringstream &label, const std::string &shape="")
 
virtual std::string printNodeDeclaration (const OperationNode< Base > &op, const std::string &label="", const std::string &shape="")
 
void printEdges (const std::string &name, const OperationNode< Base > &node, const std::string &style="")
 
void printEdges (const std::string &name, const OperationNode< Base > &node, const std::vector< std::string > &args, const std::string &style="")
 
void printEdges (const std::string &name, const OperationNode< Base > &node, const std::vector< std::string > &args, const std::vector< std::string > &styles)
 
void printEdge (const OperationNode< Base > &from, const std::string &to, const std::string &style="")
 
void printEdge (const std::string &from, const std::string &to, const std::string &style="")
 
virtual std::string printExpressionNoVarCheck (OperationNode< Base > &node)
 
virtual std::string printAssignOp (OperationNode< Base > &node)
 
virtual std::string printPowFunction (OperationNode< Base > &op)
 
virtual std::string printUnaryFunction (OperationNode< Base > &op)
 
virtual std::string printOperationAlias (OperationNode< Base > &op)
 
virtual std::string printOperationAdd (OperationNode< Base > &op)
 
virtual std::string printOperationMinus (OperationNode< Base > &op)
 
virtual std::string printOperationDiv (OperationNode< Base > &op)
 
virtual std::string printOperationMul (OperationNode< Base > &op)
 
virtual std::string printOperationUnaryMinus (OperationNode< Base > &op)
 
virtual std::string printConditionalAssignment (OperationNode< Base > &node)
 
virtual std::string printArrayCreationOp (OperationNode< Base > &op)
 
virtual std::string printSparseArrayCreationOp (OperationNode< Base > &op)
 
size_t printArrayCreationUsingLoop (const std::string arrayName, const OperationNode< Base > &array, size_t startj, const size_t *indexes)
 
virtual std::string printArrayElementOp (OperationNode< Base > &op)
 
virtual std::string printAtomicForwardOp (OperationNode< Base > &atomicFor)
 
virtual std::string printAtomicReverseOp (OperationNode< Base > &atomicRev)
 
virtual std::string printDependentMultiAssign (OperationNode< Base > &node)
 
virtual std::string printLoopStart (OperationNode< Base > &node)
 
virtual std::string printLoopEnd (OperationNode< Base > &node)
 
virtual std::string printLoopIndexedDep (OperationNode< Base > &node)
 
virtual std::string printLoopIndexedIndep (OperationNode< Base > &node)
 
virtual std::string printLoopIndexedTmp (OperationNode< Base > &node)
 
virtual std::string printTmpVar (OperationNode< Base > &node)
 
virtual std::string printIndexAssign (OperationNode< Base > &node)
 
virtual std::string printIndexCondExprOp (OperationNode< Base > &node)
 
virtual std::string printStartIf (OperationNode< Base > &node)
 
virtual std::string printElseIf (OperationNode< Base > &node)
 
virtual std::string printElse (OperationNode< Base > &node)
 
virtual std::string printEndIf (OperationNode< Base > &node)
 
virtual std::string printCondResult (OperationNode< Base > &node)
 
bool isDependent (const OperationNode< Base > &arg) const
 
virtual void getComparison (std::ostream &os, enum CGOpCode op) const
 

Static Protected Member Functions

static bool isFunction (enum CGOpCode op)
 
static bool isUnaryFunction (enum CGOpCode op)
 
static bool isCondAssign (enum CGOpCode op)
 

Protected Attributes

LanguageGenerationData< Base > * _info
 
std::string _endline
 
std::ostringstream _code
 
VariableNameGenerator< Base > * _nameGen
 
std::ostringstream _ss
 
size_t _independentSize
 
size_t _minTemporaryVarID
 
std::map< size_t, size_t > _dependentIDs
 
const ArrayView< CG< Base > > * _dependent
 
bool _ignoreZeroDepAssign
 
std::string _filename
 
std::vector< const LoopStartOperationNode< Base > * > _currentLoops
 
size_t _parameterPrecision
 
bool _combineParameterNodes
 
std::string _indepNodeStyle
 
std::string _depNodeStyle
 

Static Protected Attributes

static const std::string _C_STATIC_INDEX_ARRAY = "index"
 
static const std::string _C_SPARSE_INDEX_ARRAY = "idx"
 

Detailed Description

template<class Base>
class CppAD::cg::LanguageDot< Base >

Generates the model using the dot language used by graphviz.

Author
Joao Leal

Definition at line 27 of file language_dot.hpp.

Constructor & Destructor Documentation

◆ LanguageDot()

template<class Base >
CppAD::cg::LanguageDot< Base >::LanguageDot ( )
inline

Creates a MathML language source code generator

Definition at line 73 of file language_dot.hpp.

Member Function Documentation

◆ createsNewVariable()

template<class Base >
virtual bool CppAD::cg::LanguageDot< Base >::createsNewVariable ( const OperationNode< Base > &  op,
size_t  totalUseCount 
) const
inlineoverrideprotectedvirtual

Whether or not a new variable is created as a result of this operation

Parameters
opOperation
Returns
true if a new variable is created

Implements CppAD::cg::Language< Base >.

Definition at line 453 of file language_dot.hpp.

◆ directlyAssignsVariable()

template<class Base >
virtual bool CppAD::cg::LanguageDot< Base >::directlyAssignsVariable ( const OperationNode< Base > &  var) const
inlineprotectedvirtual

Whether or not this operation assign its expression to a variable by itself.

Parameters
varthe operation node
Returns

Definition at line 502 of file language_dot.hpp.

◆ generateSourceCode()

template<class Base >
virtual void CppAD::cg::LanguageDot< Base >::generateSourceCode ( std::ostream &  out,
const std::unique_ptr< LanguageGenerationData< Base > > &  info 
)
inlineoverrideprotectedvirtual

generate index array names (might be used for variable names)

generate variable names

Loop indexes

function variable declaration

Determine the dependent variables that result from the same operations

non-constant variables

Source code generation magic!

Implements CppAD::cg::Language< Base >.

Definition at line 237 of file language_dot.hpp.

◆ getDepNodeStyle()

template<class Base >
const std::string& CppAD::cg::LanguageDot< Base >::getDepNodeStyle ( ) const
inline

Provides the style for the dependent variable nodes

Definition at line 146 of file language_dot.hpp.

◆ getIndepNodeStyle()

template<class Base >
const std::string& CppAD::cg::LanguageDot< Base >::getIndepNodeStyle ( ) const
inline

Provides the style for the independent variable nodes

Definition at line 132 of file language_dot.hpp.

◆ getParameterPrecision()

template<class Base >
virtual size_t CppAD::cg::LanguageDot< Base >::getParameterPrecision ( ) const
inlinevirtual

Provides the maximum precision used to print constant values in the generated source code

Returns
the maximum number of digits

Definition at line 108 of file language_dot.hpp.

◆ printArrayCreationUsingLoop()

template<class Base >
size_t CppAD::cg::LanguageDot< Base >::printArrayCreationUsingLoop ( const std::string  arrayName,
const OperationNode< Base > &  array,
size_t  startj,
const size_t *  indexes 
)
inlineprotected

constant value?

print the loop

Definition at line 90 of file language_dot_arrays.hpp.

Referenced by CppAD::cg::LanguageDot< Base >::printConditionalAssignment().

◆ printAtomicForwardOp()

template<class Base >
virtual std::string CppAD::cg::LanguageDot< Base >::printAtomicForwardOp ( OperationNode< Base > &  atomicFor)
inlineprotectedvirtual

Edges

Definition at line 1021 of file language_dot.hpp.

◆ printAtomicReverseOp()

template<class Base >
virtual std::string CppAD::cg::LanguageDot< Base >::printAtomicReverseOp ( OperationNode< Base > &  atomicRev)
inlineprotectedvirtual

Edges

Definition at line 1063 of file language_dot.hpp.

◆ printConditionalAssignment()

template<class Base >
virtual std::string CppAD::cg::LanguageDot< Base >::printConditionalAssignment ( OperationNode< Base > &  node)
inlineprotectedvirtual

Connections

Definition at line 985 of file language_dot.hpp.

◆ printElse()

template<class Base >
virtual std::string CppAD::cg::LanguageDot< Base >::printElse ( OperationNode< Base > &  node)
inlineprotectedvirtual

the first argument is the if start node, the following arguments are assignments in the previous if branch

Definition at line 1327 of file language_dot.hpp.

◆ printElseIf()

template<class Base >
virtual std::string CppAD::cg::LanguageDot< Base >::printElseIf ( OperationNode< Base > &  node)
inlineprotectedvirtual

the first argument is the condition, the second argument is the if start node, the following arguments are assignments in the previous if branch

Definition at line 1308 of file language_dot.hpp.

◆ printIndexAssign()

template<class Base >
virtual std::string CppAD::cg::LanguageDot< Base >::printIndexAssign ( OperationNode< Base > &  node)
inlineprotectedvirtual

Connections

Definition at line 1246 of file language_dot.hpp.

◆ printLoopStart()

template<class Base >
virtual std::string CppAD::cg::LanguageDot< Base >::printLoopStart ( OperationNode< Base > &  node)
inlineprotectedvirtual

declaration

connections

Definition at line 1149 of file language_dot.hpp.

◆ printRandomIndexPatternDeclaration()

template<class Base >
void CppAD::cg::LanguageDot< Base >::printRandomIndexPatternDeclaration ( std::ostringstream &  os,
const std::set< RandomIndexPattern *> &  randomPatterns 
)
inline

◆ printStartIf()

template<class Base >
virtual std::string CppAD::cg::LanguageDot< Base >::printStartIf ( OperationNode< Base > &  node)
inlineprotectedvirtual

the first argument is the condition, following arguments are just extra dependencies that must be defined outside the if

Definition at line 1290 of file language_dot.hpp.

◆ requiresVariableDependencies()

template<class Base >
virtual bool CppAD::cg::LanguageDot< Base >::requiresVariableDependencies ( ) const
inlineoverrideprotectedvirtual

Whether or not this language can use information regarding the dependencies between different equations/variables.

Implements CppAD::cg::Language< Base >.

Definition at line 580 of file language_dot.hpp.

◆ setDepNodeStyle()

template<class Base >
void CppAD::cg::LanguageDot< Base >::setDepNodeStyle ( const std::string &  depNodeStyle)
inline

Defines the style for the dependent variable nodes

Definition at line 139 of file language_dot.hpp.

◆ setIndepNodeStyle()

template<class Base >
void CppAD::cg::LanguageDot< Base >::setIndepNodeStyle ( const std::string &  indepNodeStyle)
inline

Defines the style for the independent variable nodes

Definition at line 125 of file language_dot.hpp.

◆ setParameterPrecision()

template<class Base >
virtual void CppAD::cg::LanguageDot< Base >::setParameterPrecision ( size_t  p)
inlinevirtual

Defines the maximum precision used to print constant values in the generated source code

Parameters
pthe maximum number of digits

Definition at line 118 of file language_dot.hpp.


The documentation for this class was generated from the following files: