Skip to content

Commit ad1c0e0

Browse files
Apply suggestions from code review
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 7cf0123 commit ad1c0e0

5 files changed

Lines changed: 55 additions & 55 deletions

File tree

‎README.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ Refer to the documentation and example scripts to quickly integrate and utilize
1414

1515
## Documentation
1616

17-
| Category | Description |
18-
|----------|-------------|
19-
| [Analysis](doc/analysis/README.md) | FFT, Power Spectral Density, DCT, Root Locus |
20-
| [Controllers](doc/controllers/README.md) | PID, LQR |
21-
| [Estimators](doc/estimators/README.md) | Linear Regression, Yule-Walker |
22-
| [Filters](doc/filters/README.md) | Kalman Filter |
23-
| [Solvers](doc/solvers/README.md) | Gaussian Elimination, Levinson-Durbin, Durand-Kerner, DARE |
24-
| [Windowing](doc/windowing/README.md) | Rectangular, Hamming, Hann, Blackman |
25-
| [Neural Network](doc/neural_network/README.md) | Layers, activations, losses, optimizers, regularization |
17+
| Category | Description |
18+
|------------------------------------------------|------------------------------------------------------------|
19+
| [Analysis](doc/analysis/README.md) | FFT, Power Spectral Density, DCT, Root Locus |
20+
| [Controllers](doc/controllers/README.md) | PID, LQR |
21+
| [Estimators](doc/estimators/README.md) | Linear Regression, Yule-Walker |
22+
| [Filters](doc/filters/README.md) | Kalman Filter |
23+
| [Solvers](doc/solvers/README.md) | Gaussian Elimination, Levinson-Durbin, Durand-Kerner, DARE |
24+
| [Windowing](doc/windowing/README.md) | Rectangular, Hamming, Hann, Blackman |
25+
| [Neural Network](doc/neural_network/README.md) | Layers, activations, losses, optimizers, regularization |
2626

2727
Each category page lists its algorithms with a brief description and links to the detailed documentation.
2828

‎doc/TEMPLATE.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ Use LaTeX ($$..$$) for block equations and ($...$) for inline math.
2727
Time and space complexity WITH justification — not just Big-O, but WHY.
2828
Include best, average, and worst cases where applicable.
2929
30-
| Case | Time | Space | Notes |
31-
|---------|--------------|---------|------------------------------|
32-
| Best | ... | ... | ... |
33-
| Average | ... | ... | ... |
34-
| Worst | ... | ... | ... |
30+
| Case | Time | Space | Notes |
31+
|---------|------|-------|-------|
32+
| Best | ... | ... | ... |
33+
| Average | ... | ... | ... |
34+
| Worst | ... | ... | ... |
3535
-->
3636

3737
## Step-by-Step Walkthrough

