# Koopman

`DataDrivenDiffEq.Koopman`

— Type`mutable struct Koopman{O, M, G, T} <: DataDrivenDiffEq.AbstractKoopman`

A special basis over the states with parameters , independent variable and possible exogenous controls. It extends an `AbstractBasis`

, which also stores information about the lifted dynamics, specified by a sufficient matrix factorization, an output mapping and internal variables to update the equations. It can be called with the typical SciML signature, meaning out of place with `f(u,p,t)`

or in place with `f(du, u, p, t)`

. If control inputs are present, it is assumed that no control corresponds to zero for all inputs. The corresponding function calls are `f(u,p,t,inputs)`

and `f(du,u,p,t,inputs)`

and need to be specified fully.

If `linear_independent`

is set to `true`

, a linear independent basis is created from all atom functions in `f`

.

If `simplify_eqs`

is set to `true`

, `simplify`

is called on `f`

.

Additional keyworded arguments include `name`

, which can be used to name the basis, and `observed`

for defining observeables.

**Fields**

`eqs`

The equations of the basis

`states`

Dependent (state) variables

`ctrls`

Control variables

`ps`

Parameters

`observed`

Observed

`iv`

Independent variable

`f`

Internal function representation of the basis

`lift`

Associated lifting of the operator

`name`

Name of the basis

`systems`

Internal systems

`is_discrete`

Discrete or time continuous

`K`

The operator/generator of the dynamics

`C`

Mapping back onto the observed states

`Q`

Internal matrix

`Q`

used for updating`P`

Internal matrix

`P`

used for updating

**Note**

The keyword argument `eval_expression`

controls the function creation behavior. `eval_expression=true`

means that `eval`

is used, so normal world-age behavior applies (i.e. the functions cannot be called from the function that generates them). If `eval_expression=false`

, then construction via GeneralizedGenerated.jl is utilized to allow for same world-age evaluation. However, this can cause Julia to segfault on sufficiently large basis functions. By default eval_expression=false.

## Functions

`DataDrivenDiffEq.is_discrete`

— Function```
is_discrete(k)
```

Returns `true`

if the `AbstractKoopmanOperator`

`k`

is discrete in time.

Check if the problem is time discrete.

`DataDrivenDiffEq.is_continuous`

— Function```
is_continuous(k)
```

Returns `true`

if the `AbstractKoopmanOperator`

`k`

is continuous in time.

Check if the problem is time continuous.

`LinearAlgebra.eigen`

— Function```
eigen(k)
```

Return the eigendecomposition of the `AbstractKoopmanOperator`

.

`LinearAlgebra.eigvals`

— Function```
eigvals(k)
```

Return the eigenvalues of the `AbstractKoopmanOperator`

.

`LinearAlgebra.eigvecs`

— Function```
eigvecs(k)
```

Return the eigenvectors of the `AbstractKoopmanOperator`

.

`DataDrivenDiffEq.modes`

— Function```
modes(k)
```

Return the eigenvectors of a continuous `AbstractKoopmanOperator`

.

`DataDrivenDiffEq.frequencies`

— Function```
frequencies(k)
```

Return the eigenvalues of a continuous `AbstractKoopmanOperator`

.

`DataDrivenDiffEq.operator`

— Function```
operator(k)
```

Return the approximation of the discrete Koopman operator stored in `k`

.

`DataDrivenDiffEq.generator`

— Function```
generator(k)
```

Return the approximation of the continuous Koopman generator stored in `k`

.

`DataDrivenDiffEq.updatable`

— Function```
updatable(k)
```

Returns `true`

if the `AbstractKoopmanOperator`

is updatable.

`DataDrivenDiffEq.is_stable`

— Function```
is_stable(k)
```

Returns `true`

if either:

- the Koopman operator has just eigenvalues with magnitude less than one or
- the Koopman generator has just eigenvalues with a negative real part

`DataDrivenDiffEq.update!`

— Function```
update!(k, X, Y; p, t, U, threshold)
```

Update the Koopman `k`

given new data `X`

and `Y`

. The operator is updated in place if the L2 error of the prediction exceeds the `threshold`

.

`p`

and `t`

are the parameters of the basis and the vector of timepoints, if necessary.

## Algorithms

`DataDrivenDiffEq.DMDPINV`

— Type`mutable struct DMDPINV <: DataDrivenDiffEq.AbstractKoopmanAlgorithm`

Approximates the Koopman operator `K`

based on

`K = Y / X`

where `Y`

and `X`

are data matrices. Returns a `Eigen`

factorization of the operator.

**Fields**

**Signatures**

`DataDrivenDiffEq.DMDSVD`

— Type`mutable struct DMDSVD{T} <: DataDrivenDiffEq.AbstractKoopmanAlgorithm`

Approximates the Koopman operator `K`

based on the singular value decomposition of `X`

such that:

`K = Y*V*Σ*U'`

where `Y`

and `X = U*Σ*V'`

are data matrices. The singular value decomposition is truncated via the `truncation`

parameter, which can either be an `Int`

indiciating an index based truncation or a `Real`

indiciating a tolerance based truncation. Returns a `Eigen`

factorization of the operator.

**Fields**

`truncation`

Indiciates the truncation

**Signatures**

`DataDrivenDiffEq.TOTALDMD`

— Type`mutable struct TOTALDMD{R, A} <: DataDrivenDiffEq.AbstractKoopmanAlgorithm`

Approximates the Koopman operator `K`

with the algorithm `alg`

over the rank-reduced data matrices `Xᵣ = X Qᵣ`

and `Yᵣ = Y Qᵣ`

, where `Qᵣ`

originates from the singular value decomposition of the joint data `Z = [X; Y]`

. Based on this paper.

If `rtol`

∈ (0, 1) is given, the singular value decomposition is reduced to include only entries bigger than `rtol*maximum(Σ)`

. If `rtol`

is an integer, the reduced SVD up to `rtol`

is used for computation.

**Fields**

`truncation`

`alg`

**Signatures**