CppADCodeGen
HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
|
Public Types | |
using | Node = OperationNode< Base > |
using | Arg = Argument< Base > |
Public Member Functions | |
LanguageMathML () | |
const std::string & | getAssignMarkup () const |
void | setAssignMarkup (const std::string &assign) |
const std::string & | getAddAssignMarkup () const |
void | setAddAssignMarkup (const std::string &assignAdd) |
const std::string & | getMultiplicationMarkup () const |
void | setMultiplicationMarkup (const std::string &multOpStr) |
const std::string & | getMultiplicationConstParMarkup () const |
void | setMultiplicationConstParMarkup (const std::string &multValOpStr) |
bool | isIgnoreZeroDepAssign () const |
void | setIgnoreZeroDepAssign (bool ignore) |
void | setFilename (const std::string &name) |
void | setStyle (const std::string &style) |
const std::string & | getStyle () const |
void | setJavascript (const std::string &javascript) |
const std::string & | getJavascript () const |
void | setHeadExtraMarkup (const std::string &headExtra) |
const std::string & | getHeadExtraMarkup () const |
virtual void | setEquationMarkup (const std::string &begin, const std::string &end) |
virtual const std::string & | getEquationStartMarkup () const |
virtual const std::string & | getEquationEndMarkup () const |
virtual void | setForMarkup (const std::string &begin, const std::string &end) |
virtual const std::string & | getForStartMarkup () const |
virtual const std::string & | getForEndMarkup () const |
virtual void | setIfMarkup (const std::string &begin, const std::string &end) |
virtual const std::string & | getIfStartMarkup () const |
virtual const std::string & | getIfEndMarkup () const |
virtual void | setElseIfMarkup (const std::string &begin, const std::string &end) |
virtual const std::string & | getElseIfStartMarkup () const |
virtual const std::string & | getElseIfEndMarkup () const |
virtual void | setElseMarkup (const std::string &begin, const std::string &end) |
virtual const std::string & | getElseStartMarkup () const |
virtual const std::string & | getElseEndMarkup () const |
virtual size_t | getParameterPrecision () const |
virtual void | setParameterPrecision (size_t p) |
virtual void | setAlwaysEnclosePowBase (bool enclose) |
virtual bool | isAlwaysEnclosePowBase () const |
virtual void | setMaxAssignmentsPerFunction (size_t maxAssignmentsPerFunction, std::map< std::string, std::string > *sources) |
void | setSaveVariableRelations (bool save) |
bool | requiresVariableDependencies () const override |
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::string &identation, 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 Node &index) |
static void | indexPattern2String (std::ostream &os, const IndexPattern &ip, const std::vector< const Node *> &indexes) |
static void | linearIndexPattern2String (std::ostream &os, const LinearIndexPattern &lip, const Node &index) |
Protected Member Functions | |
void | generateSourceCode (std::ostream &out, std::unique_ptr< LanguageGenerationData< Base > > info) override |
size_t | getVariableID (const Node &node) const |
virtual void | printAlgorithmFileStart (std::ostream &out) |
virtual void | printAlgorithmFileEnd (std::ostream &out) |
unsigned | printAssignment (Node &node) |
unsigned | printAssignment (Node &nodeName, const Arg &nodeRhs) |
unsigned | printAssignment (Node &nodeName, Node &nodeRhs) |
virtual void | printAssignmentStart (Node &op) |
virtual void | printAssignmentStart (Node &node, const std::string &varName, bool isDep) |
virtual void | printAssignmentEnd () |
virtual void | printAssignmentEnd (Node &op) |
virtual void | saveLocalFunction (std::vector< std::string > &localFuncNames, bool zeroDependentArray) |
bool | createsNewVariable (const Node &var, size_t totalUseCount, size_t opCount) const override |
virtual bool | requiresVariableName (const Node &var) const |
virtual bool | directlyAssignsVariable (const Node &var) const |
bool | requiresVariableArgument (enum CGOpCode op, size_t argIndex) const override |
const std::string & | createVariableName (Node &var) |
size_t | getHtmlID (const Node &var) const |
std::string | createHtmlID (const Node *var) |
virtual std::string | createHtmlID (const Node &var) |
virtual void | printIndependentVariableName (Node &op) |
virtual unsigned | print (const Arg &arg) |
virtual unsigned | printExpression (Node &node) |
virtual unsigned | printExpressionNoVarCheck (Node &node) |
virtual unsigned | printAssignOp (Node &node) |
virtual void | printUnaryFunction (Node &op) |
virtual void | printPowFunction (Node &op) |
virtual unsigned | printOperationAlias (Node &op) |
virtual void | printOperationAdd (Node &op) |
virtual void | printOperationMinus (Node &op) |
virtual void | printOperationDiv (Node &op) |
bool | encloseInParenthesesMul (const Arg &arg) const |
bool | encloseInParenthesesMul (const Node *node) const |
virtual void | printOperationMul (Node &op) |
virtual void | printOperationUnaryMinus (Node &op) |
virtual void | printConditionalAssignment (Node &node) |
bool | isSameArgument (const Arg &newArg, const Arg *oldArg) |
virtual void | printArrayCreationOp (Node &op) |
virtual void | printSparseArrayCreationOp (Node &op) |
void | printArrayStructInit (const std::string &dataArrayName, size_t pos, const std::vector< Node *> &arrays, size_t k) |
void | printArrayStructInit (const std::string &dataArrayName, Node &array) |
void | markArrayChanged (Node &ty) |
size_t | printArrayCreationUsingLoop (size_t startPos, Node &array, size_t startj, std::vector< const Arg *> &tmpArrayValues) |
std::string | getTempArrayName (const Node &op) |
virtual void | printArrayElementOp (Node &op) |
virtual void | printAtomicForwardOp (Node &atomicFor) |
virtual void | printAtomicReverseOp (Node &atomicRev) |
virtual unsigned | printDependentMultiAssign (Node &node) |
virtual void | printLoopStart (Node &node) |
virtual void | printLoopEnd (Node &node) |
virtual void | printLoopIndexedDep (Node &node) |
virtual void | printLoopIndexedIndep (Node &node) |
virtual void | printLoopIndexedTmp (Node &node) |
virtual void | printTmpVar (Node &node) |
virtual void | printIndexAssign (Node &node) |
virtual void | printIndexCondExprOp (Node &node) |
virtual void | printStartIf (Node &node) |
virtual void | printElseIf (Node &node) |
virtual void | printElse (Node &node) |
virtual void | printEndIf (Node &node) |
virtual void | printCondResult (Node &node) |
virtual void | printUserCustom (Node &node) |
bool | isDependent (const Node &arg) const |
virtual void | printParameter (const Base &value) |
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 |
size_t | _indentationLevel |
std::string | _style |
std::string | _javascript |
std::string | _headExtra |
std::string | _startEq |
std::string | _endEq |
std::string | _forStart |
std::string | _forEnd |
std::string | _forBodyStart |
std::string | _forBodyEnd |
std::string | _ifStart |
std::string | _ifEnd |
std::string | _elseIfStart |
std::string | _elseIfEnd |
std::string | _elseStart |
std::string | _elseEnd |
std::string | _condBodyStart |
std::string | _condBodyEnd |
std::string | _assignStr |
std::string | _assignAddStr |
std::string | _multOpStr |
std::string | _multValOpStr |
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 |
size_t | _maxAssignmentsPerFile |
std::map< std::string, std::string > * | _sources |
std::vector< const Arg * > | _tmpArrayValues |
std::vector< const Arg * > | _tmpSparseArrayValues |
std::vector< const LoopStartOperationNode< Base > * > | _currentLoops |
size_t | _parameterPrecision |
bool | _powBaseEnclose |
bool | _saveVariableRelations |
Generates presentation markup using the html and MathML specification.
Definition at line 28 of file language_mathml.hpp.
|
inline |
Creates a MathML language source code generator
Definition at line 117 of file language_mathml.hpp.
|
inlineprotected |
Creates an HTML ID for the usage of a variable in particular place in the HTML
Definition at line 1144 of file language_mathml.hpp.
Referenced by CppAD::cg::LanguageMathML< Base >::createHtmlID().
|
inlineprotectedvirtual |
Creates an HTML ID for the usage of a variable in particular place in the HTML
Definition at line 1151 of file language_mathml.hpp.
|
inlineoverrideprotectedvirtual |
Whether or not a new variable is created as a result of this operation
op | Operation |
totalUseCount | the number of times this node has been used as an argument in other operations |
Implements CppAD::cg::Language< Base >.
Definition at line 1005 of file language_mathml.hpp.
|
inlineprotectedvirtual |
Whether or not this operation assign its expression to a variable by itself.
var | the operation node |
Definition at line 1055 of file language_mathml.hpp.
|
inlineoverrideprotectedvirtual |
generate index array names (might be used for variable names)
generate variable names
function variable declaration
Determine the dependent variables that result from the same operations
non-constant variables
Source code generation magic!
Create the master html file which inputs the other files
encapsulate the code in a function
Implements CppAD::cg::Language< Base >.
Definition at line 535 of file language_mathml.hpp.
|
inlinevirtual |
Provides the markup after each else.
Definition at line 401 of file language_mathml.hpp.
|
inlinevirtual |
Provides the markup after each else if.
Definition at line 375 of file language_mathml.hpp.
|
inlinevirtual |
Provides the markup preceding each else if.
Definition at line 368 of file language_mathml.hpp.
|
inlinevirtual |
Provides the markup preceding each else.
Definition at line 394 of file language_mathml.hpp.
|
inlinevirtual |
Provides the markup after each equation.
Definition at line 297 of file language_mathml.hpp.
|
inlinevirtual |
Provides the markup preceding each equation.
Definition at line 290 of file language_mathml.hpp.
|
inlinevirtual |
Provides the markup after each loop.
Definition at line 323 of file language_mathml.hpp.
|
inlinevirtual |
Provides the markup preceding each loop.
Definition at line 316 of file language_mathml.hpp.
|
inlineprotected |
The base HTML ID for a node
Definition at line 1137 of file language_mathml.hpp.
Referenced by CppAD::cg::LanguageMathML< Base >::createHtmlID().
|
inlinevirtual |
Provides the markup after each If.
Definition at line 349 of file language_mathml.hpp.
|
inlinevirtual |
Provides the markup preceding each If.
Definition at line 342 of file language_mathml.hpp.
|
inline |
Provides the mathml markup used for multiplications of constant parameters. The default is <mo>×</mo>.
Definition at line 208 of file language_mathml.hpp.
|
inline |
Provides the mathml markup used to define multiplications. The default is <mo></mo>.
Definition at line 187 of file language_mathml.hpp.
|
inlinevirtual |
Provides the maximum precision used to print constant values in the generated source code
Definition at line 411 of file language_mathml.hpp.
|
inlinevirtual |
Whether or not to always enclose the base of a power within parenthesis.
Definition at line 443 of file language_mathml.hpp.
|
inlineprotected |
from independents array
from independents array in a loop
constant value?
print the loop
update values in the global temporary array
Definition at line 139 of file language_mathml_arrays.hpp.
|
inlineprotected |
TODO: finish this
Definition at line 322 of file language_mathml_arrays.hpp.
|
inlineprotectedvirtual |
the values of ty are now changed
Definition at line 1719 of file language_mathml.hpp.
|
inlineprotectedvirtual |
the values of px are now changed
Definition at line 1762 of file language_mathml.hpp.
|
inlineprotectedvirtual |
the first argument is the if start node, the following arguments are assignments in the previous if branch
Definition at line 1984 of file language_mathml.hpp.
|
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 1952 of file language_mathml.hpp.
|
inline |
1D
2D
Definition at line 56 of file language_mathml_index_patterns.hpp.
Referenced by CppAD::cg::LanguageMathML< Base >::requiresVariableDependencies().
|
inlineprotectedvirtual |
the first argument is the condition, following arguments are just extra dependencies that must be defined outside the if
Definition at line 1934 of file language_mathml.hpp.
|
inline |
TODO
Definition at line 97 of file language_mathml_index_patterns.hpp.
Referenced by CppAD::cg::LanguageMathML< Base >::requiresVariableDependencies().
|
inlineoverridevirtual |
Whether or not this language can use information regarding the dependencies between different equations/variables.
Implements CppAD::cg::Language< Base >.
Definition at line 457 of file language_mathml.hpp.
|
inlinevirtual |
Defines whether or not to always enclose the base of a power within parenthesis. By default the base is only enclosed in parenthesis if it contains of a mathematical expression.
enclose | true to always enclose the base in parenthesis |
Definition at line 433 of file language_mathml.hpp.
|
inlinevirtual |
Defines the surrounding markup for each else if.
begin | the opening html markup |
end | the closing html markup |
Definition at line 359 of file language_mathml.hpp.
|
inlinevirtual |
Defines the surrounding markup for each else.
begin | the opening html markup |
end | the closing html markup |
Definition at line 385 of file language_mathml.hpp.
|
inlinevirtual |
Defines the surrounding markup for each equation.
begin | the opening html markup |
end | the closing html markup |
Definition at line 281 of file language_mathml.hpp.
|
inlinevirtual |
Defines the surrounding markup for each for loop.
begin | the opening html markup |
end | the closing html markup |
Definition at line 307 of file language_mathml.hpp.
|
inline |
Defines additional markup to be added to head section of the html document.
headExtra | html markup to be added to the head section |
Definition at line 267 of file language_mathml.hpp.
|
inlinevirtual |
Defines the surrounding markup for each If.
begin | the opening html markup |
end | the closing html markup |
Definition at line 333 of file language_mathml.hpp.
|
inline |
Defines Javascript source code to be added to head section of the html document.
javascript | the Javascript source code |
Definition at line 254 of file language_mathml.hpp.
|
inline |
Defines the mathml markup used for multiplications of constant parameters. The default is <mo>×</mo>. Another common alternative is "<mo>⋅</mo>". Please take into account that numbers too close together are difficult to distinguish.
Definition at line 220 of file language_mathml.hpp.
|
inline |
Defines the mathml markup used for multiplications. The default is <mo></mo>. Other common alternatives are "<mo>⋅</mo>" and "<mo>×</mo>".
Definition at line 199 of file language_mathml.hpp.
|
inlinevirtual |
Defines the maximum precision used to print constant values in the generated source code
p | the maximum number of digits |
Definition at line 421 of file language_mathml.hpp.
|
inline |
Defines the CSS style to be added to head section of the html document.
style | the content of the CSS |
Definition at line 241 of file language_mathml.hpp.