CasADi Python API

1. Expression tools

acos(*args)

Arc cosine: x -> acos(x)

acos(float x) -> float
acos(DM x) -> DM
acos(SX x) -> SX
acos(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L374

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L374-L376

acosh(*args)

Inverse hyperbolic cosine: x -> acosh(x)

acosh(float x) -> float
acosh(DM x) -> DM
acosh(SX x) -> SX
acosh(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L446

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L446-L448

adj(*args)

Matrix adjoint.

adj(DM A) -> DM
adj(SX A) -> SX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L504

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L504-L506

asin(*args)

Arc sine: x -> asin(x)

asin(float x) -> float
asin(DM x) -> DM
asin(SX x) -> SX
asin(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L362

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L362-L364

asinh(*args)

Inverse hyperbolic sin: x -> asinh(x)

asinh(float x) -> float
asinh(DM x) -> DM
asinh(SX x) -> SX
asinh(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L434

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L434-L436

atan(*args)

Arc tangent: x -> atan(x)

atan(float x) -> float
atan(DM x) -> DM
atan(SX x) -> SX
atan(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L350

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L350-L352

atan2(*args)

Two argument arc tangent: (y,x) -> atan2(y,x)

atan2(float x, float y) -> float
atan2(DM x, DM y) -> DM
atan2(SX x, SX y) -> SX
atan2(MX x, MX y) -> MX

theta = atan2(y,x) corresponds to x = r cos(theta), y = r sin(theta)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L648

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L648-L650

atanh(*args)

Inverse hyperbolic tangent: x -> atanh(x)

atanh(float x) -> float
atanh(DM x) -> DM
atanh(SX x) -> SX
atanh(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L422

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L422-L424

bilin(*args)

Calculate bilinear/quadratic form x^T A y.

bilin(DM A, DM x) -> DM
bilin(SX A, SX x) -> SX
bilin(MX A, MX x) -> MX
bilin(DM A, DM x, DM y) -> DM
bilin(SX A, SX x, SX y) -> SX
bilin(MX A, MX x, MX y) -> MX

1. Parameters:

y: can be omitted, in which case x^T A x is calculated

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L409

blockcat(*args)

Construct a matrix from 4 blocks.

blockcat([[DM]] v) -> DM
blockcat([[SX]] v) -> SX
blockcat([[MX]] v) -> MX
blockcat(Sparsity A, Sparsity B, Sparsity C, Sparsity D) -> Sparsity
blockcat(DM A, DM B, DM C, DM D) -> DM
blockcat(SX A, SX B, SX C, SX D) -> SX
blockcat(MX A, MX B, MX C, MX D) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L234

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L234-L236

bspline(*args)
bspline(MX x, DM coeffs, [[float]] knots, [int] degree, int m, dict opts) -> MX
bspline(MX x, MX coeffs, [[float]] knots, [int] degree, int m, dict opts) -> MX
ceil(*args)

Round up to nearest integer: x -> ceil(x)

ceil(float x) -> float
ceil(DM x) -> DM
ceil(SX x) -> SX
ceil(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L530

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L530-L532

chol(*args)

Obtain a Cholesky factorisation of a matrix.

chol(DM A) -> DM
chol(SX A) -> SX

Performs and LDL transformation [L,D] = ldl(A) and returns diag(sqrt(D))*L’

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L562

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L562-L564

cofactor(*args)

Get the (i,j) cofactor matrix.

cofactor(DM x, int i, int j) -> DM
cofactor(SX x, int i, int j) -> SX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L518

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L518-L520

collocation_coeff(*args)

[INTERNAL]

collocation_coeff([float] tau) -> (DM OUTPUT, DM OUTPUT, DM OUTPUT)

Obtain collocation interpolating matrices.

A collocation method poses a polynomial Pi that interpolates exactly

through an initial state (0,X_0) and helper states at collocation points (tau_j,Xc_j) with j=1..degree.

This function computes the linear mapping between dPi/dt and coefficients Z=[X_0 Xc].

1. Parameters:

tau: location of collocation points (length: degree), as obtained from

collocation_points

C: interpolating coefficients to obtain derivatives. Size: (degree+1)-by-

degree

You may find the slopes of Pi at the collocation points as

dPi/dt @ Xc = (1/h) Z*C,

with h the length of the integration interval.

1. Parameters:

D: interpolating coefficients to obtain end state. Size: (degree+1)-by-1

You may find the end point of Pi as

Pi @X_f = Z*D

1. Parameters:

B: quadrature coefficients Size: degree-by-1

Given quadrature righ-hand-sides ‘quad’ evaluated at the collocation

points, you may find the integrated quadratures as

q = quad*B*h

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L233

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L233-L287

collocation_points(*args)

[INTERNAL]

collocation_points(int order, str scheme) -> [float]

Obtain collocation points of specific order and scheme.

1. Parameters:

order: Which order (1 to 9 supported)

scheme: ‘radau’ or ‘legendre’

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L120

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L120-L122

conditional(*args)

Create a switch.

conditional(DM ind, [DM] x, DM x_default, bool short_circuit) -> DM
conditional(SX ind, [SX] x, SX x_default, bool short_circuit) -> SX
conditional(MX ind, [MX] x, MX x_default, bool short_circuit) -> MX

If the condition

1. Parameters:

ind: evaluates to the integer k, where 0<=k<f.size(), then x[k] will be

returned, otherwise

x_default: will be returned.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L647

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L647-L650

constpow(*args)

Elementwise power with const power

constpow(float x, float y) -> float
constpow(DM x, DM y) -> DM
constpow(SX x, SX y) -> SX
constpow(MX x, MX y) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L720

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L720-L722

convexify(*args)
convexify(MX H, dict opts) -> MX
copysign(*args)

Copy sign

copysign(float x, float y) -> float
copysign(DM x, DM y) -> DM
copysign(SX x, SX y) -> SX
copysign(MX x, MX y) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L710

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L710-L712

cos(*args)

Cosine: x -> cos(x)

cos(float x) -> float
cos(DM x) -> DM
cos(SX x) -> SX
cos(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L326

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L326-L328

cosh(*args)

Hyperbolic cosine: x -> cosh(x)

cosh(float x) -> float
cosh(DM x) -> DM
cosh(SX x) -> SX
cosh(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L410

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L410-L412

cross(*args)

Matlab’s cross command.

cross(DM a, DM b, int dim) -> DM
cross(SX a, SX b, int dim) -> SX
cross(MX a, MX b, int dim) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L467

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L467-L469

cse(*args)

Common subexpression elimination.

cse(DM e) -> DM
cse([DM] e) -> [DM]
cse([SX] e) -> [SX]
cse(SX e) -> SX
cse(MX e) -> MX
cse([MX] e) -> [MX]

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L702

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L702-L704

cumsum(*args)

cumulative sum

cumsum(DM A, int axis) -> DM
cumsum(SX A, int axis) -> SX
cumsum(MX A, int axis) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L864

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L864-L872

dae_init_gen(*args)

[INTERNAL]

dae_init_gen(dict:SX dae, dict:SX dae_red, str init_solver, dict:DM init_strength, dict init_solver_options) -> Function
dae_init_gen(dict:MX dae, dict:MX dae_red, str init_solver, dict:DM init_strength, dict init_solver_options) -> Function

Obtain a generator Function for producing consistent initial guesses of a reduced DAE.

1. Parameters:

dae: Original (unreduced) DAE structure

dae_red: Reduced DAE (see dae_reduce_index)

init_solver: NLP solver plugin name for nlpsol used to construct an initial

guess

init_strength: Influence the nature of the NLP Structure with keys x_impl, dx_impl, z

corresponding to inputs of init_gen Each key maps to a DM that

should

match the variable size corresponding to that key. For each variable

the meaning of the corresponding DM value is as follows: When >=0,

indicates that the provided initial guess is used in a quadratic penalty (value used as weight) When -1, indicates that the provided initial guess must be observed (simple bound on variable)

init_solver_options: NLP solver options to be passed to nlpsol

init_gen A function to generate a consistent initial guess that can be

used to pass to an integrator constructed from a semi explict reduced DAE

Inputs: x_impl, dx_impl, z: initial guesses in the original DAE space

p: parameters

t: time Outputs:

x0, z0: (semi explicit) integrator states and algebraic variables;

typically used as input for integrators

See:

dae_reduce_index

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L1215

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L1215-L1218


dae_init_gen(dict:SX dae, dict:SX dae_red, str init_solver, dict:DM init_strength, dict init_solver_options)

[INTERNAL] Obtain a generator Function for producing consistent initial guesses of a reduced DAE.

1. Parameters:

dae: Original (unreduced) DAE structure

dae_red: Reduced DAE (see dae_reduce_index)

init_solver: NLP solver plugin name for nlpsol used to construct an initial

guess

init_strength: Influence the nature of the NLP Structure with keys x_impl, dx_impl, z

corresponding to inputs of init_gen Each key maps to a DM that

should

match the variable size corresponding to that key. For each variable

the meaning of the corresponding DM value is as follows: When >=0,

indicates that the provided initial guess is used in a quadratic penalty (value used as weight) When -1, indicates that the provided initial guess must be observed (simple bound on variable)

init_solver_options: NLP solver options to be passed to nlpsol

init_gen A function to generate a consistent initial guess that can be

used to pass to an integrator constructed from a semi explict reduced DAE

Inputs: x_impl, dx_impl, z: initial guesses in the original DAE space

p: parameters

t: time Outputs:

x0, z0: (semi explicit) integrator states and algebraic variables;

typically used as input for integrators

See:

dae_reduce_index

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L1215

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L1215-L1218



dae_init_gen(dict:MX dae, dict:MX dae_red, str init_solver, dict:DM init_strength, dict init_solver_options)

[INTERNAL] Obtain a generator Function for producing consistent initial guesses of a reduced DAE.

1. Parameters:

dae: Original (unreduced) DAE structure

dae_red: Reduced DAE (see dae_reduce_index)

init_solver: NLP solver plugin name for nlpsol used to construct an initial

guess

init_strength: Influence the nature of the NLP Structure with keys x_impl, dx_impl, z

corresponding to inputs of init_gen Each key maps to a DM that

should

match the variable size corresponding to that key. For each variable

the meaning of the corresponding DM value is as follows: When >=0,

indicates that the provided initial guess is used in a quadratic penalty (value used as weight) When -1, indicates that the provided initial guess must be observed (simple bound on variable)

init_solver_options: NLP solver options to be passed to nlpsol

init_gen A function to generate a consistent initial guess that can be

used to pass to an integrator constructed from a semi explict reduced DAE

Inputs: x_impl, dx_impl, z: initial guesses in the original DAE space

p: parameters

t: time Outputs:

x0, z0: (semi explicit) integrator states and algebraic variables;

typically used as input for integrators

See:

dae_reduce_index

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L1210

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L1210-L1213


dae_map_semi_expl(*args)

[INTERNAL]

dae_map_semi_expl(dict:SX dae, dict:SX dae_red) -> (dict:SX , Function OUTPUT, Function OUTPUT)
dae_map_semi_expl(dict:MX dae, dict:MX dae_red) -> (dict:MX , Function OUTPUT, Function OUTPUT)

Turn a reduced DAE into a semi explicit form suitable for CasADi

integrator.

1. Parameters:

dae: Original (unreduced) DAE structure

dae_red: Reduced DAE (see dae_reduce_index)

state_to_orig: A mapping of integrator (semi explicit) states to states of the original DAE

phi: A function to compute the invariants of the reduced DAE Inputs: x and z: (semi explicit) integrator states; typically integrator outputs xf and zf

p: parameters

t: time

Semi explicit DAE dictionary, suitable to pass to a CasADi integrator

See:

dae_reduce_index

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L1205

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L1205-L1208


dae_map_semi_expl(dict:SX dae, dict:SX dae_red)

[INTERNAL] Turn a reduced DAE into a semi explicit form suitable for CasADi

integrator.

1. Parameters:

dae: Original (unreduced) DAE structure

dae_red: Reduced DAE (see dae_reduce_index)

state_to_orig: A mapping of integrator (semi explicit) states to states of the original DAE

phi: A function to compute the invariants of the reduced DAE Inputs: x and z: (semi explicit) integrator states; typically integrator outputs xf and zf

p: parameters

t: time

Semi explicit DAE dictionary, suitable to pass to a CasADi integrator

See:

dae_reduce_index

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L1205

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L1205-L1208



dae_map_semi_expl(dict:MX dae, dict:MX dae_red)

[INTERNAL] Turn a reduced DAE into a semi explicit form suitable for CasADi

integrator.

1. Parameters:

dae: Original (unreduced) DAE structure

dae_red: Reduced DAE (see dae_reduce_index)

state_to_orig: A mapping of integrator (semi explicit) states to states of the original DAE

phi: A function to compute the invariants of the reduced DAE Inputs: x and z: (semi explicit) integrator states; typically integrator outputs xf and zf

p: parameters

t: time

Semi explicit DAE dictionary, suitable to pass to a CasADi integrator

See:

dae_reduce_index

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L1200

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L1200-L1203


dae_reduce_index(*args)

[INTERNAL]

dae_reduce_index(dict:SX dae, dict opts) -> (dict:SX , dict OUTPUT)
dae_reduce_index(dict:MX dae, dict opts) -> (dict:MX , dict OUTPUT)

Reduce index.

Index reduction leads to a new set of variables and equations.

In the process, a set of constraints (algebraic equations or derivatives) a.k.a invariants is constructed that are invariant to the

problem: whenever an initial point satisfies these constraints, the

boundary-value-problem outcome will keep satisfying those constraints automatically, even though they are not part of the reduced DAE.

For any practical numerical integration method, there will be numerical drift away from satisfaction of those constraints. In other words, you will

see the value of invariants slowly moving away from

original zero.

A classic mitigation technique is Baumgarte stabilization: you add these invariants to the reduced DAE as a correction term that acts in a way to make small (numerical) perturbations to the invariants decay to the origin as a dampened linear system.

in which a certain set of constraints (algebraic equations or derivatives) has been dropped in favour of

1. Parameters:

dae: Expression dictionary describing the DAE

Each value must be a dense column vector.

keys: x_impl: symbol for implicit differential states

dx_impl: symbol for implicit differential state derivatives

z: symbol for algebraic variables

alg: expression for algebraic equations

t: symbol for time

p: symbol for parameters

1. Parameters:

opts: Option dictionary

‘baumgarte_pole’: double Poles (inverse time constants) of the Baumgarte invariant correction term. Must be <0 to dampen out perturbations 0 (default) amounts to no correction. Corresponds to -gamma of equation (1.5)

in Ascher, Uri M., Hongsheng Chin, and

Sebastian Reich. “Stabilization of

DAEs and invariant manifolds.”

Numerische Mathematik 67.2 (1994): 131-149.

1. Parameters:

stats: Statistics

Expression dictionary describing the reduced DAE

In addition the fields allowed in the input DAE, the following keys occur:

x: symbol for explicit differential states

ode: expression for right-hand-side of explicit differential states

I: expression for invariants

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L1060

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L1060-L1062


dae_reduce_index(dict:SX dae, dict opts)

[INTERNAL] Reduce index.

Index reduction leads to a new set of variables and equations.

In the process, a set of constraints (algebraic equations or derivatives) a.k.a invariants is constructed that are invariant to the

problem: whenever an initial point satisfies these constraints, the

boundary-value-problem outcome will keep satisfying those constraints automatically, even though they are not part of the reduced DAE.

For any practical numerical integration method, there will be numerical drift away from satisfaction of those constraints. In other words, you will

see the value of invariants slowly moving away from

original zero.

A classic mitigation technique is Baumgarte stabilization: you add these invariants to the reduced DAE as a correction term that acts in a way to make small (numerical) perturbations to the invariants decay to the origin as a dampened linear system.

in which a certain set of constraints (algebraic equations or derivatives) has been dropped in favour of

1. Parameters:

dae: Expression dictionary describing the DAE

Each value must be a dense column vector.

keys: x_impl: symbol for implicit differential states

dx_impl: symbol for implicit differential state derivatives

z: symbol for algebraic variables

alg: expression for algebraic equations

t: symbol for time

p: symbol for parameters

1. Parameters:

opts: Option dictionary

‘baumgarte_pole’: double Poles (inverse time constants) of the Baumgarte invariant correction term. Must be <0 to dampen out perturbations 0 (default) amounts to no correction. Corresponds to -gamma of equation (1.5)

in Ascher, Uri M., Hongsheng Chin, and

Sebastian Reich. “Stabilization of

DAEs and invariant manifolds.”

Numerische Mathematik 67.2 (1994): 131-149.

1. Parameters:

stats: Statistics

Expression dictionary describing the reduced DAE

In addition the fields allowed in the input DAE, the following keys occur:

x: symbol for explicit differential states

ode: expression for right-hand-side of explicit differential states

I: expression for invariants

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L1060

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L1060-L1062



dae_reduce_index(dict:MX dae, dict opts)

[INTERNAL] Reduce index.

Index reduction leads to a new set of variables and equations.

In the process, a set of constraints (algebraic equations or derivatives) a.k.a invariants is constructed that are invariant to the

problem: whenever an initial point satisfies these constraints, the

boundary-value-problem outcome will keep satisfying those constraints automatically, even though they are not part of the reduced DAE.

For any practical numerical integration method, there will be numerical drift away from satisfaction of those constraints. In other words, you will

see the value of invariants slowly moving away from

original zero.

A classic mitigation technique is Baumgarte stabilization: you add these invariants to the reduced DAE as a correction term that acts in a way to make small (numerical) perturbations to the invariants decay to the origin as a dampened linear system.

in which a certain set of constraints (algebraic equations or derivatives) has been dropped in favour of

1. Parameters:

dae: Expression dictionary describing the DAE

Each value must be a dense column vector.

keys: x_impl: symbol for implicit differential states

dx_impl: symbol for implicit differential state derivatives

z: symbol for algebraic variables

alg: expression for algebraic equations

t: symbol for time

p: symbol for parameters

1. Parameters:

opts: Option dictionary

‘baumgarte_pole’: double Poles (inverse time constants) of the Baumgarte invariant correction term. Must be <0 to dampen out perturbations 0 (default) amounts to no correction. Corresponds to -gamma of equation (1.5)

in Ascher, Uri M., Hongsheng Chin, and

Sebastian Reich. “Stabilization of

DAEs and invariant manifolds.”

Numerische Mathematik 67.2 (1994): 131-149.

1. Parameters:

stats: Statistics

Expression dictionary describing the reduced DAE

In addition the fields allowed in the input DAE, the following keys occur:

x: symbol for explicit differential states

ode: expression for right-hand-side of explicit differential states

I: expression for invariants

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.hpp#L1056

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/integration_tools.cpp#L1056-L1058


densify(*args)

Make the matrix dense and assign nonzeros to a value.

densify(DM x) -> DM
densify(SX x) -> SX
densify(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L617

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L617-L619

depends_on(*args)

Check if expression depends on the argument.

depends_on(DM f, DM arg) -> bool
depends_on(SX f, SX arg) -> bool
depends_on(MX f, MX arg) -> bool

The argument must be symbolic

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L657

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L657-L659

det(*args)

Matrix determinant (experimental)

det(DM A) -> DM
det(SX A) -> SX
det(MX A) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L488

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L488-L488

detect_simple_bounds(*args)

[INTERNAL]

detect_simple_bounds(SX xX, SX p, SX g, SX lbg, SX ubg) -> ([int] OUTPUT, SX OUTPUT, SX OUTPUT, Function OUTPUT, Function OUTPUT)
detect_simple_bounds(MX xX, MX p, MX g, MX lbg, MX ubg) -> ([int] OUTPUT, MX OUTPUT, MX OUTPUT, Function OUTPUT, Function OUTPUT)

detect_simple_bounds(SX xX, SX p, SX g, SX lbg, SX ubg)

[INTERNAL] Detect simple bounds from general constraints.

Given parametric constraints:

*   subject to lbg(p) <= g(x,p) <= ubg(p)
*

Returns an equivalent set

*   subject to  lbg(p)(gi) <= g(x,p)(gi) <= ubg(p)(gi)
*               lbx(p) <= x                 <= ubx(p)
*

1. Parameters:

lam_forward: (lam_g,p)->(lam_sg,lam_x)

lam_backward: (lam_sg,lam_x,p)->(lam_g)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/nlp_tools.hpp#L207

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/nlp_tools.cpp#L207-L215



detect_simple_bounds(MX xX, MX p, MX g, MX lbg, MX ubg)

[INTERNAL]


diag(*args)

Get the diagonal of a matrix or construct a diagonal.

diag(DM A) -> DM
diag(SX A) -> SX
diag(MX A) -> MX

When the input is square, the diagonal elements are returned. If the input is vector-like, a diagonal matrix is constructed with it.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L596

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L596-L598

diagsplit(*args)

split diagonally, retaining fixed-sized matrices

diagsplit(Sparsity x, int incr) -> [Sparsity]
diagsplit(DM x, int incr) -> [DM]
diagsplit(SX x, int incr) -> [SX]
diagsplit(MX x, int incr) -> [MX]
diagsplit(Sparsity x, [int] output_offset) -> [Sparsity]
diagsplit(DM x, [int] output_offset) -> [DM]
diagsplit(SX x, [int] output_offset) -> [SX]
diagsplit(MX x, [int] output_offset) -> [MX]
diagsplit(Sparsity x, int incr1, int incr2) -> [Sparsity]
diagsplit(Sparsity x, [int] output_offset1, [int] output_offset2) -> [Sparsity]
diagsplit(DM x, int incr1, int incr2) -> [DM]
diagsplit(DM x, [int] output_offset1, [int] output_offset2) -> [DM]
diagsplit(SX x, int incr1, int incr2) -> [SX]
diagsplit(SX x, [int] output_offset1, [int] output_offset2) -> [SX]
diagsplit(MX x, int incr1, int incr2) -> [MX]
diagsplit(MX x, [int] output_offset1, [int] output_offset2) -> [MX]

1. Parameters:

incr1: Row dimension of each matrix

incr2: Column dimension of each matrix

diagsplit(diagsplit(x, …)) = x

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L324

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L324-L326

diff(*args)

diff

diff(DM A, int n, int axis) -> DM
diff(SX A, int n, int axis) -> SX
diff(MX A, int n, int axis) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L886

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L886-L893

dot(*args)

Inner product of two matrices.

dot(DM x, DM y) -> DM
dot(SX x, SX y) -> SX
dot(MX x, MX y) -> MX

with x and y matrices of the same dimension

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L565

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L565-L567

eig_symbolic(*args)

Attempts to find the eigenvalues of a symbolic matrix.

eig_symbolic(DM m) -> DM
eig_symbolic(SX m) -> SX

This will only work for up to 3x3 matrices

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L833

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L833-L835

einstein(*args)

Computes an einstein dense tensor contraction.

einstein(DM A, DM B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> DM
einstein(SX A, SX B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> SX
einstein(MX A, MX B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> MX
einstein(DM A, DM B, DM C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> DM
einstein(SX A, SX B, SX C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> SX
einstein(MX A, MX B, MX C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> MX

Computes the product: C_c = A_a + B_b where a b c are index/einstein

notation in an encoded form

For example, an matrix-matrix product may be written as: C_ij = A_ik B_kj

The encoded form uses strictly negative numbers to indicate labels. For the

above example, we would have: a {-1, -3} b {-3, -2} c {-1 -2}

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L520

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L646-L652

eq(*args)

Logical equal to: (x,y) -> x == y.

eq(float x, float y) -> float
eq(DM x, DM y) -> DM
eq(SX x, SX y) -> SX
eq(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L191

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L191-L193

erf(*args)

Error function: x -> erf(x)

erf(float x) -> float
erf(DM x) -> DM
erf(SX x) -> SX
erf(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L542

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L542-L544

erfinv(*args)

Inverse error function: x -> erfinv(x)

erfinv(float x) -> float
erfinv(DM x) -> DM
erfinv(SX x) -> SX
erfinv(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L554

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L554-L556

evalf(*args)

Evaluates the expression numerically.

evalf(DM x) -> DM
evalf(SX x) -> DM
evalf(MX x) -> DM

An error is raised when the expression contains symbols

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L802

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L802-L804

exp(*args)

Elementwise exponential: x -> exp(x)

exp(float x) -> float
exp(DM x) -> DM
exp(SX x) -> SX
exp(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L458

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L458-L460

expand(*args)

Expand the expression as a weighted sum (with constant weights)

expand(DM ex) -> (DM OUTPUT1, DM OUTPUT2)
expand(SX ex) -> (SX OUTPUT1, SX OUTPUT2)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L620

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L620-L623

expm(*args)

Calculate Matrix exponential.

expm(DM A) -> DM
expm(SX A) -> SX
expm(MX A) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L790

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L790-L792

expm1(*args)

Precision variant for elementwise exponential: x -> exp(x)-1.

expm1(float x) -> float
expm1(DM x) -> DM
expm1(SX x) -> SX
expm1(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L506

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L506-L508

expm_const(*args)

Calculate Matrix exponential.

expm_const(DM A, DM t) -> DM
expm_const(SX A, SX t) -> SX
expm_const(MX A, MX t) -> MX

Computes expm(A*t) with A constant

1. Parameters:

A[in]: Square matrix

t[in]: Scalar

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L782

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L782-L784

extract(*args)

Introduce intermediate variables for selected nodes in a graph.

extract([DM] ex, dict opts) -> ([DM] OUTPUT1, [DM] OUTPUT2, [DM] OUTPUT3)
extract([SX] ex, dict opts) -> ([SX] OUTPUT1, [SX] OUTPUT2, [SX] OUTPUT3)
extract([MX] ex, dict opts) -> ([MX] OUTPUT1, [MX] OUTPUT2, [MX] OUTPUT3)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L959

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L959-L964

find(*args)

find nonzeros

find(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L559

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L559-L565

floor(*args)

Round down to nearest integer: x -> floor(x)

floor(float x) -> float
floor(DM x) -> DM
floor(SX x) -> SX
floor(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L518

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L518-L520

fmax(*args)

Largest of two values: (x,y) -> max(x,y)

fmax(float x, float y) -> float
fmax(DM x, DM y) -> DM
fmax(SX x, SX y) -> SX
fmax(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L684

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L684-L686

fmin(*args)

Smallest of two values: (x,y) -> min(x,y)

fmin(float x, float y) -> float
fmin(DM x, DM y) -> DM
fmin(SX x, SX y) -> SX
fmin(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L672

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L672-L674

fmod(*args)

Remainder after division: (x,y) -> fmod(x,y)

fmod(float x, float y) -> float
fmod(DM x, DM y) -> DM
fmod(SX x, SX y) -> SX
fmod(MX x, MX y) -> MX

This Function follows the convention of https://en.cppreference.com/w/c/numeric/math/fmod

Notably: fmod(5,3) -> 2

fmod(5,-3) -> 2

fmod(-5,3) -> -2

fmod(-5,-3) -> -2

This is equivalent to Python’s numpy.fmod and Matlab’s rem.

seealso remainder

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L613

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L613-L615

gauss_quadrature(*args)

Integrate f from a to b using Gaussian quadrature with n points.

gauss_quadrature(DM f, DM x, DM a, DM b, int order) -> DM
gauss_quadrature(SX f, SX x, SX a, SX b, int order) -> SX
gauss_quadrature(DM f, DM x, DM a, DM b, int order, DM w) -> DM
gauss_quadrature(SX f, SX x, SX a, SX b, int order, SX w) -> SX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L732

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L732-L736

ge(*args)

Logical greater or equal to: (x,y) -> x <= y.

ge(float x, float y) -> float
ge(DM x, DM y) -> DM
ge(SX x, SX y) -> SX
ge(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L176

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L176-L178

gradient(*args)

Calculate the gradient of an expression.

gradient(DM ex, DM arg) -> DM
gradient(SX ex, SX arg) -> SX
gradient(MX ex, MX arg) -> MX

1. Parameters:

ex[in]: Scalar expression to take the gradient of

arg[in]: Vector expression of symbols

opts[in]: Options

Dense column vector

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L812

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L812-L814

graph_substitute(*args)

Substitute multiple expressions in graph.

graph_substitute(MX ex, [MX] v, [MX] vdef) -> MX
graph_substitute([MX] ex, [MX] v, [MX] vdef) -> [MX]

Substitute variable var with expression expr in multiple expressions,

preserving nodes

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L720

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L720-L724

gt(*args)

Logical greater than: (x,y) -> x > y.

gt(float x, float y) -> float
gt(DM x, DM y) -> DM
gt(SX x, SX y) -> SX
gt(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L161

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L161-L163

heaviside(*args)

Heaviside function.

heaviside(DM x) -> DM
heaviside(SX x) -> SX

[ begin {cases} H(x) = 0 & x<0 \ H(x) = 1/2 & x=0 \ H(x) = 1 & x>0 \ end {cases} ]

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L668

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L668-L670

hessian(*args)

Hessian and (optionally) gradient.

hessian(DM ex, DM arg, dict opts) -> (DM , DM OUTPUT1)
hessian(SX ex, SX arg, dict opts) -> (SX , SX OUTPUT1)
hessian(MX ex, MX arg, dict opts) -> (MX , MX OUTPUT1)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L865

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L865-L868

horzsplit(*args)

split horizontally, retaining fixed-sized groups of columns

horzsplit(Sparsity v, int incr) -> [Sparsity]
horzsplit(DM v, int incr) -> [DM]
horzsplit(SX v, int incr) -> [SX]
horzsplit(MX v, int incr) -> [MX]
horzsplit(Sparsity v, [int] offset) -> [Sparsity]
horzsplit(DM v, [int] offset) -> [DM]
horzsplit(SX v, [int] offset) -> [SX]
horzsplit(MX v, [int] offset) -> [MX]

1. Parameters:

incr: Size (width) of each group of columns

horzcat(horzsplit(x, …)) = x

seealso horzsplit_n

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L134

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L134-L136

horzsplit_n(*args)

split horizontally, retaining fixed-sized groups of columns

horzsplit_n(Sparsity v, int n) -> [Sparsity]
horzsplit_n(DM v, int n) -> [DM]
horzsplit_n(SX v, int n) -> [SX]
horzsplit_n(MX v, int n) -> [MX]

1. Parameters:

n: Number of groups of columns

Will error when the number of columns is not a multiple of n

horzcat(horzsplit(x, …)) = x

seealso horzsplit

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L149

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L149-L151

hypot(*args)

Precision variant for 2 norm: (x,y) -> sqrt(x^2+y^2)

hypot(float x, float y) -> float
hypot(DM x, DM y) -> DM
hypot(SX x, SX y) -> SX
hypot(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L742

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L742-L744

if_else(*args)

Ternary if_else: x ? y : z.

if_else(DM cond, DM if_true, DM if_false, bool short_circuit) -> DM
if_else(SX cond, SX if_true, SX if_false, bool short_circuit) -> SX
if_else(MX cond, MX if_true, MX if_false, bool short_circuit) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sx_elem.hpp#L265

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sx_elem.hpp#L265-L267

interp1d(*args)

Performs 1d linear interpolation.

interp1d([float] x, DM v, [float] xq, str mode, bool equidistant) -> DM
interp1d([float] x, SX v, [float] xq, str mode, bool equidistant) -> SX
interp1d([float] x, MX v, [float] xq, str mode, bool equidistant) -> MX
The data-points to be interpolated are given as (x[i], v[i]). xq[j] is

used as interplating value

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L311

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L311-L314

inv(*args)

Element-wise inverse.

inv(DM A) -> DM
inv(SX A) -> SX
inv(MX A) -> MX
inv(DM A, str lsolver, dict opts) -> DM
inv(SX A, str lsolver, dict opts) -> SX
inv(MX A, str lsolver, dict opts) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sx_elem.hpp#L222

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sx_elem.cpp#L159-L165

inv_minor(*args)

Matrix inverse (experimental)

inv_minor(DM A) -> DM
inv_minor(SX A) -> SX
inv_minor(MX A) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L493

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L493-L493

inv_node(*args)

Inverse node.

inv_node(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L793

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L793-L795

inv_skew(*args)

Generate the 3-vector progenitor of a skew symmetric matrix.

inv_skew(DM a) -> DM
inv_skew(SX a) -> SX
inv_skew(MX a) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L481

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L481-L483

is_equal(*args)

Check if two nodes are equivalent up to a given depth.

is_equal(float x, float y, int depth) -> bool
is_equal(DM x, DM y, int depth) -> bool
is_equal(SX x, SX y, int depth) -> bool
is_equal(MX x, MX y, int depth) -> bool

Depth=0 checks if the expressions are identical, i.e. points to the same node.

a = x*x b = x*x

is_equal(a,b,0) will return false, but a.is_equal(a,b,1) will return true

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L703

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L703-L705

is_linear(*args)

Is expr linear in var?

is_linear(DM expr, DM var) -> bool
is_linear(SX expr, SX var) -> bool
is_linear(MX expr, MX var) -> bool

False negatives are possible (an expression may not be recognised as linear

while it really is), false positives not.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L895

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L895-L897

is_quadratic(*args)

Is expr quadratic in var?

is_quadratic(DM expr, DM var) -> bool
is_quadratic(SX expr, SX var) -> bool
is_quadratic(MX expr, MX var) -> bool

False negatives are possible (an expression may not be recognised as

quadratic while it really is), false positives not.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L906

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L906-L908

jacobian(*args)

Calculate Jacobian.

jacobian(DM ex, DM arg, dict opts) -> DM
jacobian(SX ex, SX arg, dict opts) -> SX
jacobian(MX ex, MX arg, dict opts) -> MX

Sparse matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L799

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L799-L802

jacobian_sparsity(*args)

Get the sparsity pattern of a jacobian.

jacobian_sparsity(DM f, DM x) -> Sparsity
jacobian_sparsity(SX f, SX x) -> Sparsity
jacobian_sparsity(MX f, MX x) -> Sparsity

Equivalent to, but cheaper to compute than, jacobian(f,x). sparsity()

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L884

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L884-L886

jtimes(*args)

Calculate the Jacobian and multiply by a vector from the right.

jtimes(DM ex, DM arg, DM v, bool tr) -> DM
jtimes(SX ex, SX arg, SX v, bool tr) -> SX
jtimes(MX ex, MX arg, MX v, bool tr) -> MX

This is equivalent to mul(jacobian(ex, arg), v) or mul(jacobian(ex, arg).T, v) for tr set to false and true respectively. If contrast to these

expressions, it will use directional derivatives which is typically (but not necessarily) more efficient if the complete Jacobian is not needed and v has few rows.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L832

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L832-L835

kron(*args)

Kronecker tensor product.

kron(Sparsity a, Sparsity b) -> Sparsity
kron(DM a, DM b) -> DM
kron(SX a, SX b) -> SX
kron(MX a, MX b) -> MX

Creates a block matrix in which each element (i, j) is a_ij*b

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L451

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L451-L453

ldivide(*args)
ldivide(float x, float y) -> float
ldivide(DM x, DM y) -> DM
ldivide(SX x, SX y) -> SX
ldivide(MX x, MX y) -> MX
ldl(*args)

Sparse LDL^T factorization.

ldl(DM A, bool amd) -> (DM OUTPUT1, DM OUTPUT2, [int] OUTPUT3)
ldl(SX A, bool amd) -> (SX OUTPUT1, SX OUTPUT2, [int] OUTPUT3)

Returns D and the strictly upper triangular entries of L^T I.e. ones on the

diagonal are ignored. Only guarenteed to work for positive

definite matrices.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L573

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L573-L576

ldl_solve(*args)

Solve using a sparse LDL^T factorization.

ldl_solve(DM b, DM D, DM LT, [int] p) -> DM
ldl_solve(SX b, SX D, SX LT, [int] p) -> SX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L582

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L582-L585

le(*args)

Logical less or equal to: (x,y) -> x <= y.

le(float x, float y) -> float
le(DM x, DM y) -> DM
le(SX x, SX y) -> SX
le(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L146

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L146-L148

linear_coeff(*args)

Recognizes linear form in vector expression.

linear_coeff(DM ex, DM arg, bool check) -> (DM OUTPUT1, DM OUTPUT2)
linear_coeff(SX ex, SX arg, bool check) -> (SX OUTPUT1, SX OUTPUT2)
linear_coeff(MX ex, MX arg, bool check) -> (MX OUTPUT1, MX OUTPUT2)

A x + b

1. Parameters:

check[in]: When true (default)m, A is checked to be independent of x. Provided to

deal with false positive dependency checks.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L933

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L933-L936

linearize(*args)

Linearize an expression.

linearize(DM f, DM x, DM x0) -> DM
linearize(SX f, SX x, SX x0) -> SX
linearize(MX f, MX x, MX x0) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L740

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L740-L743

linspace(*args)

Matlab’s linspace.

linspace(DM a, DM b, int nsteps) -> DM
linspace(SX a, SX b, int nsteps) -> SX
linspace(MX a, MX b, int nsteps) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L784

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/casadi_misc.hpp#L784-L795

log(*args)

Natural logarithm: x -> log(x)

log(float x) -> float
log(DM x) -> DM
log(SX x) -> SX
log(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L470

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L470-L472

log10(*args)

Base-10 logarithm: x -> log10(x)

log10(float x) -> float
log10(DM x) -> DM
log10(SX x) -> SX
log10(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L482

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L482-L484

log1p(*args)

Precision variant for natural logarithm: x -> log(x+1)

log1p(float x) -> float
log1p(DM x) -> DM
log1p(SX x) -> SX
log1p(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L494

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L494-L496

logsumexp(*args)

Scaled version of logsumexp.

logsumexp(DM a) -> DM
logsumexp(SX a) -> SX
logsumexp(MX a) -> MX
logsumexp(DM a, DM margin) -> DM
logsumexp(SX a, SX margin) -> SX
logsumexp(MX a, MX margin) -> MX

Scaled such that max(x) <= logsumexp(x, margin) <= max(x)+margin

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L451

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L451-L454

low(*args)

Find first nonzero.

low(MX v, MX p, dict options) -> MX

If failed, returns the number of rows

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L699

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L699-L701

lt(*args)

Logical less than: (x,y) -> x < y.

lt(float x, float y) -> float
lt(DM x, DM y) -> DM
lt(SX x, SX y) -> SX
lt(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L131

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L131-L133

mac(*args)

Multiply-accumulate operation.

mac(Sparsity X, Sparsity Y, Sparsity Z) -> Sparsity
mac(DM X, DM Y, DM Z) -> DM
mac(SX X, SX Y, SX Z) -> SX
mac(MX X, MX Y, MX Z) -> MX

Matrix product of two matrices (x and y), adding the result to a third

matrix z. The result has the same sparsity pattern as C meaning that other entries of (x*y) are ignored. The operation is equivalent to:

z+mtimes(x,y).project(z.sparsity()).

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L358

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L358-L360

matrix_expand(*args)

Expand MX graph to SXFunction call.

matrix_expand(MX e, [MX] boundary, dict options) -> MX
matrix_expand([MX] e, [MX] boundary, dict options) -> [MX]

Expand the given expression e, optionally supplying expressions contained in it at which expansion should stop.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L745

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L745-L749

minor(*args)

Get the (i,j) minor matrix.

minor(DM x, int i, int j) -> DM
minor(SX x, int i, int j) -> SX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L511

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L511-L513

minus(*args)

Subtraction: (x,y) -> x - y.

minus(float x, float y) -> float
minus(DM x, DM y) -> DM
minus(SX x, SX y) -> SX
minus(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L83

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L83-L85

mldivide(*args)

Matrix divide (cf. backslash ‘' in MATLAB)

mldivide(DM x, DM y) -> DM
mldivide(SX x, SX y) -> SX
mldivide(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L383

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L383-L385

mmax(*args)

Largest element in a matrix.

mmax(DM x) -> DM
mmax(SX x) -> SX
mmax(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L997

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L997-L999

mmin(*args)

Smallest element in a matrix.

mmin(DM x) -> DM
mmin(SX x) -> SX
mmin(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L988

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L988-L990

mpower(*args)

Matrix power x^n.

mpower(DM x, DM n) -> DM
mpower(SX x, SX n) -> SX
mpower(MX x, MX n) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L319

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L319-L321

mrdivide(*args)

Matrix divide (cf. slash ‘/’ in MATLAB)

mrdivide(DM x, DM y) -> DM
mrdivide(SX x, SX y) -> SX
mrdivide(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L376

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L376-L378

mtaylor(*args)

multivariate Taylor series expansion

mtaylor(DM ex, DM x, DM a, int order) -> DM
mtaylor(SX ex, SX x, SX a, int order) -> SX
mtaylor(DM ex, DM x, DM a, int order, [int] order_contributions) -> DM
mtaylor(SX ex, SX x, SX a, int order, [int] order_contributions) -> SX

Do Taylor expansions until the aggregated order of a term is equal to

‘order’. The aggregated order of $x^n y^m$ equals $n+m$.

The argument order_contributions can denote how match each variable

contributes to the aggregated order. If x=[x, y] and

order_contributions=[1, 2], then the aggregated order of $x^n y^m$ equals $1n+2m$.

Example usage

>>> taylor(sin(x+y),[x, y],[a, b], 1)

$ sin(b+a)+cos(b+a)(x-a)+cos(b+a)(y-b) $

>>> taylor(sin(x+y),[x, y],[0, 0], 4)

$ y+x-(x^3+3y x^2+3 y^2 x+y^3)/6 $

>>> taylor(sin(x+y),[x, y],[0, 0], 4,[1, 2])

$ (-3 x^2 y-x^3)/6+y+x $

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L801

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L801-L805

mtimes(*args)

Matrix product of n matrices.

mtimes([Sparsity] args) -> Sparsity
mtimes([DM] args) -> DM
mtimes([SX] args) -> SX
mtimes([MX] args) -> MX
mtimes(Sparsity x, Sparsity y) -> Sparsity
mtimes(DM x, DM y) -> DM
mtimes(SX x, SX y) -> SX
mtimes(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L345

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L345-L347

n_nodes(*args)
n_nodes(DM A) -> int
n_nodes(SX A) -> int
n_nodes(MX A) -> int
ne(*args)

Logical not equal to: (x,y) -> x != y.

ne(float x, float y) -> float
ne(DM x, DM y) -> DM
ne(SX x, SX y) -> SX
ne(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L206

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L206-L208

no_grad(*args)

Stop first derivatives of an expression wrt to all its symbolic

no_grad(MX expr) -> MX

variables.

seealso stop_diff

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L818

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L818-L820

no_hess(*args)

Stop second derivatives of an expression wrt to all its symbolic

no_hess(MX expr) -> MX

variables.

seealso stop_diff

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L827

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L827-L829

norm_0_mul(*args)
norm_0_mul(Sparsity x, Sparsity y) -> int
norm_0_mul(DM x, DM y) -> int
norm_0_mul(SX x, SX y) -> int
norm_0_mul(MX x, MX y) -> int
norm_1(*args)

1-norm

norm_1(DM x) -> DM
norm_1(SX x) -> SX
norm_1(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L539

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L539-L539

norm_2(*args)

2-norm

norm_2(DM x) -> DM
norm_2(SX x) -> SX
norm_2(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L534

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L534-L534

norm_fro(*args)

Frobenius norm.

norm_fro(DM x) -> DM
norm_fro(SX x) -> SX
norm_fro(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L529

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L529-L529

norm_inf(*args)

Infinity-norm.

norm_inf(DM x) -> DM
norm_inf(SX x) -> SX
norm_inf(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L544

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L544-L544

norm_inf_mul(*args)

Inf-norm of a Matrix-Matrix product.

norm_inf_mul(DM x, DM y) -> DM
norm_inf_mul(SX x, SX y) -> SX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L605

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L605-L607

nullspace(*args)

Computes the nullspace of a matrix A.

nullspace(DM A) -> DM
nullspace(SX A) -> SX
nullspace(MX A) -> MX

Finds Z m-by-(m-n) such that AZ = 0 with A n-by-m with m > n

Assumes A is full rank

Inspired by Numerical Methods in Scientific Computing by Ake Bjorck

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L579

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L579-L581

pinv(*args)

Computes the Moore-Penrose pseudo-inverse.

pinv(DM A) -> DM
pinv(SX A) -> SX
pinv(MX A) -> MX
pinv(DM A, str lsolver, dict opts) -> DM
pinv(SX A, str lsolver, dict opts) -> SX
pinv(MX A, str lsolver, dict opts) -> MX

If the matrix A is fat (size1>size2), mul(A, pinv(A)) is unity. If the

matrix A is slender (size2<size1), mul(pinv(A), A) is unity.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L767

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L767-L770

plus(*args)
plus(float x, float y) -> float
plus(DM x, DM y) -> DM
plus(SX x, SX y) -> SX
plus(MX x, MX y) -> MX
poly_coeff(*args)

extracts polynomial coefficients from an expression

poly_coeff(DM ex, DM x) -> DM
poly_coeff(SX ex, SX x) -> SX

1. Parameters:

ex: Scalar expression that represents a polynomial

x: Scalar symbol that the polynomial is build up with

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L813

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L813-L816

poly_roots(*args)

Attempts to find the roots of a polynomial.

poly_roots(DM p) -> DM
poly_roots(SX p) -> SX

This will only work for polynomials up to order 3 It is assumed that the roots are real.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L824

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L824-L826

polyval(*args)

Evaluate a polynomial with coefficients p in x.

polyval(DM p, DM x) -> DM
polyval(SX p, SX x) -> SX
polyval(MX p, MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L586

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L586-L588

power(*args)
power(float x, float n) -> float
power(DM x, DM n) -> DM
power(SX x, SX n) -> SX
power(MX x, MX n) -> MX
print_operator(*args)

Get a string representation for a binary MatType, using custom

print_operator(DM xb, [str] args) -> str
print_operator(SX xb, [str] args) -> str
print_operator(MX xb, [str] args) -> str

arguments.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L952

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L952-L954

project(*args)

Create a new matrix with a given sparsity pattern but with the.

project(DM A, Sparsity sp, bool intersect) -> DM
project(SX A, Sparsity sp, bool intersect) -> SX
project(MX A, Sparsity sp, bool intersect) -> MX

nonzeros taken from an existing matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L626

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L626-L629

pw_const(*args)

Create a piecewise constant function.

pw_const(DM t, DM tval, DM val) -> DM
pw_const(SX t, SX tval, SX val) -> SX

Create a piecewise constant function with n=val.size() intervals

Inputs:

1. Parameters:

t: a scalar variable (e.g. time)

tval: vector with the discrete values of t at the interval transitions

(length n-1)

val: vector with the value of the function for each interval (length n)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L635

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L635-L639

pw_lin(*args)

t a scalar variable (e.g. time)

pw_lin(DM t, DM tval, DM val) -> DM
pw_lin(SX t, SX tval, SX val) -> SX

Create a piecewise linear function

Create a piecewise linear function:

Inputs:

tval vector with the the discrete values of t (monotonically increasing)

val vector with the corresponding function values (same length as tval)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L652

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L652-L655

qr(*args)

QR factorization using the modified Gram-Schmidt algorithm.

qr(DM A) -> (DM OUTPUT1, DM OUTPUT2)
qr(SX A) -> (SX OUTPUT1, SX OUTPUT2)
More stable than the classical Gram-Schmidt, but may break down if the

rows of A are nearly linearly dependent See J. Demmel: Applied

Numerical Linear

Algebra (algorithm 3.1.). Note that in SWIG, Q and R

are returned by value.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L530

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L530-L532

qr_solve(*args)

Solve using a sparse QR factorization.

qr_solve(DM b, DM v, DM r, DM beta, [int] prinv, [int] pc, bool tr) -> DM
qr_solve(SX b, SX v, SX r, SX beta, [int] prinv, [int] pc, bool tr) -> SX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L549

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L549-L554

qr_sparse(*args)

Sparse direct QR factorization.

qr_sparse(DM A, bool amd) -> (DM OUTPUT1, DM OUTPUT2, DM OUTPUT3, [int] OUTPUT4, [int] OUTPUT5)
qr_sparse(SX A, bool amd) -> (SX OUTPUT1, SX OUTPUT2, SX OUTPUT3, [int] OUTPUT4, [int] OUTPUT5)

See T. Davis: Direct Methods for Sparse Linear Systems

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L539

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L539-L543

quadratic_coeff(*args)

Recognizes quadratic form in scalar expression.

quadratic_coeff(DM ex, DM arg, bool check) -> (DM OUTPUT1, DM OUTPUT2, DM OUTPUT3)
quadratic_coeff(SX ex, SX arg, bool check) -> (SX OUTPUT1, SX OUTPUT2, SX OUTPUT3)
quadratic_coeff(MX ex, MX arg, bool check) -> (MX OUTPUT1, MX OUTPUT2, MX OUTPUT3)

1/2*x’ A x + b’ x + c

e = 0.5*bilin(A,x,x)+dot(b,x)+c

1. Parameters:

check[in]: When true (default), A is checked to be independent of x. Provided to deal with false positive dependency checks.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L920

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L920-L923

ramp(*args)

ramp function

ramp(DM x) -> DM
ramp(SX x) -> SX

[ begin {cases} R(x) = 0 & x <= 1 \ R(x) = x & x > 1

\ end {cases} ]

Also called: slope function

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L717

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L717-L719

rank1(*args)

Make a rank-1 update to a matrix A.

rank1(DM A, DM alpha, DM x, DM y) -> DM
rank1(SX A, SX alpha, SX x, SX y) -> SX
rank1(MX A, MX alpha, MX x, MX y) -> MX

Calculates A + 1/2 * alpha * x*y’

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L422

rdivide(*args)

Elementwise division: (x,y) -> x ./ y.

rdivide(float x, float y) -> float
rdivide(DM x, DM y) -> DM
rdivide(SX x, SX y) -> SX
rdivide(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L115

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L115-L117

rectangle(*args)

rectangle function

rectangle(DM x) -> DM
rectangle(SX x) -> SX
[ begin {cases} Pi(x) = 1 & |x| < 1/2 \ Pi(x) =

1/2

& |x| = 1/2 \ Pi(x) = 0 & |x| > 1/2 \ end {cases} ]

Also called: gate function, block function, band function, pulse function, window function

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L685

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L685-L687

remainder(*args)

Remainder after division: (x,y) -> remainder(x,y)

remainder(float x, float y) -> float
remainder(DM x, DM y) -> DM
remainder(SX x, SX y) -> SX
remainder(MX x, MX y) -> MX

This Function follows the convention of https://en.cppreference.com/w/c/numeric/math/remainder

Notably: remainder(5,3) -> -1

remainder(5,-3) -> -1

remainder(-5,3) -> 1

remainder(-5,-3) -> 1

This is equivalent to Python’s math.remainder. There is no equivalence

in

Matlab.

seealso fmod

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L634

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L634-L636

repmat(*args)

Repeat matrix A n times vertically and m times horizontally.

repmat(Sparsity A, int n, int m) -> Sparsity
repmat(Sparsity A, (int,int) rc) -> Sparsity
repmat(DM A, int n, int m) -> DM
repmat(DM A, (int,int) rc) -> DM
repmat(SX A, int n, int m) -> SX
repmat(SX A, (int,int) rc) -> SX
repmat(MX A, int n, int m) -> MX
repmat(MX A, (int,int) rc) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L465

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L465-L467

repsum(*args)

Given a repeated matrix, computes the sum of repeated parts.

repsum(DM A, int n, int m) -> DM
repsum(SX A, int n, int m) -> SX
repsum(MX A, int n, int m) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L980

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L980-L982

reshape(*args)

Reshape the matrix.

reshape(Sparsity a, (int,int) rc) -> Sparsity
reshape(Sparsity a, Sparsity sp) -> Sparsity
reshape(DM a, (int,int) rc) -> DM
reshape(DM a, Sparsity sp) -> DM
reshape(SX a, (int,int) rc) -> SX
reshape(SX a, Sparsity sp) -> SX
reshape(MX a, (int,int) rc) -> MX
reshape(MX a, Sparsity sp) -> MX
reshape(Sparsity a, int nrow, int ncol) -> Sparsity
reshape(DM a, int nrow, int ncol) -> DM
reshape(SX a, int nrow, int ncol) -> SX
reshape(MX a, int nrow, int ncol) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L407

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L407-L409

shared(*args)

Get a shared (owning) reference.

shared([DM] ex, str v_prefix, str v_suffix) -> ([DM] OUTPUT1, [DM] OUTPUT2, [DM] OUTPUT3)
shared([SX] ex, str v_prefix, str v_suffix) -> ([SX] OUTPUT1, [SX] OUTPUT2, [SX] OUTPUT3)
shared([MX] ex, str v_prefix, str v_suffix) -> ([MX] OUTPUT1, [MX] OUTPUT2, [MX] OUTPUT3)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/shared_object.hpp#L198

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/shared_object.cpp#L141-L147

sign(*args)

Sign function:

sign(float x) -> float
sign(DM x) -> DM
sign(SX x) -> SX
sign(MX x) -> MX

sign(x) := -1 for x<0 sign(x) := 1 for x>0, sign(0) := 0 sign(NaN) := NaN

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L571

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L571-L573

simplify(*args)

Simplify an expression.

simplify(float x) -> float
simplify(DM x) -> DM
simplify(SX x) -> SX
simplify(MX x) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L944

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L944-L946

sin(*args)

Sine: x -> sin(x)

sin(float x) -> float
sin(DM x) -> DM
sin(SX x) -> SX
sin(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L314

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L314-L316

sinh(*args)

Hyperbolic sin: x -> sinh(x)

sinh(float x) -> float
sinh(DM x) -> DM
sinh(SX x) -> SX
sinh(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L398

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L398-L400

skew(*args)

Generate a skew symmetric matrix from a 3-vector.

skew(DM a) -> DM
skew(SX a) -> SX
skew(MX a) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L474

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L474-L476

soc(*args)

Construct second-order-convex.

soc(DM x, DM y) -> DM
soc(SX x, SX y) -> SX
soc(MX x, MX y) -> MX

1. Parameters:

x: vector expression of size n

y: scalar expression

soc(x,y) computes [y*eye(n) x; x’ y]

soc(x,y) positive semi definite <=> || x ||_2 <= y

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L334

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L334-L336

solve(*args)

Crunch the numbers; solve the problem.

solve(DM A, DM b) -> DM
solve(SX A, SX b) -> SX
solve(MX A, MX b) -> MX
solve(DM A, DM b, str lsolver, dict opts) -> DM
solve(SX A, SX b, str lsolver, dict opts) -> SX
solve(MX A, MX b, str lsolver, dict opts) -> MX

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/optistack.hpp#L204

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/optistack.cpp#L153-L159

sparsify(*args)

Make a matrix sparse by removing numerical zeros.

sparsify(DM A, float tol) -> DM
sparsify(SX A, float tol) -> SX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L613

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L613-L615

sparsity_cast(*args)

Cast matrix nonzeros to different Sparsity.

sparsity_cast(Sparsity a, Sparsity sp) -> Sparsity
sparsity_cast(DM a, Sparsity sp) -> DM
sparsity_cast(SX a, Sparsity sp) -> SX
sparsity_cast(MX a, Sparsity sp) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L414

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L414-L416

sprank(*args)
sprank(Sparsity A) -> int
sprank(DM A) -> int
sprank(SX A) -> int
sprank(MX A) -> int
sqrt(*args)

Square root: x -> sqrt(x)

sqrt(float x) -> float
sqrt(DM x) -> DM
sqrt(SX x) -> SX
sqrt(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L290

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L290-L292

stop_diff(*args)

Stop derivatives of an expression wrt to a select set of symbolic

stop_diff(MX expr, int order) -> MX
stop_diff(MX expr, MX var, int order) -> MX

variables.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L835

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L835-L837

substitute(*args)

Substitute variable var with expression expr in multiple expressions.

substitute(DM ex, DM v, DM vdef) -> DM
substitute([DM] ex, [DM] v, [DM] vdef) -> [DM]
substitute(SX ex, SX v, SX vdef) -> SX
substitute([SX] ex, [SX] v, [SX] vdef) -> [SX]
substitute(MX ex, MX v, MX vdef) -> MX
substitute([MX] ex, [MX] v, [MX] vdef) -> [MX]

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L673

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L673-L676

substitute_inplace(*args)

Inplace substitution with piggyback expressions.

substitute_inplace([DM] v, bool reverse) -> ([DM] INOUT1, [DM] INOUT2)
substitute_inplace([SX] v, bool reverse) -> ([SX] INOUT1, [SX] INOUT2)
substitute_inplace([MX] v, bool reverse) -> ([MX] INOUT1, [MX] INOUT2)

Substitute variables v out of the expressions vdef sequentially, as well as

out of a number of other expressions piggyback

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L685

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L685-L689

sum1(*args)

Return a row-wise summation of elements.

sum1(Sparsity x) -> Sparsity
sum1(DM x) -> DM
sum1(SX x) -> SX
sum1(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L586

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L586-L586

sum2(*args)

Return a column-wise summation of elements.

sum2(Sparsity x) -> Sparsity
sum2(DM x) -> DM
sum2(SX x) -> SX
sum2(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L591

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L591-L591

sumsqr(*args)

Calculate sum of squares: sum_ij X_ij^2.

sumsqr(DM X) -> DM
sumsqr(SX X) -> SX
sumsqr(MX X) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L429

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L429-L431

symvar(*args)

Get symbols present in expression.

symvar(DM x) -> [DM]
symvar(SX x) -> [SX]
symvar(MX x) -> [MX]
Returned vector is ordered according to the order of variable()/parameter()

calls used to create the variables

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/optistack.hpp#L525

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/optistack.cpp#L432-L438

tan(*args)

Tangent: x -> tan(x)

tan(float x) -> float
tan(DM x) -> DM
tan(SX x) -> SX
tan(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L338

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L338-L340

tangent(*args)

Calculate the tangent of an expression.

tangent(DM ex, DM arg) -> DM
tangent(SX ex, SX arg) -> SX
tangent(MX ex, MX arg) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L819

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L819-L821

tanh(*args)

Hyperbolic tangent: x -> tanh(x)

tanh(float x) -> float
tanh(DM x) -> DM
tanh(SX x) -> SX
tanh(MX x) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L386

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L386-L388

taylor(*args)

univariate Taylor series expansion

taylor(DM ex, DM x, DM a, int order) -> DM
taylor(SX ex, SX x, SX a, int order) -> SX

Calculate the Taylor expansion of expression ‘ex’ up to order ‘order’ with respect to variable ‘x’ around the point ‘a’

$(x)=f(a)+f’(a)(x-a)+f’’(a)frac

{(x-a)^2}{2!}+f’’’(a)frac{(x-a)^3}{3!}+ldots$

Example usage:

>>> taylor(sin(x), x)
>>   x

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L758

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L758-L760

times(*args)

Elementwise multiplication: (x,y) -> x .* y.

times(float x, float y) -> float
times(DM x, DM y) -> DM
times(SX x, SX y) -> SX
times(MX x, MX y) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L99

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_expression.hpp#L99-L101

trace(*args)

Matrix trace.

trace(DM a) -> DM
trace(SX a) -> SX
trace(MX a) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L514

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L514-L514

transpose(*args)

Transpose.

transpose(Sparsity X) -> Sparsity
transpose(DM X) -> DM
transpose(SX X) -> SX
transpose(MX X) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L365

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L365-L367

triangle(*args)

triangle function

triangle(DM x) -> DM
triangle(SX x) -> SX

[ begin {cases} Lambda(x) = 0 & |x| >= 1 \ Lambda(x)

= 1-|x| & |x| < 1 end {cases} ]

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L700

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L700-L702

tril(*args)

Get the lower triangular part of a matrix.

tril(Sparsity a, bool includeDiagonal) -> Sparsity
tril(DM a, bool includeDiagonal) -> DM
tril(SX a, bool includeDiagonal) -> SX
tril(MX a, bool includeDiagonal) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L442

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L442-L444

tril2symm(*args)

Convert a lower triangular matrix to a symmetric one.

tril2symm(DM a) -> DM
tril2symm(SX a) -> SX
tril2symm(MX a) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L519

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L519-L519

triu(*args)

Get the upper triangular part of a matrix.

triu(Sparsity a, bool includeDiagonal) -> Sparsity
triu(DM a, bool includeDiagonal) -> DM
triu(SX a, bool includeDiagonal) -> SX
triu(MX a, bool includeDiagonal) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L435

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L435-L437

triu2symm(*args)

Convert a upper triangular matrix to a symmetric one.

triu2symm(DM a) -> DM
triu2symm(SX a) -> SX
triu2symm(MX a) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L524

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L524-L524

unite(*args)

Unite two matrices no overlapping sparsity.

unite(DM A, DM B) -> DM
unite(SX A, SX B) -> SX
unite(MX A, MX B) -> MX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L603

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L603-L605

vec(*args)

make a vector

vec(Sparsity a) -> Sparsity
vec(DM a) -> DM
vec(SX a) -> SX
vec(MX a) -> MX

Reshapes/vectorizes the matrix such that the shape becomes (expr.numel(), 1). Columns are stacked on top of each other. Same as reshape(expr, expr.numel(), 1)

a c b d

turns into

a b c d

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L386

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/sparsity_interface.hpp#L386-L388

which_depends(*args)

Find out which variables enter with some order.

which_depends(DM expr, DM var, int order, bool tr) -> [bool]
which_depends(SX expr, SX var, int order, bool tr) -> [bool]
which_depends(MX expr, MX var, int order, bool tr) -> [bool]

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L874

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/generic_matrix.hpp#L874-L877

2. Classes

2.1. DM

class DM(*args)
.. py:method:: DM.assign(*args)
module:

casadi.casadi

assign(self, DM rhs)
static binary(*args)
binary(int op, DM x, DM y) -> DM
clear(*args)

[INTERNAL]

clear(self)
dep(*args)
dep(self, int ch) -> DM
static deserialize(*args)
deserialize(std::istream & stream) -> DM
deserialize(casadi::DeserializingStream & s) -> DM
deserialize(str s) -> DM
disp(*args)

[INTERNAL]

disp(self, bool more)

Print a representation of the object.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L877

element_hash(*args)
element_hash(self) -> int
elements(*args)

[INTERNAL]

elements(self) -> [float]

Get all elements.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1135

enlarge(*args)

[INTERNAL]

enlarge(self, int nrow, int ncol, [int] rr, [int] cc, bool ind1)

Enlarge matrix.

Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L952

erase(*args)

[INTERNAL]

erase(self, [int] rr, bool ind1)
erase(self, [int] rr, [int] cc, bool ind1)

Erase a submatrix (leaving structural zeros in its place)

Erase elements of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L937


erase(self, [int] rr, bool ind1)

[INTERNAL] Erase a submatrix (leaving structural zeros in its place)

Erase elements of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L937



erase(self, [int] rr, [int] cc, bool ind1)

[INTERNAL] Erase a submatrix (leaving structural zeros in its place)

Erase rows and/or columns of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L929


export_code(*args)
export_code(self, str lang, dict options)
static eye(*args)
eye(int n) -> DM
static from_file(*args)
from_file(str filename, str format_hint) -> DM
full(*args)
full(self) -> PyObject *
get(*args)
get(self, bool ind1, Sparsity sp) -> DM
get(self, bool ind1, Slice rr) -> DM
get(self, bool ind1, IM rr) -> DM
get(self, bool ind1, Slice rr, Slice cc) -> DM
get(self, bool ind1, Slice rr, IM cc) -> DM
get(self, bool ind1, IM rr, Slice cc) -> DM
get(self, bool ind1, IM rr, IM cc) -> DM
static get_free(*args)
get_free(Function f) -> [DM]
static get_input(*args)
get_input(Function f) -> [DM]
static get_max_depth(*args)
get_max_depth() -> int
get_nz(*args)
get_nz(self, bool ind1, Slice k) -> DM
get_nz(self, bool ind1, IM k) -> DM
has_duplicates(*args)
has_duplicates(self) -> bool
has_nz(*args)

[INTERNAL]

has_nz(self, int rr, int cc) -> bool

Returns true if the matrix has a non-zero at location rr, cc.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L219

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L65-L67

has_zeros(*args)

[INTERNAL]

has_zeros(self) -> bool

Check if the matrix has any zero entries which are not structural zeros.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1125

static inf(*args)

[INTERNAL]

inf(int nrow, int ncol) -> DM
inf((int,int) rc) -> DM
inf(Sparsity sp) -> DM

create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1005


inf(int nrow, int ncol)

[INTERNAL] create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1004



inf((int,int) rc)

[INTERNAL] create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1005



inf(Sparsity sp)

[INTERNAL] create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1003


info(*args)
info(self) -> dict
is_commutative(*args)
is_commutative(self) -> bool
is_constant(*args)

[INTERNAL]

is_constant(self) -> bool

Check if the matrix is constant (note that false negative answers are possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1085

is_eye(*args)

[INTERNAL]

is_eye(self) -> bool

check if the matrix is an identity matrix (note that false negative answers

are possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1114

is_integer(*args)

[INTERNAL]

is_integer(self) -> bool

Check if the matrix is integer-valued.

(note that false negative answers are possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1092

is_leaf(*args)
is_leaf(self) -> bool
is_minus_one(*args)

[INTERNAL]

is_minus_one(self) -> bool

check if the matrix is -1 (note that false negative answers are

possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1107

is_one(*args)

[INTERNAL]

is_one(self) -> bool

check if the matrix is 1 (note that false negative answers are

possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1102

is_op(*args)
is_op(self, int op) -> bool
is_regular(*args)
is_regular(self) -> bool
is_smooth(*args)
is_smooth(self) -> bool
is_symbolic(*args)
is_symbolic(self) -> bool
is_valid_input(*args)
is_valid_input(self) -> bool
is_zero(*args)

[INTERNAL]

is_zero(self) -> bool

check if the matrix is 0 (note that false negative answers are

possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1097

static matrix_matrix(*args)
matrix_matrix(int op, DM x, DM y) -> DM
static matrix_scalar(*args)
matrix_scalar(int op, DM x, DM y) -> DM
n_dep(*args)
n_dep(self) -> int
name(*args)
name(self) -> str
static nan(*args)

[INTERNAL]

nan(int nrow, int ncol) -> DM
nan((int,int) rc) -> DM
nan(Sparsity sp) -> DM

create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1014


nan(int nrow, int ncol)

[INTERNAL] create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1013



nan((int,int) rc)

[INTERNAL] create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1014



nan(Sparsity sp)

[INTERNAL] create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1012


nonzeros(*args)

[INTERNAL]

nonzeros(self) -> [float]

Get all nonzeros.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1142

op(*args)
op(self) -> int
print_dense(*args)

[INTERNAL]

print_dense(self, bool truncate)

Print dense matrix-stype.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L889

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L686-L688

print_scalar(*args)

[INTERNAL]

print_scalar(self)

Print scalar.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L883

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L609-L633

print_sparse(*args)

[INTERNAL]

print_sparse(self, bool truncate)

Print sparse matrix style.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L892

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L691-L693

print_split(*args)

[INTERNAL]

print_split(self) -> ([str] OUTPUT, [str] OUTPUT)

Get strings corresponding to the nonzeros and the interdependencies.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L873

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L696-L700

print_vector(*args)

[INTERNAL]

print_vector(self, bool truncate)

Print vector-style.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L886

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L636-L638

printme(*args)
printme(self, DM y) -> DM
static rand(*args)

[INTERNAL]

rand(int nrow, int ncol) -> DM
rand((int,int) rc) -> DM
rand(Sparsity sp) -> DM

Create a matrix with uniformly distributed random numbers.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201


rand(Sparsity sp)


rand(int nrow, int ncol)

[INTERNAL] Create a matrix with uniformly distributed random numbers.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1197



rand((int,int) rc)

[INTERNAL] Create a matrix with uniformly distributed random numbers.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201


remove(*args)

[INTERNAL]

remove(self, [int] rr, [int] cc)

Remove columns and rows.

Remove/delete rows and/or columns of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L944

reserve(*args)

[INTERNAL]

reserve(self, int nnz)
reserve(self, int nnz, int ncol)
reset_input(*args)
reset_input(self)
resize(*args)

[INTERNAL]

resize(self, int nrow, int ncol)
static rng(*args)
rng(int seed)
static scalar_matrix(*args)
scalar_matrix(int op, DM x, DM y) -> DM
serialize(*args)

[INTERNAL]

serialize(self) -> str
serialize(self, casadi::SerializingStream & s)

Serialize an object.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1249


serialize(self, casadi::SerializingStream & s)

[INTERNAL] Serialize an object.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1249



serialize(self)

[INTERNAL] Serialize.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1234


set(*args)
set(self, DM m, bool ind1, Sparsity sp)
set(self, DM m, bool ind1, Slice rr)
set(self, DM m, bool ind1, IM rr)
set(self, DM m, bool ind1, Slice rr, Slice cc)
set(self, DM m, bool ind1, Slice rr, IM cc)
set(self, DM m, bool ind1, IM rr, Slice cc)
set(self, DM m, bool ind1, IM rr, IM cc)
static set_max_depth(*args)
set_max_depth(int eq_depth)
set_nz(*args)
set_nz(self, DM m, bool ind1, Slice k)
set_nz(self, DM m, bool ind1, IM k)
static set_precision(*args)
set_precision(int precision)
static set_scientific(*args)
set_scientific(bool scientific)
static set_width(*args)
set_width(int width)
sparse(*args)
sparse(self) -> PyObject *
sparsity(*args)

[INTERNAL]

sparsity(self) -> Sparsity

Get an owning reference to the sparsity pattern.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L979

str(*args)

[INTERNAL]

str(self, bool more) -> str

Get string representation.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L880

to_file(*args)

[INTERNAL]

to_file(self, str filename, str format)

Export numerical matrix to file

Supported formats:

*   - .mtx   Matrix Market (sparse)
*   - .txt   Ascii full precision representation (sparse)
*            Whitespace separated, aligned.
*            Comments with # % or /
*            Uses C locale
*            Structural zeros represented by 00
*            Does not scale well for large sparse matrices
*

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1269

static triplet(*args)
triplet([int] row, [int] col, DM d) -> DM
triplet([int] row, [int] col, DM d, (int,int) rc) -> DM
triplet([int] row, [int] col, DM d, int nrow, int ncol) -> DM
static type_name(*args)
type_name() -> str
static unary(*args)
unary(int op, DM x) -> DM

2.2. SX

class SX(*args)
.. py:method:: SX.binary(*args)
module:

casadi.casadi

staticmethod:

binary(int op, SX x, SX y) -> SX
clear(*args)

[INTERNAL]

clear(self)
dep(*args)
dep(self, int ch) -> SX
static deserialize(*args)
deserialize(std::istream & stream) -> SX
deserialize(casadi::DeserializingStream & s) -> SX
deserialize(str s) -> SX
disp(*args)

[INTERNAL]

disp(self, bool more)

Print a representation of the object.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L877

element_hash(*args)
element_hash(self) -> int
elements(*args)

[INTERNAL]

elements(self) -> [SXElem]

Get all elements.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1135

enlarge(*args)

[INTERNAL]

enlarge(self, int nrow, int ncol, [int] rr, [int] cc, bool ind1)

Enlarge matrix.

Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L952

erase(*args)

[INTERNAL]

erase(self, [int] rr, bool ind1)
erase(self, [int] rr, [int] cc, bool ind1)

Erase a submatrix (leaving structural zeros in its place)

Erase elements of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L937


erase(self, [int] rr, bool ind1)

[INTERNAL] Erase a submatrix (leaving structural zeros in its place)

Erase elements of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L937



erase(self, [int] rr, [int] cc, bool ind1)

[INTERNAL] Erase a submatrix (leaving structural zeros in its place)

Erase rows and/or columns of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L929


export_code(*args)
export_code(self, str lang, dict options)
static eye(*args)
eye(int n) -> SX
static from_file(*args)
from_file(str filename, str format_hint) -> DM
get(*args)
get(self, bool ind1, Sparsity sp) -> SX
get(self, bool ind1, Slice rr) -> SX
get(self, bool ind1, IM rr) -> SX
get(self, bool ind1, Slice rr, Slice cc) -> SX
get(self, bool ind1, Slice rr, IM cc) -> SX
get(self, bool ind1, IM rr, Slice cc) -> SX
get(self, bool ind1, IM rr, IM cc) -> SX
static get_free(*args)
get_free(Function f) -> [SX]
static get_input(*args)
get_input(Function f) -> [SX]
static get_max_depth(*args)
get_max_depth() -> int
get_nz(*args)
get_nz(self, bool ind1, Slice k) -> SX
get_nz(self, bool ind1, IM k) -> SX
has_duplicates(*args)
has_duplicates(self) -> bool
has_nz(*args)

[INTERNAL]

has_nz(self, int rr, int cc) -> bool

Returns true if the matrix has a non-zero at location rr, cc.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L219

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L65-L67

has_zeros(*args)

[INTERNAL]

has_zeros(self) -> bool

Check if the matrix has any zero entries which are not structural zeros.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1125

static inf(*args)

[INTERNAL]

inf(int nrow, int ncol) -> SX
inf((int,int) rc) -> SX
inf(Sparsity sp) -> SX

create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1005


inf(int nrow, int ncol)

[INTERNAL] create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1004



inf((int,int) rc)

[INTERNAL] create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1005



inf(Sparsity sp)

[INTERNAL] create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1003


info(*args)
info(self) -> dict
is_commutative(*args)
is_commutative(self) -> bool
is_constant(*args)

[INTERNAL]

is_constant(self) -> bool

Check if the matrix is constant (note that false negative answers are possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1085

is_eye(*args)

[INTERNAL]

is_eye(self) -> bool

check if the matrix is an identity matrix (note that false negative answers

are possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1114

is_integer(*args)

[INTERNAL]

is_integer(self) -> bool

Check if the matrix is integer-valued.

(note that false negative answers are possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1092

is_leaf(*args)
is_leaf(self) -> bool
is_minus_one(*args)

[INTERNAL]

is_minus_one(self) -> bool

check if the matrix is -1 (note that false negative answers are

possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1107

is_one(*args)

[INTERNAL]

is_one(self) -> bool

check if the matrix is 1 (note that false negative answers are

possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1102

is_op(*args)
is_op(self, int op) -> bool
is_regular(*args)
is_regular(self) -> bool
is_smooth(*args)
is_smooth(self) -> bool
is_symbolic(*args)
is_symbolic(self) -> bool
is_valid_input(*args)
is_valid_input(self) -> bool
is_zero(*args)

[INTERNAL]

is_zero(self) -> bool

check if the matrix is 0 (note that false negative answers are

possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1097

static matrix_matrix(*args)
matrix_matrix(int op, SX x, SX y) -> SX
static matrix_scalar(*args)
matrix_scalar(int op, SX x, SX y) -> SX
n_dep(*args)
n_dep(self) -> int
name(*args)
name(self) -> str
static nan(*args)

[INTERNAL]

nan(int nrow, int ncol) -> SX
nan((int,int) rc) -> SX
nan(Sparsity sp) -> SX

create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1014


nan(int nrow, int ncol)

[INTERNAL] create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1013



nan((int,int) rc)

[INTERNAL] create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1014



nan(Sparsity sp)

[INTERNAL] create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1012


nonzeros(*args)

[INTERNAL]

nonzeros(self) -> [SXElem]

Get all nonzeros.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1142

op(*args)
op(self) -> int
print_dense(*args)

[INTERNAL]

print_dense(self, bool truncate)

Print dense matrix-stype.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L889

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L686-L688

print_scalar(*args)

[INTERNAL]

print_scalar(self)

Print scalar.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L883

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L609-L633

print_sparse(*args)

[INTERNAL]

print_sparse(self, bool truncate)

Print sparse matrix style.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L892

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L691-L693

print_split(*args)

[INTERNAL]

print_split(self) -> ([str] OUTPUT, [str] OUTPUT)

Get strings corresponding to the nonzeros and the interdependencies.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L873

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L696-L700

print_vector(*args)

[INTERNAL]

print_vector(self, bool truncate)

Print vector-style.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L886

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_impl.hpp#L636-L638

printme(*args)
printme(self, SX y) -> SX
static rand(*args)

[INTERNAL]

rand(int nrow, int ncol) -> SX
rand((int,int) rc) -> SX
rand(Sparsity sp) -> SX

Create a matrix with uniformly distributed random numbers.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201


rand(Sparsity sp)


rand(int nrow, int ncol)

[INTERNAL] Create a matrix with uniformly distributed random numbers.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1197



rand((int,int) rc)

[INTERNAL] Create a matrix with uniformly distributed random numbers.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1201


remove(*args)

[INTERNAL]

remove(self, [int] rr, [int] cc)

Remove columns and rows.

Remove/delete rows and/or columns of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L944

reserve(*args)

[INTERNAL]

reserve(self, int nnz)
reserve(self, int nnz, int ncol)
reset_input(*args)
reset_input(self)
resize(*args)

[INTERNAL]

resize(self, int nrow, int ncol)
static rng(*args)
rng(int seed)
static scalar_matrix(*args)
scalar_matrix(int op, SX x, SX y) -> SX
serialize(*args)

[INTERNAL]

serialize(self) -> str
serialize(self, casadi::SerializingStream & s)

Serialize an object.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1249


serialize(self, casadi::SerializingStream & s)

[INTERNAL] Serialize an object.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1249



serialize(self)

[INTERNAL] Serialize.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1234


set(*args)
set(self, SX m, bool ind1, Sparsity sp)
set(self, SX m, bool ind1, Slice rr)
set(self, SX m, bool ind1, IM rr)
set(self, SX m, bool ind1, Slice rr, Slice cc)
set(self, SX m, bool ind1, Slice rr, IM cc)
set(self, SX m, bool ind1, IM rr, Slice cc)
set(self, SX m, bool ind1, IM rr, IM cc)
static set_max_depth(*args)
set_max_depth(int eq_depth)
set_nz(*args)
set_nz(self, SX m, bool ind1, Slice k)
set_nz(self, SX m, bool ind1, IM k)
static set_precision(*args)
set_precision(int precision)
static set_scientific(*args)
set_scientific(bool scientific)
static set_width(*args)
set_width(int width)
sparsity(*args)

[INTERNAL]

sparsity(self) -> Sparsity

Get an owning reference to the sparsity pattern.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L979

str(*args)

[INTERNAL]

str(self, bool more) -> str

Get string representation.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L880

to_file(*args)

[INTERNAL]

to_file(self, str filename, str format)

Export numerical matrix to file

Supported formats:

*   - .mtx   Matrix Market (sparse)
*   - .txt   Ascii full precision representation (sparse)
*            Whitespace separated, aligned.
*            Comments with # % or /
*            Uses C locale
*            Structural zeros represented by 00
*            Does not scale well for large sparse matrices
*

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/matrix_decl.hpp#L1269

static triplet(*args)
triplet([int] row, [int] col, SX d) -> SX
triplet([int] row, [int] col, SX d, (int,int) rc) -> SX
triplet([int] row, [int] col, SX d, int nrow, int ncol) -> SX
static type_name(*args)
type_name() -> str
static unary(*args)
unary(int op, SX x) -> SX

2.3. MX

class MX(*args)

[INTERNAL]

MX -  Matrix expression.

The MX class is used to build up trees made up from MXNodes. It is a more

general graph representation than the scalar expression, SX, and much less efficient for small objects. On the other hand, the class allows much more general operations than does SX, in particular matrix valued

operations and calls to arbitrary differentiable functions.

The MX class is designed to have identical syntax with the Matrix<> template

class, and uses DM (i.e. Matrix<double>) as its internal

representation of the values at a node. By keeping the syntaxes identical, it is possible to switch from one class to the other, as well as inlining MX functions to SXElem functions.

Note that an operation is always “lazy”, making a matrix multiplication will create a matrix multiplication node, not perform the actual multiplication.

Joel Andersson

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

C++ includes: mx.hpp

attachAssert(*args)

[INTERNAL]

attachAssert(self, MX y, str fail_message) -> MX

returns itself, but with an assertion attached

If y does not evaluate to 1, a runtime error is raised

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L851

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L699-L704

static binary(*args)

[INTERNAL]

binary(int op, MX x, MX y) -> MX

Create nodes by their ID.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L398

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L507-L532

static bspline_dual(*args)

[INTERNAL]

bspline_dual([float] x, [[float]] knots, [int] degree, dict opts) -> DM
dep(*args)

[INTERNAL]

dep(self, int ch) -> MX

Get the nth dependency as MX.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L236

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L730-L732

static deserialize(*args)
deserialize(casadi::DeserializingStream & s) -> MX
static einstein(*args)

[INTERNAL]

einstein(MX A, MX B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> MX
einstein(MX A, MX B, MX C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c) -> MX

Computes an einstein dense tensor contraction.

Computes the product: C_c = A_a + B_b where a b c are index/einstein

notation in an encoded form

For example, an matrix-matrix product may be written as: C_ij = A_ik B_kj

The encoded form uses strictly negative numbers to indicate labels. For the

above example, we would have: a {-1, -3} b {-3, -2} c {-1 -2}

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L520

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L646-L652


einstein(MX A, MX B, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c)

[INTERNAL] Computes an einstein dense tensor contraction.

Computes the product: C_c = A_a + B_b where a b c are index/einstein

notation in an encoded form

For example, an matrix-matrix product may be written as: C_ij = A_ik B_kj

The encoded form uses strictly negative numbers to indicate labels. For the

above example, we would have: a {-1, -3} b {-3, -2} c {-1 -2}

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L520

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L646-L652



einstein(MX A, MX B, MX C, [int] dim_a, [int] dim_b, [int] dim_c, [int] a, [int] b, [int] c)

[INTERNAL] Computes an einstein dense tensor contraction.

Computes the product: C_c = A_a + B_b where a b c are index/einstein

notation in an encoded form

For example, an matrix-matrix product may be written as: C_ij = A_ik B_kj

The encoded form uses strictly negative numbers to indicate labels. For the

above example, we would have: a {-1, -3} b {-3, -2} c {-1 -2}

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L514

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L638-L644


enlarge(*args)

[INTERNAL]

enlarge(self, int nrow, int ncol, [int] rr, [int] cc, bool ind1)

Enlarge matrix.

Make the matrix larger by inserting empty rows and columns, keeping the existing non-zeros

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L211

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L618-L626

erase(*args)

[INTERNAL]

erase(self, [int] rr, bool ind1)
erase(self, [int] rr, [int] cc, bool ind1)

Erase a submatrix (leaving structural zeros in its place)

Erase elements of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L204

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L604-L616


erase(self, [int] rr, bool ind1)

[INTERNAL] Erase a submatrix (leaving structural zeros in its place)

Erase elements of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L204

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L604-L616



erase(self, [int] rr, [int] cc, bool ind1)

[INTERNAL] Erase a submatrix (leaving structural zeros in its place)

Erase rows and/or columns of a matrix

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L196

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L590-L602


eval_mx(*args)

[INTERNAL]

eval_mx(self, [MX] arg) -> [MX]

Evaluate the MX node with new symbolic dependencies.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L897

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L2288-L2294

static eye(*args)
eye(int n) -> MX
get(*args)

[INTERNAL]

get(self, bool ind1, int rr) -> MX
get(self, bool ind1, Sparsity sp) -> MX
get(self, bool ind1, Slice rr) -> MX
get(self, bool ind1, IM rr) -> MX
get(self, bool ind1, MX rr) -> MX
get(self, bool ind1, int rr, int cc) -> MX
get(self, bool ind1, int rr, Slice cc) -> MX
get(self, bool ind1, Slice rr, int cc) -> MX
get(self, bool ind1, Slice rr, Slice cc) -> MX
get(self, bool ind1, Slice rr, IM cc) -> MX
get(self, bool ind1, Slice rr, MX cc) -> MX
get(self, bool ind1, IM rr, Slice cc) -> MX
get(self, bool ind1, IM rr, IM cc) -> MX
get(self, bool ind1, MX rr, Slice cc) -> MX
get(self, bool ind1, MX rr, MX cc) -> MX

Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L460

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L218-L221


get(self, bool ind1, IM rr)
get(self, bool ind1, Slice rr, IM cc)
get(self, bool ind1, IM rr, Slice cc)
get(self, bool ind1, IM rr, IM cc)


get(self, bool ind1, int rr)

[INTERNAL] Get a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L436

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L436-L438



get(self, bool ind1, Sparsity sp)

[INTERNAL] Get a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L434

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L194-L200



get(self, bool ind1, Slice rr)

[INTERNAL] Get a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L432

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L171-L174



get(self, bool ind1, MX rr)

[INTERNAL] Get a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L435

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L202-L206



get(self, bool ind1, int rr, int cc)

[INTERNAL] Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L454

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L454-L457



get(self, bool ind1, int rr, Slice cc)

[INTERNAL] Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L449

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L449-L451



get(self, bool ind1, Slice rr, int cc)

[INTERNAL] Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L445

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L445-L447



get(self, bool ind1, Slice rr, Slice cc)

[INTERNAL] Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L443

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L141-L144



get(self, bool ind1, Slice rr, MX cc)

[INTERNAL] Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L459

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L208-L211



get(self, bool ind1, MX rr, Slice cc)

[INTERNAL] Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L458

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L213-L216



get(self, bool ind1, MX rr, MX cc)

[INTERNAL] Get a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L460

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L218-L221


static get_free(*args)
get_free(Function f) -> [MX]
static get_input(*args)
get_input(Function f) -> [MX]
static get_max_depth(*args)
get_max_depth() -> int
get_nz(*args)

[INTERNAL]

get_nz(self, bool ind1, int kk) -> MX
get_nz(self, bool ind1, Slice kk) -> MX
get_nz(self, bool ind1, IM kk) -> MX
get_nz(self, bool ind1, MX kk) -> MX
get_nz(self, bool ind1, Slice inner, MX outer) -> MX
get_nz(self, bool ind1, MX inner, Slice outer) -> MX
get_nz(self, bool ind1, MX inner, MX outer) -> MX

Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L488

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L427-L430


get_nz(self, bool ind1, IM kk)


get_nz(self, bool ind1, int kk)

[INTERNAL] Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L483

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L483-L485



get_nz(self, bool ind1, Slice kk)

[INTERNAL] Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L480

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L384-L387



get_nz(self, bool ind1, MX kk)

[INTERNAL] Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L482

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L422-L425



get_nz(self, bool ind1, Slice inner, MX outer)

[INTERNAL] Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L487

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L432-L435



get_nz(self, bool ind1, MX inner, Slice outer)

[INTERNAL] Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L486

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L437-L440



get_nz(self, bool ind1, MX inner, MX outer)

[INTERNAL] Get a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L488

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L427-L430


get_output(*args)

[INTERNAL]

get_output(self, int oind) -> MX

Get an output.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L246

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L845-L847

get_temp(*args)
get_temp(self) -> int
has_duplicates(*args)
has_duplicates(self) -> bool
static inf(*args)

[INTERNAL]

inf(int nrow, int ncol) -> MX
inf((int,int) rc) -> MX
inf(Sparsity sp) -> MX

create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L408

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L554-L556


inf(int nrow, int ncol)

[INTERNAL] create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L407

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L550-L552



inf((int,int) rc)

[INTERNAL] create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L408

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L554-L556



inf(Sparsity sp)

[INTERNAL] create a matrix with all inf

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L406

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L558-L560


info(*args)

[INTERNAL]

info(self) -> dict

Obtain information about node

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L374

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L798-L800

static interpn_linear(*args)
interpn_linear([MX] x, MX v, [MX] xq, dict opts) -> MX
is_binary(*args)

[INTERNAL]

is_binary(self) -> bool

Is binary operation.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L365

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L786-L788

is_call(*args)

[INTERNAL]

is_call(self) -> bool

Check if evaluation.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L269

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L750-L752

is_commutative(*args)

[INTERNAL]

is_commutative(self) -> bool

Check if commutative operation.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L287

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L822-L827

is_constant(*args)

[INTERNAL]

is_constant(self) -> bool

Check if constant.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L266

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L746-L748

is_eye(*args)

[INTERNAL]

is_eye(self) -> bool

check if identity

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L339

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L937-L939

is_minus_one(*args)

[INTERNAL]

is_minus_one(self) -> bool

check if zero (note that false negative answers are possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L354

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L953-L955

is_multiplication(*args)

[INTERNAL]

is_multiplication(self) -> bool

Check if multiplication.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L284

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L770-L772

is_norm(*args)

[INTERNAL]

is_norm(self) -> bool

Check if norm.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L290

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L774-L776

is_one(*args)

[INTERNAL]

is_one(self) -> bool

check if zero (note that false negative answers are possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L349

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L949-L951

is_op(*args)

[INTERNAL]

is_op(self, int op) -> bool

Is it a certain operation.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L281

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L766-L768

is_output(*args)

[INTERNAL]

is_output(self) -> bool

Check if evaluation output.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L275

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L758-L760

is_regular(*args)

[INTERNAL]

is_regular(self) -> bool

Checks if expression does not contain NaN or Inf.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L362

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L961-L967

is_symbolic(*args)

[INTERNAL]

is_symbolic(self) -> bool

Check if symbolic.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L263

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L742-L744

is_transpose(*args)

[INTERNAL]

is_transpose(self) -> bool

Is the expression a transpose?

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L359

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L957-L959

is_unary(*args)

[INTERNAL]

is_unary(self) -> bool

Is unary operation.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L368

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L790-L792

is_valid_input(*args)

[INTERNAL]

is_valid_input(self) -> bool

Check if matrix can be used to define function inputs.

Valid inputs for MXFunctions are combinations of Reshape, concatenations and SymbolicMX

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L297

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L897-L899

is_zero(*args)

[INTERNAL]

is_zero(self) -> bool

check if zero (note that false negative answers are possible)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L344

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L941-L947

join_primitives(*args)

[INTERNAL]

join_primitives(self, [MX] v) -> MX

Join an expression along symbolic primitives.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L317

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L921-L927

mapping(*args)

[INTERNAL]

mapping(self) -> IM

Get an IM representation of a GetNonzeros or SetNonzeros node.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L866

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L829-L831

monitor(*args)

[INTERNAL]

monitor(self, str comment) -> MX

Monitor an expression.

Returns itself, but with the side effect of printing the nonzeros along with a comment

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L858

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L706-L708

n_dep(*args)

[INTERNAL]

n_dep(self) -> int

Get the number of dependencies of a binary SXElem.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L251

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L734-L736

n_out(*args)

[INTERNAL]

n_out(self) -> int

Number of outputs.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L241

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L841-L843

n_primitives(*args)

[INTERNAL]

n_primitives(self) -> int

Get the number of primitives for MXFunction inputs/outputs.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L302

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L901-L903

name(*args)

[INTERNAL]

name(self) -> str

Get the name.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L254

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L738-L740

static nan(*args)

[INTERNAL]

nan(int nrow, int ncol) -> MX
nan((int,int) rc) -> MX
nan(Sparsity sp) -> MX

create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L417

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L566-L568


nan(int nrow, int ncol)

[INTERNAL] create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L416

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L562-L564



nan((int,int) rc)

[INTERNAL] create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L417

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L566-L568



nan(Sparsity sp)

[INTERNAL] create a matrix with all nan

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L415

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L570-L572


op(*args)

[INTERNAL]

op(self) -> int

Get operation type.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L371

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L794-L796

primitives(*args)

[INTERNAL]

primitives(self) -> [MX]

Get primitives.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L307

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L905-L911

printme(*args)

[INTERNAL]

printme(self, MX b) -> MX
reset_input(*args)
reset_input(self)
serialize(*args)

[INTERNAL]

serialize(self, casadi::SerializingStream & s)

Serialize an object.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L379

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L802-L804

set(*args)
set(self, MX m, bool ind1, Sparsity sp)
set(self, MX m, bool ind1, Slice rr)
set(self, MX m, bool ind1, IM rr)
set(self, MX m, bool ind1, Slice rr, Slice cc)
set(self, MX m, bool ind1, Slice rr, IM cc)
set(self, MX m, bool ind1, IM rr, Slice cc)
set(self, MX m, bool ind1, IM rr, IM cc)

set(self, MX m, bool ind1, IM rr)
set(self, MX m, bool ind1, Slice rr, IM cc)
set(self, MX m, bool ind1, IM rr, Slice cc)
set(self, MX m, bool ind1, IM rr, IM cc)


set(self, MX m, bool ind1, Sparsity sp)

[INTERNAL] Set a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L467

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L371-L382



set(self, MX m, bool ind1, Slice rr)

[INTERNAL] Set a submatrix, single argument

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L465

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L298-L301



set(self, MX m, bool ind1, Slice rr, Slice cc)

[INTERNAL] Set a submatrix, two arguments

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L472

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L223-L226


static set_max_depth(*args)
set_max_depth(int eq_depth)
set_nz(*args)

[INTERNAL]

set_nz(self, MX m, bool ind1, int kk)
set_nz(self, MX m, bool ind1, Slice kk)
set_nz(self, MX m, bool ind1, IM kk)
set_nz(self, MX m, bool ind1, MX kk)

Set a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L496

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L496-L496


set_nz(self, MX m, bool ind1, IM kk)


set_nz(self, MX m, bool ind1, int kk)

[INTERNAL] Set a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L496

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L496-L496



set_nz(self, MX m, bool ind1, Slice kk)

[INTERNAL] Set a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L493

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L442-L445



set_nz(self, MX m, bool ind1, MX kk)

[INTERNAL] Set a set of nonzeros

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L495

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L503-L505


set_temp(*args)
set_temp(self, int t)
sparsity(*args)

[INTERNAL]

sparsity(self) -> Sparsity

Get an owning reference to the sparsity pattern.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L189

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L189-L189

split_primitives(*args)

[INTERNAL]

split_primitives(self, MX x) -> [MX]

Split up an expression along symbolic primitives.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L312

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L913-L919

static test_cast(*args)
test_cast(casadi::SharedObjectInternal const * ptr) -> bool
to_DM(*args)
to_DM(self) -> DM
static type_name(*args)
type_name() -> str
static unary(*args)

[INTERNAL]

unary(int op, MX x) -> MX

Create nodes by their ID.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L399

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L534-L536

which_function(*args)

[INTERNAL]

which_function(self) -> Function

Get function - only valid when is_call() is true.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L272

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L754-L756

which_output(*args)

[INTERNAL]

which_output(self) -> int

Get the index of evaluation output - only valid when is_output() is true.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.hpp#L278

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/mx.cpp#L762-L764

2.4. Sparsity

class Sparsity(*args)
.. py:method:: Sparsity.add_nz(*args)
module:

casadi.casadi

add_nz(self, int rr, int cc) -> int
amd(*args)
amd(self) -> [int]
append(*args)
append(self, Sparsity sp)
appendColumns(*args)
appendColumns(self, Sparsity sp)
static band(*args)
band(int n, int p) -> Sparsity
static banded(*args)
banded(int n, int p) -> Sparsity
btf(*args)
btf(self) -> (int , [int] OUTPUT, [int] OUTPUT, [int] OUTPUT, [int] OUTPUT, [int] OUTPUT, [int] OUTPUT)
bw_lower(*args)
bw_lower(self) -> int
bw_upper(*args)
bw_upper(self) -> int
colind(*args)
colind(self) -> [int]
colind(self, int cc) -> int
columns(*args)
columns(self) -> int
combine(*args)
combine(self, Sparsity y, bool f0x_is_zero, bool function0_is_zero) -> Sparsity
compress(*args)
compress(self) -> [int]
static compressed(*args)
compressed([int] v, bool order_rows) -> Sparsity
static dense(*args)
dense(int nrow, int ncol) -> Sparsity
dense((int,int) rc) -> Sparsity
density(*args)
density(self) -> float
static deserialize(*args)
deserialize(std::istream & stream) -> Sparsity
deserialize(casadi::DeserializingStream & s) -> Sparsity
deserialize(str s) -> Sparsity
dfs(*args)
dfs(self, int j, int top, [int] pinv) -> (int , [int] INOUT, [int] INOUT, [bool] INOUT)
static diag(*args)
diag(int nrow) -> Sparsity
diag((int,int) rc) -> Sparsity
diag(int nrow, int ncol) -> Sparsity
dim(*args)
dim(self, bool with_nz) -> str
enlarge(*args)
enlarge(self, int nrow, int ncol, [int] rr, [int] cc, bool ind1)
enlargeColumns(*args)
enlargeColumns(self, int ncol, [int] cc, bool ind1)
enlargeRows(*args)
enlargeRows(self, int nrow, [int] rr, bool ind1)
erase(*args)
erase(self, [int] rr, bool ind1) -> [int]
erase(self, [int] rr, [int] cc, bool ind1) -> [int]
etree(*args)
etree(self, bool ata) -> [int]
export_code(*args)
export_code(self, str lang, dict options)
find(*args)
find(self, bool ind1) -> [int]
static from_file(*args)
from_file(str filename, str format_hint) -> Sparsity
get_ccs(*args)
get_ccs(self) -> ([int] OUTPUT, [int] OUTPUT)
get_col(*args)
get_col(self) -> [int]
get_crs(*args)
get_crs(self) -> ([int] OUTPUT, [int] OUTPUT)
get_diag(*args)
get_diag(self) -> (Sparsity , [int] OUTPUT)
get_lower(*args)
get_lower(self) -> [int]
get_nz(*args)
get_nz(self) -> [int]
get_nz(self, int rr, int cc) -> int
get_nz(self, [int] rr, [int] cc) -> [int]
get_triplet(*args)
get_triplet(self) -> ([int] OUTPUT, [int] OUTPUT)
get_upper(*args)
get_upper(self) -> [int]
has_nz(*args)
has_nz(self, int rr, int cc) -> bool
hash(*args)
hash(self) -> std::size_t
info(*args)
info(self) -> dict
intersect(*args)
intersect(self, Sparsity y) -> Sparsity
is_column(*args)
is_column(self) -> bool
is_dense(*args)
is_dense(self) -> bool
is_diag(*args)
is_diag(self) -> bool
is_empty(*args)
is_empty(self, bool both) -> bool
is_equal(*args)
is_equal(self, Sparsity y) -> bool
is_equal(self, int nrow, int ncol, [int] colind, [int] row) -> bool
is_orthonormal(*args)
is_orthonormal(self, bool allow_empty) -> bool
is_orthonormal_columns(*args)
is_orthonormal_columns(self, bool allow_empty) -> bool
is_orthonormal_rows(*args)
is_orthonormal_rows(self, bool allow_empty) -> bool
is_permutation(*args)
is_permutation(self) -> bool
is_reshape(*args)
is_reshape(self, Sparsity y) -> bool
is_row(*args)
is_row(self) -> bool
is_scalar(*args)
is_scalar(self, bool scalar_and_dense) -> bool
is_selection(*args)
is_selection(self, bool allow_empty) -> bool
is_singular(*args)
is_singular(self) -> bool
is_square(*args)
is_square(self) -> bool
is_stacked(*args)
is_stacked(self, Sparsity y, int n) -> bool
is_subset(*args)
is_subset(self, Sparsity rhs) -> bool
is_symmetric(*args)
is_symmetric(self) -> bool
is_transpose(*args)
is_transpose(self, Sparsity y) -> bool
is_tril(*args)
is_tril(self, bool strictly) -> bool
is_triu(*args)
is_triu(self, bool strictly) -> bool
is_vector(*args)
is_vector(self) -> bool
static kkt(*args)
kkt(Sparsity H, Sparsity J, bool with_x_diag, bool with_lam_g_diag) -> Sparsity
largest_first(*args)
largest_first(self) -> [int]
ldl(*args)
ldl(self, bool amd) -> (Sparsity , [int] OUTPUT)
static lower(*args)
lower(int n) -> Sparsity
makeDense(*args)
makeDense(self) -> (Sparsity , [int] OUTPUT)
nnz(*args)
nnz(self) -> int
nnz_diag(*args)
nnz_diag(self) -> int
nnz_lower(*args)
nnz_lower(self, bool strictly) -> int
nnz_upper(*args)
nnz_upper(self, bool strictly) -> int
static nonzeros(*args)
nonzeros(int nrow, int ncol, [int] nz, bool ind1) -> Sparsity
numel(*args)
numel(self) -> int
pattern_inverse(*args)
pattern_inverse(self) -> Sparsity
static permutation(*args)
permutation([int] p, bool invert) -> Sparsity
permutation_vector(*args)
permutation_vector(self, bool invert) -> [int]
pmult(*args)
pmult(self, [int] p, bool permute_rows, bool permute_columns, bool invert_permutation) -> Sparsity
postfix_dim(*args)
postfix_dim(self) -> str
qr_sparse(*args)
qr_sparse(self, bool amd) -> (Sparsity OUTPUT, Sparsity OUTPUT, [int] OUTPUT, [int] OUTPUT)
removeDuplicates(*args)
removeDuplicates(self) -> [int]
repr_el(*args)
repr_el(self, int k) -> str
resize(*args)
resize(self, int nrow, int ncol)
row(*args)
row(self) -> [int]
row(self, int el) -> int
static rowcol(*args)
rowcol([int] row, [int] col, int nrow, int ncol) -> Sparsity
rows(*args)
rows(self) -> int
rowsSequential(*args)
rowsSequential(self, bool strictly) -> bool
static scalar(*args)
scalar(bool dense_scalar) -> Sparsity
scc(*args)
scc(self) -> (int , [int] OUTPUT, [int] OUTPUT)
serialize(*args)
serialize(self) -> str
serialize(self, casadi::SerializingStream & s)
size(*args)
size(self) -> (int,int)
size(self, int axis) -> int
size1(*args)
size1(self) -> int
size2(*args)
size2(self) -> int
sparsity_cast_mod(*args)
sparsity_cast_mod(self, Sparsity X, Sparsity Y) -> Sparsity
spy(*args)
spy(self)
spy_matlab(*args)
spy_matlab(self, str mfile)
star_coloring(*args)
star_coloring(self, int ordering, int cutoff) -> Sparsity
star_coloring2(*args)
star_coloring2(self, int ordering, int cutoff) -> Sparsity
sub(*args)
sub(self, [int] rr, Sparsity sp, bool ind1) -> (Sparsity , [int] OUTPUT)
sub(self, [int] rr, [int] cc, bool ind1) -> (Sparsity , [int] OUTPUT)
static test_cast(*args)
test_cast(casadi::SharedObjectInternal const * ptr) -> bool
to_file(*args)
to_file(self, str filename, str format_hint)
transpose(*args)
transpose(self, bool invert_mapping) -> (Sparsity , [int] OUTPUT)
static triplet(*args)
triplet(int nrow, int ncol, [int] row, [int] col) -> Sparsity
triplet(int nrow, int ncol, [int] row, [int] col, bool invert_mapping) -> (Sparsity , [int] OUTPUT)
static type_name(*args)
type_name() -> str
uni_coloring(*args)
uni_coloring(self, Sparsity AT, int cutoff) -> Sparsity
static unit(*args)
unit(int n, int el) -> Sparsity
unite(*args)
unite(self, Sparsity y) -> Sparsity
static upper(*args)
upper(int n) -> Sparsity

2.5. Function

class Function(*args)

[INTERNAL]

Function object.

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.

Joel Andersson

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

>List of available options

Id

Type

Description

Used in

ad_weight

OT_DOUBLE

Weighting factor for derivative calculation.When there is an option of either using forward or reverse mode directional derivatives, the condition ad_wei ght*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::Function Internal

ad_weight_sp

OT_DOUBLE

Weighting factor for sparsity pattern calculation calc ulation.Override s 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::Function Internal

always_inline

OT_BOOL

Force inlining.

casadi::Function Internal

cache

OT_DICT

Prepopulate the function cache. Default: empty

casadi::Function Internal

compiler

OT_STRING

Just-in-time compiler plugin to be used.

casadi::Function Internal

custom_jacobian

OT_FUNCTION

Override CasADi’s AD. Use together with ‘jac_penalty’: 0. Note: Highly experimental. Syntax may break often.

casadi::Function Internal

der_options

OT_DICT

Default options to be used to populate forward_options, reverse_options, and jacobian_options before those options are merged in.

casadi::Function Internal

derivative_of

OT_FUNCTION

The function is a derivative of another function. The type of derivative (directional derivative, Jacobian) is inferred from the function name.

casadi::Function Internal

dump

OT_BOOL

Dump function to file upon first evaluation. [false]

casadi::Function Internal

dump_dir

OT_STRING

Directory to dump inputs/outputs to. Make sure the directory exists [.]

casadi::Function Internal

dump_format

OT_STRING

Choose file format to dump matrices. See DM.from_file [mtx]

casadi::Function Internal

dump_in

OT_BOOL

Dump numerical values of inputs to file (readable with DM.from_file ) [default: false]

casadi::Function Internal

dump_out

OT_BOOL

Dump numerical values of outputs to file (readable with DM.from_file ) [default: false]

casadi::Function Internal

enable_fd

OT_BOOL

Enable derivative calculation by finite differencing. [default: false]]

casadi::Function Internal

enable_forward

OT_BOOL

Enable derivative calculation using generated functions for Jacobian-times- vector products - typically using forward mode AD - if available. [default: true]

casadi::Function Internal

enable_jacobian

OT_BOOL

Enable derivative calculation using generated functions for Jacobians of all differentiable outputs with respect to all differentiable inputs - if available. [default: true]

casadi::Function Internal

enable_reverse

OT_BOOL

Enable derivative calculation using generated functions for transposed Jacobian-times- vector products - typically using reverse mode AD - if available. [default: true]

casadi::Function Internal

error_on_fail

OT_BOOL

Throw exceptions when function evaluation fails (default true).

casadi::ProtoFun ction

fd_method

OT_STRING

Method for finite differencing [default ‘central’]

casadi::Function Internal

fd_options

OT_DICT

Options to be passed to the finite difference instance

casadi::Function Internal

forward_options

OT_DICT

Options to be passed to a forward mode constructor

casadi::Function Internal

gather_stats

OT_BOOL

Deprecated option (ignored): Statistics are now always collected.

casadi::Function Internal

input_scheme

OT_STRINGVECTOR

Deprecated option (ignored)

casadi::Function Internal

inputs_check

OT_BOOL

Throw exceptions when the numerical values of the inputs don’t make sense

casadi::Function Internal

is_diff_in

OT_BOOLVECTOR

Indicate for each input if it should be differentiable.

casadi::Function Internal

is_diff_out

OT_BOOLVECTOR

Indicate for each output if it should be differentiable.

casadi::Function Internal

jac_penalty

OT_DOUBLE

When 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 strategy

casadi::Function Internal

jacobian_options

OT_DICT

Options to be passed to a Jacobian constructor

casadi::Function Internal

jit

OT_BOOL

Use just-in-time compiler to speed up the evaluation

casadi::Function Internal

jit_cleanup

OT_BOOL

Cleanup up the temporary source file that jit creates. Default: true

casadi::Function Internal

jit_name

OT_STRING

The file name used to write out code. The actual file names used depend on ‘jit_t emp_suffix’ and include extensions. Default: ‘jit_tmp’

casadi::Function Internal

jit_options

OT_DICT

Options to be passed to the jit compiler.

casadi::Function Internal

jit_serialize

OT_STRING

Specify behaviour when serializing a jitted function: SOURCE|link|embe d.

casadi::Function Internal

jit_temp_suffix

OT_BOOL

Use 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: true

casadi::Function Internal

max_io

OT_INT

Acceptable number of inputs and outputs. Warn if exceeded.

casadi::Function Internal

max_num_dir

OT_INT

Specify the maximum number of directions for derivative functions. Overrules the builtin optimize d_num_dir.

casadi::Function Internal

never_inline

OT_BOOL

Forbid inlining.

casadi::Function Internal

output_scheme

OT_STRINGVECTOR

Deprecated option (ignored)

casadi::Function Internal

post_expand

OT_BOOL

After construction, expand this Function . Default: False

casadi::Function Internal

post_expand_opti ons

OT_DICT

Options to be passed to post- construction expansion. Default: empty

casadi::Function Internal

print_in

OT_BOOL

Print numerical values of inputs [default: false]

casadi::Function Internal

print_out

OT_BOOL

Print numerical values of outputs [default: false]

casadi::Function Internal

print_time

OT_BOOL

print information about execution time. Implies record_time.

casadi::ProtoFun ction

record_time

OT_BOOL

record information about execution time, for retrieval with stats() .

casadi::ProtoFun ction

regularity_check

OT_BOOL

Throw exceptions when NaN or Inf appears during evaluation

casadi::ProtoFun ction

reverse_options

OT_DICT

Options to be passed to a reverse mode constructor

casadi::Function Internal

user_data

OT_VOIDPTR

A user-defined field that can be used to identify the function or pass additional information

casadi::Function Internal

verbose

OT_BOOL

Verbose evaluation for debugging

casadi::ProtoFun ction

C++ includes: function.hpp

assert_size_in(*args)

[INTERNAL]

assert_size_in(self, int i, int nrow, int ncol)

Assert that an input dimension is equal so some given value.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1189

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1723-L1729

assert_size_out(*args)

[INTERNAL]

assert_size_out(self, int i, int nrow, int ncol)

Assert that an output dimension is equal so some given value.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1192

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1731-L1736

assert_sparsity_out(*args)

[INTERNAL]

assert_sparsity_out(self, int i, Sparsity sp, int n, bool allow_all_zero_sparse)

Assert that an output sparsity is a multiple of some given sparsity.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1195

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1738-L1747

static bspline(*args)
bspline(str name, [[float]] knots, [float] coeffs, [int] degree, int m, dict opts) -> Function
buffer()

Create a FunctionBuffer object for evaluating with minimal overhead

cache(*args)

[INTERNAL]

cache(self) -> dict

Get all functions in the cache.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1212

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1773-L1780

call(*args)

[INTERNAL]

call(self, dict:DM arg, bool always_inline, bool never_inline) -> dict:DM
call(self, [DM] arg, bool always_inline, bool never_inline) -> [DM]
call(self, [SX] arg, bool always_inline, bool never_inline) -> [SX]
call(self, dict:SX arg, bool always_inline, bool never_inline) -> dict:SX
call(self, dict:MX arg, bool always_inline, bool never_inline) -> dict:MX
call(self, [MX] arg, bool always_inline, bool never_inline) -> [MX]

Evaluate the function symbolically or numerically.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L524

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1414-L1421


call(self, dict:DM arg, bool always_inline, bool never_inline)

[INTERNAL] Evaluate the function symbolically or numerically.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L520

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1396-L1403



call(self, [DM] arg, bool always_inline, bool never_inline)

[INTERNAL] Evaluate the function symbolically or numerically.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L514

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L325-L332



call(self, [SX] arg, bool always_inline, bool never_inline)

[INTERNAL] Evaluate the function symbolically or numerically.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L516

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L334-L341



call(self, dict:SX arg, bool always_inline, bool never_inline)

[INTERNAL] Evaluate the function symbolically or numerically.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L522

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1405-L1412



call(self, dict:MX arg, bool always_inline, bool never_inline)

[INTERNAL] Evaluate the function symbolically or numerically.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L524

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1414-L1421



call(self, [MX] arg, bool always_inline, bool never_inline)

[INTERNAL] Evaluate the function symbolically or numerically.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L518

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L343-L350


change_option(*args)

[INTERNAL]

change_option(self, str option_name, GenericType option_value)

Change option after object creation for debugging.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L455

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1116-L1126

static check_name(*args)
check_name(str name) -> bool
checkout(*args)

[INTERNAL]

checkout(self) -> int

Checkout a memory object.

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1199

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1711-L1713

static conditional(*args)
conditional(str name, Function f, dict opts) -> Function
conditional(str name, [Function] f, Function f_def, dict opts) -> Function
convert_in(*args)

[INTERNAL]

convert_in(self, dict:DM arg) -> [DM]
convert_in(self, [DM] arg) -> dict:DM
convert_in(self, [SX] arg) -> dict:SX
convert_in(self, dict:SX arg) -> [SX]
convert_in(self, dict:MX arg) -> [MX]
convert_in(self, [MX] arg) -> dict:MX

Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L996

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1595-L1597


convert_in(self, dict:DM arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L988

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1563-L1565



convert_in(self, [DM] arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L987

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1559-L1561



convert_in(self, [SX] arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L991

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1575-L1577



convert_in(self, dict:SX arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L992

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1579-L1581



convert_in(self, dict:MX arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L996

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1595-L1597



convert_in(self, [MX] arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L995

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1591-L1593


convert_out(*args)

[INTERNAL]

convert_out(self, dict:DM arg) -> [DM]
convert_out(self, [DM] arg) -> dict:DM
convert_out(self, [SX] arg) -> dict:SX
convert_out(self, dict:SX arg) -> [SX]
convert_out(self, dict:MX arg) -> [MX]
convert_out(self, [MX] arg) -> dict:MX

Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L998

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1603-L1605


convert_out(self, dict:DM arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L990

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1571-L1573



convert_out(self, [DM] arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L989

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1567-L1569



convert_out(self, [SX] arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L993

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1583-L1585



convert_out(self, dict:SX arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L994

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1587-L1589



convert_out(self, dict:MX arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L998

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1603-L1605



convert_out(self, [MX] arg)

[INTERNAL] Convert from/to input/output lists/map.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L997

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1599-L1601


default_in(*args)

[INTERNAL]

default_in(self, int ind) -> float

Get default input value.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L346

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1423-L1425

static deserialize(*args)
deserialize(std::istream & stream) -> Function
deserialize(casadi::DeserializingStream & s) -> Function
deserialize(str s) -> Function
expand(*args)

[INTERNAL]

expand(self) -> Function
expand(self, str name, dict opts) -> Function

Expand a function to SX.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L207

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L286-L302


expand(self)

[INTERNAL] Expand a function to SX.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L206

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L276-L284



expand(self, str name, dict opts)

[INTERNAL] Expand a function to SX.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L207

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L286-L302


export_code(*args)

[INTERNAL]

export_code(self, str lang, dict options) -> str
export_code(self, str lang, str fname, dict options)

Export function in specific language.

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

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L902

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1244-L1248


export_code(self, str lang, dict options)

[INTERNAL] Export function in specific language.

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

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L902

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1244-L1248



export_code(self, str lang, str fname, dict options)

[INTERNAL] Export function in specific language.

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

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L875

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1205-L1209


factory(*args)

[INTERNAL]

factory(self, str name, [str] s_in, [str] s_out, dict:[str] aux, dict opts) -> Function
find_function(*args)

[INTERNAL]

find_function(self, str name, int max_depth) -> Function

Get a specific function embedded in the expression graphs.

1. Parameters:

name: Name of function needed

max_depth: Maximum depth - a negative number indicates no maximum

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1242

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1826-L1843

find_functions(*args)

[INTERNAL]

find_functions(self, int max_depth) -> [Function]

Get all functions embedded in the expression graphs.

1. Parameters:

max_depth: Maximum depth - a negative number indicates no maximum

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1234

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1808-L1824

static fix_name(*args)
fix_name(str name) -> str
fold(*args)

[INTERNAL]

fold(self, int N, dict opts) -> Function

Create a mapaccumulated version of this function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L698

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L477-L483

forward(*args)

[INTERNAL]

forward(self, int nfwd) -> Function

Get a function that calculates nfwd forward derivatives.

 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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L800

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1079-L1085

free_mx(*args)

[INTERNAL]

free_mx(self) -> [MX]

Get all the free variables of the function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1019

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1619-L1625

free_sx(*args)

[INTERNAL]

free_sx(self) -> [SX]

Get all the free variables of the function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1014

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1611-L1617

generate(*args)

[INTERNAL]

generate(self, dict opts) -> str
generate(self, str fname, dict opts) -> str

Export / Generate C code for the function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L840

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1132-L1134


generate(self, dict opts)

[INTERNAL] Export / Generate C code for the function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L840

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1132-L1134



generate(self, str fname, dict opts)

[INTERNAL] Export / Generate C code for the function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L835

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1136-L1140


generate_dependencies(*args)

[INTERNAL]

generate_dependencies(self, str fname, dict opts) -> str

Export / Generate C code for the dependency function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L845

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1142-L1144

generate_in(*args)

[INTERNAL]

generate_in(self, str fname) -> [DM]
generate_in(self, str fname, [DM] arg)

Export an input file that can be passed to generate C code with a main.

See:

generate_out

See:

convert_in to convert between dict/map and vector

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L855

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1176-L1186


generate_in(self, str fname)

[INTERNAL] Export an input file that can be passed to generate C code with a main.

See:

generate_out

See:

convert_in to convert between dict/map and vector

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L855

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1176-L1186



generate_in(self, str fname, [DM] arg)

[INTERNAL] Export an input file that can be passed to generate C code with a main.

See:

generate_out

See:

convert_in to convert between dict/map and vector

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L854

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1146-L1159


generate_lifted(*args)

[INTERNAL]

generate_lifted(self) -> (Function OUTPUT, Function OUTPUT)

Extract the functions needed for the Lifted Newton method.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1024

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1639-L1645

generate_out(*args)

[INTERNAL]

generate_out(self, str fname) -> [DM]
generate_out(self, str fname, [DM] arg)

Export an output file that can be checked with generated C code

output.

See:

generate_in

See:

convert_out to convert between dict/map and vector

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L866

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1188-L1198


generate_out(self, str fname)

[INTERNAL] Export an output file that can be checked with generated C code

output.

See:

generate_in

See:

convert_out to convert between dict/map and vector

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L866

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1188-L1198



generate_out(self, str fname, [DM] arg)

[INTERNAL] Export an output file that can be checked with generated C code

output.

See:

generate_in

See:

convert_out to convert between dict/map and vector

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L865

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1161-L1174


get_free(*args)

[INTERNAL]

get_free(self) -> [str]

Get free variables as a string.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1009

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1128-L1130

get_function(*args)

[INTERNAL]

get_function(self) -> [str]
get_function(self, str name) -> Function

Get a dependency function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1222

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1791-L1797


get_function(self, str name)

[INTERNAL] Get a dependency function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1222

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1791-L1797



get_function(self)

[INTERNAL] Get a list of all functions.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1217

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1782-L1789


has_free(*args)

[INTERNAL]

has_free(self) -> bool

Does the function have free variables.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1004

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1635-L1637

has_function(*args)

[INTERNAL]

has_function(self, str fname) -> bool

Check if a particular dependency exists.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1227

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1799-L1806

has_option(*args)

[INTERNAL]

has_option(self, str option_name) -> bool

Does a particular option exist.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L447

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1107-L1114

has_spfwd(*args)

[INTERNAL]

has_spfwd(self) -> bool

Is the class able to propagate seeds through the algorithm?

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1078

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1627-L1629

has_sprev(*args)

[INTERNAL]

has_sprev(self) -> bool

Is the class able to propagate seeds through the algorithm?

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1079

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1631-L1633

hessian_old(*args)

[DEPRECATED] Replaced by Function::factory.

hessian_old(self, int iind, int oind) -> Function

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L471

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L864-L872

static if_else(*args)
if_else(str name, Function f_true, Function f_false, dict opts) -> Function
index_in(*args)

[INTERNAL]

index_in(self, str name) -> int

Find the index for a string describing a particular entry of an input scheme.

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

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L333

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L927-L933

index_out(*args)

[INTERNAL]

index_out(self, str name) -> int

Find the index for a string describing a particular entry of an output

scheme.

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

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L341

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L935-L941

info(*args)

[INTERNAL]

info(self) -> dict

Obtain information about function

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1245

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1872-L1874

instruction_MX(*args)

[INTERNAL]

instruction_MX(self, int k) -> MX

Get the MX node corresponding to an instruction (MXFunction)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1064

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1655-L1661

instruction_constant(*args)

[INTERNAL]

instruction_constant(self, int k) -> float

Get the floating point output argument of an instruction (SXFunction)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1052

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1687-L1693

instruction_id(*args)

[INTERNAL]

instruction_id(self, int k) -> int

Identifier index of the instruction (SXFunction/MXFunction)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1040

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1671-L1677

instruction_input(*args)

[INTERNAL]

instruction_input(self, int k) -> [int]

Locations in the work vector for the inputs of the instruction.

(SXFunction/MXFunction)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1047

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1679-L1685

instruction_output(*args)

[INTERNAL]

instruction_output(self, int k) -> [int]

Location in the work vector for the output of the instruction.

(SXFunction/MXFunction)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1059

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1695-L1701

instructions_sx(*args)

[INTERNAL]

instructions_sx(self) -> SX

Get the SX node corresponding to all instructions (SXFunction)

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1072

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1663-L1669

is_a(*args)

[INTERNAL]

is_a(self, str type, bool recursive) -> bool

Check if the function is of a particular type.

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

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L1144

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1607-L1609

is_diff_in(*args)

[INTERNAL]

is_diff_in(self) -> [bool]
is_diff_in(self, int ind) -> bool

Get differentiability of inputs/output.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L390

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1007-L1013


is_diff_in(self)

[INTERNAL] Get differentiability of inputs/output.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L390

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1007-L1013



is_diff_in(self, int ind)

[INTERNAL] Get differentiability of inputs/output.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L388

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L991-L997


is_diff_out(*args)

[INTERNAL]

is_diff_out(self) -> [bool]
is_diff_out(self, int ind) -> bool

Get differentiability of inputs/output.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L391

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1015-L1021


is_diff_out(self)

[INTERNAL] Get differentiability of inputs/output.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L391

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L1015-L1021



is_diff_out(self, int ind)

[INTERNAL] Get differentiability of inputs/output.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L389

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L999-L1005


jac_sparsity(*args)

[INTERNAL]

jac_sparsity(self, bool compact) -> [Sparsity]
jac_sparsity(self, int oind, int iind, bool compact) -> Sparsity

Get, if necessary generate, the sparsity of a single Jacobian block.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L830

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L911-L917


jac_sparsity(self, bool compact)

[INTERNAL] Get, if necessary generate, the sparsity of all Jacobian blocks.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L825

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L900-L909



jac_sparsity(self, int oind, int iind, bool compact)

[INTERNAL] Get, if necessary generate, the sparsity of a single Jacobian block.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L830

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L911-L917


jacobian(*args)

[INTERNAL]

jacobian(self) -> Function

Calculate all Jacobian blocks.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L508

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L884-L890

jacobian_old(*args)

[DEPRECATED] Replaced by Function::factory.

jacobian_old(self, int iind, int oind) -> Function

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L466

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L856-L862

static jit(*args)

[INTERNAL]

jit(str name, str body, [str] name_in, [str] name_out, dict opts) -> Function
jit(str name, str body, [str] name_in, [str] name_out, [Sparsity] sparsity_in, [Sparsity] sparsity_out, dict opts) -> Function

Create a just-in-time compiled function from a C language string.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L189

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L262-L274


jit(str name, str body, [str] name_in, [str] name_out, dict opts)

[INTERNAL] Create a just-in-time compiled function from a C language string.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L185

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L253-L260



jit(str name, str body, [str] name_in, [str] name_out, [Sparsity] sparsity_in, [Sparsity] sparsity_out, dict opts)

[INTERNAL] Create a just-in-time compiled function from a C language string.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L189

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L262-L274


static load(*args)
load(str filename) -> Function
map(*args)

[INTERNAL]

map(self, int n, str parallelization) -> Function
map(self, int n, [bool] reduce_in, [bool] reduce_out, dict opts) -> Function
map(self, int n, str parallelization, int max_num_threads) -> Function
map(self, str name, str parallelization, int n, [str] reduce_in, [str] reduce_out, dict opts) -> Function
map(self, str name, str parallelization, int n, [int] reduce_in, [int] reduce_out, dict opts) -> Function

Map with reduction.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L745

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L605-L611


map(self, int n, [bool] reduce_in, [bool] reduce_out, dict opts)

[INTERNAL] Map with reduction.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L745

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L605-L611



map(self, str name, str parallelization, int n, [str] reduce_in, [str] reduce_out, dict opts)

[INTERNAL] Map with reduction.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L741

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L636-L643



map(self, str name, str parallelization, int n, [int] reduce_in, [int] reduce_out, dict opts)

[INTERNAL] Map with reduction.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L737

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L613-L634



map(self, int n, str parallelization, int max_num_threads)

[INTERNAL]



map(self, int n, str parallelization)

[INTERNAL] Create a mapped version of this function.

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))

1. Parameters:

parallelization: Type of parallelization used: unroll|serial|openmp

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L726

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L677-L712


mapaccum(*args)

[INTERNAL]

mapaccum(self, int N, dict opts) -> Function
mapaccum(self, str name, int N, dict opts) -> Function
mapaccum(self, str name, int N, int n_accum, dict opts) -> Function
mapaccum(self, str name, int n, [str] accum_in, [str] accum_out, dict opts) -> Function
mapaccum(self, str name, int n, [int] accum_in, [int] accum_out, dict opts) -> Function

Create a mapaccumulated version of this function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L697

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L484-L486


mapaccum(self, int N, dict opts)

[INTERNAL] Create a mapaccumulated version of this function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L697

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L484-L486



mapaccum(self, str name, int N, dict opts)

[INTERNAL] Create a mapaccumulated version of this function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L686

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L487-L489



mapaccum(self, str name, int N, int n_accum, dict opts)

[INTERNAL] Create a mapaccumulated version of this function.

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

Doc source: https://github.com/casadi/casadi/blob/develop/casadi/core/function.hpp#L687

Implementation: https://github.com/casadi/casadi/blob/develop/casadi/core/function.cpp#L490-L518



mapaccum(self, str name, int n, [str] accum_in, [str] accum_out, dict opts)

[INTERNAL] Create a mapaccumulated version of this function.

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