25 #include "callback_internal.hpp"
33 casadi_error(
"Callback objects cannot be copied");
38 casadi_error(
"Cannot create '" +
name +
"': Internal class already created");
41 (*this)->construct(opts);
47 if (!
is_null()) get<CallbackInternal>()->self_ =
nullptr;
49 casadi_warning(
"Problem in Callback destructor");
54 double **res,
const std::vector<casadi_int>& sizes_res)
const {
55 casadi_error(
"eval_buffer not overloaded.");
61 return (*this)->FunctionInternal::eval_dm(arg);
65 return (*this)->FunctionInternal::get_n_in();
69 return (*this)->FunctionInternal::get_n_out();
73 return (*this)->FunctionInternal::get_sparsity_in(i);
77 return (*this)->FunctionInternal::get_sparsity_out(i);
81 return (*this)->FunctionInternal::get_name_in(i);
85 return (*this)->FunctionInternal::get_name_out(i);
89 return (*this)->FunctionInternal::uses_output();
93 return (*this)->FunctionInternal::has_jacobian();
98 const std::vector<std::string>& inames,
99 const std::vector<std::string>& onames,
100 const Dict& opts)
const {
101 return (*this)->FunctionInternal::get_jacobian(
name, inames, onames, opts);
105 get_forward(casadi_int nfwd,
const std::string& name,
106 const std::vector<std::string>& inames,
107 const std::vector<std::string>& onames,
108 const Dict& opts)
const {
109 return (*this)->FunctionInternal::get_forward(nfwd,
name, inames, onames, opts);
113 return (*this)->FunctionInternal::has_forward(nfwd);
117 get_reverse(casadi_int nadj,
const std::string& name,
118 const std::vector<std::string>& inames,
119 const std::vector<std::string>& onames,
120 const Dict& opts)
const {
121 return (*this)->FunctionInternal::get_reverse(nadj,
name, inames, onames, opts);
125 return (*this)->FunctionInternal::has_reverse(nadj);
Callback function functionality.
virtual Function get_forward(casadi_int nfwd, const std::string &name, const std::vector< std::string > &inames, const std::vector< std::string > &onames, const Dict &opts) const
Return function that calculates forward derivatives.
virtual Sparsity get_sparsity_in(casadi_int i)
Get the sparsity of an input.
void construct(const std::string &name, const Dict &opts=Dict())
Construct internal object.
virtual std::string get_name_out(casadi_int i)
Get the name of an output.
virtual bool has_eval_buffer() const
Does the Callback class support a copy-free low level interface ?
virtual Function get_reverse(casadi_int nadj, const std::string &name, const std::vector< std::string > &inames, const std::vector< std::string > &onames, const Dict &opts) const
Return function that calculates adjoint derivatives.
virtual std::string get_name_in(casadi_int i)
Get the name of an input.
Callback()
Default constructor.
virtual bool has_jacobian() const
Return Jacobian of all input elements with respect to all output elements.
virtual ~Callback()
Destructor.
virtual bool has_reverse(casadi_int nadj) const
Return function that calculates adjoint derivatives.
virtual casadi_int get_n_out()
Get the number of outputs.
virtual bool has_forward(casadi_int nfwd) const
Return function that calculates forward derivatives.
virtual int eval_buffer(const double **arg, const std::vector< casadi_int > &sizes_arg, double **res, const std::vector< casadi_int > &sizes_res) const
A copy-free low level interface.
virtual std::vector< DM > eval(const std::vector< DM > &arg) const
Evaluate numerically, using temporary matrices and work vectors.
virtual bool uses_output() const
Do the derivative functions need nondifferentiated outputs?
virtual Sparsity get_sparsity_out(casadi_int i)
Get the sparsity of an output.
virtual casadi_int get_n_in()
Get the number of inputs.
virtual Function get_jacobian(const std::string &name, const std::vector< std::string > &inames, const std::vector< std::string > &onames, const Dict &opts) const
Return Jacobian of all input elements with respect to all output elements.
const std::string & name() const
Name of the function.
bool is_null() const
Is a null pointer?
void own(SharedObjectInternal *node)
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.