List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions
casadi::Function Class Reference

Function object. More...

#include <function.hpp>

Detailed Description

A Function instance is a general multiple-input, multiple-output function where each input and output can be a sparse matrix.
For an introduction to this class, see the CasADi user guide.
Function is a reference counted and immutable class; copying a class instance is very cheap and its behavior (with some exceptions) is not affected by calling its member functions.

Author
Joel Andersson
Date
2010-2017

Extra doc: https://github.com/casadi/casadi/wiki/L_1uw

List of available options
IdTypeDescriptionUsed in
ad_weightOT_DOUBLEWeighting factor for derivative calculation.When there is an option of either using forward or reverse mode directional derivatives, the condition ad_weight*nf<=(1-ad_weight)*na is used where nf and na are estimates of the number of forward/reverse mode directional derivatives needed. By default, ad_weight is calculated automatically, but this can be overridden by setting this option. In particular, 0 means forcing forward mode and 1 forcing reverse mode. Leave unset for (class specific) heuristics.casadi::FunctionInternal
ad_weight_spOT_DOUBLEWeighting factor for sparsity pattern calculation calculation.Overrides default behavior. Set to 0 and 1 to force forward and reverse mode respectively. Cf. option "ad_weight". When set to -1, sparsity is completely ignored and dense matrices are used.casadi::FunctionInternal
always_inlineOT_BOOLForce inlining.casadi::FunctionInternal
cacheOT_DICTPrepopulate the function cache. Default: emptycasadi::FunctionInternal
compilerOT_STRINGJust-in-time compiler plugin to be used.casadi::FunctionInternal
custom_jacobianOT_FUNCTIONOverride CasADi's AD. Use together with 'jac_penalty': 0. Note: Highly experimental. Syntax may break often.casadi::FunctionInternal
der_optionsOT_DICTDefault options to be used to populate forward_options, reverse_options, and jacobian_options before those options are merged in.casadi::FunctionInternal
derivative_ofOT_FUNCTIONThe function is a derivative of another function. The type of derivative (directional derivative, Jacobian) is inferred from the function name.casadi::FunctionInternal
dumpOT_BOOLDump function to file upon first evaluation. [false]casadi::FunctionInternal
dump_dirOT_STRINGDirectory to dump inputs/outputs to. Make sure the directory exists [.]casadi::FunctionInternal
dump_formatOT_STRINGChoose file format to dump matrices. See DM.from_file [mtx]casadi::FunctionInternal
dump_inOT_BOOLDump numerical values of inputs to file (readable with DM.from_file) [default: false]casadi::FunctionInternal
dump_outOT_BOOLDump numerical values of outputs to file (readable with DM.from_file) [default: false]casadi::FunctionInternal
enable_fdOT_BOOLEnable derivative calculation by finite differencing. [default: false]]casadi::FunctionInternal
enable_forwardOT_BOOLEnable derivative calculation using generated functions for Jacobian-times-vector products - typically using forward mode AD - if available. [default: true]casadi::FunctionInternal
enable_jacobianOT_BOOLEnable derivative calculation using generated functions for Jacobians of all differentiable outputs with respect to all differentiable inputs - if available. [default: true]casadi::FunctionInternal
enable_reverseOT_BOOLEnable derivative calculation using generated functions for transposed Jacobian-times-vector products - typically using reverse mode AD - if available. [default: true]casadi::FunctionInternal
error_on_failOT_BOOLThrow exceptions when function evaluation fails (default true).casadi::ProtoFunction
external_transformOT_VECTORVECTORList of external_transform instruction arguments. Default: emptycasadi::FunctionInternal
fd_methodOT_STRINGMethod for finite differencing [default 'central']casadi::FunctionInternal
fd_optionsOT_DICTOptions to be passed to the finite difference instancecasadi::FunctionInternal
forward_optionsOT_DICTOptions to be passed to a forward mode constructorcasadi::FunctionInternal
gather_statsOT_BOOLDeprecated option (ignored): Statistics are now always collected.casadi::FunctionInternal
input_schemeOT_STRINGVECTORDeprecated option (ignored)casadi::FunctionInternal
inputs_checkOT_BOOLThrow exceptions when the numerical values of the inputs don't make sensecasadi::FunctionInternal
is_diff_inOT_BOOLVECTORIndicate for each input if it should be differentiable.casadi::FunctionInternal
is_diff_outOT_BOOLVECTORIndicate for each output if it should be differentiable.casadi::FunctionInternal
jac_penaltyOT_DOUBLEWhen requested for a number of forward/reverse directions, it may be cheaper to compute first the full jacobian and then multiply with seeds, rather than obtain the requested directions in a straightforward manner. Casadi uses a heuristic to decide which is cheaper. A high value of 'jac_penalty' makes it less likely for the heurstic to chose the full Jacobian strategy. The special value -1 indicates never to use the full Jacobian strategycasadi::FunctionInternal
jacobian_optionsOT_DICTOptions to be passed to a Jacobian constructorcasadi::FunctionInternal
jitOT_BOOLUse just-in-time compiler to speed up the evaluationcasadi::FunctionInternal
jit_cleanupOT_BOOLCleanup up the temporary source file that jit creates. Default: truecasadi::FunctionInternal
jit_nameOT_STRINGThe file name used to write out code. The actual file names used depend on 'jit_temp_suffix' and include extensions. Default: 'jit_tmp'casadi::FunctionInternal
jit_optionsOT_DICTOptions to be passed to the jit compiler.casadi::FunctionInternal
jit_serializeOT_STRINGSpecify behaviour when serializing a jitted function: SOURCE|link|embed.casadi::FunctionInternal
jit_temp_suffixOT_BOOLUse a temporary (seemingly random) filename suffix for generated code and libraries. This is desired for thread-safety. This behaviour may defeat caching compiler wrappers. Default: truecasadi::FunctionInternal
max_ioOT_INTAcceptable number of inputs and outputs. Warn if exceeded.casadi::FunctionInternal
max_num_dirOT_INTSpecify the maximum number of directions for derivative functions. Overrules the builtin optimized_num_dir.casadi::FunctionInternal
never_inlineOT_BOOLForbid inlining.casadi::FunctionInternal
output_schemeOT_STRINGVECTORDeprecated option (ignored)casadi::FunctionInternal
post_expandOT_BOOLAfter construction, expand this Function. Default: Falsecasadi::FunctionInternal
post_expand_optionsOT_DICTOptions to be passed to post-construction expansion. Default: emptycasadi::FunctionInternal
print_inOT_BOOLPrint numerical values of inputs [default: false]casadi::FunctionInternal
print_outOT_BOOLPrint numerical values of outputs [default: false]casadi::FunctionInternal
print_timeOT_BOOLprint information about execution time. Implies record_time.casadi::ProtoFunction
record_timeOT_BOOLrecord information about execution time, for retrieval with stats().casadi::ProtoFunction
regularity_checkOT_BOOLThrow exceptions when NaN or Inf appears during evaluationcasadi::ProtoFunction
reverse_optionsOT_DICTOptions to be passed to a reverse mode constructorcasadi::FunctionInternal
user_dataOT_VOIDPTRA user-defined field that can be used to identify the function or pass additional informationcasadi::FunctionInternal
verboseOT_BOOLVerbose evaluation – for debuggingcasadi::ProtoFunction
Examples
SX/SXFunction_constr_oct.m, SX/SXFunction_constr_py.py, integrators/simulator.py, solvers/callback.py, solvers/exacthessian.py, and solvers/ipopt.py.

Definition at line 58 of file function.hpp.

Inheritance diagram for casadi::Function:
Inheritance graph
[legend]
Collaboration diagram for casadi::Function:
Collaboration graph
[legend]

Public Types

typedef std::map< std::string, std::vector< std::string > > AuxOut
 
using internal_base_type = SharedObjectInternal
 
using base_type = SharedObject
 

Public Member Functions

 Function ()
 Default constructor, null pointer. More...
 
 Function (const std::string &fname)
 Construct from a file. More...
 
 ~Function ()
 Destructor. More...
 
casadi_int n_in () const
 Get the number of function inputs. More...
 
casadi_int n_out () const
 Get the number of function outputs. More...
 
const std::vector< std::string > & name_in () const
 Get input scheme. More...
 
const std::vector< std::string > & name_out () const
 Get output scheme. More...
 
const std::string & name_in (casadi_int ind) const
 Get input scheme name by index. More...
 
const std::string & name_out (casadi_int ind) const
 Get output scheme name by index. More...
 
casadi_int index_in (const std::string &name) const
 Find the index for a string describing a particular entry of an input scheme. More...
 
casadi_int index_out (const std::string &name) const
 Find the index for a string describing a particular entry of an output scheme. More...
 
bool has_in (const std::string &name) const
 Does the function have a particularly named input? More...
 
bool has_out (const std::string &name) const
 Does the function have a particularly named output? More...
 
double default_in (casadi_int ind) const
 Get default input value. More...
 
double max_in (casadi_int ind) const
 Get largest input value. More...
 
double min_in (casadi_int ind) const
 Get smallest input value. More...
 
std::vector< double > nominal_in (casadi_int ind) const
 Get nominal input value. More...
 
std::vector< double > nominal_out (casadi_int ind) const
 Get nominal output value. More...
 
Function factory (const std::string &name, const std::vector< std::string > &s_in, const std::vector< std::string > &s_out, const AuxOut &aux=AuxOut(), const Dict &opts=Dict()) const
 
Function oracle () const
 Get oracle. More...
 
Function wrap () const
 Wrap in an Function instance consisting of only one MX call. More...
 
Function wrap_as_needed (const Dict &opts) const
 Wrap in a Function with options. More...
 
std::vector< bool > which_depends (const std::string &s_in, const std::vector< std::string > &s_out, casadi_int order=1, bool tr=false) const
 Which variables enter with some order. More...
 
void print_dimensions (std::ostream &stream=casadi::uout()) const
 Print dimensions of inputs and outputs. More...
 
void print_options (std::ostream &stream=casadi::uout()) const
 Print options to a stream. More...
 
void print_option (const std::string &name, std::ostream &stream=casadi::uout()) const
 Print all information there is to know about a certain option. More...
 
bool has_option (const std::string &option_name) const
 Does a particular option exist. More...
 
void change_option (const std::string &option_name, const GenericType &option_value)
 Change option after object creation for debugging. More...
 
bool uses_output () const
 Do the derivative functions need nondifferentiated outputs? More...
 
Function jacobian_old (casadi_int iind, casadi_int oind) const
 [DEPRECATED] Replaced by Function::factory. More...
 
Function hessian_old (casadi_int iind, casadi_int oind) const
 [DEPRECATED] Replaced by Function::factory. More...
 
Function jacobian () const
 Calculate all Jacobian blocks. More...
 
bool operator== (const Function &f) const
 Check if same as another function. More...
 
int operator() (const double **arg, double **res, casadi_int *iw, double *w, int mem) const
 Evaluate memory-less, numerically. More...
 
int operator() (const double **arg, double **res, casadi_int *iw, double *w) const
 Evaluate numerically with checkout/release. More...
 
int operator() (const SXElem **arg, SXElem **res, casadi_int *iw, SXElem *w, int mem=0) const
 Evaluate memory-less SXElem. More...
 
int operator() (const bvec_t **arg, bvec_t **res, casadi_int *iw, bvec_t *w, int mem=0) const
 Propagate sparsity forward. More...
 
int rev (bvec_t **arg, bvec_t **res, casadi_int *iw, bvec_t *w, int mem=0) const
 Propagate sparsity backward. More...
 
int rev (std::vector< bvec_t * > arg, std::vector< bvec_t * > res) const
 Propagate sparsity backward with temporary memory allocation. More...
 
std::vector< MXmapsum (const std::vector< MX > &x, const std::string &parallelization="serial") const
 Evaluate symbolically in parallel and sum (matrix graph) More...
 
Function map (casadi_int n, const std::string &parallelization="serial") const
 Create a mapped version of this function. More...
 
Function map (casadi_int n, const std::string &parallelization, casadi_int max_num_threads) const
 
Function slice (const std::string &name, const std::vector< casadi_int > &order_in, const std::vector< casadi_int > &order_out, const Dict &opts=Dict()) const
 returns a new function with a selection of inputs/outputs of the original More...
 
Function forward (casadi_int nfwd) const
 Get a function that calculates nfwd forward derivatives. More...
 
Function reverse (casadi_int nadj) const
 Get a function that calculates nadj adjoint derivatives. More...
 
const std::vector< Sparsity > & jac_sparsity (bool compact=false) const
 Get, if necessary generate, the sparsity of all Jacobian blocks. More...
 
Sparsity jac_sparsity (casadi_int oind, casadi_int iind, bool compact=false) const
 Get, if necessary generate, the sparsity of a single Jacobian block. More...
 
std::string generate (const std::string &fname, const Dict &opts=Dict()) const
 Export / Generate C code for the function. More...
 
std::string generate (const Dict &opts=Dict()) const
 Export / Generate C code for the function. More...
 
std::string generate_dependencies (const std::string &fname, const Dict &opts=Dict()) const
 Export / Generate C code for the dependency function. More...
 
FunctionInternalget () const
 
template<typename T >
T * get () const
 Get a pointer and typecast. More...
 
FunctionInternaloperator-> () const
 Const access functions of the node. More...
 
Dict stats (int mem=0) const
 Get all statistics obtained at the end of the last evaluate call. More...
 
bool has_free () const
 Does the function have free variables. More...
 
std::vector< std::string > get_free () const
 Get free variables as a string. More...
 
std::vector< SXfree_sx () const
 Get all the free variables of the function. More...
 
std::vector< MXfree_mx () const
 Get all the free variables of the function. More...
 
void generate_lifted (Function &vdef_fcn, Function &vinit_fcn) const
 Extract the functions needed for the Lifted Newton method. More...
 
casadi_int n_nodes () const
 Number of nodes in the algorithm. More...
 
casadi_int n_instructions () const
 Number of instruction in the algorithm (SXFunction/MXFunction) More...
 
casadi_int instruction_id (casadi_int k) const
 Identifier index of the instruction (SXFunction/MXFunction) More...
 
std::vector< casadi_int > instruction_input (casadi_int k) const
 Locations in the work vector for the inputs of the instruction. More...
 
double instruction_constant (casadi_int k) const
 Get the floating point output argument of an instruction (SXFunction) More...
 
std::vector< casadi_int > instruction_output (casadi_int k) const
 Location in the work vector for the output of the instruction. More...
 
MX instruction_MX (casadi_int k) const
 Get the MX node corresponding to an instruction (MXFunction) More...
 
SX instructions_sx () const
 Get the SX node corresponding to all instructions (SXFunction) More...
 
size_t sz_arg () const
 Get required length of arg field. More...
 
size_t sz_res () const
 Get required length of res field. More...
 
size_t sz_iw () const
 Get required length of iw field. More...
 
size_t sz_w () const
 Get required length of w field. More...
 
void sz_work (size_t &sz_arg, size_t &sz_res, size_t &sz_iw, size_t &sz_w) const
 Get number of temporary variables needed. More...
 
void set_work (const double **&arg, double **&res, casadi_int *&iw, double *&w, int mem=0) const
 Set the (persistent) work vectors. More...
 
void set_temp (const double **arg, double **res, casadi_int *iw, double *w, int mem=0) const
 Set the (temporary) work vectors. More...
 
void setup (const double **arg, double **res, casadi_int *iw, double *w, int mem=0) const
 Set the (persistent and temporary) work vectors. More...
 
template<typename M >
void call_gen (const std::map< std::string, M > &arg, std::map< std::string, M > &res, bool always_inline, bool never_inline) const
 Call using a map. More...
 
void merge (const std::vector< MX > &arg, std::vector< MX > &subs_from, std::vector< MX > &subs_to) const
 List merge opportunitities. More...
 
const std::string & name () const
 Name of the function. More...
 
bool is_a (const std::string &type, bool recursive=true) const
 Check if the function is of a particular type. More...
 
void assert_size_in (casadi_int i, casadi_int nrow, casadi_int ncol) const
 Assert that an input dimension is equal so some given value. More...
 
void assert_size_out (casadi_int i, casadi_int nrow, casadi_int ncol) const
 Assert that an output dimension is equal so some given value. More...
 
void assert_sparsity_out (casadi_int i, const Sparsity &sp, casadi_int n=1, bool allow_all_zero_sparse=true) const
 Assert that an output sparsity is a multiple of some given sparsity. More...
 
casadi_int checkout () const
 Checkout a memory object. More...
 
void release (int mem) const
 Release a memory object. More...
 
void * memory (int ind) const
 Get memory object. More...
 
Dict cache () const
 Get all functions in the cache. More...
 
std::vector< std::string > get_function () const
 Get a list of all functions. More...
 
Function get_function (const std::string &name) const
 Get a dependency function. More...
 
bool has_function (const std::string &fname) const
 Check if a particular dependency exists. More...
 
std::vector< Functionfind_functions (casadi_int max_depth=-1) const
 Get all functions embedded in the expression graphs. More...
 
Function find_function (const std::string &name, casadi_int max_depth=-1) const
 Get a specific function embedded in the expression graphs. More...
 
Dict info () const
 
std::string class_name () const
 Get class name. More...
 
void disp (std::ostream &stream, bool more=false) const
 Print a description of the object. More...
 
std::string get_str (bool more=false) const
 Get string representation. More...
 
void print_ptr (std::ostream &stream=casadi::uout()) const
 
void own (SharedObjectInternal *node)
 
void assign (SharedObjectInternal *node)
 Assign the node to a node class pointer without reference counting. More...
 
casadi_int getCount () const
 Get the reference count. More...
 
void swap (GenericShared &other)
 Swap content with another instance. More...
 
std::string debug_repr () const
 
bool is_null () const
 Is a null pointer? More...
 
casadi_int __hash__ () const
 Returns a number that is unique for a given Node. More...
 
