|
| DerivativesCppadCG (FUN_TYPE_CG &f, int inputDim=IN_DIM, int outputDim=OUT_DIM) |
| Contructs the derivatives for codegeneration using a FUN_TYPE_CG function. More...
|
|
| DerivativesCppadCG (const DerivativesCppadCG &arg) |
| copy constructor More...
|
|
virtual | ~DerivativesCppadCG ()=default |
| destructor More...
|
|
DerivativesCppadCG * | clone () const |
| deep cloning of Jacobian More...
|
|
void | generateJacobianSource (const std::string &derivativeName, const std::string &outputDir=ct::core::CODEGEN_OUTPUT_DIR, const std::string &templateDir=ct::core::CODEGEN_TEMPLATE_DIR, const std::string &ns1="core", const std::string &ns2="generated", const Sparsity &sparsity=Sparsity::Ones(), bool useReverse=true, bool ignoreZero=true) |
| Generates code for computing the Jacobian and writes it to file. More...
|
|
void | generateForwardZeroSource (const std::string &forwardZeroName, const std::string &outputDir=ct::core::CODEGEN_OUTPUT_DIR, const std::string &templateDir=ct::core::CODEGEN_TEMPLATE_DIR, const std::string &ns1="core", const std::string &ns2="generated", bool ignoreZero=true) |
| Generates code for computing the zero-order derivative and writes it to file. More...
|
|
void | generateHessianSource (const std::string &derivativeName, const std::string &outputDir=ct::core::CODEGEN_OUTPUT_DIR, const std::string &templateDir=ct::core::CODEGEN_TEMPLATE_DIR, const std::string &ns1="core", const std::string &ns2="generated", const HessianSparsity &sparsity=HessianSparsity::Ones(), bool useReverse=true, bool ignoreZero=true) |
| Generates code for computing the Hessian and writes it to file. More...
|
|
template<int IN_DIM, int OUT_DIM>
class ct::core::DerivativesCppadCG< IN_DIM, OUT_DIM >
Jacobian using Auto-Diff Codegeneration.
Uses Auto-Diff code generation to compute the Jacobian of a regular vector-valued mathematical function .
x has IN_DIM dimension and y has OUT_DIM dimension. Thus, they can be scalar functions (IN_DIM = 1, OUT_DIM = 1), fixed or variable size (IN_DIM = -1, OUT_DIM = -1) functions.
- Note
- In fact, this class is called Jacobian but computes also zero order derivatives
- Template Parameters
-
IN_DIM | Input dimensionality of the function (use Eigen::Dynamic (-1) for dynamic size) |
OUT_DIM | Output dimensionailty of the function (use Eigen::Dynamic (-1) for dynamic size) |
template<int IN_DIM, int OUT_DIM>
void ct::core::DerivativesCppadCG< IN_DIM, OUT_DIM >::generateJacobianSource |
( |
const std::string & |
derivativeName, |
|
|
const std::string & |
outputDir = ct::core::CODEGEN_OUTPUT_DIR , |
|
|
const std::string & |
templateDir = ct::core::CODEGEN_TEMPLATE_DIR , |
|
|
const std::string & |
ns1 = "core" , |
|
|
const std::string & |
ns2 = "generated" , |
|
|
const Sparsity & |
sparsity = Sparsity::Ones() , |
|
|
bool |
useReverse = true , |
|
|
bool |
ignoreZero = true |
|
) |
| |
|
inline |
Generates code for computing the Jacobian and writes it to file.
This function is optional and can be used if you want to generate code for a Jacobian and write it to file. This can be useful to pre-compile Jacobians rather than compiling them at runtime using compileJIT(). This function can make use of a template file in which the keyword "AUTOGENERATED_CODE_PLACEHOLDER" is replaced with the autogenerated code.
- Parameters
-
derivativeName | name of the resulting Jacobian class |
outputDir | output directory |
templateDir | directory in which template file is located |
ns1 | first namespace layer of the Jacobian class |
ns2 | second namespace layer of the Jacobian class |
sparsity | sparsity pattern to generate sparse Jacobian |
useReverse | if true, uses Auto-Diff reverse mode, otherwise uses forward mode |
ignoreZero | do not assign 0 to sparse entries or zero entries |
References ct::core::internal::CGHelpers::generateJacobianSource(), and ct::core::internal::SparsityPattern::initPattern().
template<int IN_DIM, int OUT_DIM>
void ct::core::DerivativesCppadCG< IN_DIM, OUT_DIM >::generateForwardZeroSource |
( |
const std::string & |
forwardZeroName, |
|
|
const std::string & |
outputDir = ct::core::CODEGEN_OUTPUT_DIR , |
|
|
const std::string & |
templateDir = ct::core::CODEGEN_TEMPLATE_DIR , |
|
|
const std::string & |
ns1 = "core" , |
|
|
const std::string & |
ns2 = "generated" , |
|
|
bool |
ignoreZero = true |
|
) |
| |
|
inline |
Generates code for computing the zero-order derivative and writes it to file.
This function is optional and can be used if you want to generate code for a zero-order derivative, i.e. the function itself and write it to file. While it seems weird at first to regenerate code from existing code, this can help to speed up complex computations. Generating source code can be useful to pre-compile the zero order dynamics rather than compiling them at runtime using compileJIT(). This function can make use of a template file in which the keyword "AUTOGENERATED_CODE_PLACEHOLDER" is replaced with the autogenerated code.
- Parameters
-
forwardZeroName | name of the resulting class |
outputDir | output directory |
templateDir | directory in which template file is located |
ns1 | first namespace layer of the class |
ns2 | second namespace layer of the class |
ignoreZero | do not assign 0 to sparse entries or zero entries |
References ct::core::internal::CGHelpers::generateForwardZeroSource().
template<int IN_DIM, int OUT_DIM>
void ct::core::DerivativesCppadCG< IN_DIM, OUT_DIM >::generateHessianSource |
( |
const std::string & |
derivativeName, |
|
|
const std::string & |
outputDir = ct::core::CODEGEN_OUTPUT_DIR , |
|
|
const std::string & |
templateDir = ct::core::CODEGEN_TEMPLATE_DIR , |
|
|
const std::string & |
ns1 = "core" , |
|
|
const std::string & |
ns2 = "generated" , |
|
|
const HessianSparsity & |
sparsity = HessianSparsity::Ones() , |
|
|
bool |
useReverse = true , |
|
|
bool |
ignoreZero = true |
|
) |
| |
|
inline |
Generates code for computing the Hessian and writes it to file.
This function is optional and can be used if you want to generate code for a hessian, i.e. the function itself and write it to file. While it seems weird at first to regenerate code from existing code, this can help to speed up complex computations. Generating source code can be useful to pre-compile the hessian dynamics rather than compiling them at runtime using compileJIT(). This function can make use of a template file in which the keyword "AUTOGENERATED_CODE_PLACEHOLDER" is replaced with the autogenerated code.
- Parameters
-
derivativeName | name of the resulting class |
outputDir | output directory |
templateDir | directory in which template file is located |
ns1 | first namespace layer of the class |
ns2 | second namespace layer of the class |
sparsity | sparsity pattern to generate sparse Jacobian |
useReverse | if true, uses Auto-Diff reverse mode, otherwise uses forward mode |
ignoreZero | do not assign 0 to sparse entries or zero entries |
References ct::core::internal::CGHelpers::generateHessianSource(), ct::core::internal::SparsityPattern::initPattern(), ct::core::internal::CGHelpers::parseFile(), ct::core::internal::CGHelpers::replaceAll(), ct::core::internal::CGHelpers::replaceOnce(), ct::core::internal::CGHelpers::writeFile(), x, and y.