28 #include "shared_object.hpp"
29 #include "matrix_fwd.hpp"
32 #include "generic_matrix.hpp"
33 #include "generic_expression.hpp"
34 #include "generic_type.hpp"
35 #include "printable.hpp"
37 #ifdef CASADI_WITH_THREAD
38 #ifdef CASADI_WITH_THREAD_MINGW
39 #include <mingw.mutex.h>
52 class SerializingStream;
53 class DeserializingStream;
56 struct ConvexifyData {
57 std::vector<casadi_int> scc_offset, scc_mapping;
141 class CASADI_EXPORT
MX :
142 public SWIG_IF_ELSE(GenericExpressionCommon, GenericExpression<MX>),
143 public SWIG_IF_ELSE(PrintableCommon, Printable<MX>),
226 MX(casadi_int nrow, casadi_int ncol);
232 explicit MX(
const std::pair<casadi_int, casadi_int>& rc);
461 MX(
const std::vector<double> &x);
533 static std::vector<MX> createMultipleOutput(
MXNode* node);
573 typedef MX ScalarType;
678 void erase(
const std::vector<casadi_int>& rr,
const std::vector<casadi_int>& cc,
714 void erase(
const std::vector<casadi_int>& rr,
bool ind1=
false);
761 void enlarge(casadi_int nrow, casadi_int ncol,
762 const std::vector<casadi_int>& rr,
const std::vector<casadi_int>& cc,
832 const MXNode* operator->()
const;
1127 explicit operator double()
const;
2027 bool has_duplicates()
const;
2032 void reset_input()
const;
2613 casadi_int get_temp()
const;
2616 void set_temp(casadi_int t)
const;
2680 bool unique_x=
false,
bool unique_y=
false);
2681 static MX unary(casadi_int op,
const MX &x,
bool unique=
false);
2716 static MX inf(casadi_int nrow=1, casadi_int ncol=1);
2717 static MX inf(
const std::pair<casadi_int, casadi_int>& rc);
2751 static MX nan(casadi_int nrow=1, casadi_int ncol=1);
2752 static MX nan(
const std::pair<casadi_int, casadi_int>& rc);
2793 MX nzref(
const Sparsity& sp,
const std::vector<casadi_int>& nz)
const;
2890 void get(
MX& SWIG_OUTPUT(m),
bool ind1,
const MX& rr)
const;
2891 void get(
MX& SWIG_OUTPUT(m),
bool ind1,
const casadi_int rr)
const {
2953 void get(
MX& SWIG_OUTPUT(m),
bool ind1,
const Slice& rr, casadi_int cc)
const {
2957 void get(
MX& SWIG_OUTPUT(m),
bool ind1, casadi_int rr,
const Slice& cc)
const {
2962 void get(
MX& SWIG_OUTPUT(m),
bool ind1, casadi_int rr,
2963 casadi_int cc)
const {
2966 void get(
MX& SWIG_OUTPUT(m),
bool ind1,
const MX& rr,
const Slice& cc)
const;
2967 void get(
MX& SWIG_OUTPUT(m),
bool ind1,
const Slice& rr,
const MX& cc)
const;
2968 void get(
MX& SWIG_OUTPUT(m),
bool ind1,
const MX& rr,
const MX& cc)
const;
3175 void get_nz(
MX& SWIG_OUTPUT(m),
bool ind1, casadi_int kk)
const {
3180 void get_nz(
MX& SWIG_OUTPUT(m),
bool ind1,
const MX& inner,
const MX& outer)
const;
3311 const std::vector<casadi_int>& dim_a,
const std::vector<casadi_int>& dim_b,
3312 const std::vector<casadi_int>& dim_c,
3313 const std::vector<casadi_int>& a,
const std::vector<casadi_int>& b,
3314 const std::vector<casadi_int>& c);
3317 const std::vector<casadi_int>& dim_a,
const std::vector<casadi_int>& dim_b,
3318 const std::vector<casadi_int>& dim_c,
3319 const std::vector<casadi_int>& a,
const std::vector<casadi_int>& b,
3320 const std::vector<casadi_int>& c);
3327 static bool is_equal(
const MX& x,
const MX& y, casadi_int depth=0);
3328 static MX mmin(
const MX &x);
3329 static MX mmax(
const MX &x);
3334 static MX horzcat(
const std::vector<MX>& x);
3335 static MX diagcat(
const std::vector<MX>& x);
3336 static MX vertcat(
const std::vector<MX>& x);
3337 static std::vector<MX> horzsplit(
const MX& x,
const std::vector<casadi_int>& offset);
3338 static std::vector<MX> diagsplit(
const MX& x,
const std::vector<casadi_int>& offset1,
3339 const std::vector<casadi_int>& offset2);
3340 static std::vector<MX> vertsplit(
const MX& x,
const std::vector<casadi_int>& offset);
3341 static MX blockcat(
const std::vector< std::vector<MX > > &v);
3342 static MX mtimes(
const MX& x,
const MX& y,
3343 const std::string& blas =
"reference");
3344 static MX mac(
const MX& x,
const MX& y,
const MX& z,
3345 const std::string& blas =
"reference");
3346 static MX reshape(
const MX& x, casadi_int nrow, casadi_int ncol);
3348 static MX sparsity_cast(
const MX& x,
const Sparsity& sp);
3349 static MX kron(
const MX& x,
const MX& b);
3351 static MX repmat(
const MX& x, casadi_int n, casadi_int m=1);
3356 static MX linspace(
const MX& a,
const MX& b, casadi_int nsteps);
3357 static MX jacobian(
const MX& f,
const MX& x,
const Dict& opts =
Dict());
3358 static MX hessian(
const MX& f,
const MX& x,
const Dict& opts =
Dict());
3359 static MX hessian(
const MX& f,
const MX& x,
MX& g,
const Dict& opts =
Dict());
3360 static std::vector<std::vector<MX> >
3361 forward(
const std::vector<MX> &ex,
3362 const std::vector<MX> &arg,
3363 const std::vector<std::vector<MX> > &v,
3365 static std::vector<std::vector<MX> >
3366 reverse(
const std::vector<MX> &ex,
3367 const std::vector<MX> &arg,
3368 const std::vector<std::vector<MX> > &v,
3370 static std::vector<bool> which_depends(
const MX &expr,
const MX &var,
3371 casadi_int order=1,
bool tr=
false);
3372 static Sparsity jacobian_sparsity(
const MX& f,
const MX& x);
3373 static MX substitute(
const MX& ex,
const MX& v,
const MX& vdef);
3374 static std::vector<MX> substitute(
const std::vector<MX> &ex,
3375 const std::vector<MX> &v,
3376 const std::vector<MX> &vdef);
3377 static void substitute_inplace(
const std::vector<MX>& v,
3378 std::vector<MX>& vdef,
3379 std::vector<MX>& ex,
bool reverse);
3380 static MX solve(
const MX& a,
const MX& b);
3381 static MX solve(
const MX& a,
const MX& b,
const std::string& lsolver,
3383 static MX inv_minor(
const MX& A);
3384 static MX inv_node(
const MX& A);
3385 static MX inv(
const MX& A,
const std::string& lsolver=
"qr",
const Dict& dict =
Dict());
3386 static MX pinv(
const MX& A,
const std::string& lsolver=
"qr",
3388 static MX expm_const(
const MX& A,
const MX& t);
3389 static MX expm(
const MX& A);
3390 static casadi_int n_nodes(
const MX& x);
3391 static std::string print_operator(
const MX& x,
const std::vector<std::string>& args);
3392 static void extract(std::vector<MX>& ex, std::vector<MX>& v,
3393 std::vector<MX>& vdef,
const Dict& opts =
Dict());
3394 static void shared(std::vector<MX>& ex, std::vector<MX>& v,
3395 std::vector<MX>& vdef,
const std::string& v_prefix,
const std::string& v_suffix);
3396 static MX if_else(
const MX& cond,
const MX& if_true,
3397 const MX& if_false,
bool short_circuit=
false);
3398 static MX conditional(
const MX& ind,
const std::vector<MX> &x,
const MX& x_default,
3399 bool short_circuit=
false);
3400 static bool depends_on(
const MX& x,
const MX& arg);
3401 static bool contains_all(
const std::vector<MX>& v,
const std::vector<MX> &n);
3402 static bool contains_any(
const std::vector<MX>& v,
const std::vector<MX> &n);
3403 static MX simplify(
const MX& x);
3404 static MX transform(
const MX& x,
const Dict& opts =
Dict());
3405 static MX transform(
const MX& x,
3406 const std::vector<std::vector<GenericType> >& passes,
const Dict& opts =
Dict());
3407 static std::vector<MX> transform(
const std::vector<MX>& x,
const Dict& opts =
Dict());
3408 static std::vector<MX> transform(
const std::vector<MX>& x,
3409 const std::vector<std::vector<GenericType> >& passes,
const Dict& opts =
Dict());
3410 static MX dot(
const MX& x,
const MX& y);
3411 static MX mrdivide(
const MX& a,
const MX& b);
3412 static MX mldivide(
const MX& a,
const MX& b);
3413 static MX norm_2(
const MX& x);
3414 static MX norm_fro(
const MX& x);
3415 static MX norm_1(
const MX& x);
3416 static MX norm_inf(
const MX& x);
3417 static MX unite(
const MX& A,
const MX& B);
3418 static MX trace(
const MX& x);
3419 static MX diag(
const MX& x);
3420 static MX sum2(
const MX& x);
3421 static MX sum1(
const MX& x);
3422 static MX polyval(
const MX& p,
const MX& x);
3423 static MX det(
const MX& x);
3424 static MX det(
const MX& x,
const std::string& lsolver,
const Dict& opts=
Dict());
3425 static std::vector<MX> symvar(
const MX& x);
3426 static MX nullspace(
const MX& A);
3427 static MX repsum(
const MX& x, casadi_int n, casadi_int m=1);
3428 static MX densify(
const MX& x,
const MX& val=0);
3429 static MX _bilin(
const MX& A,
const MX& x,
const MX& y);
3430 static MX _rank1(
const MX& A,
const MX& alpha,
const MX& x,
const MX& y);
3431 static MX project(
const MX& x,
const Sparsity& sp,
bool intersect=
false);
3432 static MX cumsum(
const MX &x, casadi_int axis=-1);
3433 static MX _logsumexp(
const MX& x);
3434 static std::vector<MX> cse(
const std::vector<MX>& e);
3435 static void extract_parametric(
const MX &expr,
const MX& par,
3436 MX& expr_ret, std::vector<MX>& symbols, std::vector<MX>& parametric,
const Dict& opts);
3437 static void separate_linear(
const MX &expr,
3438 const MX &sym_lin,
const MX &sym_const,
3439 MX& expr_const,
MX& expr_lin,
MX& expr_nonlin);
3444 static MX find(
const MX& x);
3445 static MX low(
const MX& v,
const MX& p,
const Dict& options =
Dict());
3446 static MX graph_substitute(
const MX& x,
const std::vector<MX> &v,
3447 const std::vector<MX> &vdef);
3448 static MX graph_substitute(
const MX& x,
const std::vector<MX> &v,
3449 const std::vector<MX> &vdef,
bool& updated);
3450 static std::vector<MX> graph_substitute(
const std::vector<MX> &ex,
3451 const std::vector<MX> &v,
3452 const std::vector<MX> &vdef);
3453 static std::vector<MX> graph_substitute(
const std::vector<MX> &ex,
3454 const std::vector<MX> &v,
3455 const std::vector<MX> &vdef,
3457 static MX matrix_expand(
const MX& e,
const std::vector<MX> &boundary,
3458 const Dict& options);
3459 static std::vector<MX> matrix_expand(
const std::vector<MX>& e,
3460 const std::vector<MX>& boundary,
3461 const Dict& options);
3462 static MX lift(
const MX& x,
const MX& x_guess);
3463 static DM evalf(
const MX& m);
3464 static MX bspline(
const MX& x,
3466 const std::vector< std::vector<double> >& knots,
3467 const std::vector<casadi_int>& degree,
3470 static MX bspline(
const MX& x,
const MX& coeffs,
3471 const std::vector< std::vector<double> >& knots,
3472 const std::vector<casadi_int>& degree,
3475 static MX bspline(
const MX& x,
const MX& coeffs,
3476 const std::vector<MX>& knots,
3477 const std::vector<casadi_int>& degree,
3480 static MX convexify(
const MX& H,
const Dict& opts =
Dict());
3481 static MX stop_diff(
const MX& expr, casadi_int order);
3482 static MX stop_diff(
const MX& expr,
const MX& var, casadi_int order);
3483 static std::vector<MX> difference(
const std::vector<MX>& a,
const std::vector<MX>& b);
3491 std::vector<MX>& res,
3496 std::vector<MX>& res,
3501 std::vector<MX>& res,
3555 const std::vector< std::vector<double> >& knots,
3556 const std::vector<casadi_int>& degree,
3669 #if !defined(SWIG) || defined(DOXYGEN)
3803 return MX::low(v, p, options);
3888 const std::vector<MX> &vdef) {
3893 const std::vector<MX> &vdef,
bool& updated) {
3934 inline friend std::vector<MX>
3936 const std::vector<MX> &v,
3937 const std::vector<MX> &vdef) {
3941 inline friend std::vector<MX>
3943 const std::vector<MX> &v,
3944 const std::vector<MX> &vdef,
4030 inline friend std::vector<MX>
4032 const std::vector<MX> &boundary = std::vector<MX>(),
4117 const std::vector< std::vector<double> >& knots,
4118 const std::vector<casadi_int>& degree,
4121 return MX::bspline(x, coeffs, knots, degree, m, opts);
4170 const std::vector< std::vector<double> >& knots,
4171 const std::vector<casadi_int>& degree,
4174 return MX::bspline(x, coeffs, knots, degree, m, opts);
4217 const std::vector<MX>& knots,
4218 const std::vector<casadi_int>& degree,
4221 return MX::bspline(x, coeffs, knots, degree, m, opts);
4226 const std::vector< std::vector<double> >& knots,
4227 const std::vector<casadi_int>& degree,
4674 inline friend std::vector<MX>
difference(
const std::vector<MX>& a,
const std::vector<MX>& b) {
5110 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& SWIG_OUTPUT(res),
5111 const std::vector<bool>& unique=std::vector<bool>())
const;
5118 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
5119 std::vector<std::vector<MX> >& fsens)
const;
5120 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
5121 std::vector<std::vector<MX> >& asens)
const;
5125 MX(
const Sparsity& sp,
double val,
bool dummy);
5128 static MX _sym(
const std::string& name,
const Sparsity& sp);
5130 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
5131 static std::mutex& get_mutex_temp() {
return mutex_temp; }
5132 static std::mutex mutex_temp;
5137 MX(
MXNode* node,
bool dummy1,
bool dummy2,
bool dummy3,
bool dummy4);
5140 static casadi_int eq_depth_;
5214 return MX::kron_contract(m, x, inner);
5225 CASADI_EXPORT std::string export_graph(
const MX& expression,
const Dict& opts=
Dict());
5226 CASADI_EXPORT std::string export_graph(
const std::vector<MX>& expressions,
5228 CASADI_EXPORT
void export_graph(
const MX& expression,
const std::string& fname,
5230 CASADI_EXPORT
void export_graph(
const std::vector<MX>& expressions,
const std::string& fname,
Helper class for Serialization.
Node class for MX objects.
void get_nz(MX &m, bool ind1, casadi_int kk) const
Get a set of nonzeros (what x.nz[k] does)
void erase(const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, bool ind1=false)
Erase a submatrix (leaving structural zeros in its place)
static std::vector< MX > get_free(const Function &f)
Get the free variables of a Function.
static bool simplify_const_folding(std::vector< MX > &arg, std::vector< MX > &res, const Dict &opts=Dict())
static bool simplify_ref_count(std::vector< MX > &arg, std::vector< MX > &res, const Dict &opts=Dict())
bool is_multiplication() const
Check if the node is a matrix product (mtimes)
bool is_minus_one() const
Check if the node is a constant with all nonzeros -1 (false negatives possible)
bool is_valid_input() const
Check if the expression can be used as a Function input.
static bool test_cast(const SharedObjectInternal *ptr)
Check if a SharedObjectInternal pointer refers to an MX node (C++ only)
bool is_eye() const
Check if the node is a constant identity matrix.
void get_nz(MX &m, bool ind1, const Slice &inner, const MX &outer) const
Get a set of nonzeros (what x.nz[k] does)
bool is_value(double val) const
Check if the node is a constant with all nonzeros equal to val.
static casadi_int get_max_depth()
Get the depth to which equalities are checked for simplifications.
static MX binary(casadi_int op, const MX &x, const MX &y, bool unique_x=false, bool unique_y=false)
Create an elementwise binary or unary node from an operation code.
static MX nan(const Sparsity &sp)
Create a constant with all nonzeros NaN.
std::vector< MX > split_primitives(const MX &x) const
Split a value along the symbolic primitives of this expression.
MX operator-() const
Unary minus.
bool is_output() const
Check if the node selects one output of a multiple-output node.
casadi_int n_out() const
Number of outputs of this node.
void get(MX &m, bool ind1, const Sparsity &sp) const
Get a submatrix by linear index (what x[k] does)
void erase(const std::vector< casadi_int > &rr, bool ind1=false)
Erase elements (leaving structural zeros in their place)
static MX deserialize(DeserializingStream &s)
Deserialize an expression from a stream, with type disambiguation.
static MX eye(casadi_int n)
Identity matrix constant of size n-by-n, with a diagonal sparsity pattern.
casadi_int n_dep() const
Get the number of dependencies (child nodes) of this node.
void get(MX &m, bool ind1, const MX &rr, const MX &cc) const
Get a submatrix by row and column index (what x[i, j] does)
casadi_int n_primitives() const
Get the number of symbolic primitives in a valid Function input.
void set(const MX &m, bool ind1, const Matrix< casadi_int > &rr)
Assign to a submatrix by linear index (what x[k] = m does)
bool __nonzero__() const
Truth value of a 1-by-1 constant.
bool is_half() const
Check if the node is a constant with all nonzeros 0.5 (false negatives possible)
void get(MX &m, bool ind1, const MX &rr) const
Get a submatrix by linear index (what x[k] does)
static MX inf(casadi_int nrow=1, casadi_int ncol=1)
Create a constant with all nonzeros +inf.
bool is_call() const
Check if the node is a call to a Function.
std::string name() const
Get the name of a symbolic primitive.
bool has_output() const
Check if this is a multiple-output node.
bool is_integer() const
Check if the node is a constant with integer-valued nonzeros.
void get(MX &m, bool ind1, const MX &rr, const Slice &cc) const
Get a submatrix by row and column index (what x[i, j] does)
MX(const Sparsity &sp, const std::string &fname)
Construct a constant whose nonzeros are read from a text file.
bool is_inf() const
Check if the node is a constant with all nonzeros +inf (false negatives possible)
void set(const MX &m, bool ind1, const Slice &rr, const Slice &cc)
Assign to a submatrix by row and column index (what x[i, j] = m does)
bool is_constant() const
Check if the node is a constant.
Sparsity get_sparsity() const
Get an owning reference to the sparsity pattern.
MX operator+() const
Unary plus: returns the expression itself.
static MX nan(const std::pair< casadi_int, casadi_int > &rc)
Create a constant with all nonzeros NaN.
MX dump(const std::string &base_filename, const Dict &opts=Dict()) const
Return the expression with the side effect of writing its value to a file.
void reset_dump_count()
Reset the file counter of a dump node; raises an error on any other node.
bool is_commutative() const
Check if a binary operation is commutative.
MX(const Sparsity &sp, const MX &val)
Construct a matrix with a given sparsity pattern and given nonzeros.
static MX einstein(const MX &A, const MX &B, const MX &C, const std::vector< casadi_int > &dim_a, const std::vector< casadi_int > &dim_b, const std::vector< casadi_int > &dim_c, const std::vector< casadi_int > &a, const std::vector< casadi_int > &b, const std::vector< casadi_int > &c)
Compute a dense tensor contraction in Einstein notation.
void set_nz(const MX &m, bool ind1, casadi_int kk)
Assign to a set of nonzeros (what x.nz[k] = m does)
void set_nz(const MX &m, bool ind1, const MX &kk)
Assign to a set of nonzeros (what x.nz[k] = m does)
void get(MX &m, bool ind1, const casadi_int rr) const
Get a submatrix by linear index (what x[k] does)
void set(const MX &m, bool ind1, const Sparsity &sp)
Assign to a submatrix by linear index (what x[k] = m does)
void get_nz(MX &m, bool ind1, const MX &inner, const MX &outer) const
Get a set of nonzeros (what x.nz[k] does)
void get_nz(MX &m, bool ind1, const MX &kk) const
Get a set of nonzeros (what x.nz[k] does)
static void set_max_depth(casadi_int eq_depth=1)
Set the depth to which equalities are checked for simplifications.
DM join_primitives(const std::vector< DM > &v) const
Join values along the symbolic primitives of this expression.
static MX unary(casadi_int op, const MX &x, bool unique=false)
Create an elementwise binary or unary node from an operation code.
MX T() const
Transpose the matrix.
void get(MX &m, bool ind1, const Slice &rr, const Matrix< casadi_int > &cc) const
Get a submatrix by row and column index (what x[i, j] does)
void get(MX &m, bool ind1, const Slice &rr, const MX &cc) const
Get a submatrix by row and column index (what x[i, j] does)
void get(MX &m, bool ind1, casadi_int rr, casadi_int cc) const
Get a submatrix by row and column index (what x[i, j] does)
MX(casadi_int nrow, casadi_int ncol)
Create a sparse matrix with all structural zeros.
void get(MX &m, bool ind1, const Slice &rr, casadi_int cc) const
Get a submatrix by row and column index (what x[i, j] does)
Function which_function() const
Get the Function of a call node.
void get(MX &m, bool ind1, const Slice &rr, const Slice &cc) const
Get a submatrix by row and column index (what x[i, j] does)
void get_nz(MX &m, bool ind1, const MX &inner, const Slice &outer) const
Get a set of nonzeros (what x.nz[k] does)
static MX inf(const std::pair< casadi_int, casadi_int > &rc)
Create a constant with all nonzeros +inf.
void get(MX &m, bool ind1, const Matrix< casadi_int > &rr, const Slice &cc) const
Get a submatrix by row and column index (what x[i, j] does)
MX(double x)
Create a 1-by-1 constant (also used for implicit conversion from a number)
MX(const Sparsity &sp)
Create a constant with a given sparsity pattern and all nonzeros equal to one.
static std::string type_name()
Get type name.
bool is_op(casadi_int op) const
Check if the node is a certain operation.
void get(MX &m, bool ind1, const Matrix< casadi_int > &rr) const
Get a submatrix by linear index (what x[k] does)
bool is_minus_inf() const
Check if the node is a constant with all nonzeros -inf (false negatives possible)
bool is_norm() const
Check if the node is a norm (norm_1, norm_2, norm_inf or norm_fro)
void set_nz(const MX &m, bool ind1, const Slice &kk)
Assign to a set of nonzeros (what x.nz[k] = m does)
static bool simplify_combine_terms(std::vector< MX > &arg, std::vector< MX > &res, const Dict &opts=Dict())
MX()
Default constructor: a 0-by-0 constant.
bool is_regular() const
Check that a constant node contains neither NaN nor Inf.
MX(const Matrix< double > &val, const std::string &name)
Construct a named constant that generated code exposes as a modifiable pool.
casadi_int which_output() const
Get the output index of an OutputNode.
void serialize(SerializingStream &s) const
Serialize the expression to a stream.
static MX nan(casadi_int nrow=1, casadi_int ncol=1)
Create a constant with all nonzeros NaN.
MX inv() const
Element-wise inverse, 1/x.
void set(const MX &m, bool ind1, const Slice &rr, const Matrix< casadi_int > &cc)
Assign to a submatrix by row and column index (what x[i, j] = m does)
SX join_primitives(const std::vector< SX > &v) const
Join values along the symbolic primitives of this expression.
MX attachAssert(const MX &y, const std::string &fail_message="") const
Return the expression with a run-time assertion attached.
Dict info() const
Obtain information about the node as a dictionary.
std::map< std::string, MX > MXDict
Readability typedef.
void set(const MX &m, bool ind1, const Slice &rr)
Assign to a submatrix by linear index (what x[k] = m does)
std::vector< MX > primitives() const
Get the symbolic primitives of a valid Function input.
bool is_one() const
Check if the node is a constant with all nonzeros one (false negatives possible)
void get_nz(MX &m, bool ind1, const Matrix< casadi_int > &kk) const
Get a set of nonzeros (what x.nz[k] does)
std::vector< DM > split_primitives(const DM &x) const
Split a value along the symbolic primitives of this expression.
void get(MX &m, bool ind1, const Slice &rr) const
Get a submatrix by linear index (what x[k] does)
void set(const MX &m, bool ind1, const Matrix< casadi_int > &rr, const Matrix< casadi_int > &cc)
Assign to a submatrix by row and column index (what x[i, j] = m does)
std::vector< MX > get_nonzeros() const
Get the nonzeros as a list of 1-by-1 expressions.
MX join_primitives(const std::vector< MX > &v) const
Join values along the symbolic primitives of this expression.
void get(MX &m, bool ind1, const Matrix< casadi_int > &rr, const Matrix< casadi_int > &cc) const
Get a submatrix by row and column index (what x[i, j] does)
MX(const Matrix< double > &x)
Create a constant from a DM (also used for implicit conversion)
MX dep(casadi_int ch=0) const
Get the ch-th dependency (child node) of this node.
void set(const MX &m, bool ind1, const Matrix< casadi_int > &rr, const Slice &cc)
Assign to a submatrix by row and column index (what x[i, j] = m does)
MX monitor(const std::string &comment) const
Return the expression with the side effect of printing its value.
Matrix< casadi_int > mapping() const
Get the nonzero mapping of a GetNonzeros or SetNonzeros node.
static MX interpn_linear(const std::vector< MX > &x, const MX &v, const std::vector< MX > &xq, const Dict &opts=Dict())
Low-level inlined multilinear interpolation.
bool is_binary() const
Check if the node is an elementwise binary operation.
void set_nz(const MX &m, bool ind1, const Matrix< casadi_int > &kk)
Assign to a set of nonzeros (what x.nz[k] = m does)
void get(MX &m, bool ind1, casadi_int rr, const Slice &cc) const
Get a submatrix by row and column index (what x[i, j] does)
std::vector< SX > split_primitives(const SX &x) const
Split a value along the symbolic primitives of this expression.
bool is_unary() const
Check if the node is an elementwise unary operation.
static MX einstein(const MX &A, const MX &B, const std::vector< casadi_int > &dim_a, const std::vector< casadi_int > &dim_b, const std::vector< casadi_int > &dim_c, const std::vector< casadi_int > &a, const std::vector< casadi_int > &b, const std::vector< casadi_int > &c)
Compute a dense tensor contraction in Einstein notation.
bool is_zero() const
Check if the node is a constant zero (false negatives are possible)
bool is_transpose() const
Check if the node is a transpose operation.
void get_nz(MX &m, bool ind1, const Slice &kk) const
Get a set of nonzeros (what x.nz[k] does)
bool is_doubled() const
Check if the node is the sum of two equal expressions, or 2*x.
bool is_symbolic() const
Check if the node is a symbolic primitive (created by MX.sym)
void enlarge(casadi_int nrow, casadi_int ncol, const std::vector< casadi_int > &rr, const std::vector< casadi_int > &cc, bool ind1=false)
Enlarge matrix.
MX printme(const MX &b) const
Return the expression with the side effect of printing its value with a tag.
static std::vector< MX > get_input(const Function &f)
Get the symbolic inputs of a Function, as MX.
MX get_output(casadi_int oind) const
Get an output of a multiple-output node.
casadi_int op() const
Get the operation type of the node.
void eval_mx(const std::vector< MX > &arg, std::vector< MX > &res, const std::vector< bool > &unique=std::vector< bool >()) const
Re-apply the operation of this node to new dependencies.
bool is_nonnegative() const
Check if a value is always nonnegative (false negatives are allowed)
static DM bspline_dual(const std::vector< double > &x, const std::vector< std::vector< double > > &knots, const std::vector< casadi_int > °ree, const Dict &opts=Dict())
Evaluate the B-spline basis functions at given points.
static MX inf(const Sparsity &sp)
Create a constant with all nonzeros +inf.
Helper class for Serialization.
GenericShared implements a reference counting framework similar for efficient and.
Class representing a Slice.
std::map< std::string, MX > MXDict
std::vector< MX > MXVector
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
std::vector< MXVector > MXVectorVector
MX kron_contract(const MX &m, const MX &x, bool inner)
Kronecker contraction, the adjoint of kron.
std::initializer_list< MX > MXIList