‎doc/controllers/Lqr.md‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ $$Q_{ii} = \frac{1}{(\text{max acceptable } x_i)^2}, \qquad R_{jj} = \frac{1}{(\
5050

5151
## Complexity Analysis
5252

53-
| Phase | Time | Space | Notes |
54-
|-------|------|-------|-------|
55-
| DARE solve (offline) | $O(I \cdot n^3)$ | $O(n^2)$ | $I$ iterations, each involving $n \times n$ matrix operations |
56-
| Control step (online) | $O(n \cdot m)$ | $O(n \cdot m)$ | Single matrix-vector multiply $u = -Kx$ |
53+
| Phase | Time | Space | Notes |
54+
|-----------------------|------------------|----------------|---------------------------------------------------------------|
55+
| DARE solve (offline) | $O(I \cdot n^3)$ | $O(n^2)$ | $I$ iterations, each involving $n \times n$ matrix operations |
56+
| Control step (online) | $O(n \cdot m)$ | $O(n \cdot m)$ | Single matrix-vector multiply $u = -Kx$ |
5757

5858
The DARE iteration is the expensive part, but it is done **once** (offline or at initialization). The per-sample cost is just a matrix-vector product.
5959

@@ -90,14 +90,14 @@ $$Q = \begin{bmatrix} 100 & 0 \\ 0 & 1 \end{bmatrix}, \quad R = [1]$$
9090

9191
## Variants & Generalizations
9292

93-
| Variant | Key Difference |
94-
|---------|---------------|
95-
| **Continuous-time LQR** | Solves the Continuous ARE instead of DARE; used for continuous-time plant models |
96-
| **LQG (Linear Quadratic Gaussian)** | Combines LQR with Kalman filter for systems with noisy, partial observations |
97-
| **LQR with integral action** | Augments the state with integral of tracking error to eliminate steady-state offset |
98-
| **Finite-horizon LQR** | Time-varying gain $K[k]$ for finite-duration tasks |
99-
| **Robust LQR (H∞)** | Accounts for model uncertainty by optimizing the worst-case cost |
100-
| **Pre-computed gain** | $K$ is computed offline (e.g., in MATLAB with `dlqr`) and hard-coded for embedded targets |
93+
| Variant | Key Difference |
94+
|-------------------------------------|-------------------------------------------------------------------------------------------|
95+
| **Continuous-time LQR** | Solves the Continuous ARE instead of DARE; used for continuous-time plant models |
96+
| **LQG (Linear Quadratic Gaussian)** | Combines LQR with Kalman filter for systems with noisy, partial observations |
97+
| **LQR with integral action** | Augments the state with integral of tracking error to eliminate steady-state offset |
98+
| **Finite-horizon LQR** | Time-varying gain $K[k]$ for finite-duration tasks |
99+
| **Robust LQR (H∞)** | Accounts for model uncertainty by optimizing the worst-case cost |
100+
| **Pre-computed gain** | $K$ is computed offline (e.g., in MATLAB with `dlqr`) and hard-coded for embedded targets |
101101

102102
## Applications
103103

@@ -122,12 +122,12 @@ graph LR
122122
PID -.->|"model-free alternative"| LQR
123123
```
124124

125-
| Algorithm | Relationship |
126-
|-----------|-------------|
127-
| [DARE Solver](../solvers/DiscreteAlgebraicRiccatiEquation.md) | Computes the cost-to-go matrix $P$ from which $K$ is derived |
128-
| [Gaussian Elimination](../solvers/GaussianElimination.md) | Used inside DARE iteration to solve linear sub-systems |
129-
| [Kalman Filter](../filters/active/KalmanFilter.md) | Provides state estimates when direct measurement is unavailable (forming LQG) |
130-
| [PID Controller](Pid.md) | Model-free alternative; simpler to deploy but not optimal |
125+
| Algorithm | Relationship |
126+
|---------------------------------------------------------------|-------------------------------------------------------------------------------|
127+
| [DARE Solver](../solvers/DiscreteAlgebraicRiccatiEquation.md) | Computes the cost-to-go matrix $P$ from which $K$ is derived |
128+
| [Gaussian Elimination](../solvers/GaussianElimination.md) | Used inside DARE iteration to solve linear sub-systems |
129+
| [Kalman Filter](../filters/active/KalmanFilter.md) | Provides state estimates when direct measurement is unavailable (forming LQG) |
130+
| [PID Controller](Pid.md) | Model-free alternative; simpler to deploy but not optimal |
131131

132132
## References & Further Reading
133133

‎doc/controllers/Pid.md‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ The output is clamped to $[u_{\min}, u_{\max}]$ after each computation, which al
4141

4242
## Complexity Analysis
4343

44-
| Case | Time | Space | Notes |
45-
|------|------|-------|-------|
44+
| Case | Time | Space | Notes |
45+
|------------|--------|--------|-----------------------------------------|
4646
| Per sample | $O(1)$ | $O(1)$ | 3 multiplications, 3 additions, 1 clamp |
4747

4848
The algorithm uses a fixed-size recursive buffer storing $e[n-1]$, $e[n-2]$, and $u[n-1]$. No loops, no dynamic allocation, fully deterministic execution time.
@@ -56,12 +56,12 @@ The algorithm uses a fixed-size recursive buffer storing $e[n-1]$, $e[n-2]$, and
5656
- $a_1 = -(2 + 0.2) = -2.2$
5757
- $a_2 = 0.1$
5858

59-
| Step | Measured | $e[n]$ | $e[n-1]$ | $e[n-2]$ | $\Delta u$ | $u[n]$ (clamped) |
60-
|------|----------|--------|-----------|-----------|------------|-------------------|
61-
| 0 | 0.0 | 5.0 | 0 | 0 | $2.6 \times 5 = 13$ | **10.0** (clamped) |
62-
| 1 | 2.0 | 3.0 | 5.0 | 0 | $2.6(3) - 2.2(5) + 0.1(0) = -3.2$ | **6.8** |
63-
| 2 | 4.0 | 1.0 | 3.0 | 5.0 | $2.6(1) - 2.2(3) + 0.1(5) = -3.5$ | **3.3** |
64-
| 3 | 4.8 | 0.2 | 1.0 | 3.0 | $2.6(0.2) - 2.2(1) + 0.1(3) = -1.38$ | **1.92** |
59+
| Step | Measured | $e[n]$ | $e[n-1]$ | $e[n-2]$ | $\Delta u$ | $u[n]$ (clamped) |
60+
|------|----------|--------|----------|----------|--------------------------------------|--------------------|
61+
| 0 | 0.0 | 5.0 | 0 | 0 | $2.6 \times 5 = 13$ | **10.0** (clamped) |
62+
| 1 | 2.0 | 3.0 | 5.0 | 0 | $2.6(3) - 2.2(5) + 0.1(0) = -3.2$ | **6.8** |
63+
| 2 | 4.0 | 1.0 | 3.0 | 5.0 | $2.6(1) - 2.2(3) + 0.1(5) = -3.5$ | **3.3** |
64+
| 3 | 4.8 | 0.2 | 1.0 | 3.0 | $2.6(0.2) - 2.2(1) + 0.1(3) = -1.38$ | **1.92** |
6565

6666
The output converges toward the steady-state value needed to maintain the setpoint.
6767

@@ -75,14 +75,14 @@ The output converges toward the steady-state value needed to maintain the setpoi
7575

7676
## Variants & Generalizations
7777

78-
| Variant | Key Difference |
79-
|---------|---------------|
80-
| **Standard (positional) PID** | Computes $u[n]$ from scratch each step using an explicit integral accumulator |
81-
| **PI controller** | $K_d = 0$; simpler, no derivative noise issues |
82-
| **PD controller** | $K_i = 0$; no steady-state error correction, used when offset is acceptable |
83-
| **PID with derivative filter** | Low-passes the derivative term to reject high-frequency noise |
84-
| **Gain-scheduled PID** | Tuning parameters vary as a function of operating point |
85-
| **Cascade PID** | Inner and outer loops, each with its own PID — common in motor control |
78+
| Variant | Key Difference |
79+
|--------------------------------|-------------------------------------------------------------------------------|
80+
| **Standard (positional) PID** | Computes $u[n]$ from scratch each step using an explicit integral accumulator |
81+
| **PI controller** | $K_d = 0$; simpler, no derivative noise issues |
82+
| **PD controller** | $K_i = 0$; no steady-state error correction, used when offset is acceptable |
83+
| **PID with derivative filter** | Low-passes the derivative term to reject high-frequency noise |
84+
| **Gain-scheduled PID** | Tuning parameters vary as a function of operating point |
85+
| **Cascade PID** | Inner and outer loops, each with its own PID — common in motor control |
8686

8787
## Applications
8888

@@ -104,10 +104,10 @@ graph LR
104104
KF -->|"filtered measurement"| PID
105105
```
106106

107-
| Algorithm | Relationship |
108-
|-----------|-------------|
109-
| [LQR Controller](Lqr.md) | Optimal alternative when a state-space model is available; PID is model-free. |
110-
| [Kalman Filter](../filters/active/KalmanFilter.md) | Can provide filtered state estimates as input to either PID or LQR |
107+
| Algorithm | Relationship |
108+
|----------------------------------------------------|-------------------------------------------------------------------------------|
109+
| [LQR Controller](Lqr.md) | Optimal alternative when a state-space model is available; PID is model-free. |
110+
| [Kalman Filter](../filters/active/KalmanFilter.md) | Can provide filtered state estimates as input to either PID or LQR |
111111

112112
## References & Further Reading
113113

‎doc/controllers/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Feedback control algorithms for regulating dynamic systems in real time.
44

55
## Algorithms
66

7-
| Algorithm | Description |
8-
|-----------|-------------|
9-
| [PID Controller](Pid.md) | Proportional-Integral-Derivative controller using a discrete recursive formulation |
7+
| Algorithm | Description |
8+
|--------------------------|-----------------------------------------------------------------------------------------|
9+
| [PID Controller](Pid.md) | Proportional-Integral-Derivative controller using a discrete recursive formulation |
1010
| [LQR Controller](Lqr.md) | Linear Quadratic Regulator — optimal state-feedback control minimizing a quadratic cost |

0 commit comments

Comments
 (0)