CppADCodeGen
HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
|
Public Types | |
using | Node = OperationNode< Base > |
using | Arg = Argument< Base > |
Public Member Functions | |
LanguageLatex () | |
const std::string & | getAssignString () const |
void | setAssignString (const std::string &assign) |
bool | isIgnoreZeroDepAssign () const |
void | setIgnoreZeroDepAssign (bool ignore) |
virtual void | setFilename (const std::string &name) |
virtual void | setVariableEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getVariableEnvironmentStart () const |
virtual const std::string & | getVariableEnvironmentEnd () const |
virtual void | setDependentVarEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getDependentVarEnvironmentStart () const |
virtual const std::string & | getDependentVarEnvironmentEnd () const |
virtual void | setIndependentVarEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getIndependentVarEnvironmentStart () const |
virtual const std::string & | getIndependentVarEnvironmentEnd () const |
virtual void | setEquationEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getEquationEnvironmentStart () const |
virtual const std::string & | getEquationEnvironmentEnd () const |
virtual void | setAlgorithmLineEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getAlgorithmLineEnvironmentStart () const |
virtual const std::string & | getAlgorithmLineEnvironmentEnd () const |
virtual void | setEquationBlockEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getEquationBlockEnvironmentStart () const |
virtual const std::string & | getEquationBlockEnvironmentEnd () const |
virtual void | setAgorithmFileEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getAgorithmFileEnvironmentStart () const |
virtual const std::string & | getAgorithmFileEnvironmentEnd () const |
virtual void | setForEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getForEnvironmentStart () const |
virtual const std::string & | getForEnvironmentEnd () const |
virtual void | setConditionEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getConditionEnvironmentStart () const |
virtual const std::string & | getConditionEnvironmentEnd () const |
virtual void | setIfEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getIfEnvironmentStart () const |
virtual const std::string & | getIfEnvironmentEnd () const |
virtual void | setElseIfEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getElseIfEnvironmentStart () const |
virtual const std::string & | getElseIfEnvironmentEnd () const |
virtual void | setElseEnvironment (const std::string &begin, const std::string &end) |
virtual const std::string & | getElseEnvironmentStart () const |
virtual const std::string & | getElseEnvironmentEnd () const |
virtual size_t | getParameterPrecision () const |
virtual void | setParameterPrecision (size_t p) |
virtual void | setAlwaysEnclosePowBase (bool enclose) |
virtual bool | isAlwaysEnclosePowBase () const |
const std::string & | getMultiplicationOperator () const |
void | setMultiplicationOperator (const std::string &multOpStr) |
const std::string & | getMultiplicationConstParOperator () const |
void | setMultiplicationConstParOperator (const std::string &multValOpStr) |
virtual void | setMaxAssignmentsPerFunction (size_t maxAssignmentsPerFunction, std::map< std::string, std::string > *sources) |
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 std::string | indexPattern2String (const IndexPattern &ip, const Node &index) |
static std::string | indexPattern2String (const IndexPattern &ip, const std::vector< const Node *> &indexes) |
static std::string | linearIndexPattern2String (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) |
virtual void | checkEquationEnvStart () |
virtual void | checkEquationEnvEnd () |
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) |
bool | requiresVariableDependencies () const override |
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 const std::string & | getComparison (enum CGOpCode op) const |
const std::string & | getPrintfBaseFormat () |
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 | _startVar |
std::string | _endVar |
std::string | _startDepVar |
std::string | _endDepVar |
std::string | _startIndepVar |
std::string | _endIndepVar |
std::string | _startEq |
std::string | _endEq |
std::string | _startAlgLine |
std::string | _endAlgLine |
std::string | _startEqBlock |
std::string | _endEqBlock |
std::string | _algFileStart |
std::string | _algFileEnd |
std::string | _forStart |
std::string | _forEnd |
std::string | _conditionStart |
std::string | _conditionEnd |
std::string | _ifStart |
std::string | _ifEnd |
std::string | _elseIfStart |
std::string | _elseIfEnd |
std::string | _elseStart |
std::string | _elseEnd |
std::string | _assignStr |
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 |
std::map< size_t, Node * > | _temporary |
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 | _inEquationEnv |
bool | _powBaseEnclose |
Generates code for the Latex language. It creates a generic implementation using custom latex environments which must be implemented by the user.
Definition at line 30 of file language_latex.hpp.
|
inline |
Creates a Latex language source code generator
Definition at line 140 of file language_latex.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 1060 of file language_latex.hpp.
|
inlineprotectedvirtual |
Whether or not this operation assign its expression to a variable by itself.
var | the operation node |
Definition at line 1110 of file language_latex.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 latex file which inputs the other files
encapsulate the code in a function
Implements CppAD::cg::Language< Base >.
Definition at line 683 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each algorithm file.
Definition at line 385 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each algorithm file.
Definition at line 378 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each line.
Definition at line 330 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each line.
Definition at line 323 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each condition.
Definition at line 437 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each condition.
Definition at line 430 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each dependent variable.
Definition at line 252 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each dependent variable.
Definition at line 245 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each else.
Definition at line 515 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each else.
Definition at line 508 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each else if.
Definition at line 489 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each else if.
Definition at line 482 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each equation block which can contain multiple equation lines with the same indentation.
Definition at line 359 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each equation block which can contain multiple equation lines with the same indentation.
Definition at line 351 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each equation.
Definition at line 304 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each equation.
Definition at line 297 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each for loop.
Definition at line 411 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each for loop.
Definition at line 404 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each If.
Definition at line 463 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each If.
Definition at line 456 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each independent variable.
Definition at line 278 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each independent variable.
Definition at line 271 of file language_latex.hpp.
|
inline |
Provides the operator used for multiplication of constant parameters. The default is "\times".
Definition at line 589 of file language_latex.hpp.
|
inline |
Provides the operator used to define multiplications. The default is an empty space.
Definition at line 569 of file language_latex.hpp.
|
inlinevirtual |
Provides the maximum precision used to print constant values in the generated source code
Definition at line 525 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to terminate the environment for each variable.
Definition at line 226 of file language_latex.hpp.
|
inlinevirtual |
Provides the string used to create the environment for each variable.
Definition at line 219 of file language_latex.hpp.
|
inlinevirtual |
Whether or not to always enclose the base of a power within parenthesis.
Definition at line 557 of file language_latex.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 140 of file language_latex_arrays.hpp.
|
inlineprotected |
TODO: finish this
Definition at line 317 of file language_latex_arrays.hpp.
|
inlineprotectedvirtual |
the values of ty are now changed
Definition at line 1739 of file language_latex.hpp.
|
inlineprotectedvirtual |
the values of px are now changed
Definition at line 1778 of file language_latex.hpp.
|
inlineprotectedvirtual |
the first argument is the if start node, the following arguments are assignments in the previous if branch
Definition at line 2002 of file language_latex.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 1968 of file language_latex.hpp.
|
inline |
1D
2D
Definition at line 56 of file language_latex_index_patterns.hpp.
Referenced by CppAD::cg::LanguageLatex< Base >::setMultiplicationConstParOperator().
|
inlineprotectedvirtual |
the first argument is the condition, following arguments are just extra dependencies that must be defined outside the if
Definition at line 1946 of file language_latex.hpp.
|
inlineoverrideprotectedvirtual |
Whether or not this language can use information regarding the dependencies between different equations/variables.
Implements CppAD::cg::Language< Base >.
Definition at line 1189 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each algorithm file.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 369 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each algorithm line.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 314 of file language_latex.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 547 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each condition.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 421 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each dependent variable.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 236 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each else.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 499 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each else if.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 473 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each equation block which can contain multiple equation lines with the same indentation.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 341 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each equation.
begin | a string creating the environment (e.g. "$", "\\begin{algomathdisplay}", "\\[") |
end | a string terminating the environment (e.g. "$\\;", "\\end{algomathdisplay}\\;", "\\]\\;") |
Definition at line 288 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each for loop.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 395 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each If.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 447 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each independent variable.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 262 of file language_latex.hpp.
|
inline |
Defines the operator used for multiplication of constant parameters. The default is "\times". Another common alternative is "\cdot". Please take into account that numbers too close together are difficult to distinguish.
Definition at line 600 of file language_latex.hpp.
|
inline |
Defines the operator used for multiplications. The default is an empty space. Other common alternatives are "\cdot" and "\times".
Definition at line 581 of file language_latex.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 535 of file language_latex.hpp.
|
inlinevirtual |
Defines the Latex environment for each variable.
begin | a string creating the environment |
end | a string terminating the environment |
Definition at line 210 of file language_latex.hpp.