`CarlemanLinearization.build_matrix`

— Method`build_matrix(F₁, F₂, N; compress=false)`

Compute the Carleman linearization matrix associated to the quadratic system $x' = F₁x + F₂(x⊗x)$, truncated at order $N$.

**Input**

`F₁`

– sparse matrix of size $n × n$`F₂`

– sparse matrix of size $n × n^2$`N`

– integer representing the truncation order, should be at least two`compress`

– if`true`

produces the matrix corresponding to the commutative monomials only

**Output**

Sparse matrix `A`

.

**Algorithm**

See references [1] and [2] of CARLIN.md.

`CarlemanLinearization.build_matrix_compressed`

— Method`build_matrix_compressed(F₁, F₂, N)`

Compute the compressed Carleman linearization matrix associated to the quadratic system $x' = F₁x + F₂(x⊗x)$, truncated at order $N$.

Input & Output are the same as for `build_matrix`

.

`CarlemanLinearization.generate_monomials`

— Method`generate_monomials(n, N)`

Return a list of `n`

-tuples of nonegative integers with the sum at most `N`

, ordered by the total degree (no other guarantees on the ordering).

`CarlemanLinearization.kron_id`

— Method`kron_id(n, k)`

Compute the k-fold Kronecker product of the identity: `I ⊗ I ⊗ ... ⊗ I`

, k times.

**Input**

`n`

– integer representing the order (dimension of the identity)`k`

– integer representing the power

**Output**

A `Diagonal`

matrix with element `1`

in the diagonal and order $n^k$.

**Examples**

```
julia> kron_id(2, 2)
4×4 Diagonal{Float64,Array{Float64,1}}:
1.0 ⋅ ⋅ ⋅
⋅ 1.0 ⋅ ⋅
⋅ ⋅ 1.0 ⋅
⋅ ⋅ ⋅ 1.0
```

`CarlemanLinearization.kron_pow`

— Method`kron_pow(x::Vector{<:AbstractVariable}, pow::Int)`

Compute the higher order concrete Kronecker power: `x ⊗ x ⊗ ... ⊗ x`

, `pow`

times for a vector of symbolic monomials.

**Input**

`x`

– polynomial variable`pow`

– integer

**Output**

Vector of multivariate monomial corresponding to `x^{⊗ pow}`

.

**Examples**

```
julia> using DynamicPolynomials
julia> @polyvar x[1:2]
(PolyVar{true}[x₁, x₂],)
julia> x
2-element Vector{PolyVar{true}}:
x₁
x₂
julia> kron_pow(x, 2)
4-element Vector{Monomial{true}}:
x₁²
x₁x₂
x₁x₂
x₂²
```

`CarlemanLinearization.kron_sandwich`

— Method`kron_sandwich(F, n, k1, k2)`

Compute `A ⊗ F ⊗ C`

where `A = I^{⊗ k1}`

and `C = I^{⊗ k2}`

where `I`

is the identity matrix of order `n`

, the `k1`

-fold and `k2`

-fold Kronecker product of the identity and `F`

in between.

**Input**

`F`

– matrix`n`

– integer, dimension of the identity`k1`

– nonnegative integer`k2`

– nonnegative integer

**Output**

The kronecker product `I^{⊗ k1} ⊗ F ⊗ I^{⊗ k2}`

, represented as a sparse matrix if `F`

is sparse.

**Examples**

```
julia> F = sparse([0 1; -1 0.])
2×2 SparseMatrixCSC{Float64,Int64} with 2 stored entries:
[2, 1] = -1.0
[1, 2] = 1.0
julia> Q = kron_sandwich(F, 2, 2, 2);
julia> size(Q)
(32, 32)
julia> I2 = I(2)
IdentityMultiple{Float64} of value 1.0 and order 2
julia> Q == reduce(kron, [I2, I2, F, I2, I2])
true
```

`CarlemanLinearization.kron_sum`

— Method`kron_sum(F::AbstractMatrix, k::Int)`

Compute the Kronecker sum of order k defined as:

\[ F ⊕ F ⊕ ... ⊕ F := F ⊗ I ⊗ ... ⊗ I + I ⊗ F ⊗ I ⊗ ... ⊗ I + ... + I ⊗ ... ⊗ I ⊗ F\]

where each term has `k`

products and there are a total of `k`

summands and `I`

is the identity matrix of order `n`

.

**Examples**

It holds that:

- $k = 1: F$
- $k = 2: F ⊗ I + I ⊗ F$
- $k = 3: F ⊗ I ⊗ I + I ⊗ F ⊗ I + I ⊗ I ⊗ F$

```
julia> F = sparse([0 1; -1 0.])
2×2 SparseMatrixCSC{Float64,Int64} with 2 stored entries:
[2, 1] = -1.0
[1, 2] = 1.0
julia> kron_sum(F, 1) == F
true
julia> I2 = I(2)
IdentityMultiple{Float64} of value 1.0 and order 2
julia> kron_sum(F, 2) == kron(F, I2) + kron(I2, F)
true
julia> kron_sum(F, 3) == sum(reduce(kron, X) for X in [[F, I2, I2], [I2, F, I2], [I2, I2, F]])
true
```

`CarlemanLinearization.lift_vector`

— Method`lift_vector(X0, N)`

Return a vector of monomials in `X0`

(hyperrectangle) of degree at most `N`

.

`CarlemanLinearization.quadratic_matrix_form`

— Method`quadratic_matrix_form(f, vars)`

Extract the linear and quadratic matrices of a system of polynomial equations.

**Input**

`f`

– vector of polynomials`vars`

– vector of variables

**Output**

Matrices `F1`

and `F2`

of size `n × n`

and `n × n^2`

respectively, such that `F1`

contains the linear coefficients of the polynomial vector field `f`

and `F2`

the quadratic coefficients, which indexing that respects the Kronecker power `vars ⊗ vars`

.

**Examples**

TO-DO