26 #include "jit_function.hpp"
27 #include "casadi_misc.hpp"
35 const std::vector<std::string>& name_in,
36 const std::vector<std::string>& name_out,
37 const std::vector<Sparsity>& sparsity_in,
38 const std::vector<Sparsity>& sparsity_out)
56 "Buffer the calls, user does not need to "}},
59 "Function body for Jacobian"}},
62 "Function body for Hessian"}}
71 for (
auto&& op : opts) {
72 if (op.first==
"buffered") {
74 }
else if (op.first==
"jac") {
76 }
else if (op.first==
"hess") {
93 for (casadi_int i=0; i<
n_in_; ++i) {
104 for (casadi_int i=0; i<
n_out_; ++i) {
117 for (casadi_int i=0; i<
n_out_; ++i) {
129 const std::vector<std::string>& inames,
130 const std::vector<std::string>& onames,
131 const Dict& opts)
const {
Helper class for C code generation.
std::string copy(const std::string &arg, std::size_t n, const std::string &res)
Create a copy operation.
void local(const std::string &name, const std::string &type, const std::string &ref="")
Declare a local variable.
Internal class for Function.
void init(const Dict &opts) override
Initialize.
std::vector< Sparsity > sparsity_in_
Input and output sparsity.
const Sparsity & sparsity_in(casadi_int ind) const
Input/output sparsity.
bool jit_
Use just-in-time compiler.
size_t n_in_
Number of inputs and outputs.
casadi_int nnz_in() const
Number of input/output nonzeros.
static const Options options_
Options.
std::vector< Sparsity > sparsity_out_
const Sparsity & sparsity_out(casadi_int ind) const
Input/output sparsity.
void alloc_w(size_t sz_w, bool persistent=false)
Ensure required length of w field.
casadi_int nnz_out() const
Number of input/output nonzeros.
std::vector< std::string > name_out_
std::vector< std::string > name_in_
Input and output scheme.
static Function jit(const std::string &name, const std::string &body, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
Create a just-in-time compiled function from a C language string.
JitFunction(const std::string &name, const std::string &body, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const std::vector< Sparsity > &sparsity_in, const std::vector< Sparsity > &sparsity_out)
Constructor.
bool has_jacobian() const override
Jacobian of all outputs with respect to all inputs.
void init(const Dict &opts) override
Initialize.
static const Options options_
Options.
Function get_jacobian(const std::string &name, const std::vector< std::string > &inames, const std::vector< std::string > &onames, const Dict &opts) const override
Jacobian of all outputs with respect to all inputs.
void codegen_body(CodeGenerator &g) const override
Generate code for the function body.
~JitFunction() override
Destructor.
void clear_mem()
Clear all memory (called from destructor)
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
Options metadata for a class.