26 #ifndef CASADI_CALL_SX_HPP
27 #define CASADI_CALL_SX_HPP
29 #include "sx_node.hpp"
30 #include "output_sx.hpp"
31 #include "function.hpp"
36 #include <unordered_map>
37 #define CACHING_MAP std::unordered_map
58 casadi_assert(f.
nnz_in()==dep.size(),
59 "CallSX::create(f,dep): dimension mismatch: " +
str(f.
nnz_in()) +
" vs " +
str(dep.size()));
65 std::vector<SXElem> dep;
66 for (casadi_int i=0;i<f.
n_in();++i) {
67 dep.insert(dep.end(), arg[i], arg[i]+f.
nnz_in(i));
73 casadi_int offset = 0;
74 for (casadi_int i=0;i<f.
n_out();++i) {
94 std::string
class_name()
const override {
return "CallSX";}
101 casadi_int
n_dep()
const override {
return dep_.size();}
109 if (!cache_.
incache(oind, ret)) {
119 const SXElem&
dep(casadi_int i)
const override {
return dep_[i];}
130 bool is_call()
const override {
return true; }
145 std::string
print(
const std::string& arg1,
const std::string& arg2)
const override {
157 s.
pack(
"CallSX::f", f_);
158 s.
pack(
"CallSX::dep", dep_);
162 std::vector<SXElem> dep;
165 s.
unpack(
"CallSX::dep", dep);
166 return new CallSX(f, dep);
casadi_int n_dep() const override
Number of dependencies.
static SXNode * deserialize(DeserializingStream &s)
SXElem & dep(casadi_int i) override
get the reference of a child
bool has_output() const override
Check if a multiple output node.
bool is_op(casadi_int op) const override
check properties of a node
SXElem get_output(casadi_int oind) const override
Get an output.
std::vector< SXElem > dep_
The dependencies of the node.
bool is_call() const override
Check if call node.
Function which_function() const override
Get function.
const SXElem & dep(casadi_int i) const override
get the reference of a dependency
static SXElem create(const Function &f, const std::vector< SXElem > &dep)
Create a binary expression.
void serialize_node(SerializingStream &s) const override
casadi_int op() const override
Get the operation.
std::string print(const std::string &arg1, const std::string &arg2) const override
Print expression.
static int eval_sx(const Function &f, const SXElem **arg, SXElem **res)
~CallSX() override
Destructor.
std::string class_name() const override
Get type name.
Helper class for Serialization.
void unpack(Sparsity &e)
Reconstruct an object from the input stream.
casadi_int nnz_out() const
Get number of output nonzeros.
casadi_int n_out() const
Get the number of function outputs.
casadi_int n_in() const
Get the number of function inputs.
casadi_int nnz_in() const
Get number of input nonzeros.
Internal * get() const
Get a const pointer to the node.
The basic scalar symbolic class of CasADi.
static std::vector< SXElem > call(const Function &f, const std::vector< SXElem > &deps)
static SXElem create(SXNode *node)
Internal node class for SX.
SXElem shared_from_this()
Get a shared object from the current internal object.
Helper class for Serialization.
void pack(const Sparsity &e)
Serializes an object to the output stream.
bool incache(const K &key, T &f, bool needs_lock=true) const
void tocache_if_missing(const K &key, T &f)
void casadi_copy(const T1 *x, casadi_int n, T1 *y)
COPY: y <-x.
std::string str(const T &v)
String representation, any type.
T * get_ptr(std::vector< T > &v)
Get a pointer to the data contained in the vector.