Skip to content

Commit 2c5ba19

Browse files
chore: clean up (#105)
* clean up * fix build * Apply suggestion from @github-actions[bot] Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 9ce0c04 commit 2c5ba19

83 files changed

Lines changed: 390 additions & 1671 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/copilot-instructions.md‎

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ This is a numerical algorithms library providing digital signal processing (DSP)
1616
- `neural_network/`: Neural network components (layers, activations, optimizers)
1717
- `solvers/`: Numerical solvers (Levinson-Durbin)
1818
- `windowing/`: Window functions for signal processing
19-
- **examples/**: Demonstrates library usage with practical implementations
2019
- **doc/**: Comprehensive documentation for each algorithm with mathematical background
2120
- **embedded-infra-lib/**: Submodule containing infrastructure foundations and utilities for embedded systems
2221

@@ -64,15 +63,6 @@ Place code here when it is:
6463
- Hardware-agnostic and reusable across projects
6564
- Organized by domain (analysis, controllers, dynamics, filters, estimators, math, neural_network, solvers, windowing)
6665

67-
### Examples (`examples/`)
68-
69-
Place code here when it is:
70-
- Demonstrating proper usage of library components
71-
- Showing practical implementations and patterns
72-
- Providing working reference implementations
73-
- Testing algorithms in realistic scenarios
74-
- Each example should be self-contained and demonstrate specific features
75-
7666
### Documentation (`doc/`)
7767

7868
When implementing or modifying algorithms:
@@ -105,6 +95,14 @@ When implementing or modifying algorithms:
10595
}
10696
```
10797
98+
### Comments
99+
100+
- **AVOID COMMENTS**: Code should be self-documenting through clear naming, small functions, and expressive types
101+
- Do not add comments that restate what the code does
102+
- Do not add `TODO`, `FIXME`, or `HACK` comments in production code
103+
- Do not add function/method docstrings unless the API is non-obvious to a domain expert
104+
- Acceptable exceptions: legal headers, `NOLINT` annotations, and brief clarifications of non-trivial math or domain-specific constants
105+
108106
### Error Handling
109107
110108
- Use `infra::Optional` for functions that may not return a value
@@ -180,17 +178,19 @@ When implementing or modifying algorithms:
180178
Header-only templates are compiled into test executables, which do **not** have `--coverage` flags.
181179
To get coverage, template code must be explicitly instantiated in a `.cpp` file that is part of the library (which **does** have coverage flags).
182180
183-
1. **Add `extern template` declarations** at the bottom of the header (prevents implicit instantiation in other TUs):
181+
Both the `extern template` declarations in headers and the matching `.cpp` files are **conditionally compiled only when `EMIL_ENABLE_COVERAGE` is set** (i.e. the `coverage` CMake preset). This avoids polluting non-coverage builds.
182+
183+
1. **Add `extern template` declarations** at the bottom of the header, guarded by `NUMERICAL_TOOLBOX_COVERAGE_BUILD`:
184184
```cpp
185-
// In Algorithm.hpp, at the bottom of the namespace, after all template definitions
185+
#ifdef NUMERICAL_TOOLBOX_COVERAGE_BUILD
186186
extern template class Algorithm<float, 3>;
187187
extern template class Algorithm<math::Q15, 3>;
188+
#endif
188189
}
189190
```
190191

191-
2. **Create a matching `.cpp` file** with explicit instantiation (compiled with `--coverage` as part of the library):
192+
2. **Create a matching `.cpp` file** with explicit instantiation:
192193
```cpp
193-
// Algorithm.cpp
194194
#include "numerical/domain/Algorithm.hpp"
195195

196196
namespace domain
@@ -200,7 +200,14 @@ To get coverage, template code must be explicitly instantiated in a `.cpp` file
200200
}
201201
```
202202
203-
3. **Add the `.cpp` file to `CMakeLists.txt`** in `target_sources`
203+
3. **Add the `.cpp` file to `CMakeLists.txt`** conditionally:
204+
```cmake
205+
if (EMIL_ENABLE_COVERAGE)
206+
target_sources(numerical.domain PRIVATE
207+
Algorithm.cpp
208+
)
209+
endif()
210+
```
204211

205212
4. **Instantiate all specializations used by tests** — each `extern template` in the header must have a matching `template class` in the `.cpp` file
206213

@@ -277,8 +284,8 @@ class Algorithm
277284
- Support for host (simulation and testing) and embedded targets
278285
- Separate build configurations for Debug, Release, RelWithDebInfo
279286
- GoogleTest for unit testing
280-
- Optional build of examples via `NUMERICAL_TOOLBOX_BUILD_EXAMPLES`
281287
- Optional compiler optimizations via `NUMERICAL_TOOLBOX_ENABLE_OPTIMIZATIONS`
288+
- Coverage builds via the `coverage` CMake preset (`EMIL_ENABLE_COVERAGE=On`)
282289

283290
## Version Control
284291

@@ -314,8 +321,7 @@ When implementing a new algorithm:
314321
- Implementation details
315322
- Usage examples
316323
- Numerical considerations (stability, range, precision)
317-
6. **Create example in `examples/`** demonstrating practical usage
318-
7. **Consider SIMD optimizations** where applicable using `math::SingleInstructionMultipleData`
324+
6. **Consider SIMD optimizations** where applicable using `math::SingleInstructionMultipleData`
319325

320326
### Performance Optimization Guidelines
321327

‎CMakeLists.txt‎

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ endif()
66

77
option(CMAKE_COMPILE_WARNING_AS_ERROR "Enable warnings-as-error" On)
88
option(NUMERICAL_TOOLBOX_INCLUDE_DEFAULT_INIT "Include default initialization code; turn off when providing custom initialization" On)
9-
option(NUMERICAL_TOOLBOX_BUILD_EXAMPLES "Enable build of the examples" Off)
109
option(NUMERICAL_TOOLBOX_BUILD_SIMULATOR "Enable build of the Qt simulator applications" Off)
1110
option(NUMERICAL_TOOLBOX_BUILD_TESTS "Enable build of the tests" Off)
1211
option(NUMERICAL_TOOLBOX_ENABLE_OPTIMIZATIONS "Enable compiler optimizations for numerical routines" On)
@@ -22,6 +21,10 @@ if (NUMERICAL_TOOLBOX_ENABLE_OPTIMIZATIONS)
2221
add_definitions(-DNumericalToolbox_ENABLE_OPTIMIZATIONS=1)
2322
endif()
2423

24+
if (EMIL_ENABLE_COVERAGE)
25+
add_definitions(-DNUMERICAL_TOOLBOX_COVERAGE_BUILD=1)
26+
endif()
27+
2528
add_definitions(-DEMIL_ENABLE_TRACING=1)
2629

2730
if (NUMERICAL_TOOLBOX_STANDALONE)
@@ -57,35 +60,12 @@ if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
5760
endif()
5861

5962
if (NUMERICAL_TOOLBOX_STANDALONE)
60-
# Configure Git to use HTTPS instead of SSH for GitHub
6163
execute_process(
6264
COMMAND git config --global url.https://github.com/.insteadOf git@github.com:
6365
RESULT_VARIABLE GIT_CONFIG_RESULT
6466
OUTPUT_QUIET
6567
ERROR_QUIET
6668
)
67-
68-
FetchContent_Declare(
69-
sciplot
70-
GIT_REPOSITORY https://github.com/sciplot/sciplot.git
71-
GIT_TAG v0.2.2
72-
GIT_SHALLOW TRUE
73-
GIT_SUBMODULES_RECURSE TRUE
74-
)
75-
76-
FetchContent_GetProperties(sciplot)
77-
if(NOT sciplot_POPULATED)
78-
FetchContent_Populate(sciplot)
79-
endif()
80-
81-
add_library(sciplot INTERFACE)
82-
target_include_directories(sciplot INTERFACE
83-
${sciplot_SOURCE_DIR}
84-
OPTIONS
85-
-Wno-error # Disable -Werror for sciplot headers
86-
-Wno-unused-variable # Disable specific warning
87-
-Wno-sign-compare # Disable specific warning
88-
)
8969
endif()
9070

9171
set_directory_properties(PROPERTY USE_FOLDERS ON)
@@ -103,7 +83,6 @@ if (NUMERICAL_TOOLBOX_BUILD_TESTS)
10383
emil_enable_testing()
10484
endif()
10585

106-
add_subdirectory(examples)
10786
add_subdirectory(numerical)
10887

10988
if (NUMERICAL_TOOLBOX_BUILD_SIMULATOR)
@@ -122,7 +101,6 @@ if(TARGET yaml-cpp)
122101
set_target_properties(yaml-cpp PROPERTIES COMPILE_WARNING_AS_ERROR OFF)
123102
endif()
124103

125-
emil_clangformat_directories(examples DIRECTORIES .)
126104
emil_clangformat_directories(numerical DIRECTORIES .)
127105

128106
if (NUMERICAL_TOOLBOX_BUILD_SIMULATOR)

‎CMakePresets.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"installDir": "${sourceDir}/install",
1414
"cacheVariables": {
1515
"CMAKE_EXPORT_COMPILE_COMMANDS": "On",
16-
"CMAKE_COMPILE_WARNING_AS_ERROR": "On",
17-
"NUMERICAL_TOOLBOX_BUILD_EXAMPLES": true
16+
"CMAKE_COMPILE_WARNING_AS_ERROR": "On"
1817
}
1918
},
2019
{

‎README.md‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,22 @@ This library provides a comprehensive collection of digital signal processing (D
1010

1111
## Getting Started
1212

13-
Refer to the documentation and example scripts to quickly integrate and utilize the library's signal processing and control algorithms in your projects.
13+
Refer to the documentation to quickly integrate and utilize the library's signal processing and control algorithms in your projects.
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+
| [Dynamics](doc/dynamics/README.md) | Euler-Lagrange, Newton-Euler, Recursive Newton-Euler, ABA |
22+
| [Estimators](doc/estimators/README.md) | Linear Regression, Yule-Walker |
23+
| [Filters](doc/filters/README.md) | Kalman, Extended Kalman, Unscented Kalman, FIR, IIR |
24+
| [Kinematics](doc/kinematics/README.md) | Forward Kinematics |
25+
| [Neural Network](doc/neural_network/README.md) | Layers, activations, losses, optimizers, regularization |
26+
| [Solvers](doc/solvers/README.md) | Gaussian Elimination, Levinson-Durbin, Durand-Kerner, Cholesky, DARE |
27+
| [Windowing](doc/windowing/README.md) | Rectangular, Hamming, Hann, Blackman |
28+
| [Performance Optimization](doc/performance-optimization/README.md) | Compiler optimizations, SIMD |
2629

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

‎examples/CMakeLists.txt‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎examples/analysis/CMakeLists.txt‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎examples/analysis/FastFourierTransformRadix2/CMakeLists.txt‎

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎examples/analysis/FastFourierTransformRadix2/FastFourierTransformRadix2.cpp‎

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)