GenericWeakRef< SharedObject, SharedObjectInternal > * weak ()
 Get a weak reference to the object. More...
 
 Function (const std::string &name, const std::vector< SX > &ex_in, const std::vector< SX > &ex_out, const Dict &opts=Dict())
 Construct an SX function. More...
 
 Function (const std::string &name, const std::vector< SX > &ex_in, const std::vector< SX > &ex_out, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
 Construct an SX function. More...
 
 Function (const std::string &name, const std::map< std::string, SX > &dict, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
 Construct an SX function. More...
 
 Function (const std::string &name, const std::vector< MX > &ex_in, const std::vector< MX > &ex_out, const Dict &opts=Dict())
 Construct an MX function. More...
 
 Function (const std::string &name, const std::vector< MX > &ex_in, const std::vector< MX > &ex_out, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
 Construct an MX function. More...
 
 Function (const std::string &name, const std::map< std::string, MX > &dict, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts=Dict())
 Construct an MX function. More...
 
 Function (const std::string &name, SXIList ex_in, const SXVector &ex_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, const SXVector &ex_in, SXIList ex_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, SXIList ex_in, SXIList ex_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, SXIList ex_in, const SXVector &ex_out, const StringVector &name_in, const StringVector &name_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, const SXVector &ex_in, SXIList ex_out, const StringVector &name_in, const StringVector &name_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, SXIList ex_in, SXIList ex_out, const StringVector &name_in, const StringVector &name_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, MXIList ex_in, const MXVector &ex_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, const MXVector &ex_in, MXIList ex_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, MXIList ex_in, MXIList ex_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, MXIList ex_in, const MXVector &ex_out, const StringVector &name_in, const StringVector &name_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, const MXVector &ex_in, MXIList ex_out, const StringVector &name_in, const StringVector &name_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
 Function (const std::string &name, MXIList ex_in, MXIList ex_out, const StringVector &name_in, const StringVector &name_out, const Dict &opts=Dict())
 To resolve ambiguity on some compilers. More...
 
Function expand () const
 Expand a function to SX. More...
 
Function expand (const std::string &name, const Dict &opts=Dict()) const
 Expand a function to SX. More...
 
casadi_int size1_in (casadi_int ind) const
 Get input dimension. More...
 
casadi_int size1_in (const std::string &iname) const
 Get input dimension. More...
 
casadi_int size2_in (casadi_int ind) const
 Get input dimension. More...
 
casadi_int size2_in (const std::string &iname) const
 Get input dimension. More...
 
std::pair< casadi_int, casadi_int > size_in (casadi_int ind) const
 Get input dimension. More...
 
std::pair< casadi_int, casadi_int > size_in (const std::string &iname) const
 Get input dimension. More...
 
casadi_int size1_out (casadi_int ind) const
 Get output dimension. More...
 
casadi_int size1_out (const std::string &oname) const
 Get output dimension. More...
 
casadi_int size2_out (casadi_int ind) const
 Get output dimension. More...
 
casadi_int size2_out (const std::string &oname) const
 Get output dimension. More...
 
std::pair< casadi_int, casadi_int > size_out (casadi_int ind) const
 Get output dimension. More...
 
std::pair< casadi_int, casadi_int > size_out (const std::string &oname) const
 Get output dimension. More...
 
casadi_int nnz_in () const
 Get number of input nonzeros. More...
 
casadi_int nnz_in (casadi_int ind) const
 Get number of input nonzeros. More...
 
casadi_int nnz_in (const std::string &iname) const
 Get number of input nonzeros. More...
 
casadi_int nnz_out () const
 Get number of output nonzeros. More...
 
casadi_int nnz_out (casadi_int ind) const
 Get number of output nonzeros. More...
 
casadi_int nnz_out (const std::string &oname) const
 Get number of output nonzeros. More...
 
casadi_int numel_in () const
 Get number of input elements. More...
 
casadi_int numel_in (casadi_int ind) const
 Get number of input elements. More...
 
casadi_int numel_in (const std::string &iname) const
 Get number of input elements. More...
 
casadi_int numel_out () const
 Get number of output elements. More...
 
casadi_int numel_out (casadi_int ind) const
 Get number of output elements. More...
 
casadi_int numel_out (const std::string &oname) const
 Get number of output elements. More...
 
const Sparsitysparsity_in (casadi_int ind) const
 Get sparsity of a given input. More...
 
const Sparsitysparsity_in (const std::string &iname) const
 Get sparsity of a given input. More...
 
const Sparsitysparsity_out (casadi_int ind) const
 Get sparsity of a given output. More...
 
const Sparsitysparsity_out (const std::string &iname) const
 Get sparsity of a given output. More...
 
bool is_diff_in (casadi_int ind) const
 Get differentiability of inputs/output. More...
 
bool is_diff_out (casadi_int ind) const
 Get differentiability of inputs/output. More...
 
std::vector< bool > is_diff_in () const
 Get differentiability of inputs/output. More...
 
std::vector< bool > is_diff_out () const
 Get differentiability of inputs/output. More...
 
const Sparsity sparsity_jac (casadi_int iind, casadi_int oind, bool compact=false, bool symmetric=false) const
 
const Sparsity sparsity_jac (const std::string &iind, casadi_int oind=0, bool compact=false, bool symmetric=false) const
 
const Sparsity sparsity_jac (casadi_int iind, const std::string &oind, bool compact=false, bool symmetric=false) const
 
const Sparsity sparsity_jac (const std::string &iind, const std::string &oind, bool compact=false, bool symmetric=false) const
 
void call (const std::vector< DM > &arg, std::vector< DM > &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const std::vector< SX > &arg, std::vector< SX > &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const std::vector< MX > &arg, std::vector< MX > &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const DMDict &arg, DMDict &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const SXDict &arg, SXDict &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
void call (const MXDict &arg, MXDict &res, bool always_inline=false, bool never_inline=false) const
 Evaluate the function symbolically or numerically. More...
 
std::vector< DMoperator() (const std::vector< DM > &arg) const
 
std::vector< SXoperator() (const std::vector< SX > &arg) const
 
std::vector< MXoperator() (const std::vector< MX > &arg) const
 
const DMDict operator() (const DMDict &arg) const
 
const SXDict operator() (const SXDict &arg) const
 
const MXDict operator() (const MXDict &arg) const
 
void operator() (std::vector< const double * > arg, std::vector< double * > res) const
 Evaluate with temporary memory allocation. More...
 
void operator() (std::vector< const bvec_t * > arg, std::vector< bvec_t * > res) const
 Evaluate with temporary memory allocation. More...
 
void operator() (std::vector< const SXElem * > arg, std::vector< SXElem * > res) const
 Evaluate with temporary memory allocation. More...
 
template<typename D >
void call_gen (std::vector< const D * > arg, std::vector< D * > res) const
 Evaluate with temporary memory allocation. More...
 
void operator() (VecArg arg, VecRes res) const
 Numerical evaluation. More...
 
void operator() (VecArg arg, MapRes res) const
 Numerical evaluation. More...
 
void operator() (VecArg arg, VPrRes res) const
 Numerical evaluation. More...
 
void operator() (VecArg arg, MPrRes res) const
 Numerical evaluation. More...
 
void operator() (MapArg arg, VecRes res) const
 Numerical evaluation. More...
 
void operator() (MapArg arg, MapRes res) const
 Numerical evaluation. More...
 
void operator() (MapArg arg, VPrRes res) const
 Numerical evaluation. More...
 
void operator() (MapArg arg, MPrRes res) const
 Numerical evaluation. More...
 
std::vector< DMoperator() (const DM &arg0) const
 
std::vector< SXoperator() (const SX &arg0) const
 
std::vector< MXoperator() (const MX &arg0) const
 
Function mapaccum (const std::string &name, casadi_int N, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function mapaccum (const std::string &name, casadi_int N, casadi_int n_accum, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function mapaccum (const std::string &name, casadi_int n, const std::vector< casadi_int > &accum_in, const std::vector< casadi_int > &accum_out, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function mapaccum (const std::string &name, casadi_int n, const std::vector< std::string > &accum_in, const std::vector< std::string > &accum_out, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function mapaccum (casadi_int N, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function fold (casadi_int N, const Dict &opts=Dict()) const
 Create a mapaccumulated version of this function. More...
 
Function map (const std::string &name, const std::string &parallelization, casadi_int n, const std::vector< casadi_int > &reduce_in, const std::vector< casadi_int > &reduce_out, const Dict &opts=Dict()) const
 Map with reduction. More...
 
Function map (const std::string &name, const std::string &parallelization, casadi_int n, const std::vector< std::string > &reduce_in, const std::vector< std::string > &reduce_out, const Dict &opts=Dict()) const
 Map with reduction. More...
 
Function map (casadi_int n, const std::vector< bool > &reduce_in, const std::vector< bool > &reduce_out=std::vector< bool >(), const Dict &opts=Dict()) const
 Map with reduction. More...
 
void generate_in (const std::string &fname, const std::vector< DM > &arg)
 Export an input file that can be passed to generate C code with a main. More...
 
std::vector< DMgenerate_in (const std::string &fname)
 Export an input file that can be passed to generate C code with a main. More...
 
void generate_out (const std::string &fname, const std::vector< DM > &arg)
 Export an output file that can be checked with generated C code output. More...
 
std::vector< DMgenerate_out (const std::string &fname)
 Export an output file that can be checked with generated C code output. More...
 
void export_code (const std::string &lang, const std::string &fname, const Dict &options=Dict()) const
 Export function in specific language. More...
 
void serialize (std::ostream &stream, const Dict &opts=Dict()) const
 Serialize. More...
 
void serialize (SerializingStream &s) const
 Serialize an object. More...
 
std::string serialize (const Dict &opts=Dict()) const
 Serialize. More...
 
void save (const std::string &fname, const Dict &opts=Dict()) const
 Save Function to a file. More...
 
std::string export_code (const std::string &lang, const Dict &options=Dict()) const
 Export function in specific language. More...
 
void export_code (const std::string &lang, std::ostream &stream, const Dict &options=Dict()) const
 Export function in specific language. More...
 
const SX sx_in (casadi_int iind) const
 Get symbolic primitives equivalent to the input expressions. More...
 
const SX sx_in (const std::string &iname) const
 Get symbolic primitives equivalent to the input expressions. More...
 
const std::vector< SXsx_in () const
 Get symbolic primitives equivalent to the input expressions. More...
 
const MX mx_in (casadi_int ind) const
 Get symbolic primitives equivalent to the input expressions. More...
 
const MX mx_in (const std::string &iname) const
 Get symbolic primitives equivalent to the input expressions. More...
 
const std::vector< MXmx_in () const
 Get symbolic primitives equivalent to the input expressions. More...
 
const SX sx_out (casadi_int oind) const
 Get symbolic primitives equivalent to the output expressions. More...
 
const SX sx_out (const std::string &oname) const
 Get symbolic primitives equivalent to the output expressions. More...
 
const std::vector< SXsx_out () const
 Get symbolic primitives equivalent to the output expressions. More...
 
const MX mx_out (casadi_int ind) const
 Get symbolic primitives equivalent to the output expressions. More...
 
const MX mx_out (const std::string &oname) const
 Get symbolic primitives equivalent to the output expressions. More...
 
const std::vector< MXmx_out () const
 Get symbolic primitives equivalent to the output expressions. More...
 
std::vector< double > nz_from_in (const std::vector< DM > &arg) const
 Convert from/to flat vector of input/output nonzeros. More...
 
std::vector< double > nz_from_out (const std::vector< DM > &arg) const
 Convert from/to flat vector of input/output nonzeros. More...
 
std::vector< DMnz_to_in (const std::vector< double > &arg) const
 Convert from/to flat vector of input/output nonzeros. More...
 
std::vector< DMnz_to_out (const std::vector< double > &arg) const
 Convert from/to flat vector of input/output nonzeros. More...
 
DMDict convert_in (const std::vector< DM > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< DMconvert_in (const DMDict &arg) const
 Convert from/to input/output lists/map. More...
 
DMDict convert_out (const std::vector< DM > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< DMconvert_out (const DMDict &arg) const
 Convert from/to input/output lists/map. More...
 
SXDict convert_in (const std::vector< SX > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< SXconvert_in (const SXDict &arg) const
 Convert from/to input/output lists/map. More...
 
SXDict convert_out (const std::vector< SX > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< SXconvert_out (const SXDict &arg) const
 Convert from/to input/output lists/map. More...
 
MXDict convert_in (const std::vector< MX > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< MXconvert_in (const MXDict &arg) const
 Convert from/to input/output lists/map. More...
 
MXDict convert_out (const std::vector< MX > &arg) const
 Convert from/to input/output lists/map. More...
 
std::vector< MXconvert_out (const MXDict &arg) const
 Convert from/to input/output lists/map. More...
 
bool has_spfwd () const
 Is the class able to propagate seeds through the algorithm? More...
 
bool has_sprev () const
 Is the class able to propagate seeds through the algorithm? More...
 

Static Public Member Functions

static std::string type_name ()
 Get type name. More...
 
static Function create (FunctionInternal *node)
 Create from node. More...
 
static Function create (FunctionInternal *node, const Dict &opts)
 Create from node and initialize. More...
 
static Function conditional (const std::string &name, const std::vector< Function > &f, const Function &f_def, const Dict &opts=Dict())
 Constuct a switch function. More...
 
static Function conditional (const std::string &name, const Function &f, const Dict &opts=Dict())
 Conditional call to a function. More...
 
static Function bspline (const std::string &name, const std::vector< std::vector< double > > &knots, const std::vector< double > &coeffs, const std::vector< casadi_int > &degree, casadi_int m=1, const Dict &opts=Dict())
 BSpline evaluator function. More...
 
static Function if_else (const std::string &name, const Function &f_true, const Function &f_false, const Dict &opts=Dict())
 Constructor (if-else) More...
 
static bool test_cast (const SharedObjectInternal *ptr)
 Check if a particular cast is allowed. More...
 
static bool check_name (const std::string &name)
 Check if a string is a valid function name. More...
 
static std::string fix_name (const std::string &name)
 Turn a string into a valid function name as defined by "check_name". More...
 
static Function deserialize (std::istream &stream)
 Build function from serialization. More...
 
static Function deserialize (const std::string &s)
 Build function from serialization. More...
 
static Function load (const std::string &filename)
 Build function from serialization. More...
 
static Function deserialize (DeserializingStream &s)
 Build function from serialization. More...
 
static std::vector< SXorder (const std::vector< SX > &expr)
 
static std::vector< MXorder (const std::vector< MX > &expr)
 
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. More...
 
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 std::vector< Sparsity > &sparsity_in, const std::vector< Sparsity > &sparsity_out, const Dict &opts=Dict())
 Create a just-in-time compiled function from a C language string. More...
 

Protected Member Functions

Function mapaccum (const std::string &name, const std::vector< Function > &chain, casadi_int n_accum=1, const Dict &opts=Dict()) const
 Helper function for mapaccum. More...
 
void count_up ()
 
void count_down ()
 
void construct (const std::string &name, const std::vector< SX > &ex_in, const std::vector< SX > &ex_out, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts)
 Called by constructors. More...
 
void construct (const std::string &name, const std::vector< MX > &ex_in, const std::vector< MX > &ex_out, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts)
 Called by constructors. More...
 
template<typename M >
void construct (const std::string &name, const std::map< std::string, M > &dict, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts)
 Called by constructors. More...
 

Static Protected Member Functions

static bool proceed_to (std::istream &file, const std::string &str)
 Helper function for parsing .casadi files. More...
 
typedef const std::vector< std::vector< double > > & VecArg
 Supported arguments for numerical evaluation and converters. More...
 
typedef std::vector< std::vector< double > > & VecRes
 Supported arguments for numerical evaluation and converters. More...
 
typedef std::vector< std::vector< double > * > VPrRes
 Supported arguments for numerical evaluation and converters. More...
 
typedef const std::map< std::string, std::vector< double > > & MapArg
 Supported arguments for numerical evaluation and converters. More...
 
typedef std::map< std::string, std::vector< double > > & MapRes
 Supported arguments for numerical evaluation and converters. More...
 
typedef std::map< std::string, std::vector< double > * > MPrRes
 Supported arguments for numerical evaluation and converters. More...
 
std::vector< const double * > buf_in (VecArg arg) const
 Supported arguments for numerical evaluation and converters. More...
 
std::vector< double * > buf_out (VecRes res) const
 Supported arguments for numerical evaluation and converters. More...
 
std::vector< double * > buf_out (VPrRes res) const
 Supported arguments for numerical evaluation and converters. More...
 
std::vector< const double * > buf_in (MapArg arg) const
 Supported arguments for numerical evaluation and converters. More...
 
std::vector< double * > buf_out (MapRes res) const
 Supported arguments for numerical evaluation and converters. More...
 
std::vector< double * > buf_out (MPrRes res) const
 Supported arguments for numerical evaluation and converters. More...
 

Member Typedef Documentation

◆ AuxOut

typedef std::map<std::string, std::vector<std::string> > casadi::Function::AuxOut

Definition at line 404 of file function.hpp.

◆ base_type

Definition at line 103 of file shared_object.hpp.

◆ internal_base_type

Definition at line 102 of file shared_object.hpp.

◆ MapArg

typedef const std::map<std::string, std::vector<double> >& casadi::Function::MapArg

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 572 of file function.hpp.

◆ MapRes

typedef std::map<std::string, std::vector<double> >& casadi::Function::MapRes

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 574 of file function.hpp.

◆ MPrRes

typedef std::map<std::string, std::vector<double>*> casadi::Function::MPrRes

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 576 of file function.hpp.

◆ VecArg

typedef const std::vector<std::vector<double> >& casadi::Function::VecArg

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 565 of file function.hpp.

◆ VecRes

typedef std::vector<std::vector<double> >& casadi::Function::VecRes

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 567 of file function.hpp.

◆ VPrRes

typedef std::vector<std::vector<double>*> casadi::Function::VPrRes

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 569 of file function.hpp.

Constructor & Destructor Documentation

◆ Function() [1/20]

casadi::Function::Function ( )

Extra doc: https://github.com/casadi/casadi/wiki/L_1uy

Definition at line 58 of file function.cpp.

58  {
59  }

Referenced by bspline(), deserialize(), expand(), find_function(), fold(), map(), and mapaccum().

◆ Function() [2/20]

casadi::Function::Function ( const std::string &  fname)

Extra doc: https://github.com/casadi/casadi/wiki/L_1uz

Definition at line 92 of file function.cpp.

92  {
93  casadi_error("Not implemented");
94  }

◆ Function() [3/20]

casadi::Function::Function ( const std::string &  name,
const std::vector< SX > &  ex_in,
const std::vector< SX > &  ex_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v0

Definition at line 96 of file function.cpp.

98  {
99  construct(name, ex_in, ex_out, {}, {}, opts);
100  }
void construct(const std::string &name, const std::vector< SX > &ex_in, const std::vector< SX > &ex_out, const std::vector< std::string > &name_in, const std::vector< std::string > &name_out, const Dict &opts)
Called by constructors.
Definition: function.cpp:217
const std::string & name() const
Name of the function.
Definition: function.cpp:1307

References construct(), and name().

◆ Function() [4/20]

casadi::Function::Function ( const std::string &  name,
const std::vector< SX > &  ex_in,
const std::vector< SX > &  ex_out,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v0

Definition at line 102 of file function.cpp.

106  {
107  construct(name, ex_in, ex_out, name_in, name_out, opts);
108  }
const std::vector< std::string > & name_in() const
Get input scheme.
Definition: function.cpp:961
const std::vector< std::string > & name_out() const
Get output scheme.
Definition: function.cpp:965

References construct(), name(), name_in(), and name_out().

◆ Function() [5/20]

casadi::Function::Function ( const std::string &  name,
const std::map< std::string, SX > &  dict,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v0

Definition at line 183 of file function.cpp.

185  {
186  construct(name, dict, name_in, name_out, opts);
187  }

References construct(), name(), name_in(), and name_out().

◆ Function() [6/20]

casadi::Function::Function ( const std::string &  name,
const std::vector< MX > &  ex_in,
const std::vector< MX > &  ex_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v1

Definition at line 110 of file function.cpp.

112  {
113  construct(name, ex_in, ex_out, {}, {}, opts);
114  }

References construct(), and name().

◆ Function() [7/20]

casadi::Function::Function ( const std::string &  name,
const std::vector< MX > &  ex_in,
const std::vector< MX > &  ex_out,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v1

Definition at line 116 of file function.cpp.

120  {
121  construct(name, ex_in, ex_out, name_in, name_out, opts);
122  }

References construct(), name(), name_in(), and name_out().

◆ Function() [8/20]

casadi::Function::Function ( const std::string &  name,
const std::map< std::string, MX > &  dict,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v1

Definition at line 189 of file function.cpp.

191  {
192  construct(name, dict, name_in, name_out, opts);
193  }

References construct(), name(), name_in(), and name_out().

◆ Function() [9/20]

casadi::Function::Function ( const std::string &  name,
SXIList  ex_in,
const SXVector ex_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 124 of file function.cpp.

125  {
126  construct(name, SXVector(ex_in), ex_out, {}, {}, opts);
127  }
std::vector< SX > SXVector
Definition: sx_fwd.hpp:37

References construct(), and name().

◆ Function() [10/20]

casadi::Function::Function ( const std::string &  name,
const SXVector ex_in,
SXIList  ex_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 129 of file function.cpp.

130  {
131  construct(name, ex_in, SXVector(ex_out), {}, {}, opts);
132  }

References construct(), and name().

◆ Function() [11/20]

casadi::Function::Function ( const std::string &  name,
SXIList  ex_in,
SXIList  ex_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 134 of file function.cpp.

134  {
135  construct(name, SXVector(ex_in), SXVector(ex_out), {}, {}, opts);
136  }

References construct(), and name().

◆ Function() [12/20]

casadi::Function::Function ( const std::string &  name,
SXIList  ex_in,
const SXVector ex_out,
const StringVector name_in,
const StringVector name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 138 of file function.cpp.

140  {
141  construct(name, SXVector(ex_in), ex_out, name_in, name_out, opts);
142  }

References construct(), name(), name_in(), and name_out().

◆ Function() [13/20]

casadi::Function::Function ( const std::string &  name,
const SXVector ex_in,
SXIList  ex_out,
const StringVector name_in,
const StringVector name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 144 of file function.cpp.

145  {
146  construct(name, ex_in, SXVector(ex_out), name_in, name_out, opts);
147  }

References construct(), name(), name_in(), and name_out().

◆ Function() [14/20]

casadi::Function::Function ( const std::string &  name,
SXIList  ex_in,
SXIList  ex_out,
const StringVector name_in,
const StringVector name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 149 of file function.cpp.

150  {
151  construct(name, SXVector(ex_in), SXVector(ex_out), name_in, name_out, opts);
152  }

References construct(), name(), name_in(), and name_out().

◆ Function() [15/20]

casadi::Function::Function ( const std::string &  name,
MXIList  ex_in,
const MXVector ex_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 154 of file function.cpp.

155  {
156  construct(name, MXVector(ex_in), ex_out, {}, {}, opts);
157  }
std::vector< MX > MXVector
Definition: mx.hpp:1006

References construct(), and name().

◆ Function() [16/20]

casadi::Function::Function ( const std::string &  name,
const MXVector ex_in,
MXIList  ex_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 159 of file function.cpp.

160  {
161  construct(name, ex_in, MXVector(ex_out), {}, {}, opts);
162  }

References construct(), and name().

◆ Function() [17/20]

casadi::Function::Function ( const std::string &  name,
MXIList  ex_in,
MXIList  ex_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 164 of file function.cpp.

164  {
165  construct(name, MXVector(ex_in), MXVector(ex_out), {}, {}, opts);
166  }

References construct(), and name().

◆ Function() [18/20]

casadi::Function::Function ( const std::string &  name,
MXIList  ex_in,
const MXVector ex_out,
const StringVector name_in,
const StringVector name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 168 of file function.cpp.

169  {
170  construct(name, MXVector(ex_in), ex_out, name_in, name_out, opts);
171  }

References construct(), name(), name_in(), and name_out().

◆ Function() [19/20]

casadi::Function::Function ( const std::string &  name,
const MXVector ex_in,
MXIList  ex_out,
const StringVector name_in,
const StringVector name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 173 of file function.cpp.

174  {
175  construct(name, ex_in, MXVector(ex_out), name_in, name_out, opts);
176  }

References construct(), name(), name_in(), and name_out().

◆ Function() [20/20]

casadi::Function::Function ( const std::string &  name,
MXIList  ex_in,
MXIList  ex_out,
const StringVector name_in,
const StringVector name_out,
const Dict opts = Dict() 
)

Extra doc: https://github.com/casadi/casadi/wiki/L_1v2

Definition at line 178 of file function.cpp.

179  {
180  construct(name, MXVector(ex_in), MXVector(ex_out), name_in, name_out, opts);
181  }

References construct(), name(), name_in(), and name_out().

◆ ~Function()

casadi::Function::~Function ( )

Extra doc: https://github.com/casadi/casadi/wiki/L_1v4

Definition at line 61 of file function.cpp.

61  {
62  }

Member Function Documentation

◆ __hash__()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::__hash__
inherited

If the Object does not point to any node, "0" is returned.

Extra doc: https://github.com/casadi/casadi/wiki/L_av

Definition at line 124 of file generic_shared_impl.hpp.

137  {
138  return reinterpret_cast<casadi_int>(get());
139  }

◆ assert_size_in()

void casadi::Function::assert_size_in ( casadi_int  i,
casadi_int  nrow,
casadi_int  ncol 
) const

Definition at line 1785 of file function.cpp.

1785  {
1786  casadi_assert(size1_in(i)==nrow && size2_in(i)==ncol,
1787  "Incorrect shape for " + str(*this) + " input " + str(i) + " \""
1788  + name_in(i) + "\". Expected " + str(nrow) + "-by-" + str(ncol)
1789  + " but got " + str(size1_in(i)) + "-by-" + str(size2_in(i)));
1790 
1791  }
casadi_int size1_in(casadi_int ind) const
Get input dimension.
Definition: function.cpp:827
casadi_int size2_in(casadi_int ind) const
Get input dimension.
Definition: function.cpp:831
std::string str(const T &v)
String representation, any type.

References name_in(), size1_in(), size2_in(), and casadi::str().

Referenced by casadi::FunctionInternal::forward(), and casadi::FunctionInternal::reverse().

◆ assert_size_out()

void casadi::Function::assert_size_out ( casadi_int  i,
casadi_int  nrow,
casadi_int  ncol 
) const

Definition at line 1793 of file function.cpp.

1793  {
1794  casadi_assert(size1_out(i)==nrow && size2_out(i)==ncol,
1795  "Incorrect shape for " + str(*this) + " output " + str(i) + " \""
1796  + name_out(i) + "\". Expected " + str(nrow) + "-by-" + str(ncol)
1797  + " but got " + str(size1_out(i)) + "-by-" + str(size2_out(i)));
1798  }
casadi_int size2_out(casadi_int ind) const
Get output dimension.
Definition: function.cpp:839
casadi_int size1_out(casadi_int ind) const
Get output dimension.
Definition: function.cpp:835

References name_out(), size1_out(), size2_out(), and casadi::str().

Referenced by assert_sparsity_out().

◆ assert_sparsity_out()

void casadi::Function::assert_sparsity_out ( casadi_int  i,
const Sparsity sp,
casadi_int  n = 1,
bool  allow_all_zero_sparse = true 
) const

Definition at line 1800 of file function.cpp.

1801  {
1802  // Assert shape
1803  assert_size_out(i, sp.size1(), sp.size2() * n);
1804  // Quick return if empty sparse
1805  if (allow_all_zero_sparse && sparsity_out(i).nnz() == 0) return;
1806  // Check sparsities
1807  casadi_assert(sparsity_out(i).is_stacked(sp, n), "Mismatching sparsity "
1808  "(but correct dimensions) for " + str(*this) + " output " + name_out(i));
1809  }
const Sparsity & sparsity_out(casadi_int ind) const
Get sparsity of a given output.
Definition: function.cpp:1031
void assert_size_out(casadi_int i, casadi_int nrow, casadi_int ncol) const
Assert that an output dimension is equal so some given value.
Definition: function.cpp:1793

References assert_size_out(), name_out(), casadi::Sparsity::size1(), casadi::Sparsity::size2(), sparsity_out(), and casadi::str().

Referenced by casadi::FunctionInternal::forward(), and casadi::FunctionInternal::reverse().

◆ assign()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::assign ( Internal *  node)
inherited

improper use will cause memory leaks!

Extra doc: https://github.com/casadi/casadi/wiki/L_at

Definition at line 97 of file generic_shared_impl.hpp.

75  {
76  node = node_;
77  }

◆ bspline()

Function casadi::Function::bspline ( const std::string &  name,
const std::vector< std::vector< double > > &  knots,
const std::vector< double > &  coeffs,
const std::vector< casadi_int > &  degree,
casadi_int  m = 1,
const Dict opts = Dict() 
)
static

Requires a known coefficient tensor

Extra doc: https://github.com/casadi/casadi/wiki/L_1wo

Definition at line 791 of file function.cpp.

794  {
795  try {
796  casadi_assert(degree.size()==knots.size(), "Degree list length (" + str(degree.size()) + ") "
797  "must match knot list length (" + str(knots.size()) + ").");
798  MX x = MX::sym("x", degree.size());
799  std::vector<std::string> lookup_mode;
800  Dict opts_remainder = extract_from_dict(opts, "lookup_mode", lookup_mode);
801  Dict opts_bspline;
802  opts_bspline["lookup_mode"] = lookup_mode;
803  MX y = MX::bspline(x, DM(coeffs), knots, degree, m, opts_bspline);
804  return Function(name, {x}, {y}, opts_remainder);
805  } catch(std::exception& e) {
806  THROW_ERROR_NOOBJ("bspline", e.what(), "BSpline");
807  }
808  }
Function()
Default constructor, null pointer.
Definition: function.cpp:58
static MX sym(const std::string &name, casadi_int nrow=1, casadi_int ncol=1)
Create an nrow-by-ncol symbolic primitive.
static MX bspline(const MX &x, const DM &coeffs, const std::vector< std::vector< double > > &knots, const std::vector< casadi_int > &degree, casadi_int m, const Dict &opts=Dict())
Definition: mx.cpp:2116
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
Matrix< double > DM
Definition: dm_fwd.hpp:33
Dict extract_from_dict(const Dict &d, const std::string &key, T &value)

References casadi::MX::bspline(), casadi::extract_from_dict(), Function(), name(), casadi::str(), and casadi::GenericMatrix< MX >::sym().

◆ buf_in() [1/2]

std::vector< const double * > casadi::Function::buf_in ( Function::MapArg  arg) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 418 of file function.cpp.

418  {
419  // Return value (RVO)
420  std::vector<const double*> ret(sz_arg(), nullptr);
421 
422  // Read inputs
423  for (auto i=arg.begin(); i!=arg.end(); ++i) {
424  casadi_int ind = index_in(i->first);
425  casadi_assert_dev(i->second.size()==nnz_in(ind));
426  ret[ind] = get_ptr(i->second);
427  }
428 
429  return ret;
430  }
casadi_int index_in(const std::string &name) const
Find the index for a string describing a particular entry of an input scheme.
Definition: function.cpp:969
size_t sz_arg() const
Get required length of arg field.
Definition: function.cpp:1083
casadi_int nnz_in() const
Get number of input nonzeros.
Definition: function.cpp:851
T * get_ptr(std::vector< T > &v)
Get a pointer to the data contained in the vector.

References casadi::get_ptr(), index_in(), nnz_in(), and sz_arg().

◆ buf_in() [2/2]

std::vector< const double * > casadi::Function::buf_in ( Function::VecArg  arg) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 384 of file function.cpp.

384  {
385  casadi_assert_dev(arg.size()==n_in());
386  auto arg_it=arg.begin();
387  std::vector<const double*> buf_arg(sz_arg());
388  for (casadi_uint i=0; i<arg.size(); ++i) {
389  casadi_assert_dev(arg_it->size()==nnz_in(i));
390  buf_arg[i] = get_ptr(*arg_it++);
391  }
392  return buf_arg;
393  }
casadi_int n_in() const
Get the number of function inputs.
Definition: function.cpp:819

References casadi::get_ptr(), n_in(), nnz_in(), and sz_arg().

◆ buf_out() [1/4]

std::vector< double * > casadi::Function::buf_out ( Function::MapRes  res) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 432 of file function.cpp.

432  {
433  // Return value (RVO)
434  std::vector<double*> ret(sz_res(), nullptr);
435 
436  // Read outputs
437  for (auto i=res.begin(); i!=res.end(); ++i) {
438  casadi_int ind = index_out(i->first);
439  i->second.resize(nnz_out(ind));
440  ret[ind] = get_ptr(i->second);
441  }
442 
443  return ret;
444  }
casadi_int nnz_out() const
Get number of output nonzeros.
Definition: function.cpp:855
size_t sz_res() const
Get required length of res field.
Definition: function.cpp:1085
casadi_int index_out(const std::string &name) const
Find the index for a string describing a particular entry of an output scheme.
Definition: function.cpp:977

References casadi::get_ptr(), index_out(), nnz_out(), and sz_res().

◆ buf_out() [2/4]

std::vector< double * > casadi::Function::buf_out ( Function::MPrRes  res) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 446 of file function.cpp.

446  {
447  // Return value (RVO)
448  std::vector<double*> ret(sz_res(), nullptr);
449 
450  // Read outputs
451  for (auto i=res.begin(); i!=res.end(); ++i) {
452  casadi_int ind = index_out(i->first);
453  casadi_assert_dev(i->second!=0);
454  i->second->resize(nnz_out(ind));
455  ret[ind] = get_ptr(*i->second);
456  }
457 
458  return ret;
459  }

References casadi::get_ptr(), index_out(), nnz_out(), and sz_res().

◆ buf_out() [3/4]

std::vector< double * > casadi::Function::buf_out ( Function::VecRes  res) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 395 of file function.cpp.

395  {
396  res.resize(n_out());
397  auto res_it=res.begin();
398  std::vector<double*> buf_res(sz_res());
399  for (casadi_uint i=0; i<res.size(); ++i) {
400  res_it->resize(nnz_out(i));
401  buf_res[i] = get_ptr(*res_it++);
402  }
403  return buf_res;
404  }
casadi_int n_out() const
Get the number of function outputs.
Definition: function.cpp:823

References casadi::get_ptr(), n_out(), nnz_out(), and sz_res().

◆ buf_out() [4/4]

std::vector< double * > casadi::Function::buf_out ( Function::VPrRes  res) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w9

Definition at line 406 of file function.cpp.

406  {
407  casadi_assert_dev(res.size()==n_out());
408  auto res_it=res.begin();
409  std::vector<double*> buf_res(sz_res());
410  for (casadi_uint i=0; i<res.size(); ++i) {
411  casadi_assert_dev(*res_it!=0);
412  (*res_it)->resize(nnz_out(i));
413  buf_res[i] = get_ptr(**res_it++);
414  }
415  return buf_res;
416  }

References casadi::get_ptr(), n_out(), nnz_out(), and sz_res().

◆ cache()

Dict casadi::Function::cache ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_26i

Definition at line 1835 of file function.cpp.

1835  {
1836  try {
1837  return (*this)->cache();
1838  } catch(std::exception& e) {
1839  THROW_ERROR("cache", e.what());
1840  return {};
1841  }
1842  }

◆ call() [1/6]

void casadi::Function::call ( const DMDict arg,
DMDict res,
bool  always_inline = false,
bool  never_inline = false 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Definition at line 1453 of file function.cpp.

1454  {
1455  try {
1456  call_gen(arg, res, always_inline, never_inline);
1457  } catch(std::exception& e) {
1458  THROW_ERROR("call", e.what());
1459  }
1460  }
void call_gen(std::vector< const D * > arg, std::vector< D * > res) const
Evaluate with temporary memory allocation.
Definition: function.cpp:462

References call_gen().

◆ call() [2/6]

void casadi::Function::call ( const MXDict arg,
MXDict res,
bool  always_inline = false,
bool  never_inline = false 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Definition at line 1471 of file function.cpp.

1472  {
1473  try {
1474  call_gen(arg, res, always_inline, never_inline);
1475  } catch(std::exception& e) {
1476  THROW_ERROR("call", e.what());
1477  }
1478  }

References call_gen().

◆ call() [3/6]

void casadi::Function::call ( const std::vector< DM > &  arg,
std::vector< DM > &  res,
bool  always_inline = false,
bool  never_inline = false 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Definition at line 357 of file function.cpp.

358  {
359  try {
360  (*this)->call(arg, res, always_inline, never_inline);
361  } catch(std::exception& e) {
362  THROW_ERROR("call", e.what());
363  }
364  }

Referenced by call_gen(), casadi::detect_simple_bounds_gen(), casadi::FunctionInternal::eval_mx(), map(), casadi::MX::matrix_expand(), operator()(), and casadi::MX::substitute().

◆ call() [4/6]

void casadi::Function::call ( const std::vector< MX > &  arg,
std::vector< MX > &  res,
bool  always_inline = false,
bool  never_inline = false 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Definition at line 375 of file function.cpp.

376  {
377  try {
378  (*this)->call(arg, res, always_inline, never_inline);
379  } catch(std::exception& e) {
380  THROW_ERROR("call", e.what());
381  }
382  }

◆ call() [5/6]

void casadi::Function::call ( const std::vector< SX > &  arg,
std::vector< SX > &  res,
bool  always_inline = false,
bool  never_inline = false 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Definition at line 366 of file function.cpp.

367  {
368  try {
369  (*this)->call(arg, res, always_inline, never_inline);
370  } catch(std::exception& e) {
371  THROW_ERROR("call", e.what());
372  }
373  }

◆ call() [6/6]

void casadi::Function::call ( const SXDict arg,
SXDict res,
bool  always_inline = false,
bool  never_inline = false 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w7

Definition at line 1462 of file function.cpp.

1463  {
1464  try {
1465  call_gen(arg, res, always_inline, never_inline);
1466  } catch(std::exception& e) {
1467  THROW_ERROR("call", e.what());
1468  }
1469  }

References call_gen().

◆ call_gen() [1/2]

template<typename M >
void casadi::Function::call_gen ( const std::map< std::string, M > &  arg,
std::map< std::string, M > &  res,
bool  always_inline,
bool  never_inline 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xu

Definition at line 1419 of file function.cpp.

1420  {
1421  // Convert to vector arguments
1422  std::vector<M> arg_v = (*this)->convert_arg(arg);
1423 
1424  // Make call
1425  std::vector<M> res_v;
1426  call(arg_v, res_v, always_inline, never_inline);
1427 
1428  // Save to map
1429  res.clear();
1430  for (casadi_int i=0; i<res_v.size(); ++i) {
1431  res[name_out(i)] = res_v[i];
1432  }
1433  }
void call(const std::vector< DM > &arg, std::vector< DM > &res, bool always_inline=false, bool never_inline=false) const
Evaluate the function symbolically or numerically.
Definition: function.cpp:357

References call(), and name_out().

◆ call_gen() [2/2]

template<typename D >
void casadi::Function::call_gen ( std::vector< const D * >  arg,
std::vector< D * >  res 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w8

Definition at line 462 of file function.cpp.

462  {
463  // Input buffer
464  casadi_assert_dev(arg.size()>=n_in());
465  arg.resize(sz_arg());
466 
467  // Output buffer
468  casadi_assert_dev(res.size()>=n_out());
469  res.resize(sz_res());
470 
471  // Work vectors
472  std::vector<casadi_int> iw(sz_iw());
473  std::vector<D> w(sz_w());
474 
475  // Evaluate memoryless
476  (*this)(get_ptr(arg), get_ptr(res), get_ptr(iw), get_ptr(w), 0);
477  }
size_t sz_iw() const
Get required length of iw field.
Definition: function.cpp:1087
size_t sz_w() const
Get required length of w field.
Definition: function.cpp:1089

References casadi::get_ptr(), n_in(), n_out(), sz_arg(), sz_iw(), sz_res(), and sz_w().

Referenced by call(), and operator()().

◆ change_option()

void casadi::Function::change_option ( const std::string &  option_name,
const GenericType option_value 
)

This is only possible for a selected number of options that do not change the numerical results of the computation, e.g. to enable a more verbose output or saving to file.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w2

Definition at line 1172 of file function.cpp.

1172  {
1173  try {
1174  // Assert existance
1175  if (!has_option(option_name))
1176  casadi_error("Option '" + option_name + "' does not exist");
1177  // Call internal class
1178  (*this)->change_option(option_name, option_value);
1179  } catch(std::exception& e) {
1180  THROW_ERROR("change_option", e.what());
1181  }
1182  }
bool has_option(const std::string &option_name) const
Does a particular option exist.
Definition: function.cpp:1163

References has_option().

◆ check_name()

bool casadi::Function::check_name ( const std::string &  name)
static

Valid function names consist of

  • At least one character
  • Upper and lower case letters: a-zA-Z
  • Numbers 0-9, but never as first character
  • Underscore, but never as first character and never next to another underscore

May not be one of the following keywords: "null", "jac", "hess"

Extra doc: https://github.com/casadi/casadi/wiki/L_1xx

Definition at line 1316 of file function.cpp.

1316  {
1317  // Check if empty
1318  if (name.empty()) return false;
1319 
1320  // Check if keyword
1321  for (const char* kw : {"null", "jac", "hess"}) {
1322  if (name==kw) return false;
1323  }
1324 
1325  // Make sure that the first character is a letter
1326  auto it=name.begin();
1327  if (!std::isalpha(*it++)) return false;
1328 
1329  // Check remain_ing characters
1330  for (; it!=name.end(); ++it) {
1331  if (*it=='_') {
1332  // Make sure that the next character isn't also an underscore
1333  if (it+1!=name.end() && *(it+1)=='_') return false;
1334  } else {
1335  // Make sure alphanumeric
1336  if (!std::isalnum(*it)) return false;
1337  }
1338  }
1339 
1340  // Valid function name if reached this point
1341  return true;
1342  }

References name().

Referenced by casadi::CodeGenerator::CodeGenerator(), fix_name(), and casadi::FunctionInternal::FunctionInternal().

◆ checkout()

casadi_int casadi::Function::checkout ( ) const

Definition at line 1773 of file function.cpp.

1773  {
1774  return (*this)->checkout();
1775  }

Referenced by casadi::QpToNlp::alloc_mem(), and casadi::FunctionBuffer::operator=().

◆ class_name()

std::string casadi::SharedObject::class_name ( ) const
inherited

◆ conditional() [1/2]

Function casadi::Function::conditional ( const std::string &  name,
const Function f,
const Dict opts = Dict() 
)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1wn

Definition at line 774 of file function.cpp.

775  {
776  try {
777  // Create a dummy function with the same signature as f
778  std::vector<MX> dummy_in = f.mx_in();
779  std::vector<MX> dummy_out(f.n_out());
780  for (casadi_int i = 0; i < dummy_out.size(); ++i) {
781  dummy_out.at(i) = MX::zeros(f.sparsity_out(i));
782  }
783  Function dummy("dummy_" + f.name(), dummy_in, dummy_out, f.name_in(), f.name_out());
784  // Form a conditional call
785  return if_else(name, f, dummy, opts);
786  } catch(std::exception& e) {
787  THROW_ERROR_NOOBJ("conditional", e.what(), "Switch");
788  }
789  }
static Function if_else(const std::string &name, const Function &f_true, const Function &f_false, const Dict &opts=Dict())
Constructor (if-else)
Definition: function.cpp:810
static MX zeros(casadi_int nrow=1, casadi_int ncol=1)
Create a dense matrix or a matrix with specified sparsity with all entries zero.

References if_else(), mx_in(), n_out(), name(), name_in(), name_out(), sparsity_out(), and casadi::GenericMatrix< MX >::zeros().

◆ conditional() [2/2]

Function casadi::Function::conditional ( const std::string &  name,
const std::vector< Function > &  f,
const Function f_def,
const Dict opts = Dict() 
)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1wm

Definition at line 765 of file function.cpp.

766  {
767  try {
768  return create(new Switch(name, f, f_def), opts);
769  } catch(std::exception& e) {
770  THROW_ERROR_NOOBJ("conditional", e.what(), "Switch");
771  }
772  }
static Function create(FunctionInternal *node)
Create from node.
Definition: function.cpp:336

References create(), and name().

Referenced by casadi::MX::conditional(), casadi::Switch::get_forward(), casadi::Switch::get_reverse(), and casadi::DaeBuilderInternal::transition().

◆ construct() [1/3]

template<typename M >
void casadi::Function::construct ( const std::string &  name,
const std::map< std::string, M > &  dict,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts 
)
protected

Extra doc: https://github.com/casadi/casadi/wiki/L_1y8

Definition at line 196 of file function.cpp.

199  {
200  std::vector<M> ex_in(name_in.size()), ex_out(name_out.size());
201  for (auto&& i : dict) {
202  std::vector<std::string>::const_iterator it;
203  if ((it = std::find(name_in.begin(), name_in.end(), i.first))!=name_in.end()) {
204  // Input expression
205  ex_in[it-name_in.begin()] = i.second;
206  } else if ((it = std::find(name_out.begin(), name_out.end(), i.first))!=name_out.end()) {
207  // Output expression
208  ex_out[it-name_out.begin()] = i.second;
209  } else {
210  // Neither
211  casadi_error("Unknown dictionary entry: '" + i.first + "'");
212  }
213  }
214  construct(name, ex_in, ex_out, name_in, name_out, opts);
215  }

References construct(), name(), name_in(), and name_out().

◆ construct() [2/3]

void casadi::Function::construct ( const std::string &  name,
const std::vector< MX > &  ex_in,
const std::vector< MX > &  ex_out,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts 
)
protected

Extra doc: https://github.com/casadi/casadi/wiki/L_1y8

Definition at line 245 of file function.cpp.

249  {
250  try {
251  own(new MXFunction(name, ex_in, ex_out, name_in, name_out));
252  (*this)->construct(opts);
253 
254  // Perform post-construction expand
255  auto it = opts.find("post_expand");
256  if (it!=opts.end()) {
257  if (!it->second) return;
258  auto it = opts.find("post_expand_options");
259  if (it==opts.end()) {
260  operator=((*this).expand());
261  } else {
262  operator=((*this).expand((*this).name(), it->second));
263  }
264  }
265 
266  // Perform external transformations
267  it = opts.find("external_transform");
268  if (it!=opts.end()) {
269  auto v = it->second.to_vector_vector();
270  for (const std::vector<GenericType>& vec : v) {
271  casadi_assert(vec.size()>=2, "external_transform: inner list must be length >=2");
272  casadi_assert(vec.size()<=3, "external_transform: inner list must be length <=3");
273  std::string name = vec[0].to_string();
274  std::string op = vec[1].to_string();
275  Dict opts = vec.size()==3 ? vec[2].to_dict() : Dict();
276  operator=(external_transform(name, op, (*this), opts));
277  }
278  }
279 
280  } catch(std::exception& e) {
281  THROW_ERROR_NOOBJ("Function", e.what(), "MXFunction");
282  }
283  }
GenericShared & operator=(const GenericShared &ref)
Assignment operator.
Function external_transform(const std::string &name, const std::string &op, const Function &f, const Dict &opts)
Apply a transformation defined externally.
Definition: tools.cpp:45

References casadi::external_transform(), name(), name_in(), name_out(), casadi::GenericShared< SharedObject, SharedObjectInternal >::operator=(), and casadi::GenericShared< SharedObject, SharedObjectInternal >::own().

◆ construct() [3/3]

void casadi::Function::construct ( const std::string &  name,
const std::vector< SX > &  ex_in,
const std::vector< SX > &  ex_out,
const std::vector< std::string > &  name_in,
const std::vector< std::string > &  name_out,
const Dict opts 
)
protected

Extra doc: https://github.com/casadi/casadi/wiki/L_1y8

Definition at line 217 of file function.cpp.

221  {
222  try {
223  own(new SXFunction(name, ex_in, ex_out, name_in, name_out));
224  (*this)->construct(opts);
225 
226  // Perform external transformations
227  auto it = opts.find("external_transform");
228  if (it!=opts.end()) {
229  auto v = it->second.to_vector_vector();
230  for (const std::vector<GenericType>& vec : v) {
231  casadi_assert(vec.size()>=2, "external_transform: inner list must be length >=2");
232  casadi_assert(vec.size()<=3, "external_transform: inner list must be length <=3");
233  std::string name = vec[0].to_string();
234  std::string op = vec[1].to_string();
235  Dict opts = vec.size()==3 ? vec[2].to_dict() : Dict();
236  operator=(external_transform(name, op, (*this), opts));
237  }
238  }
239 
240  } catch(std::exception& e) {
241  THROW_ERROR_NOOBJ("Function", e.what(), "SXFunction");
242  }
243  }

References casadi::external_transform(), name(), name_in(), name_out(), casadi::GenericShared< SharedObject, SharedObjectInternal >::operator=(), and casadi::GenericShared< SharedObject, SharedObjectInternal >::own().

Referenced by construct(), and Function().

◆ convert_in() [1/6]

std::vector< DM > casadi::Function::convert_in ( const DMDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1620 of file function.cpp.

1620  {
1621  return (*this)->convert_arg(arg);
1622  }

◆ convert_in() [2/6]

std::vector< MX > casadi::Function::convert_in ( const MXDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1652 of file function.cpp.

1652  {
1653  return (*this)->convert_arg(arg);
1654  }

◆ convert_in() [3/6]

DMDict casadi::Function::convert_in ( const std::vector< DM > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1616 of file function.cpp.

1616  {
1617  return (*this)->convert_arg(arg);
1618  }

◆ convert_in() [4/6]

MXDict casadi::Function::convert_in ( const std::vector< MX > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1648 of file function.cpp.

1648  {
1649  return (*this)->convert_arg(arg);
1650  }

◆ convert_in() [5/6]

SXDict casadi::Function::convert_in ( const std::vector< SX > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1632 of file function.cpp.

1632  {
1633  return (*this)->convert_arg(arg);
1634  }

◆ convert_in() [6/6]

std::vector< SX > casadi::Function::convert_in ( const SXDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1636 of file function.cpp.

1636  {
1637  return (*this)->convert_arg(arg);
1638  }

◆ convert_out() [1/6]

std::vector< DM > casadi::Function::convert_out ( const DMDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1628 of file function.cpp.

1628  {
1629  return (*this)->convert_res(arg);
1630  }

◆ convert_out() [2/6]

std::vector< MX > casadi::Function::convert_out ( const MXDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1660 of file function.cpp.

1660  {
1661  return (*this)->convert_res(arg);
1662  }

◆ convert_out() [3/6]

DMDict casadi::Function::convert_out ( const std::vector< DM > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1624 of file function.cpp.

1624  {
1625  return (*this)->convert_res(arg);
1626  }

◆ convert_out() [4/6]

MXDict casadi::Function::convert_out ( const std::vector< MX > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1656 of file function.cpp.

1656  {
1657  return (*this)->convert_res(arg);
1658  }

◆ convert_out() [5/6]

SXDict casadi::Function::convert_out ( const std::vector< SX > &  arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1640 of file function.cpp.

1640  {
1641  return (*this)->convert_res(arg);
1642  }

◆ convert_out() [6/6]

std::vector< SX > casadi::Function::convert_out ( const SXDict arg) const

Will raise an error when an unknown key is used or a list has incorrect size. Does not perform sparsity checking.

Extra doc: https://github.com/casadi/casadi/wiki/L_1x7

Definition at line 1644 of file function.cpp.

1644  {
1645  return (*this)->convert_res(arg);
1646  }

◆ count_down()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_down
protectedinherited

Definition at line 134 of file generic_shared_impl.hpp.

42  {
43 #ifdef WITH_EXTRA_CHECKS
44  casadi_assert_dev(Function::call_depth_==0);
45 #endif // WITH_EXTRA_CHECKS
46  if (!node) return;
47  if (node->weak_ref_) {
48 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
49  auto mutex = node->weak_ref_->get_mutex();
50  // Avoid triggering a delete while a weak_ref.shared_if_alive is being called
51  std::lock_guard<std::mutex> lock(*mutex);
52  // Could it be that this mutex is destroyed when the lock goes out of scope?
53 #endif // CASADI_WITH_THREADSAFE_SYMBOLICS
54 
55  if (--static_cast<Internal*>(node)->count == 0) {
56  delete node;
57  node = nullptr;
58  }
59  } else {
60  if (--static_cast<Internal*>(node)->count == 0) {
61  delete node;
62  node = nullptr;
63  }
64  }
65  }

◆ count_up()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::count_up
protectedinherited

Definition at line 133 of file generic_shared_impl.hpp.

32  {
33 #ifdef WITH_EXTRA_CHECKS
34  casadi_assert_dev(Function::call_depth_==0);
35 #endif // WITH_EXTRA_CHECKS
36 
37  if (node) static_cast<Internal*>(node)->count++;
38 
39  }

◆ create() [1/2]

Function casadi::Function::create ( FunctionInternal node)
static

◆ create() [2/2]

Function casadi::Function::create ( FunctionInternal node,
const Dict opts 
)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1v7

Definition at line 342 of file function.cpp.

342  {
343  Function ret = create(node);
344  ret->construct(opts);
345  return ret;
346  }

References casadi::ProtoFunction::construct(), and create().

◆ debug_repr()

std::string casadi::GenericShared< SharedObject , SharedObjectInternal >::debug_repr
inherited

Definition at line 113 of file generic_shared_impl.hpp.

80  {
81  if (node) {
82  return node->debug_repr(node);
83  } else {
84  return "NULL";
85  }
86  }
std::string debug_repr(const Internal *) const

◆ default_in()

double casadi::Function::default_in ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vm

Definition at line 1480 of file function.cpp.

1480  {
1481  return (*this)->get_default_in(ind);
1482  }

Referenced by casadi::Blocksqp::feasibilityRestorationPhase(), and casadi::FiniteDiff::get_default_in().

◆ deserialize() [1/3]

Function casadi::Function::deserialize ( const std::string &  s)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1y0

Definition at line 1359 of file function.cpp.

1359  {
1360  std::stringstream ss;
1361  ss << s;
1362  return deserialize(ss);
1363  }
static Function deserialize(std::istream &stream)
Build function from serialization.
Definition: function.cpp:1344

References deserialize().

◆ deserialize() [2/3]

Function casadi::Function::deserialize ( DeserializingStream s)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1y2

Definition at line 1294 of file function.cpp.

1294  {
1295  bool is_null;
1296  s.unpack("Function::null", is_null);
1297  if (is_null) return Function();
1299  }
static Function deserialize(DeserializingStream &s)
Deserialize with type disambiguation.

References casadi::FunctionInternal::deserialize(), Function(), casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null(), and casadi::DeserializingStream::unpack().

◆ deserialize() [3/3]

Function casadi::Function::deserialize ( std::istream &  stream)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1xz

Definition at line 1344 of file function.cpp.

1344  {
1345  DeserializingStream s(stream);
1346  return deserialize(s);
1347  }

Referenced by deserialize().

◆ disp()

void casadi::SharedObject::disp ( std::ostream &  stream,
bool  more = false 
) const
inherited

Definition at line 35 of file shared_object.cpp.

35  {
36  if (is_null()) {
37  stream << "NULL";
38  } else {
39  (*this)->disp(stream, more);
40  }
41  }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null().

Referenced by casadi::Nlpsol::disp_more(), and casadi::CsparseInterface::nfact().

◆ expand() [1/2]

Function casadi::Function::expand ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1v5

Examples
Function/expand.py, and MX/matrix_expand.py.

Definition at line 308 of file function.cpp.

308  {
309  Dict opts;
310  opts["ad_weight"] = (*this)->ad_weight();
311  opts["ad_weight_sp"] = (*this)->sp_weight();
312  opts["max_num_dir"] = (*this)->max_num_dir_;
313  opts["is_diff_in"] = (*this)->is_diff_in_;
314  opts["is_diff_out"] = (*this)->is_diff_out_;
315  return expand(name(), opts);
316  }
Function expand() const
Expand a function to SX.
Definition: function.cpp:308

References casadi::FunctionInternal::ad_weight(), and name().

Referenced by casadi::OracleFunction::expand(), casadi::OracleFunction::finalize(), casadi::OracleFunction::init(), casadi::MX::matrix_expand(), casadi::DaeBuilderInternal::oracle(), and casadi::qpsol_nlp().

◆ expand() [2/2]

Function casadi::Function::expand ( const std::string &  name,
const Dict opts = Dict() 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1v5

Definition at line 318 of file function.cpp.

318  {
319  casadi_assert(!has_free(),
320  "Function with free symbols cannot be expanded. "
321  "List of free variables in your Function: " +
322  join(get_free(), ","));
323 
324  Dict my_opts;
325  my_opts["ad_weight"] = (*this)->ad_weight();
326  my_opts["ad_weight_sp"] = (*this)->sp_weight();
327  my_opts["max_num_dir"] = (*this)->max_num_dir_;
328  my_opts["is_diff_in"] = (*this)->is_diff_in_;
329  my_opts["is_diff_out"] = (*this)->is_diff_out_;
330  update_dict(my_opts, opts);
331  std::vector<SX> ex_in = sx_in();
332  std::vector<SX> ex_out = Function(*this)(ex_in);
333  return Function(name, ex_in, ex_out, name_in(), name_out(), my_opts);
334  }
std::vector< std::string > get_free() const
Get free variables as a string.
Definition: function.cpp:1184
bool has_free() const
Does the function have free variables.
Definition: function.cpp:1697
const std::vector< SX > sx_in() const
Get symbolic primitives equivalent to the input expressions.
Definition: function.cpp:1568
std::string join(const std::vector< std::string > &l, const std::string &delim)
void update_dict(Dict &target, const Dict &source, bool recurse)
Update the target dictionary in place with source elements.

References Function(), get_free(), has_free(), casadi::join(), name(), name_in(), name_out(), sx_in(), and casadi::update_dict().

◆ export_code() [1/3]

std::string casadi::Function::export_code ( const std::string &  lang,
const Dict options = Dict() 
) const

Only allowed for (a subset of) SX/MX Functions

Extra doc: https://github.com/casadi/casadi/wiki/L_1wz

Definition at line 1301 of file function.cpp.

1301  {
1302  std::stringstream ss;
1303  (*this)->export_code(lang, ss, options);
1304  return ss.str();
1305  }

◆ export_code() [2/3]

void casadi::Function::export_code ( const std::string &  lang,
const std::string &  fname,
const Dict options = Dict() 
) const

Only allowed for (a subset of) SX/MX Functions

Extra doc: https://github.com/casadi/casadi/wiki/L_1wz

Definition at line 1261 of file function.cpp.

1262  {
1263  std::ofstream stream;
1264  Filesystem::open(stream, fname);
1265  return (*this)->export_code(lang, stream, options);
1266  }
static void open(std::ofstream &, const std::string &path, std::ios_base::openmode mode=std::ios_base::out)
Definition: filesystem.cpp:115

References casadi::Filesystem::open().

◆ export_code() [3/3]

void casadi::Function::export_code ( const std::string &  lang,
std::ostream &  stream,
const Dict options = Dict() 
) const

Only allowed for (a subset of) SX/MX Functions

Extra doc: https://github.com/casadi/casadi/wiki/L_1wz

Definition at line 1256 of file function.cpp.

1257  {
1258  return (*this)->export_code(lang, stream, options);
1259  }

◆ factory()

Function casadi::Function::factory ( const std::string &  name,
const std::vector< std::string > &  s_in,
const std::vector< std::string > &  s_out,
const AuxOut aux = AuxOut(),
const Dict opts = Dict() 
) const

Definition at line 1811 of file function.cpp.

1816  {
1817  try {
1818  return (*this)->factory(name, s_in, s_out, aux, opts);
1819  } catch(std::exception& e) {
1820  THROW_ERROR("factory", "Failed to create " + name + ":" + str(s_in) + "->" + str(s_out)
1821  + " with " + str(aux) + ":\n" + str(e.what()));
1822  }
1823  }

References casadi::FunctionInternal::factory(), name(), and casadi::str().

Referenced by casadi::DaeBuilderInternal::create(), casadi::OracleFunction::create_function(), casadi::FunctionInternal::factory(), casadi::KinsolInterface::get_jtimes(), hessian_old(), casadi::Rootfinder::init(), casadi::Blocksqp::init(), jacobian_old(), and casadi::Nlpsol::kkt().

◆ find_function()

Function casadi::Function::find_function ( const std::string &  name,
casadi_int  max_depth = -1 
) const
Parameters
[in]nameName of function needed
[in]max_depthMaximum depth - a negative number indicates no maximum

Extra doc: https://github.com/casadi/casadi/wiki/L_1y7

Definition at line 1888 of file function.cpp.

1888  {
1889  try {
1890  // If negative, make largest positive number
1891  if (max_depth < 0) max_depth = std::numeric_limits<casadi_int>::max();
1892  // The internal routine uses a map to avoid duplicate functions
1893  std::map<FunctionInternal*, Function> all_fun;
1894  (*this)->find(all_fun, max_depth);
1895  // Search this map
1896  for (auto&& e : all_fun) {
1897  if (e.second.name() == name) return e.second;
1898  }
1899  // Not found
1900  casadi_error("'" + name + "' not found");
1901  } catch(std::exception& e) {
1902  THROW_ERROR("find", e.what());
1903  return Function();
1904  }
1905  }

References Function(), and name().

◆ find_functions()

std::vector< Function > casadi::Function::find_functions ( casadi_int  max_depth = -1) const
Parameters
[in]max_depthMaximum depth - a negative number indicates no maximum

Extra doc: https://github.com/casadi/casadi/wiki/L_1y6

Definition at line 1870 of file function.cpp.

1870  {
1871  try {
1872  // If negative, make largest positive number
1873  if (max_depth < 0) max_depth = std::numeric_limits<casadi_int>::max();
1874  // The internal routine uses a map to avoid duplicate functions
1875  std::map<FunctionInternal*, Function> all_fun;
1876  (*this)->find(all_fun, max_depth);
1877  // Create return object
1878  std::vector<Function> ret;
1879  ret.reserve(all_fun.size());
1880  for (auto&& e : all_fun) ret.push_back(e.second);
1881  return ret;
1882  } catch(std::exception& e) {
1883  THROW_ERROR("find", e.what());
1884  return {};
1885  }
1886  }

Referenced by casadi::DaeBuilder::gather_fun().

◆ fix_name()

std::string casadi::Function::fix_name ( const std::string &  name)
static

Non-alphanumeric characters are converted into underscores and multiple consecutive undercores are dropped

Extra doc: https://github.com/casadi/casadi/wiki/L_1xy

Definition at line 1365 of file function.cpp.

1365  {
1366  // Quick return if already valid name
1367  if (check_name(name)) return name;
1368 
1369  // If empty, name it "unnamed"
1370  if (name.empty()) return "unnamed";
1371 
1372  // Construct a sane name
1373  std::stringstream ss;
1374 
1375  // If the first character isn't a character, prepend an "a"
1376  if (!std::isalpha(name.front())) ss << "a";
1377 
1378  // Treat other characters
1379  bool previous_is_underscore = false;
1380  for (char c : name) {
1381  if (std::isalnum(c)) {
1382  // Alphanumeric characters
1383  ss << c;
1384  previous_is_underscore = false;
1385  } else if (!previous_is_underscore) {
1386  // Everything else becomes an underscore
1387  ss << '_';
1388  previous_is_underscore = true;
1389  }
1390  }
1391 
1392  // If name became a keyword, append 1
1393  for (const char* kw : {"null", "jac", "hess"}) {
1394  if (ss.str()==kw) ss << "1";
1395  }
1396 
1397  return ss.str();
1398  }
static bool check_name(const std::string &name)
Check if a string is a valid function name.
Definition: function.cpp:1316

References check_name(), and name().

◆ fold()

Function casadi::Function::fold ( casadi_int  N,
const Dict opts = Dict() 
) const

Suppose the function has a signature of:

   f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

   F: (x0, U) -> (X , Y )

    with
        U: horzcat([u0, u1, ..., u_(N-1)])
        X: horzcat([x1, x2, ..., x_N])
        Y: horzcat([y0, y1, ..., y_(N-1)])

    and
        x1, y0 <- f(x0, u0)
        x2, y1 <- f(x1, u1)
        ...
        x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Definition at line 509 of file function.cpp.

509  {
510  Function base = mapaccum(N, opts);
511  std::vector<MX> base_in = base.mx_in();
512  std::vector<MX> out = base(base_in);
513  out[0] = out[0](Slice(), range((N-1)*size2_out(0), N*size2_out(0))); // NOLINT
514  return Function("fold_"+name(), base_in, out, name_in(), name_out(), opts);
515  }
Function mapaccum(const std::string &name, casadi_int N, const Dict &opts=Dict()) const
Create a mapaccumulated version of this function.
Definition: function.cpp:519
std::vector< casadi_int > range(casadi_int start, casadi_int stop, casadi_int step, casadi_int len)
Range function.

References Function(), mapaccum(), mx_in(), name(), name_in(), name_out(), casadi::range(), and size2_out().

◆ forward()

Function casadi::Function::forward ( casadi_int  nfwd) const
   Returns a function with <tt>n_in + n_out + n_in</tt> inputs
   and <tt>nfwd</tt> outputs.
   The first <tt>n_in</tt> inputs correspond to nondifferentiated inputs.
   The next <tt>n_out</tt> inputs correspond to nondifferentiated outputs.
   and the last <tt>n_in</tt> inputs correspond to forward seeds,
   stacked horizontally
   The  <tt>n_out</tt> outputs correspond to forward sensitivities,
   stacked horizontally.     *
   <tt>(n_in = n_in(), n_out = n_out())</tt>

  The functions returned are cached, meaning that if called multiple timed
  with the same value, then multiple references to the same function will be returned.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wq

Definition at line 1135 of file function.cpp.

1135  {
1136  try {
1137  return (*this)->forward(nfwd);
1138  } catch(std::exception& e) {
1139  THROW_ERROR("forward", e.what());
1140  }
1141  }

References casadi::FunctionInternal::forward().

Referenced by casadi::SXFunction::ad_forward(), casadi::DaeBuilderInternal::export_fmu(), casadi::FunctionInternal::forward(), casadi::Map::get_forward(), casadi::MapSum::get_forward(), casadi::Nlpsol::get_forward(), casadi::Switch::get_forward(), and casadi::ImplicitFixedStepIntegrator::init().

◆ free_mx()

std::vector< MX > casadi::Function::free_mx ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xb

Definition at line 1681 of file function.cpp.

1681  {
1682  try {
1683  return (*this)->free_mx();
1684  } catch(std::exception& e) {
1685  THROW_ERROR("free_mx", e.what());
1686  }
1687  }

Referenced by casadi::MX::get_free(), and casadi::MX::symvar().

◆ free_sx()

std::vector< SX > casadi::Function::free_sx ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xa

Definition at line 1673 of file function.cpp.

1673  {
1674  try {
1675  return (*this)->free_sx();
1676  } catch(std::exception& e) {
1677  THROW_ERROR("free_sx", e.what());
1678  }
1679  }

Referenced by casadi::Matrix< Scalar >::get_free().

◆ generate() [1/2]

std::string casadi::Function::generate ( const Dict opts = Dict()) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1wv

Definition at line 1188 of file function.cpp.

1188  {
1189  return generate(name(), opts);
1190  }
std::string generate(const std::string &fname, const Dict &opts=Dict()) const
Export / Generate C code for the function.
Definition: function.cpp:1192

References generate(), and name().

◆ generate() [2/2]

std::string casadi::Function::generate ( const std::string &  fname,
const Dict opts = Dict() 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1wu

Examples
SX/generateCode.py.

Definition at line 1192 of file function.cpp.

1192  {
1193  CodeGenerator gen(fname, opts);
1194  gen.add(*this);
1195  return gen.generate();
1196  }

References casadi::CodeGenerator::add(), and casadi::CodeGenerator::generate().

Referenced by generate().

◆ generate_dependencies()

std::string casadi::Function::generate_dependencies ( const std::string &  fname,
const Dict opts = Dict() 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1ww

Definition at line 1198 of file function.cpp.

1198  {
1199  return (*this)->generate_dependencies(fname, opts);
1200  }

◆ generate_in() [1/2]

std::vector< DM > casadi::Function::generate_in ( const std::string &  fname)
See also
generate_out
convert_in to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wx

Definition at line 1232 of file function.cpp.

1232  {
1233  DM data = DM::from_file(fname, "txt");
1234  // Empty files are okay
1235  if (data.is_empty(true)) data = DM(0, 1);
1236  casadi_assert(data.is_vector() && data.is_dense(), "Expected dense vector");
1237  casadi_assert(data.numel()==nnz_in(),
1238  "Dimension mismatch: file contains a vector of size " + str(data.numel())
1239  + ", while size " + str(nnz_in()) + " was expected.");
1240 
1241  return nz_to_in(data.nonzeros());
1242  }
std::vector< DM > nz_to_in(const std::vector< double > &arg) const
Convert from/to flat vector of input/output nonzeros.
Definition: function.cpp:1608
static Matrix< double > from_file(const std::string &filename, const std::string &format_hint="")

References casadi::Matrix< double >::from_file(), casadi::GenericMatrix< MatType >::is_dense(), casadi::GenericMatrix< MatType >::is_empty(), casadi::GenericMatrix< MatType >::is_vector(), nnz_in(), casadi::Matrix< Scalar >::nonzeros(), casadi::GenericMatrix< MatType >::numel(), nz_to_in(), and casadi::str().

◆ generate_in() [2/2]

void casadi::Function::generate_in ( const std::string &  fname,
const std::vector< DM > &  arg 
)
See also
generate_out
convert_in to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wx

Definition at line 1202 of file function.cpp.

1202  {
1203  std::vector<double> d = nz_from_in(arg);
1204 
1205  // Set up output stream
1206  std::ofstream of;
1207  Filesystem::open(of, fname);
1208  normalized_setup(of);
1209 
1210  // Encode each output
1211  for (casadi_int i=0; i<d.size(); ++i) {
1212  normalized_out(of, d[i]);
1213  of << std::endl;
1214  }
1215  }
std::vector< double > nz_from_in(const std::vector< DM > &arg) const
Convert from/to flat vector of input/output nonzeros.
Definition: function.cpp:1600
void normalized_setup(std::istream &stream)
void normalized_out(std::ostream &stream, double val)

References casadi::normalized_out(), casadi::normalized_setup(), nz_from_in(), and casadi::Filesystem::open().

◆ generate_lifted()

void casadi::Function::generate_lifted ( Function vdef_fcn,
Function vinit_fcn 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xc

Definition at line 1701 of file function.cpp.

1701  {
1702  try {
1703  (*this)->generate_lifted(vdef_fcn, vinit_fcn);
1704  } catch(std::exception& e) {
1705  THROW_ERROR("generate_lifted", e.what());
1706  }
1707  }

Referenced by casadi::Scpgen::init().

◆ generate_out() [1/2]

std::vector< DM > casadi::Function::generate_out ( const std::string &  fname)
See also
generate_in
convert_out to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wy

Definition at line 1244 of file function.cpp.

1244  {
1245  DM data = DM::from_file(fname, "txt");
1246  // Empty files are okay
1247  if (data.is_empty(true)) data = DM(0, 1);
1248  casadi_assert(data.is_vector() && data.is_dense(), "Expected dense vector");
1249  casadi_assert(data.numel()==nnz_out(),
1250  "Dimension mismatch: file contains a vector of size " + str(data.numel())
1251  + ", while size " + str(nnz_out()) + " was expected.");
1252 
1253  return nz_to_out(data.nonzeros());
1254  }
std::vector< DM > nz_to_out(const std::vector< double > &arg) const
Convert from/to flat vector of input/output nonzeros.
Definition: function.cpp:1612

References casadi::Matrix< double >::from_file(), casadi::GenericMatrix< MatType >::is_dense(), casadi::GenericMatrix< MatType >::is_empty(), casadi::GenericMatrix< MatType >::is_vector(), nnz_out(), casadi::Matrix< Scalar >::nonzeros(), casadi::GenericMatrix< MatType >::numel(), nz_to_out(), and casadi::str().

◆ generate_out() [2/2]

void casadi::Function::generate_out ( const std::string &  fname,
const std::vector< DM > &  arg 
)
See also
generate_in
convert_out to convert between dict/map and vector

Extra doc: https://github.com/casadi/casadi/wiki/L_1wy

Definition at line 1217 of file function.cpp.

1217  {
1218  std::vector<double> d = nz_from_out(res);
1219 
1220  // Set up output stream
1221  std::ofstream of;
1222  Filesystem::open(of, fname);
1223  normalized_setup(of);
1224 
1225  // Encode each output
1226  for (casadi_int i=0; i<d.size(); ++i) {
1227  normalized_out(of, d[i]);
1228  of << std::endl;
1229  }
1230  }
std::vector< double > nz_from_out(const std::vector< DM > &arg) const
Convert from/to flat vector of input/output nonzeros.
Definition: function.cpp:1604

References casadi::normalized_out(), casadi::normalized_setup(), nz_from_out(), and casadi::Filesystem::open().

◆ get() [1/2]

FunctionInternal * casadi::Function::get ( ) const

◆ get() [2/2]

template<typename T >
T* casadi::Function::get ( ) const
inline

Definition at line 924 of file function.hpp.

924  {
925  T* ret = dynamic_cast<T*>(get());
926  casadi_assert_dev(ret!=nullptr);
927  return ret;
928  }
FunctionInternal * get() const
Definition: function.cpp:353

References casadi::T.

◆ get_free()

std::vector< std::string > casadi::Function::get_free ( ) const

◆ get_function() [1/2]

std::vector< std::string > casadi::Function::get_function ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1y3

Definition at line 1844 of file function.cpp.

1844  {
1845  try {
1846  return (*this)->get_function();
1847  } catch(std::exception& e) {
1848  THROW_ERROR("get_function", e.what());
1849  return {};
1850  }
1851  }

Referenced by casadi::IdasInterface::psetupF().

◆ get_function() [2/2]

Function casadi::Function::get_function ( const std::string &  name) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1y4

Definition at line 1853 of file function.cpp.

1853  {
1854  try {
1855  return (*this)->get_function(name);
1856  } catch(std::exception& e) {
1857  THROW_ERROR("get_function", e.what());
1858  }
1859  }

References name().

◆ get_str()

std::string casadi::SharedObject::get_str ( bool  more = false) const
inlineinherited

Definition at line 91 of file shared_object.hpp.

91  {
92  std::stringstream ss;
93  disp(ss, more);
94  return ss.str();
95  }
void disp(std::ostream &stream, bool more=false) const
Print a description of the object.

◆ getCount()

casadi_int casadi::GenericShared< SharedObject , SharedObjectInternal >::getCount
inherited

Definition at line 103 of file generic_shared_impl.hpp.

127  {
128  return (*this)->getCount();
129  }

◆ has_free()

bool casadi::Function::has_free ( ) const

◆ has_function()

bool casadi::Function::has_function ( const std::string &  fname) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1y5

Definition at line 1861 of file function.cpp.

1861  {
1862  try {
1863  return (*this)->has_function(fname);
1864  } catch(std::exception& e) {
1865  THROW_ERROR("has_function", e.what());
1866  return false;
1867  }
1868  }

◆ has_in()

bool casadi::Function::has_in ( const std::string &  name) const

Extra doc: https://github.com/casadi/casadi/wiki/L_2c9

Definition at line 985 of file function.cpp.

985  {
986  for (const std::string& s : (*this)->name_in_) {
987  if (s==name) return true;
988  }
989  return false;
990  }

References name().

◆ has_option()

bool casadi::Function::has_option ( const std::string &  option_name) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w1

Definition at line 1163 of file function.cpp.

1163  {
1164  try {
1165  return (*this)->has_option(option_name);
1166  } catch(std::exception& e) {
1167  THROW_ERROR("has_option", e.what());
1168  return false; // never reached
1169  }
1170  }

Referenced by change_option().

◆ has_out()

bool casadi::Function::has_out ( const std::string &  name) const

Extra doc: https://github.com/casadi/casadi/wiki/L_2ca

Definition at line 992 of file function.cpp.

992  {
993  for (const std::string& s : (*this)->name_out_) {
994  if (s==name) return true;
995  }
996  return false;
997  }

References name().

◆ has_spfwd()

bool casadi::Function::has_spfwd ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xl

Definition at line 1689 of file function.cpp.

1689  {
1690  return (*this)->has_spfwd();
1691  }

◆ has_sprev()

bool casadi::Function::has_sprev ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xl

Definition at line 1693 of file function.cpp.

1693  {
1694  return (*this)->has_sprev();
1695  }

◆ hessian_old()

Function casadi::Function::hessian_old ( casadi_int  iind,
casadi_int  oind 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w5

Definition at line 896 of file function.cpp.

896  {
897  // Redirect to factory class
898  std::vector<std::string> s_in = name_in();
899  std::vector<std::string> s_out = name_out();
900  s_out.insert(s_out.begin(), "grad:" + name_out(oind) + ":" + name_in(iind));
901  s_out.insert(s_out.begin(),
902  "hess:" + name_out(oind) + ":" + name_in(iind) + ":" + name_in(iind));
903  return factory(name() + "_hess", s_in, s_out);
904  }
Function factory(const std::string &name, const std::vector< std::string > &s_in, const std::vector< std::string > &s_out, const AuxOut &aux=AuxOut(), const Dict &opts=Dict()) const
Definition: function.cpp:1812

References factory(), name(), name_in(), and name_out().

◆ if_else()

Function casadi::Function::if_else ( const std::string &  name,
const Function f_true,
const Function f_false,
const Dict opts = Dict() 
)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1wp

Definition at line 810 of file function.cpp.

811  {
812  try {
813  return create(new Switch(name, std::vector<Function>(1, f_false), f_true), opts);
814  } catch(std::exception& e) {
815  THROW_ERROR_NOOBJ("if_else", e.what(), "Switch");
816  }
817  }

References create(), and name().

Referenced by conditional(), and casadi::MX::if_else().

◆ index_in()

casadi_int casadi::Function::index_in ( const std::string &  name) const

example: schemeEntry("x_opt") -> returns NLPSOL_X if FunctionInternal adheres to SCHEME_NLPINput

Extra doc: https://github.com/casadi/casadi/wiki/L_1vk

Definition at line 969 of file function.cpp.

969  {
970  try {
971  return (*this)->index_in(name);
972  } catch(std::exception& e) {
973  THROW_ERROR("index_in", e.what());
974  }
975  }

References name().

Referenced by buf_in(), casadi::Blocksqp::feasibilityRestorationPhase(), map(), mapaccum(), sparsity_in(), and casadi::DaeBuilderInternal::update_dependencies().

◆ index_out()

casadi_int casadi::Function::index_out ( const std::string &  name) const

example: schemeEntry("x_opt") -> returns NLPSOL_X if FunctionInternal adheres to SCHEME_NLPINput

Extra doc: https://github.com/casadi/casadi/wiki/L_1vl

Definition at line 977 of file function.cpp.

977  {
978  try {
979  return (*this)->index_out(name);
980  } catch(std::exception& e) {
981  THROW_ERROR("index_out", e.what());
982  }
983  }

References name().

Referenced by buf_out(), map(), mapaccum(), sparsity_out(), and casadi::DaeBuilderInternal::update_dependencies().

◆ info()

Dict casadi::Function::info ( ) const

Obtain information about function

Definition at line 1934 of file function.cpp.

1934  {
1935  return (*this)->info();
1936  }

◆ instruction_constant()

double casadi::Function::instruction_constant ( casadi_int  k) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xh

Definition at line 1749 of file function.cpp.

1749  {
1750  try {
1751  return (*this)->instruction_constant(k);
1752  } catch(std::exception& e) {
1753  THROW_ERROR("instruction_constant", e.what());
1754  }
1755  }

Referenced by casadi::SXFunction::export_code_body().

◆ instruction_id()

casadi_int casadi::Function::instruction_id ( casadi_int  k) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xf

Definition at line 1733 of file function.cpp.

1733  {
1734  try {
1735  return (*this)->instruction_id(k);
1736  } catch(std::exception& e) {
1737  THROW_ERROR("instruction_id", e.what());
1738  }
1739  }

Referenced by casadi::MXFunction::export_code_body(), and casadi::SXFunction::export_code_body().

◆ instruction_input()

std::vector< casadi_int > casadi::Function::instruction_input ( casadi_int  k) const

(SXFunction/MXFunction)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xg

Definition at line 1741 of file function.cpp.

1741  {
1742  try {
1743  return (*this)->instruction_input(k);
1744  } catch(std::exception& e) {
1745  THROW_ERROR("instruction_input", e.what());
1746  }
1747  }

Referenced by casadi::MXFunction::export_code_body(), and casadi::SXFunction::export_code_body().

◆ instruction_MX()

MX casadi::Function::instruction_MX ( casadi_int  k) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xj

Definition at line 1717 of file function.cpp.

1717  {
1718  try {
1719  return (*this)->instruction_MX(k);
1720  } catch(std::exception& e) {
1721  THROW_ERROR("instruction_MX", e.what());
1722  }
1723  }

Referenced by casadi::MXFunction::export_code_body().

◆ instruction_output()

std::vector< casadi_int > casadi::Function::instruction_output ( casadi_int  k) const

(SXFunction/MXFunction)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xi

Definition at line 1757 of file function.cpp.

1757  {
1758  try {
1759  return (*this)->instruction_output(k);
1760  } catch(std::exception& e) {
1761  THROW_ERROR("instruction_output", e.what());
1762  }
1763  }

Referenced by casadi::MXFunction::export_code_body(), and casadi::SXFunction::export_code_body().

◆ instructions_sx()

SX casadi::Function::instructions_sx ( ) const

Note: input and output instructions have no SX representation. This method returns nan for those instructions.

Extra doc: https://github.com/casadi/casadi/wiki/L_1xk

Definition at line 1725 of file function.cpp.

1725  {
1726  try {
1727  return (*this)->instructions_sx();
1728  } catch(std::exception& e) {
1729  THROW_ERROR("instructions_sx", e.what());
1730  }
1731  }

◆ is_a()

bool casadi::Function::is_a ( const std::string &  type,
bool  recursive = true 
) const

Optionally check if name matches one of the base classes (default true)

Extra doc: https://github.com/casadi/casadi/wiki/L_1xw

Definition at line 1664 of file function.cpp.

1664  {
1665  return (*this)->is_a(type, recursive);
1666  }

Referenced by casadi::Integrator::augmented_dae(), casadi::Integrator::get_forward_dae(), casadi::MXFunction::get_stats(), and map().

◆ is_diff_in() [1/2]

std::vector< bool > casadi::Function::is_diff_in ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Definition at line 1063 of file function.cpp.

1063  {
1064  try {
1065  return (*this)->is_diff_in_;
1066  } catch(std::exception& e) {
1067  THROW_ERROR("is_diff_in", e.what());
1068  }
1069  }

◆ is_diff_in() [2/2]

bool casadi::Function::is_diff_in ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Definition at line 1047 of file function.cpp.

1047  {
1048  try {
1049  return (*this)->is_diff_in_.at(ind);
1050  } catch(std::exception& e) {
1051  THROW_ERROR("is_diff_in", e.what());
1052  }
1053  }

Referenced by casadi::FunctionInternal::get_sparsity_out(), casadi::Map::init(), and casadi::MapSum::init().

◆ is_diff_out() [1/2]

std::vector< bool > casadi::Function::is_diff_out ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Definition at line 1071 of file function.cpp.

1071  {
1072  try {
1073  return (*this)->is_diff_out_;
1074  } catch(std::exception& e) {
1075  THROW_ERROR("is_diff_out", e.what());
1076  }
1077  }

◆ is_diff_out() [2/2]

bool casadi::Function::is_diff_out ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vt

Definition at line 1055 of file function.cpp.

1055  {
1056  try {
1057  return (*this)->is_diff_out_.at(ind);
1058  } catch(std::exception& e) {
1059  THROW_ERROR("is_diff_out", e.what());
1060  }
1061  }

Referenced by casadi::FunctionInternal::get_sparsity_out(), casadi::Map::init(), and casadi::MapSum::init().

◆ is_null()

Definition at line 117 of file generic_shared_impl.hpp.

109  {
110  return node==nullptr;
111  }

◆ jac_sparsity() [1/2]

const std::vector< Sparsity > & casadi::Function::jac_sparsity ( bool  compact = false) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1ws

Definition at line 940 of file function.cpp.

940  {
941  // Make sure all are calculated
942  for (casadi_int oind = 0; oind < n_out(); ++oind) {
943  for (casadi_int iind = 0; iind < n_in(); ++iind) {
944  (void)jac_sparsity(oind, iind, compact);
945  }
946  }
947  // Return reference to internal cache
948  return (*this)->jac_sparsity_[compact];
949  }
const std::vector< Sparsity > & jac_sparsity(bool compact=false) const
Get, if necessary generate, the sparsity of all Jacobian blocks.
Definition: function.cpp:940

References n_in(), and n_out().

Referenced by casadi::_jacobian_sparsity(), casadi::CodeGenerator::add(), casadi::FunctionInternal::get_sparsity_out(), casadi::Integrator::sp_jac_dae(), casadi::Integrator::sp_jac_rdae(), and casadi::DaeBuilderInternal::update_dependencies().

◆ jac_sparsity() [2/2]

Sparsity casadi::Function::jac_sparsity ( casadi_int  oind,
casadi_int  iind,
bool  compact = false 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1wt

Definition at line 951 of file function.cpp.

951  {
952  try {
953  bool symm = (*this)->jac_is_symm(oind, iind);
954  symm = symm && sparsity_out(oind).is_dense();
955  return (*this)->jac_sparsity(oind, iind, compact, symm);
956  } catch(std::exception& e) {
957  THROW_ERROR("jac_sparsity", e.what());
958  }
959  }
bool is_dense() const
Is dense?
Definition: sparsity.cpp:273

References casadi::Sparsity::is_dense(), and sparsity_out().

◆ jacobian()

Function casadi::Function::jacobian ( ) const

Generates a function that takes all non-differentiated inputs and outputs and calculates all Jacobian blocks. Inputs that are not needed by the routine are all-zero sparse matrices with the correct dimensions. Output blocks that are not calculated, e.g. if the corresponding input or output is marked non-differentiated are also all-zero sparse. The Jacobian blocks are sorted starting by all the blocks for the first output, then all the blocks for the second output and so on. E.g. f : (x, y) -> (r, s) results in the function jac_f : (x, y, out_r, out_s) -> (jac_r_x, jac_r_y, jac_s_x, jac_s_y)

This function is cached.

Extra doc: https://github.com/casadi/casadi/wiki/L_1w6

Definition at line 916 of file function.cpp.

916  {
917  try {
918  return (*this)->jacobian();
919  } catch(std::exception& e) {
920  THROW_ERROR("jacobian", e.what());
921  }
922  }

References casadi::FunctionInternal::jacobian().

Referenced by casadi::DaeBuilderInternal::CallIO::calc_jac(), and casadi::FunctionInternal::jacobian().

◆ jacobian_old()

Function casadi::Function::jacobian_old ( casadi_int  iind,
casadi_int  oind 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w4

Definition at line 888 of file function.cpp.

888  {
889  // Redirect to factory class
890  std::vector<std::string> s_in = name_in();
891  std::vector<std::string> s_out = name_out();
892  s_out.insert(s_out.begin(), "jac:" + name_out(oind) + ":" + name_in(iind));
893  return factory(name() + "_jac", s_in, s_out);
894  }

References factory(), name(), name_in(), and name_out().

◆ jit() [1/2]

Function casadi::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() 
)
static

The names and sparsity patterns of all the inputs and outputs must be provided. If sparsities are not provided, all inputs and outputs are assumed to be scalar. Only specify the function body, assuming that input and output nonzeros are stored in arrays with the specified naming convension. The data type used is 'casadi_real', which is typically equal to 'double‘ or another data type with the same API as 'double’.

Inputs may be null pointers. This means that the all entries are zero. Outputs may be null points. This means that the corresponding result can be ignored.

If an error occurs in the evaluation, issue "return 1;";

The final generated function will have a structure similar to:

casadi_int fname(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, void* mem) { const casadi_real *x1, *x2; casadi_real *r1, *r2; x1 = *arg++; x2 = *arg++; r1 = *res++; r2 = *res++; <FUNCTION_BODY> return 0; }

Extra doc: https://github.com/casadi/casadi/wiki/L_1v3

Definition at line 285 of file function.cpp.

288  {
289  // Pass empty vectors -> default values
290  std::vector<Sparsity> sparsity_in, sparsity_out;
291  return jit(name, body, name_in, name_out, sparsity_in, sparsity_out, opts);
292  }
const Sparsity & sparsity_in(casadi_int ind) const
Get sparsity of a given input.
Definition: function.cpp:1015
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.
Definition: function.cpp:285

References name(), name_in(), name_out(), sparsity_in(), and sparsity_out().

Referenced by casadi::JitFunction::get_jacobian().

◆ jit() [2/2]

Function casadi::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 std::vector< Sparsity > &  sparsity_in,
const std::vector< Sparsity > &  sparsity_out,
const Dict opts = Dict() 
)
static

The names and sparsity patterns of all the inputs and outputs must be provided. If sparsities are not provided, all inputs and outputs are assumed to be scalar. Only specify the function body, assuming that input and output nonzeros are stored in arrays with the specified naming convension. The data type used is 'casadi_real', which is typically equal to 'double‘ or another data type with the same API as 'double’.

Inputs may be null pointers. This means that the all entries are zero. Outputs may be null points. This means that the corresponding result can be ignored.

If an error occurs in the evaluation, issue "return 1;";

The final generated function will have a structure similar to:

casadi_int fname(const casadi_real** arg, casadi_real** res, casadi_int* iw, casadi_real* w, void* mem) { const casadi_real *x1, *x2; casadi_real *r1, *r2; x1 = *arg++; x2 = *arg++; r1 = *res++; r2 = *res++; <FUNCTION_BODY> return 0; }

Extra doc: https://github.com/casadi/casadi/wiki/L_1v3

Definition at line 294 of file function.cpp.

299  {
300  try {
301  return create(new JitFunction(name, body, name_in, name_out,
302  sparsity_in, sparsity_out), opts);
303  } catch(std::exception& e) {
304  THROW_ERROR_NOOBJ("jit", e.what(), "JitFunction");
305  }
306  }

References create(), name(), name_in(), name_out(), sparsity_in(), and sparsity_out().

◆ load()

Function casadi::Function::load ( const std::string &  filename)
static

Extra doc: https://github.com/casadi/casadi/wiki/L_1y1

Definition at line 1349 of file function.cpp.

1349  {
1350  FileDeserializer fs(filename);
1351  auto t = fs.pop_type();
1352  if (t==SerializerBase::SerializationType::SERIALIZED_FUNCTION) {
1353  return fs.blind_unpack_function();
1354  } else {
1355  casadi_error("File is not loadable with 'load'. Use 'FileDeserializer' instead.");
1356  }
1357  }
std::string filename(const std::string &path)
Definition: ghc.cpp:55

References casadi::DeserializerBase::blind_unpack_function(), casadi::filename(), and casadi::DeserializerBase::pop_type().

◆ map() [1/5]

Function casadi::Function::map ( casadi_int  n,
const std::string &  parallelization,
casadi_int  max_num_threads 
) const

Definition at line 678 of file function.cpp.

679  {
680  casadi_assert(max_num_threads>=1, "max_num_threads invalid.");
681  // No need for logic when we are not saturating the limit
682  if (n<=max_num_threads) return map(n, parallelization);
683 
684  // Floored division
685  casadi_int d = n/max_num_threads;
686  if (d*max_num_threads==n) {
687  // Easy when n is divisable by max_num_threads
688  return map(d, "serial").map(max_num_threads, parallelization);
689  } else {
690  // Create a base map that computes a bit too much
691  Function base = map(d+1, "serial").map(max_num_threads, parallelization);
692  std::vector<MX> ret_in, base_in;
693  casadi_int rem = (d+1)*max_num_threads-n;
694  for (casadi_int i=0;i<n_in();++i) {
695  MX arg = MX::sym("arg", repmat(sparsity_in(i), 1, n));
696  ret_in.push_back(arg);
697  MX last_arg = arg(Slice(), range((n-1)*size2_in(i), n*size2_in(i))); // NOLINT
698  base_in.push_back(horzcat(arg, repmat(last_arg, 1, rem)));
699  }
700  std::vector<MX> ret_out = base(base_in);
701  for (casadi_int i=0;i<n_out();++i) {
702  ret_out[i] = horzsplit(ret_out[i], {0, n*size2_out(i), ret_out[i].size2()})[0];
703  }
704  return Function("helper", ret_in, ret_out, name_in(), name_out());
705  }
706  }
Function map(casadi_int n, const std::string &parallelization="serial") const
Create a mapped version of this function.
Definition: function.cpp:709

References Function(), map(), n_in(), n_out(), name_in(), name_out(), casadi::range(), size2_in(), size2_out(), sparsity_in(), and casadi::GenericMatrix< MX >::sym().

◆ map() [2/5]

Function casadi::Function::map ( casadi_int  n,
const std::string &  parallelization = "serial" 
) const

Suppose the function has a signature of:

   f: (a, p) -> ( s )

The the mapped version has the signature:

   F: (A, P) -> (S )

    with
        A: horzcat([a0, a1, ..., a_(N-1)])
        P: horzcat([p0, p1, ..., p_(N-1)])
        S: horzcat([s0, s1, ..., s_(N-1)])
    and
        s0 <- f(a0, p0)
        s1 <- f(a1, p1)
        ...
        s_(N-1) <- f(a_(N-1), p_(N-1))
Parameters
parallelizationType of parallelization used: unroll|serial|openmp

Extra doc: https://github.com/casadi/casadi/wiki/L_1wj

Definition at line 709 of file function.cpp.

709  {
710  // Make sure not degenerate
711  casadi_assert(n>0, "Degenerate map operation");
712  // Quick return if possible
713  if (n==1) return *this;
714  // Unroll?
715  if (parallelization=="unroll" || parallelization=="inline") {
716  // Construct symbolic inputs
717  std::vector<MX> arg(n_in());
718  std::vector<std::vector<MX>> v(n, arg);
719  std::vector<MX> tmp(n);
720  for (casadi_int i=0; i<arg.size(); ++i) {
721  for (casadi_int k=0; k<n; ++k) {
722  tmp[k] = v[k][i] = MX::sym(name_in(i)+"_"+str(k), sparsity_in(i));
723  }
724  arg[i] = horzcat(tmp);
725  }
726  // Evaluate
727  if (parallelization=="unroll") {
728  for (auto&& w : v) w = (*this)(w);
729  } else {
730  for (auto&& w : v) call(std::vector<MX>(w), w, !is_a("SXFunction"), false);
731  }
732  // Gather outputs
733  std::vector<MX> res(n_out());
734  for (casadi_int i=0; i<res.size(); ++i) {
735  for (casadi_int k=0; k<n; ++k) tmp[k] = v[k][i];
736  res[i] = horzcat(tmp);
737  }
738  // Construct function
739  return Function(name() + "_" + str(n), arg, res, name_in(), name_out());
740  } else {
741  // Generate/retrieve potentially cached map
742  return (*this)->map(n, parallelization);
743  }
744  }
bool is_a(const std::string &type, bool recursive=true) const
Check if the function is of a particular type.
Definition: function.cpp:1664

References call(), Function(), is_a(), n_in(), n_out(), name(), name_in(), name_out(), sparsity_in(), casadi::str(), and casadi::GenericMatrix< MX >::sym().

Referenced by casadi::Dple::get_forward(), casadi::Expm::get_forward(), casadi::External::get_forward(), casadi::Map::get_forward(), casadi::Dple::get_reverse(), casadi::Expm::get_reverse(), casadi::External::get_reverse(), casadi::Map::get_reverse(), and map().

◆ map() [3/5]

Function casadi::Function::map ( casadi_int  n,
const std::vector< bool > &  reduce_in,
const std::vector< bool > &  reduce_out = std::vector<bool>(),
const Dict opts = Dict() 
) const

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

Definition at line 637 of file function.cpp.

640  {
641  return MapSum::create("mapsum_" + str(n) + "_" + name(), "serial",
642  *this, n, reduce_in, reduce_out, opts);
643  }
static Function create(const std::string &name, const std::string &parallelization, const Function &f, casadi_int n, const std::vector< bool > &reduce_in, const std::vector< bool > &reduce_out, const Dict &opts=Dict())
Definition: mapsum.cpp:31

References casadi::MapSum::create(), name(), and casadi::str().

◆ map() [4/5]

Function casadi::Function::map ( const std::string &  name,
const std::string &  parallelization,
casadi_int  n,
const std::vector< casadi_int > &  reduce_in,
const std::vector< casadi_int > &  reduce_out,
const Dict opts = Dict() 
) const

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

Definition at line 645 of file function.cpp.

647  {
648  // Wrap in an MXFunction
649  Function f = map(n, parallelization);
650  // Start with the fully mapped inputs
651  std::vector<MX> arg = f.mx_in();
652  std::vector<MX> f_arg = arg;
653  // Replace reduced inputs
654  for (casadi_int i : reduce_in) {
655  arg[i] = mx_in(i);
656  f_arg[i] = repmat(arg[i], 1, n);
657  }
658  // Get fully mapped outputs
659  std::vector<MX> res = f(f_arg);
660  // Replace reduced outputs
661  for (casadi_int i : reduce_out) {
662  res[i] = repsum(res[i], 1, n);
663  }
664  // Construct return
665  return Function(name, arg, res, name_in(), name_out());
666  }
const std::vector< MX > mx_in() const
Get symbolic primitives equivalent to the input expressions.
Definition: function.cpp:1592

References Function(), map(), mx_in(), name(), name_in(), and name_out().

◆ map() [5/5]

Function casadi::Function::map ( const std::string &  name,
const std::string &  parallelization,
casadi_int  n,
const std::vector< std::string > &  reduce_in,
const std::vector< std::string > &  reduce_out,
const Dict opts = Dict() 
) const

A subset of the inputs are non-repeated and a subset of the outputs summed up.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wk

Definition at line 668 of file function.cpp.

670  {
671  std::vector<casadi_int> reduce_in_num, reduce_out_num;
672  for (const std::string& s : reduce_in) reduce_in_num.push_back(index_in(s));
673  for (const std::string& s : reduce_out) reduce_out_num.push_back(index_out(s));
674  return map(name, parallelization, n, reduce_in_num, reduce_out_num, opts);
675  }

References index_in(), index_out(), map(), and name().

◆ mapaccum() [1/6]

Function casadi::Function::mapaccum ( casadi_int  N,
const Dict opts = Dict() 
) const

Suppose the function has a signature of:

   f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

   F: (x0, U) -> (X , Y )

    with
        U: horzcat([u0, u1, ..., u_(N-1)])
        X: horzcat([x1, x2, ..., x_N])
        Y: horzcat([y0, y1, ..., y_(N-1)])

    and
        x1, y0 <- f(x0, u0)
        x2, y1 <- f(x1, u1)
        ...
        x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Definition at line 516 of file function.cpp.

516  {
517  return mapaccum("mapaccum_"+name(), N, opts);
518  }

References mapaccum(), and name().

◆ mapaccum() [2/6]

Function casadi::Function::mapaccum ( const std::string &  name,
casadi_int  N,
casadi_int  n_accum,
const Dict opts = Dict() 
) const

Suppose the function has a signature of:

   f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

   F: (x0, U) -> (X , Y )

    with
        U: horzcat([u0, u1, ..., u_(N-1)])
        X: horzcat([x1, x2, ..., x_N])
        Y: horzcat([y0, y1, ..., y_(N-1)])

    and
        x1, y0 <- f(x0, u0)
        x2, y1 <- f(x1, u1)
        ...
        x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Definition at line 522 of file function.cpp.

523  {
524  Dict options = opts;
525 
526  // Default base
527  casadi_int base = 10;
528  auto it = options.find("base");
529  if (it!=options.end()) {
530  base = it->second;
531  options.erase(it);
532  }
533 
534  casadi_assert(N>0, "mapaccum: N must be positive");
535 
536  if (base==-1)
537  return mapaccum(name, std::vector<Function>(N, *this), n_accum, options);
538  casadi_assert(base>=2, "mapaccum: base must be positive");
539 
540  // Decompose N into
541  std::vector<Function> chain;
542  Function c = *this;
543  while (N!=0) {
544  casadi_int r = N % base;
545  chain.insert(chain.end(), r, c);
546  N = (N-r)/base;
547  c = c.mapaccum(c.name()+"_acc"+str(base), std::vector<Function>(base, c), n_accum, options);
548  }
549  return mapaccum(name, chain, n_accum, options);
550  }

References mapaccum(), name(), and casadi::str().

◆ mapaccum() [3/6]

Function casadi::Function::mapaccum ( const std::string &  name,
casadi_int  N,
const Dict opts = Dict() 
) const

Suppose the function has a signature of:

   f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

   F: (x0, U) -> (X , Y )

    with
        U: horzcat([u0, u1, ..., u_(N-1)])
        X: horzcat([x1, x2, ..., x_N])
        Y: horzcat([y0, y1, ..., y_(N-1)])

    and
        x1, y0 <- f(x0, u0)
        x2, y1 <- f(x1, u1)
        ...
        x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Definition at line 519 of file function.cpp.

519  {
520  return mapaccum(name, N, 1, opts);
521  }

References name().

Referenced by casadi::MX::cumsum(), fold(), and mapaccum().

◆ mapaccum() [4/6]

Function casadi::Function::mapaccum ( const std::string &  name,
casadi_int  n,
const std::vector< casadi_int > &  accum_in,
const std::vector< casadi_int > &  accum_out,
const Dict opts = Dict() 
) const

Suppose the function has a signature of:

   f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

   F: (x0, U) -> (X , Y )

    with
        U: horzcat([u0, u1, ..., u_(N-1)])
        X: horzcat([x1, x2, ..., x_N])
        Y: horzcat([y0, y1, ..., y_(N-1)])

    and
        x1, y0 <- f(x0, u0)
        x2, y1 <- f(x1, u1)
        ...
        x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Definition at line 597 of file function.cpp.

600  {
601  // Shorthands
602  casadi_int n_in = this->n_in(), n_out = this->n_out();
603  // Consistency checks
604  casadi_assert_dev(in_range(accum_in, n_in) && isUnique(accum_in));
605  casadi_assert_dev(in_range(accum_out, n_out) && isUnique(accum_out));
606  casadi_assert_dev(accum_in.size()==accum_out.size());
607  casadi_int n_accum=accum_in.size();
608 
609  // Quick return if no need to reorder
610  if (accum_in==range(n_accum) && accum_out==range(n_accum)) {
611  return mapaccum(name, n, n_accum, opts);
612  }
613 
614  // Need to do some reordering
615  std::vector<casadi_int> temp_in = complement(accum_in, n_in);
616  std::vector<casadi_int> order_in = accum_in;
617  order_in.insert(order_in.end(), temp_in.begin(), temp_in.end());
618  std::vector<casadi_int> temp_out = complement(accum_out, n_out);
619  std::vector<casadi_int> order_out = accum_out;
620  order_out.insert(order_out.end(), temp_out.begin(), temp_out.end());
621  Function ret = slice("slice_" + name, order_in, order_out);
622  ret = ret.mapaccum("mapacc_" + name, n, n_accum, opts);
623  return ret.slice(name, lookupvector(order_in, n_in),
624  lookupvector(order_out, n_out), opts);
625  }
Function slice(const std::string &name, const std::vector< casadi_int > &order_in, const std::vector< casadi_int > &order_out, const Dict &opts=Dict()) const
returns a new function with a selection of inputs/outputs of the original
Definition: function.cpp:747
bool isUnique(const std::vector< T > &v)
std::vector< casadi_int > lookupvector(const std::vector< casadi_int > &v, casadi_int size)
Returns a vector for quickly looking up entries of supplied list.
bool in_range(const std::vector< T > &v, casadi_int upper)
Check if for each element of v holds: v_i < upper.
std::vector< casadi_int > complement(const std::vector< casadi_int > &v, casadi_int size)
Returns the list of all i in [0, size[ not found in supplied list.

References casadi::complement(), casadi::in_range(), casadi::isUnique(), casadi::lookupvector(), mapaccum(), n_in(), n_out(), name(), casadi::range(), and slice().

◆ mapaccum() [5/6]

Function casadi::Function::mapaccum ( const std::string &  name,
casadi_int  n,
const std::vector< std::string > &  accum_in,
const std::vector< std::string > &  accum_out,
const Dict opts = Dict() 
) const

Suppose the function has a signature of:

   f: (x, u) -> (x_next , y )

The the mapaccumulated version has the signature:

   F: (x0, U) -> (X , Y )

    with
        U: horzcat([u0, u1, ..., u_(N-1)])
        X: horzcat([x1, x2, ..., x_N])
        Y: horzcat([y0, y1, ..., y_(N-1)])

    and
        x1, y0 <- f(x0, u0)
        x2, y1 <- f(x1, u1)
        ...
        x_N, y_(N-1) <- f(x_(N-1), u_(N-1))

Mapaccum has the following benefits over writing an equivalent for-loop:

  • much faster at construction time
  • potentially much faster compilation times (for codegen)
  • offers a trade-off between memory and evaluation time

The base (settable through the options dictionary, default 10), is used to create a tower of function calls, containing unrolled for-loops of length maximum base.

This technique is much more scalable in terms of memory-usage, but slightly slower at evaluation, than a plain for-loop. The effect is similar to that of a for-loop with a check-pointing instruction after each chunk of iterations with size base.

Set base to -1 to unroll all the way; no gains in memory efficiency here.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wi

Definition at line 627 of file function.cpp.

630  {
631  std::vector<casadi_int> accum_in_num, accum_out_num;
632  for (const std::string& s : accum_in) accum_in_num.push_back(index_in(s));
633  for (const std::string& s : accum_out) accum_out_num.push_back(index_out(s));
634  return mapaccum(name, n, accum_in_num, accum_out_num, opts);
635  }

References index_in(), index_out(), mapaccum(), and name().

◆ mapaccum() [6/6]

Function casadi::Function::mapaccum ( const std::string &  name,
const std::vector< Function > &  chain,
casadi_int  n_accum = 1,
const Dict opts = Dict() 
) const
protected

Definition at line 552 of file function.cpp.

554  {
555  // Shorthands
556  casadi_int n_in = this->n_in(), n_out = this->n_out();
557  // Consistency checks
558  casadi_assert(!chain.empty(), "mapaccum: chain must be non-empty");
559  casadi_assert(n_accum<=std::min(n_in, n_out), "mapaccum: too many accumulators");
560  // Quick return?
561  if (chain.size()==1) return chain[0];
562  // Get symbolic expressions for inputs and outputs
563  std::vector<MX> arg = mx_in();
564  std::vector<MX> res;
565  // Vectorized inputs and outputs
566  std::vector<std::vector<MX>> varg(n_in), vres(n_out);
567  for (casadi_int i=0; i<n_accum; ++i) varg[i].push_back(arg[i]);
568  // For each function call
569  for (const auto& f : chain) {
570 
571  // Stacked input expressions
572  for (casadi_int i=n_accum; i<n_in; ++i) {
573  arg[i] = MX::sym(name_in(i) + "_" + str(i), f.sparsity_in(i));
574  varg[i].push_back(arg[i]);
575  }
576 
577  // Call f
578  res = f(arg);
579  // Save output expressions
580  for (casadi_int i=0; i<n_out; ++i) vres[i].push_back(res[i]);
581  // Copy function output to input
582  std::copy_n(res.begin(), n_accum, arg.begin());
583  for (casadi_int i=0; i<n_accum; ++i) {
584  // Ony get last component (allows nested calls)
585  casadi_int ncol_out=f.size2_out(i), ncol_in=size2_in(i);
586  if (ncol_out>ncol_in) {
587  arg[i] = horzsplit(arg[i], {0, ncol_out-ncol_in, ncol_out}).back();
588  }
589  }
590  }
591  // Construct return
592  for (casadi_int i=0; i<n_in; ++i) arg[i] = horzcat(varg[i]);
593  for (casadi_int i=0; i<n_out; ++i) res[i] = horzcat(vres[i]);
594  return Function(name, arg, res, name_in(), name_out(), opts);
595  }

References Function(), mx_in(), n_in(), n_out(), name(), name_in(), name_out(), size2_in(), casadi::str(), and casadi::GenericMatrix< MX >::sym().

◆ mapsum()

std::vector< MX > casadi::Function::mapsum ( const std::vector< MX > &  x,
const std::string &  parallelization = "serial" 
) const
Parameters
parallelizationType of parallelization used: unroll|serial|openmp

Extra doc: https://github.com/casadi/casadi/wiki/L_1wh

Definition at line 756 of file function.cpp.

757  {
758  try {
759  return (*this)->mapsum_mx(x, parallelization);
760  } catch(std::exception& e) {
761  THROW_ERROR("mapsum", e.what());
762  }
763  }

◆ max_in()

double casadi::Function::max_in ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vn

Definition at line 1484 of file function.cpp.

1484  {
1485  return (*this)->get_max_in(ind);
1486  }

◆ memory()

void * casadi::Function::memory ( int  ind) const

◆ merge()

void casadi::Function::merge ( const std::vector< MX > &  arg,
std::vector< MX > &  subs_from,
std::vector< MX > &  subs_to 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_2b6

Definition at line 1668 of file function.cpp.

1669  {
1670  return (*this)->merge(arg, subs_from, subs_to);
1671  }

◆ min_in()

double casadi::Function::min_in ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vo

Definition at line 1488 of file function.cpp.

1488  {
1489  return (*this)->get_min_in(ind);
1490  }

◆ mx_in() [1/3]

const std::vector< MX > casadi::Function::mx_in ( ) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Definition at line 1592 of file function.cpp.

1592  {
1593  return (*this)->mx_in();
1594  }

Referenced by map(), and mapaccum().

◆ mx_in() [2/3]

const MX casadi::Function::mx_in ( casadi_int  ind) const

◆ mx_in() [3/3]

const MX casadi::Function::mx_in ( const std::string &  iname) const
inline

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Definition at line 955 of file function.hpp.

955  {
956  return mx_in(index_in(iname));
957  }

◆ mx_out() [1/3]

const std::vector< MX > casadi::Function::mx_out ( ) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Definition at line 1596 of file function.cpp.

1596  {
1597  return (*this)->mx_out();
1598  }

◆ mx_out() [2/3]

const MX casadi::Function::mx_out ( casadi_int  ind) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Definition at line 1588 of file function.cpp.

1588  {
1589  return (*this)->mx_out(ind);
1590  }

◆ mx_out() [3/3]

const MX casadi::Function::mx_out ( const std::string &  oname) const
inline

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Definition at line 973 of file function.hpp.

973  {
974  return mx_out(index_out(oname));
975  }
const std::vector< MX > mx_out() const
Get symbolic primitives equivalent to the output expressions.
Definition: function.cpp:1596

◆ n_in()

casadi_int casadi::Function::n_in ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1v8

Definition at line 819 of file function.cpp.

819  {
820  return (*this)->n_in_;
821  }

Referenced by casadi::CodeGenerator::add(), buf_in(), casadi::OracleFunction::calc_function(), casadi::DaeBuilderInternal::CallIO::calc_jac(), casadi::Call::Call(), call_gen(), casadi::Nlpsol::callback(), casadi::FiniteDiff::codegen_body(), casadi::Sqpmethod::codegen_qp_ela_solve(), casadi::Feasiblesqpmethod::codegen_qp_solve(), casadi::Sqpmethod::codegen_qp_solve(), casadi::MapSum::create(), casadi::OracleFunction::create_function(), casadi::SXFunction::disp_more(), casadi::FiniteDiff::eval(), casadi::Scpgen::eval_exp(), casadi::Scpgen::eval_mat(), casadi::Scpgen::eval_res(), casadi::CallSX::eval_sx(), casadi::Scpgen::eval_vec(), casadi::SXFunction::ExtendedAlgEl::ExtendedAlgEl(), casadi::External::factory(), casadi::Blocksqp::feasibilityRestorationPhase(), casadi::FunctionInternal::forward(), casadi::FiniteDiff::get_default_in(), casadi::FunctionInternal::get_n_in(), casadi::FiniteDiff::get_n_in(), casadi::Switch::get_n_in(), casadi::FunctionInternal::get_n_out(), casadi::FunctionInternal::get_name_in(), casadi::FiniteDiff::get_name_in(), casadi::FunctionInternal::get_name_out(), casadi::FunctionInternal::get_sparsity_in(), casadi::FiniteDiff::get_sparsity_in(), casadi::FunctionInternal::get_sparsity_out(), casadi::Integrator::init(), casadi::Nlpsol::init(), casadi::Rootfinder::init(), casadi::BonminInterface::init(), casadi::IpoptInterface::init(), casadi::FastNewton::init(), casadi::Feasiblesqpmethod::init(), casadi::Newton::init(), casadi::Sqpmethod::init(), casadi::BonminInterface::intermediate_callback(), casadi::IpoptInterface::intermediate_callback(), jac_sparsity(), casadi::FunctionInternal::jacobian(), map(), mapaccum(), casadi::MapSum::MapSum(), casadi::SymbolicQr::nfact(), casadi::SXNode::print_compact(), casadi::qpsol_nlp(), rev(), casadi::FunctionInternal::reverse(), casadi::simpleIntegrator(), casadi::simpleIRK(), casadi::simpleRK(), casadi::WorhpInterface::solve(), casadi::Scpgen::solve(), casadi::SymbolicQr::solve(), casadi::Sqpmethod::solve_ela_QP(), casadi::Feasiblesqpmethod::solve_LP(), casadi::Feasiblesqpmethod::solve_QP(), casadi::Qrsqp::solve_QP(), casadi::Scpgen::solve_qp(), casadi::Sqpmethod::solve_QP(), and casadi::ThreadsWork().

◆ n_instructions()

casadi_int casadi::Function::n_instructions ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xe

Definition at line 1709 of file function.cpp.

1709  {
1710  try {
1711  return (*this)->n_instructions();
1712  } catch(std::exception& e) {
1713  THROW_ERROR("n_instructions", e.what());
1714  }
1715  }

Referenced by casadi::MXFunction::export_code_body(), and casadi::SXFunction::export_code_body().

◆ n_nodes()

casadi_int casadi::Function::n_nodes ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xd

Definition at line 1765 of file function.cpp.

1765  {
1766  try {
1767  return (*this)->n_nodes();
1768  } catch(std::exception& e) {
1769  THROW_ERROR("n_nodes", e.what());
1770  }
1771  }

Referenced by casadi::Scpgen::init(), and casadi::MX::n_nodes().

◆ n_out()

casadi_int casadi::Function::n_out ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1v9

Definition at line 823 of file function.cpp.

823  {
824  return (*this)->n_out_;
825  }

Referenced by casadi::CodeGenerator::add(), buf_out(), casadi::OracleFunction::calc_function(), casadi::DaeBuilderInternal::CallIO::calc_jac(), call_gen(), casadi::Nlpsol::callback(), casadi::FiniteDiff::codegen_body(), casadi::Sqpmethod::codegen_qp_ela_solve(), casadi::Feasiblesqpmethod::codegen_qp_solve(), casadi::Sqpmethod::codegen_qp_solve(), conditional(), casadi::MapSum::create(), casadi::OracleFunction::create_function(), casadi::SXFunction::disp_more(), casadi::FiniteDiff::eval(), casadi::Scpgen::eval_exp(), casadi::Scpgen::eval_mat(), casadi::Scpgen::eval_res(), casadi::CallSX::eval_sx(), casadi::Scpgen::eval_vec(), casadi::MXFunction::export_code_body(), casadi::SXFunction::ExtendedAlgEl::ExtendedAlgEl(), casadi::External::factory(), casadi::Blocksqp::feasibilityRestorationPhase(), casadi::FunctionInternal::forward(), casadi::FunctionInternal::get_n_in(), casadi::FiniteDiff::get_n_in(), casadi::FunctionInternal::get_n_out(), casadi::FiniteDiff::get_n_out(), casadi::Switch::get_n_out(), casadi::FunctionInternal::get_name_in(), casadi::FiniteDiff::get_name_in(), casadi::FunctionInternal::get_sparsity_in(), casadi::FiniteDiff::get_sparsity_in(), casadi::Integrator::init(), casadi::Nlpsol::init(), casadi::Rootfinder::init(), casadi::BonminInterface::init(), casadi::IpoptInterface::init(), casadi::Feasiblesqpmethod::init(), casadi::Sqpmethod::init(), casadi::BonminInterface::intermediate_callback(), casadi::IpoptInterface::intermediate_callback(), jac_sparsity(), casadi::FunctionInternal::jacobian(), map(), mapaccum(), casadi::MapSum::MapSum(), casadi::SymbolicQr::nfact(), casadi::Call::nout(), casadi::qpsol_nlp(), rev(), casadi::FunctionInternal::reverse(), casadi::simpleIntegrator(), casadi::simpleIRK(), casadi::simpleRK(), casadi::WorhpInterface::solve(), casadi::Scpgen::solve(), casadi::SymbolicQr::solve(), casadi::Sqpmethod::solve_ela_QP(), casadi::Feasiblesqpmethod::solve_LP(), casadi::Feasiblesqpmethod::solve_QP(), casadi::Qrsqp::solve_QP(), casadi::Scpgen::solve_qp(), casadi::Sqpmethod::solve_QP(), and casadi::ThreadsWork().

◆ name()

const std::string & casadi::Function::name ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xv

Definition at line 1307 of file function.cpp.

1307  {
1308  if (is_null()) {
1309  static std::string null = "null";
1310  return null;
1311  } else {
1312  return (*this)->name_;
1313  }
1314  }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null().

Referenced by casadi::CodeGenerator::add(), casadi::DaeBuilderInternal::add_fun(), casadi::Integrator::augmented_dae(), bspline(), casadi::Call::Call(), check_name(), conditional(), casadi::Callback::construct(), construct(), casadi::MapSum::create(), casadi::Map::create(), casadi::FixedStepIntegrator::create_advanced(), casadi::Call::disp(), casadi::Switch::disp_more(), casadi::SXFunction::disp_more(), expand(), factory(), find_function(), fix_name(), fold(), Function(), casadi::FunctionInternal::FunctionInternal(), generate(), casadi::Callback::get_forward(), casadi::MapSum::get_forward(), get_function(), casadi::Callback::get_jacobian(), casadi::FunctionInternal::get_n_in(), casadi::FunctionInternal::get_n_out(), casadi::FunctionInternal::get_name_in(), casadi::FunctionInternal::get_name_out(), casadi::Callback::get_reverse(), casadi::MapSum::get_reverse(), casadi::FunctionInternal::get_sparsity_in(), casadi::FunctionInternal::get_sparsity_out(), has_in(), has_out(), hessian_old(), if_else(), index_in(), index_out(), casadi::FunctionInternal::init(), casadi::ImplicitFixedStepIntegrator::init(), casadi::Rootfinder::init(), casadi::SundialsInterface::init(), casadi::FunctionInternal::jac_is_symm(), jacobian_old(), jit(), casadi::FunctionInternal::map(), map(), mapaccum(), casadi::SXNode::print_compact(), print_option(), casadi::OptiNode::scale_helper(), casadi::OracleFunction::set_function(), casadi::RungeKutta::setup_step(), slice(), casadi::FunctionInternal::tocache(), and casadi::FunctionInternal::tocache_if_missing().

◆ name_in() [1/2]

const std::vector< std::string > & casadi::Function::name_in ( ) const

◆ name_in() [2/2]

const std::string & casadi::Function::name_in ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vi

Definition at line 999 of file function.cpp.

999  {
1000  try {
1001  return (*this)->name_in_.at(ind);
1002  } catch(std::exception& e) {
1003  THROW_ERROR("name_in", e.what());
1004  }
1005  }

◆ name_out() [1/2]

const std::vector< std::string > & casadi::Function::name_out ( ) const

◆ name_out() [2/2]

const std::string & casadi::Function::name_out ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vj

Definition at line 1007 of file function.cpp.

1007  {
1008  try {
1009  return (*this)->name_out_.at(ind);
1010  } catch(std::exception& e) {
1011  THROW_ERROR("name_out", e.what());
1012  }
1013  }

◆ nnz_in() [1/3]

casadi_int casadi::Function::nnz_in ( ) const

◆ nnz_in() [2/3]

casadi_int casadi::Function::nnz_in ( casadi_int  ind) const

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vc

Definition at line 867 of file function.cpp.

867  {
868  return (*this)->nnz_in(ind);
869  }

◆ nnz_in() [3/3]

casadi_int casadi::Function::nnz_in ( const std::string &  iname) const
inline

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vc

Definition at line 271 of file function.hpp.

271 {return nnz_in(index_in(iname));}

References nnz_in().

Referenced by nnz_in().

◆ nnz_out() [1/3]

casadi_int casadi::Function::nnz_out ( ) const

◆ nnz_out() [2/3]

casadi_int casadi::Function::nnz_out ( casadi_int  ind) const

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vd

Definition at line 871 of file function.cpp.

871  {
872  return (*this)->nnz_out(ind);
873  }

◆ nnz_out() [3/3]

casadi_int casadi::Function::nnz_out ( const std::string &  oname) const
inline

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vd

Definition at line 282 of file function.hpp.

282 {return nnz_out(index_out(oname));}

References nnz_out().

Referenced by nnz_out().

◆ nominal_in()

std::vector< double > casadi::Function::nominal_in ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vp

Definition at line 1492 of file function.cpp.

1492  {
1493  return (*this)->get_nominal_in(ind);
1494  }

Referenced by casadi::Integrator::init().

◆ nominal_out()

std::vector< double > casadi::Function::nominal_out ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vq

Definition at line 1496 of file function.cpp.

1496  {
1497  return (*this)->get_nominal_out(ind);
1498  }

◆ numel_in() [1/3]

casadi_int casadi::Function::numel_in ( ) const

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

Definition at line 859 of file function.cpp.

859  {
860  return (*this)->numel_in();
861  }

Referenced by casadi::Integrator::init().

◆ numel_in() [2/3]

casadi_int casadi::Function::numel_in ( casadi_int  ind) const

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

Definition at line 875 of file function.cpp.

875  {
876  return (*this)->numel_in(ind);
877  }

◆ numel_in() [3/3]

casadi_int casadi::Function::numel_in ( const std::string &  iname) const
inline

For a particular input or for all of the inputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1ve

Definition at line 293 of file function.hpp.

293 {return numel_in(index_in(iname));}
casadi_int numel_in() const
Get number of input elements.
Definition: function.cpp:859

References numel_in().

Referenced by numel_in().

◆ numel_out() [1/3]

casadi_int casadi::Function::numel_out ( ) const

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

Definition at line 863 of file function.cpp.

863  {
864  return (*this)->numel_out();
865  }

Referenced by casadi::Integrator::init(), and casadi::Nlpsol::init().

◆ numel_out() [2/3]

casadi_int casadi::Function::numel_out ( casadi_int  ind) const

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

Definition at line 879 of file function.cpp.

879  {
880  return (*this)->numel_out(ind);
881  }

◆ numel_out() [3/3]

casadi_int casadi::Function::numel_out ( const std::string &  oname) const
inline

For a particular output or for all of the outputs

Extra doc: https://github.com/casadi/casadi/wiki/L_1vf

Definition at line 304 of file function.hpp.

304 {return numel_out(index_out(oname));}
casadi_int numel_out() const
Get number of output elements.
Definition: function.cpp:863

References numel_out().

Referenced by numel_out().

◆ nz_from_in()

std::vector< double > casadi::Function::nz_from_in ( const std::vector< DM > &  arg) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1x6

Definition at line 1600 of file function.cpp.

1600  {
1601  return (*this)->nz_in(arg);
1602  }

Referenced by generate_in().

◆ nz_from_out()

std::vector< double > casadi::Function::nz_from_out ( const std::vector< DM > &  arg) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1x6

Definition at line 1604 of file function.cpp.

1604  {
1605  return (*this)->nz_out(res);
1606  }

Referenced by generate_out().

◆ nz_to_in()

std::vector< DM > casadi::Function::nz_to_in ( const std::vector< double > &  arg) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1x6

Definition at line 1608 of file function.cpp.

1608  {
1609  return (*this)->nz_in(arg);
1610  }

Referenced by generate_in().

◆ nz_to_out()

std::vector< DM > casadi::Function::nz_to_out ( const std::vector< double > &  arg) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1x6

Definition at line 1612 of file function.cpp.

1612  {
1613  return (*this)->nz_out(res);
1614  }

Referenced by generate_out().

◆ operator()() [1/24]

int casadi::Function::operator() ( const bvec_t **  arg,
bvec_t **  res,
casadi_int *  iw,
bvec_t w,
int  mem = 0 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1we

Definition at line 1091 of file function.cpp.

1092  {
1093  try {
1094  return (*this)->sp_forward(arg, res, iw, w, memory(mem));
1095  } catch(std::exception& e) {
1096  THROW_ERROR("operator()", e.what());
1097  }
1098  }
void * memory(int ind) const
Get memory object.
Definition: function.cpp:1781

References memory().

◆ operator()() [2/24]

std::vector<DM> casadi::Function::operator() ( const DM arg0) const
inline

Functor shorthand for evaluation, single argument (only C++)

Definition at line 597 of file function.hpp.

597  {
598  return operator()(std::vector<DM>{arg0});
599  }
std::vector< DM > operator()(const std::vector< DM > &arg) const
Definition: function.cpp:1400

◆ operator()() [3/24]

const DMDict casadi::Function::operator() ( const DMDict arg) const

Functor shorthand for evaluation

Definition at line 1435 of file function.cpp.

1435  {
1436  DMDict res;
1437  call(arg, res);
1438  return res;
1439  }
std::map< std::string, DM > DMDict
Definition: dm_fwd.hpp:36

References call().

◆ operator()() [4/24]

int casadi::Function::operator() ( const double **  arg,
double **  res,
casadi_int *  iw,
double *  w 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1wc

Definition at line 1505 of file function.cpp.

1506  {
1507  scoped_checkout<Function> mem(*this);
1508  return operator()(arg, res, iw, w, mem);
1509  }

References operator()().

◆ operator()() [5/24]

int casadi::Function::operator() ( const double **  arg,
double **  res,
casadi_int *  iw,
double *  w,
int  mem 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1wb

Definition at line 1511 of file function.cpp.

1512  {
1513  try {
1514 #ifdef WITH_EXTRA_CHECKS
1515  // Should never happen
1516  casadi_assert_dev(call_depth_>=0);
1517  call_depth_++;
1518  // For consistency check
1519  casadi_int depth = call_depth_;
1520 #endif // WITH_EXTRA_CHECKS
1521  int ret = (*this)->eval_gen(arg, res, iw, w, memory(mem), false, false);
1522 #ifdef WITH_EXTRA_CHECKS
1523  // Consitency check
1524  casadi_assert_dev(call_depth_==depth);
1525  call_depth_--;
1526 #endif // WITH_EXTRA_CHECKS
1527  return ret;
1528  } catch (KeyboardInterruptException& e) {
1529  (void)e; // unused
1530 #ifdef WITH_EXTRA_CHECKS
1531  call_depth_--;
1532 #endif // WITH_EXTRA_CHECKS
1533  throw;
1534  } catch(std::exception& e) {
1535 #ifdef WITH_EXTRA_CHECKS
1536  call_depth_--;
1537 #endif // WITH_EXTRA_CHECKS
1538  (*this)->print_in(uerr(), arg, true);
1539  THROW_ERROR("operator()", e.what());
1540  }
1541  }
std::ostream & uerr()

References memory(), casadi::uerr(), and casadi::CasadiException::what().

◆ operator()() [6/24]

std::vector<MX> casadi::Function::operator() ( const MX arg0) const
inline

Functor shorthand for evaluation, single argument (only C++)

Definition at line 603 of file function.hpp.

603  {
604  return operator()(std::vector<MX>{arg0});
605  }

◆ operator()() [7/24]

const MXDict casadi::Function::operator() ( const MXDict arg) const

Functor shorthand for evaluation

Definition at line 1447 of file function.cpp.

1447  {
1448  MXDict res;
1449  call(arg, res);
1450  return res;
1451  }
std::map< std::string, MX > MXDict
Definition: mx.hpp:1009

References call().

◆ operator()() [8/24]

std::vector< DM > casadi::Function::operator() ( const std::vector< DM > &  arg) const

Functor shorthand for evaluation

Definition at line 1400 of file function.cpp.

1400  {
1401  std::vector<DM> res;
1402  call(arg, res);
1403  return res;
1404  }

References call().

Referenced by operator()().

◆ operator()() [9/24]

std::vector< MX > casadi::Function::operator() ( const std::vector< MX > &  arg) const

Functor shorthand for evaluation

Definition at line 1412 of file function.cpp.

1412  {
1413  std::vector<MX> res;
1414  call(arg, res);
1415  return res;
1416  }

References call().

◆ operator()() [10/24]

std::vector< SX > casadi::Function::operator() ( const std::vector< SX > &  arg) const

Functor shorthand for evaluation

Definition at line 1406 of file function.cpp.

1406  {
1407  std::vector<SX> res;
1408  call(arg, res);
1409  return res;
1410  }

References call().

◆ operator()() [11/24]

std::vector<SX> casadi::Function::operator() ( const SX arg0) const
inline

Functor shorthand for evaluation, single argument (only C++)

Definition at line 600 of file function.hpp.

600  {
601  return operator()(std::vector<SX>{arg0});
602  }

◆ operator()() [12/24]

const SXDict casadi::Function::operator() ( const SXDict arg) const

Functor shorthand for evaluation

Definition at line 1441 of file function.cpp.

1441  {
1442  SXDict res;
1443  call(arg, res);
1444  return res;
1445  }
std::map< std::string, SX > SXDict
Definition: sx_fwd.hpp:40

References call().

◆ operator()() [13/24]

int casadi::Function::operator() ( const SXElem **  arg,
SXElem **  res,
casadi_int *  iw,
SXElem w,
int  mem = 0 
) const

Same syntax as the double version, allowing use in templated code

Extra doc: https://github.com/casadi/casadi/wiki/L_1wd

Definition at line 1543 of file function.cpp.

1544  {
1545  try {
1546  return (*this)->eval_sx(arg, res, iw, w, memory(mem), false, false);
1547  } catch(std::exception& e) {
1548  THROW_ERROR("operator()", e.what());
1549  }
1550  }

References memory().

◆ operator()() [14/24]

void casadi::Function::operator() ( MapArg  arg,
MapRes  res 
) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1wa

Definition at line 590 of file function.hpp.

590 { (*this)(buf_in(arg), buf_out(res)); }
std::vector< double * > buf_out(VecRes res) const
Supported arguments for numerical evaluation and converters.
Definition: function.cpp:395
std::vector< const double * > buf_in(VecArg arg) const
Supported arguments for numerical evaluation and converters.
Definition: function.cpp:384

◆ operator()() [15/24]

void casadi::Function::operator() ( MapArg  arg,
MPrRes  res 
) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1wa

Definition at line 592 of file function.hpp.

592 { (*this)(buf_in(arg), buf_out(res)); }

◆ operator()() [16/24]

void casadi::Function::operator() ( MapArg  arg,
VecRes  res 
) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1wa

Definition at line 589 of file function.hpp.

589 { (*this)(buf_in(arg), buf_out(res)); }

◆ operator()() [17/24]

void casadi::Function::operator() ( MapArg  arg,
VPrRes  res 
) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1wa

Definition at line 591 of file function.hpp.

591 { (*this)(buf_in(arg), buf_out(res)); }

◆ operator()() [18/24]

void casadi::Function::operator() ( std::vector< const bvec_t * >  arg,
std::vector< bvec_t * >  res 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w8

Definition at line 484 of file function.cpp.

484  {
485  return call_gen(arg, res);
486  }

References call_gen().

◆ operator()() [19/24]

void casadi::Function::operator() ( std::vector< const double * >  arg,
std::vector< double * >  res 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w8

Definition at line 480 of file function.cpp.

480  {
481  return call_gen(arg, res);
482  }

References call_gen().

◆ operator()() [20/24]

void casadi::Function::operator() ( std::vector< const SXElem * >  arg,
std::vector< SXElem * >  res 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w8

Definition at line 488 of file function.cpp.

488  {
489  return call_gen(arg, res);
490  }

References call_gen().

◆ operator()() [21/24]

void casadi::Function::operator() ( VecArg  arg,
MapRes  res 
) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1wa

Definition at line 585 of file function.hpp.

585 { (*this)(buf_in(arg), buf_out(res)); }

◆ operator()() [22/24]

void casadi::Function::operator() ( VecArg  arg,
MPrRes  res 
) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1wa

Definition at line 587 of file function.hpp.

587 { (*this)(buf_in(arg), buf_out(res)); }

◆ operator()() [23/24]

void casadi::Function::operator() ( VecArg  arg,
VecRes  res 
) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1wa

Definition at line 584 of file function.hpp.

584 { (*this)(buf_in(arg), buf_out(res)); }

◆ operator()() [24/24]

void casadi::Function::operator() ( VecArg  arg,
VPrRes  res 
) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1wa

Definition at line 586 of file function.hpp.

586 { (*this)(buf_in(arg), buf_out(res)); }

◆ operator->()

FunctionInternal * casadi::Function::operator-> ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1x3

Definition at line 348 of file function.cpp.

348  {
349  casadi_assert_dev(!is_null());
350  return get();
351  }

References get(), and casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null().

◆ operator==()

bool casadi::Function::operator== ( const Function f) const

Definition at line 1924 of file function.cpp.

1924  {
1925  try {
1926  casadi_assert(!is_null(), "lhs is null");
1927  casadi_assert(!f.is_null(), "rhs is null");
1928  return get()==f.get();
1929  } catch(std::exception& e) {
1930  THROW_ERROR("operator==", e.what());
1931  }
1932  }

References get(), casadi::GenericShared< Shared, Internal >::is_null(), and casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null().

◆ oracle()

Function casadi::Function::oracle ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vu

Definition at line 1908 of file function.cpp.

1908  {
1909  try {
1910  return (*this)->oracle();
1911  } catch(std::exception& e) {
1912  THROW_ERROR("oracle", e.what());
1913  }
1914  }

References casadi::FunctionInternal::oracle().

◆ order() [1/2]

std::vector< MX > casadi::Function::order ( const std::vector< MX > &  expr)
static

Definition at line 1942 of file function.cpp.

1942  {
1943  return MXFunction::order(expr);
1944  }
static std::vector< MX > order(const std::vector< MX > &expr)

References casadi::MXFunction::order().

◆ order() [2/2]

std::vector< SX > casadi::Function::order ( const std::vector< SX > &  expr)
static

Definition at line 1938 of file function.cpp.

1938  {
1939  return SXFunction::order(expr);
1940  }
static std::vector< SX > order(const std::vector< SX > &expr)

References casadi::SXFunction::order().

Referenced by casadi::SerializerBase::pack(), and which_depends().

◆ own()

void casadi::GenericShared< SharedObject , SharedObjectInternal >::own ( Internal *  node)
inherited

Assign the node to a node class pointer (or null)

Definition at line 90 of file generic_shared_impl.hpp.

◆ print_dimensions()

void casadi::Function::print_dimensions ( std::ostream &  stream = casadi::uout()) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vy

Definition at line 1151 of file function.cpp.

1151  {
1152  (*this)->print_dimensions(stream);
1153  }

◆ print_option()

void casadi::Function::print_option ( const std::string &  name,
std::ostream &  stream = casadi::uout() 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w0

Definition at line 1159 of file function.cpp.

1159  {
1160  (*this)->print_option(name, stream);
1161  }

References name().

◆ print_options()

void casadi::Function::print_options ( std::ostream &  stream = casadi::uout()) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vz

Definition at line 1155 of file function.cpp.

1155  {
1156  (*this)->print_options(stream);
1157  }

◆ print_ptr()

void casadi::SharedObject::print_ptr ( std::ostream &  stream = casadi::uout()) const
inherited

Print the pointer to the internal class

Definition at line 43 of file shared_object.cpp.

43  {
44  stream << get();
45  }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::get().

◆ proceed_to()

bool casadi::Function::proceed_to ( std::istream &  file,
const std::string &  str 
)
staticprotected

Definition at line 64 of file function.cpp.

64  {
65  // Make sure that the file is ready for reading
66  if (!file.good()) return false;
67  // Have we already wrapped around once?
68  //bool wrapped_around = false;
69  // Read line-by-line
70  std::string tmp;
71  while (true) {
72  // Read a word
73  std::streampos cur_pos = file.tellg();
74  file >> tmp;
75  if (!file.good()) return false;
76 
77  // Check if match
78  if (str==tmp) return true;
79 
80  // If comment, continue to the end of the line
81  if (tmp.at(0)=='#') {
82  file.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
83  continue;
84  }
85 
86  // If mismatching name, rewind and break
87  file.seekg(cur_pos);
88  return false;
89  }
90  }

References casadi::str().

◆ release()

void casadi::Function::release ( int  mem) const

Definition at line 1777 of file function.cpp.

1777  {
1778  (*this)->release(mem);
1779  }

Referenced by casadi::QpToNlp::free_mem(), casadi::Sqpmethod::free_mem(), and casadi::FunctionBuffer::~FunctionBuffer().

◆ rev() [1/2]

int casadi::Function::rev ( bvec_t **  arg,
bvec_t **  res,
casadi_int *  iw,
bvec_t w,
int  mem = 0 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1wf

Definition at line 1100 of file function.cpp.

1100  {
1101  try {
1102  return (*this)->sp_reverse(arg, res, iw, w, memory(mem));
1103  } catch(std::exception& e) {
1104  THROW_ERROR("rev", e.what());
1105  }
1106  }

References memory().

Referenced by casadi::_which_depends(), rev(), casadi::Call::sp_reverse(), casadi::Map::sp_reverse(), casadi::MapSum::sp_reverse(), and casadi::Rootfinder::sp_reverse().

◆ rev() [2/2]

int casadi::Function::rev ( std::vector< bvec_t * >  arg,
std::vector< bvec_t * >  res 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1wg

Definition at line 492 of file function.cpp.

492  {
493  // Input buffer
494  casadi_assert_dev(arg.size()>=n_in());
495  arg.resize(sz_arg());
496 
497  // Output buffer
498  casadi_assert_dev(res.size()>=n_out());
499  res.resize(sz_res());
500 
501  // Work vectors
502  std::vector<casadi_int> iw(sz_iw());
503  std::vector<bvec_t> w(sz_w());
504 
505  // Evaluate memoryless
506  return rev(get_ptr(arg), get_ptr(res), get_ptr(iw), get_ptr(w), 0);
507  }
int rev(bvec_t **arg, bvec_t **res, casadi_int *iw, bvec_t *w, int mem=0) const
Propagate sparsity backward.
Definition: function.cpp:1100

References casadi::get_ptr(), n_in(), n_out(), rev(), sz_arg(), sz_iw(), sz_res(), and sz_w().

◆ reverse()

Function casadi::Function::reverse ( casadi_int  nadj) const
   Returns a function with <tt>n_in + n_out + n_out</tt> inputs
   and <tt>n_in</tt> outputs.
   The first <tt>n_in</tt> inputs correspond to nondifferentiated inputs.
   The next <tt>n_out</tt> inputs correspond to nondifferentiated outputs.
   and the last <tt>n_out</tt> inputs correspond to adjoint seeds,
   stacked horizontally
   The  <tt>n_in</tt> outputs correspond to adjoint sensitivities,
   stacked horizontally.     *
   <tt>(n_in = n_in(), n_out = n_out())</tt>

   <tt>(n_in = n_in(), n_out = n_out())</tt>

  The functions returned are cached, meaning that if called multiple timed
  with the same value, then multiple references to the same function will be returned.

Extra doc: https://github.com/casadi/casadi/wiki/L_1wr

Definition at line 1143 of file function.cpp.

1143  {
1144  try {
1145  return (*this)->reverse(nadj);
1146  } catch(std::exception& e) {
1147  THROW_ERROR("reverse", e.what());
1148  }
1149  }

References casadi::FunctionInternal::reverse().

Referenced by casadi::SXFunction::ad_reverse(), casadi::DaeBuilderInternal::export_fmu(), casadi::Map::get_reverse(), casadi::MapSum::get_reverse(), casadi::Nlpsol::get_reverse(), casadi::Switch::get_reverse(), casadi::Integrator::init(), casadi::ImplicitFixedStepIntegrator::init(), casadi::FunctionInternal::reverse(), and casadi::RungeKutta::setup_step().

◆ save()

void casadi::Function::save ( const std::string &  fname,
const Dict opts = Dict() 
) const
See also
load

Extra doc: https://github.com/casadi/casadi/wiki/L_240

Definition at line 1269 of file function.cpp.

1269  {
1270  FileSerializer fs(fname, opts);
1271  fs.pack(*this);
1272  }

References casadi::SerializerBase::pack().

◆ serialize() [1/3]

std::string casadi::Function::serialize ( const Dict opts = Dict()) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1x2

Definition at line 1274 of file function.cpp.

1274  {
1275  std::stringstream ss;
1276  serialize(ss, opts);
1277  return ss.str();
1278  }
void serialize(std::ostream &stream, const Dict &opts=Dict()) const
Serialize.
Definition: function.cpp:1280

References serialize().

◆ serialize() [2/3]

void casadi::Function::serialize ( SerializingStream s) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1x1

Definition at line 1285 of file function.cpp.

1285  {
1286  if (is_null()) {
1287  s.pack("Function::null", true);
1288  } else {
1289  s.pack("Function::null", false);
1290  (*this)->serialize(s);
1291  }
1292  }

References casadi::GenericShared< SharedObject, SharedObjectInternal >::is_null(), and casadi::SerializingStream::pack().

◆ serialize() [3/3]

void casadi::Function::serialize ( std::ostream &  stream,
const Dict opts = Dict() 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1x0

Definition at line 1280 of file function.cpp.

1280  {
1281  SerializingStream s(stream, opts);
1282  return serialize(s);
1283  }

Referenced by serialize().

◆ set_temp()

void casadi::Function::set_temp ( const double **  arg,
double **  res,
casadi_int *  iw,
double *  w,
int  mem = 0 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xs

Definition at line 1117 of file function.cpp.

1118  {
1119  try {
1120  (*this)->set_temp(memory(mem), arg, res, iw, w);
1121  } catch(std::exception& e) {
1122  THROW_ERROR("set_temp", e.what());
1123  }
1124  }

References memory().

◆ set_work()

void casadi::Function::set_work ( const double **&  arg,
double **&  res,
casadi_int *&  iw,
double *&  w,
int  mem = 0 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xr

Definition at line 1108 of file function.cpp.

1109  {
1110  try {
1111  (*this)->set_work(memory(mem), arg, res, iw, w);
1112  } catch(std::exception& e) {
1113  THROW_ERROR("set_work", e.what());
1114  }
1115  }

References memory().

◆ setup()

void casadi::Function::setup ( const double **  arg,
double **  res,
casadi_int *  iw,
double *  w,
int  mem = 0 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1xt

Definition at line 1126 of file function.cpp.

1127  {
1128  try {
1129  (*this)->setup(memory(mem), arg, res, iw, w);
1130  } catch(std::exception& e) {
1131  THROW_ERROR("setup", e.what());
1132  }
1133  }

References memory().

◆ size1_in() [1/2]

casadi_int casadi::Function::size1_in ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Definition at line 827 of file function.cpp.

827  {
828  return (*this)->size1_in(ind);
829  }

Referenced by assert_size_in(), casadi::Blocksqp::feasibilityRestorationPhase(), and casadi::Blocksqp::init().

◆ size1_in() [2/2]

casadi_int casadi::Function::size1_in ( const std::string &  iname) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Definition at line 240 of file function.hpp.

240 {return size1_in(index_in(iname));}

References size1_in().

Referenced by size1_in().

◆ size1_out() [1/2]

casadi_int casadi::Function::size1_out ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Definition at line 835 of file function.cpp.

835  {
836  return (*this)->size1_out(ind);
837  }

Referenced by assert_size_out(), and casadi::Blocksqp::init().

◆ size1_out() [2/2]

casadi_int casadi::Function::size1_out ( const std::string &  oname) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Definition at line 254 of file function.hpp.

254 {return size1_out(index_out(oname));}

References size1_out().

Referenced by size1_out().

◆ size2_in() [1/2]

casadi_int casadi::Function::size2_in ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Definition at line 831 of file function.cpp.

831  {
832  return (*this)->size2_in(ind);
833  }

Referenced by assert_size_in(), map(), and mapaccum().

◆ size2_in() [2/2]

casadi_int casadi::Function::size2_in ( const std::string &  iname) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Definition at line 242 of file function.hpp.

242 {return size2_in(index_in(iname));}

References size2_in().

Referenced by size2_in().

◆ size2_out() [1/2]

casadi_int casadi::Function::size2_out ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Definition at line 839 of file function.cpp.

839  {
840  return (*this)->size2_out(ind);
841  }

Referenced by assert_size_out(), fold(), and map().

◆ size2_out() [2/2]

casadi_int casadi::Function::size2_out ( const std::string &  oname) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Definition at line 256 of file function.hpp.

256 {return size2_out(index_out(oname));}

References size2_out().

Referenced by size2_out().

◆ size_in() [1/2]

std::pair< casadi_int, casadi_int > casadi::Function::size_in ( casadi_int  ind) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Definition at line 843 of file function.cpp.

843  {
844  return (*this)->size_in(ind);
845  }

Referenced by casadi::DaeBuilderInternal::CallIO::calc_jac(), casadi::Integrator::get_reverse(), and casadi::Nlpsol::init().

◆ size_in() [2/2]

std::pair<casadi_int, casadi_int> casadi::Function::size_in ( const std::string &  iname) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1va

Definition at line 244 of file function.hpp.

244  {
245  return size_in(index_in(iname));
246  }
std::pair< casadi_int, casadi_int > size_in(casadi_int ind) const
Get input dimension.
Definition: function.cpp:843

◆ size_out() [1/2]

std::pair< casadi_int, casadi_int > casadi::Function::size_out ( casadi_int  ind) const

◆ size_out() [2/2]

std::pair<casadi_int, casadi_int> casadi::Function::size_out ( const std::string &  oname) const
inline

Extra doc: https://github.com/casadi/casadi/wiki/L_1vb

Definition at line 258 of file function.hpp.

258  {
259  return size_out(index_out(oname));
260  }
std::pair< casadi_int, casadi_int > size_out(casadi_int ind) const
Get output dimension.
Definition: function.cpp:847

◆ slice()

Function casadi::Function::slice ( const std::string &  name,
const std::vector< casadi_int > &  order_in,
const std::vector< casadi_int > &  order_out,
const Dict opts = Dict() 
) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1wl

Definition at line 746 of file function.cpp.

748  {
749  try {
750  return (*this)->slice(name, order_in, order_out, opts);
751  } catch(std::exception& e) {
752  THROW_ERROR("slice", e.what());
753  }
754  }

References name(), and casadi::FunctionInternal::slice().

Referenced by mapaccum(), and casadi::FunctionInternal::slice().

◆ sparsity_in() [1/2]

const Sparsity & casadi::Function::sparsity_in ( casadi_int  ind) const

◆ sparsity_in() [2/2]

const Sparsity & casadi::Function::sparsity_in ( const std::string &  iname) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vr

Definition at line 1023 of file function.cpp.

1023  {
1024  try {
1025  return sparsity_in(index_in(iname));
1026  } catch(std::exception& e) {
1027  THROW_ERROR("sparsity_in", e.what());
1028  }
1029  }

References index_in(), and sparsity_in().

◆ sparsity_jac() [1/4]

const Sparsity casadi::Function::sparsity_jac ( casadi_int  iind,
casadi_int  oind,
bool  compact = false,
bool  symmetric = false 
) const

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 906 of file function.cpp.

907  {
908  try {
909  return (*this)->jac_sparsity(oind, iind, compact, symmetric);
910  } catch(std::exception& e) {
911  THROW_ERROR("sparsity_jac", e.what());
912  }
913  }

Referenced by casadi::Blocksqp::init().

◆ sparsity_jac() [2/4]

const Sparsity casadi::Function::sparsity_jac ( casadi_int  iind,
const std::string &  oind,
bool  compact = false,
bool  symmetric = false 
) const
inline

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 490 of file function.hpp.

491  {
492  return sparsity_jac(iind, index_out(oind), compact, symmetric);
493  }
const Sparsity sparsity_jac(casadi_int iind, casadi_int oind, bool compact=false, bool symmetric=false) const
Definition: function.cpp:907

◆ sparsity_jac() [3/4]

const Sparsity casadi::Function::sparsity_jac ( const std::string &  iind,
casadi_int  oind = 0,
bool  compact = false,
bool  symmetric = false 
) const
inline

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 486 of file function.hpp.

487  {
488  return sparsity_jac(index_in(iind), oind, compact, symmetric);
489  }

◆ sparsity_jac() [4/4]

const Sparsity casadi::Function::sparsity_jac ( const std::string &  iind,
const std::string &  oind,
bool  compact = false,
bool  symmetric = false 
) const
inline

[DEPRECATED] Get, if necessary generate, the sparsity of a Jacobian block

Definition at line 494 of file function.hpp.

495  {
496  return sparsity_jac(index_in(iind), index_out(oind), compact, symmetric);
497  }

◆ sparsity_out() [1/2]

const Sparsity & casadi::Function::sparsity_out ( casadi_int  ind) const

◆ sparsity_out() [2/2]

const Sparsity & casadi::Function::sparsity_out ( const std::string &  iname) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vs

Definition at line 1039 of file function.cpp.

1039  {
1040  try {
1041  return sparsity_out(index_out(iname));
1042  } catch(std::exception& e) {
1043  THROW_ERROR("sparsity_out", e.what());
1044  }
1045  }

References index_out(), and sparsity_out().

◆ stats()

Dict casadi::Function::stats ( int  mem = 0) const

Definition at line 928 of file function.cpp.

928  {
929  if (!(*this)->has_memory(mem)) {
930  THROW_ERROR("stats",
931  "No stats available: Function/solver was not yet numerically evaluated.");
932  }
933  try {
934  return (*this)->get_stats(memory(mem));
935  } catch(std::exception& e) {
936  THROW_ERROR("stats", e.what());
937  }
938  }

References memory().

Referenced by casadi::DaeBuilder::get(), casadi::MXFunction::get_stats(), casadi::ImplicitToNlp::get_stats(), casadi::FunctionBuffer::stats(), and casadi::OptiNode::stats().

◆ swap()

Definition at line 106 of file generic_shared_impl.hpp.

120  {
121  GenericShared<Shared, Internal> temp = *this;
122  *this = other;
123  other = temp;
124  }

◆ sx_in() [1/3]

const std::vector< SX > casadi::Function::sx_in ( ) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Definition at line 1568 of file function.cpp.

1568  {
1569  try {
1570  return (*this)->sx_in();
1571  } catch(std::exception& e) {
1572  THROW_ERROR("sx_in", e.what());
1573  }
1574  }

Referenced by expand().

◆ sx_in() [2/3]

const SX casadi::Function::sx_in ( casadi_int  iind) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Definition at line 1552 of file function.cpp.

1552  {
1553  try {
1554  return (*this)->sx_in(iind);
1555  } catch(std::exception& e) {
1556  THROW_ERROR("sx_in", e.what());
1557  }
1558  }

Referenced by casadi::Matrix< Scalar >::get_input(), casadi::AmplInterface::init(), and casadi::qpsol_nlp().

◆ sx_in() [3/3]

const SX casadi::Function::sx_in ( const std::string &  iname) const
inline

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x4

Definition at line 950 of file function.hpp.

950  {
951  return sx_in(index_in(iname));
952  }

◆ sx_out() [1/3]

const std::vector< SX > casadi::Function::sx_out ( ) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Definition at line 1576 of file function.cpp.

1576  {
1577  try {
1578  return (*this)->sx_out();
1579  } catch(std::exception& e) {
1580  THROW_ERROR("sx_out", e.what());
1581  }
1582  }

◆ sx_out() [2/3]

const SX casadi::Function::sx_out ( casadi_int  oind) const

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Definition at line 1560 of file function.cpp.

1560  {
1561  try {
1562  return (*this)->sx_out(oind);
1563  } catch(std::exception& e) {
1564  THROW_ERROR("sx_out", e.what());
1565  }
1566  }

◆ sx_out() [3/3]

const SX casadi::Function::sx_out ( const std::string &  oname) const
inline

There is no guarantee that subsequent calls return unique answers

Extra doc: https://github.com/casadi/casadi/wiki/L_1x5

Definition at line 968 of file function.hpp.

968  {
969  return sx_out(index_out(oname));
970  }
const std::vector< SX > sx_out() const
Get symbolic primitives equivalent to the output expressions.
Definition: function.cpp:1576

◆ sz_arg()

size_t casadi::Function::sz_arg ( ) const

◆ sz_iw()

size_t casadi::Function::sz_iw ( ) const

◆ sz_res()

size_t casadi::Function::sz_res ( ) const

◆ sz_w()

size_t casadi::Function::sz_w ( ) const

◆ sz_work()

void casadi::Function::sz_work ( size_t &  sz_arg,
size_t &  sz_res,
size_t &  sz_iw,
size_t &  sz_w 
) const

◆ test_cast()

bool casadi::Function::test_cast ( const SharedObjectInternal ptr)
static

Definition at line 924 of file function.cpp.

924  {
925  return dynamic_cast<const FunctionInternal*>(ptr)!=nullptr;
926  }

◆ type_name()

static std::string casadi::Function::type_name ( )
inlinestatic

Extra doc: https://github.com/casadi/casadi/wiki/L_1ux

Definition at line 65 of file function.hpp.

65 {return "Function";}

◆ uses_output()

bool casadi::Function::uses_output ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1w3

Definition at line 883 of file function.cpp.

883  {
884  return (*this)->uses_output();
885  }

◆ weak()

Extra doc: https://github.com/casadi/casadi/wiki/L_aw

Definition at line 131 of file generic_shared_impl.hpp.

132  {
133  return (*this)->weak();
134  }

◆ which_depends()

std::vector< bool > casadi::Function::which_depends ( const std::string &  s_in,
const std::vector< std::string > &  s_out,
casadi_int  order = 1,
bool  tr = false 
) const
Parameters
[in]orderOnly 1 (linear) and 2 (nonlinear) allowed
[in]trFlip the relationship. Return which expressions contain the variables

Extra doc: https://github.com/casadi/casadi/wiki/L_1vx

Definition at line 1825 of file function.cpp.

1827  {
1828  try {
1829  return (*this)->which_depends(s_in, s_out, order, tr);
1830  } catch(std::exception& e) {
1831  THROW_ERROR("which_depends", e.what());
1832  }
1833  }
static std::vector< SX > order(const std::vector< SX > &expr)
Definition: function.cpp:1938

References order().

Referenced by casadi::BonminInterface::init(), casadi::IpoptInterface::init(), casadi::KnitroInterface::init(), and casadi::FunctionInternal::which_depends().

◆ wrap()

Function casadi::Function::wrap ( ) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vv

Definition at line 1916 of file function.cpp.

1916  {
1917  return (*this)->wrap();
1918  }

References casadi::FunctionInternal::wrap().

Referenced by casadi::FunctionInternal::which_depends().

◆ wrap_as_needed()

Function casadi::Function::wrap_as_needed ( const Dict opts) const

Extra doc: https://github.com/casadi/casadi/wiki/L_1vw

Definition at line 1920 of file function.cpp.

1920  {
1921  return (*this)->wrap_as_needed(opts);
1922  }

References casadi::FunctionInternal::wrap_as_needed().

Referenced by casadi::MapSum::create().


The documentation for this class was generated from the following files: