-
Notifications
You must be signed in to change notification settings - Fork 0
/
gl2kr.py
29 lines (24 loc) · 844 Bytes
/
gl2kr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
The content of this module is based on the original work:
"Subspace Identification for Linear Systems, Theory, Implementation, Applications"
Van Overschee P., De Moor B.
Kluwer Academic Publishers, (1996)
"""
import numpy as np
from solvric import solvric
def gl2kr(A, G, C, L0):
if (G == []) | (L0 == []):
K = []
R = []
else:
# Solve the Riccati equation
P, flag = solvric(A, G, C, L0)
if flag == 1: # Riccati equation had no solution
print('Warning: Non positive real covariance model => K = R = []')
K = []
R = []
else:
# Make output (Page 63 for instance)
R = L0 - C @ P @ C.conj().T
K = (G - A @ P @ C.conj().T) @ np.linalg.inv(R)
return K, R