Skip to content

Polynomial Data Types

Torbjørn Cunis edited this page Mar 10, 2025 · 2 revisions

This page is under construction

The classes casos.PD and casos.PS implement polynomials of which the coefficients are constant doubles or can be symbolic expressions, respectively.

Polynomials of degree zero

Polynomials of degree zero correspond to constant or symbolic expressions without indeterminate variables.

casos.PD(M)
casos.PS(M)

creates a zero-degree polynomial which corresponds to the double or casadi.DM, or casadi.SX matrix M.

The following syntaxes for constant matrices are also supported by casos.PS:

casos.PD(m,n)
casos.PD.zeros(m,n)
casos.PD.zeros(n)

creates a zero-degree polynomial which corresponds to a m × n matrix (resp., a column vector with length n) of zeros.

casos.PD.ones(m,n)
casos.PD.ones(n)

creates a zero-degree polynomial which corresponds to a m × n matrix (resp., a column vector with length n) of ones.

casos.PD.eye(n)

creates a zero-degree polynomial which corresponds to the n × n identity matrix.

Polynomials with symbolic coefficients

The class casos.PS implements polynomials of which the coefficients can be symbolic expressions. Unlike indeterminate variables, symbolic polynomials (variables) can be decision variables of an optimization problem. The following syntax creates polynomials which have symbolic variables as coefficients. In all of the following syntaxes, the first argument corresponds to the display name (resp., prefix) for the symbolic coeffcients. See Casadi's SX symbolics for details.

casos.PS.sym('c',w)

creates a scalar polynomial with symbolic coefficients and monomials in w, if w is a scalar monomial pattern; or creates a vector/matrix of polynomials with symbolic coefficients, size equal to the size of w, and its (i,j)-th entry having the monomial terms of w(i,j).

casos.PS.sym('c',w,[m n])
casos.PS.sym('c',w,n)

creates a m × n matrix or a n × 1 vector of polynomials with symbolic coefficients and each entry having the monomial terms in w, where w must be a scalar monomial pattern.

casos.PS.sym('c',[m n])
casos.PS.sym('c',n)

creates a m × n matrix or a n × 1 vector of polynomials with degree zero; essentially, this is a symbolic matrix similar to casadi.SX.

casos.PS.sym(...,'gram')

where ... denotes any of the syntaxes above, creates a scalar or matrix polynomial in Gram form, that is, with entries p = z'*Q*z, where z is the vector of monomials in w and Q is a quadratic symbolic matrix.

Note: We say that a polynomial is symbolic if and only if all of its (nonzero) coefficients are symbols in the sense of Casadi. All polynomials created with the syntaxes above, including the Gram form, are symbolic but the result of the notation

casos.PS.sym('c',[1 2])*[x;x]

with x = casos.PS('x') would only be a symbolic expression. The queries is_symbolic and is_symexpr check whether a polynomial is a symbolic polynomial or a symbolic expression, respectively.

Quick links

Cite us

If you use CaΣoS, please cite us.

CaΣoS logo

Clone this wiki locally