# Koopman Operators

`DataDrivenDiffEq.LinearKoopman`

— Type`LinearKoopman(K, B, Q, P, discrete)`

An approximation of the Koopman operator which is linear in the states.

`K`

is the array representing the operator, `B`

is the (possible present) array representing the influence of exogenous inputs on the evolution.

`Q`

and `P`

are matrices used for updating the operator with new measurements. `discrete`

indicates if the operator is discrete or continuous.

The Koopman operator is callable with the typical signature of `f(u,p,t)`

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

, respectively.

**Example**

```
k = LinearKoopman([1.0 0; 0 0.3], [], [], [], true)
u = k([2.0; 0.5], nothing, nothing)
du = similar(u)
k(du, u, nothing, nothing)
```

`DataDrivenDiffEq.NonlinearKoopman`

— Type`NonlinearKoopman(K, B, C, basis, Q, P, discrete)`

An approximation of the Koopman operator which is nonlinear in the states.

`K`

is the array representing the operator, `B`

is the (possible present) array representing the influence of exogenous inputs on the evolution. `C`

is the array mapping from the Koopman space to the original state space. `basis`

is a [Basis]@ref(Basis), mapping the state space to the Koopman space.

`Q`

and `P`

are matrices used for updating the operator with new measurements. `discrete`

indicates if the operator is discrete or continuous.

The Koopman operator is callable with the typical signature of `f(u,p,t)`

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

, respectively.

**Example**

```
k = EDMD(X, basis)
u = k([2.0; 0.5], nothing, nothing)
du = similar(u)
k(du, u, nothing, nothing)
```

## Functions

`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.inputmap`

— Function```
inputmap(k)
Return the array `B`, mapping the exogenous inputs to the Koopman space.
```

`DataDrivenDiffEq.outputmap`

— Function```
outputmap(k)
Return the array `C`, mapping the Koopman space back onto the state space.
```

`DataDrivenDiffEq.update!`

— Function`update!(k, X, Y; threshold = eps())`

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`

.

`update!(k, X, Y; p = [], t = [], threshold = eps())`

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.

`DataDrivenDiffEq.is_discrete`

— Function`is_discrete(k)`

Returns if the `AbstractKoopmanOperator`

`k`

is discrete in time.

`DataDrivenDiffEq.is_continuous`

— Function`is_continuous(k)`

Returns if the `AbstractKoopmanOperator`

`k`

is continuous in time.

`DataDrivenDiffEq.updatable`

— Function```
updatable(k)
Returns `true` if the `AbstractKoopmanOperator` is updatable.
```

`DataDrivenDiffEq.isstable`

— Function```
isstable(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
```

`LinearAlgebra.eigen`

— Function```
eigen(k)
Return the eigendecomposition of the `AbstractKoopmanOperator`.
```

`LinearAlgebra.eigvals`

— Function```
eigevals(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.reduce_basis`

— Function`reduce_basis(k; threshold)`

Reduces the `basis`

of the nonlinear Koopman using the 1-norm of each row of the matrix `C*K`

. Rows where the threshold is not reached are deleted.