diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 60f58138..fb3d089d 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -8,14 +8,20 @@ This is a numerical algorithms library providing digital signal processing (DSP) - **numerical/**: Core implementation of algorithms organized by domain: - `analysis/`: Signal analysis (FFT, PSD, DCT) - - `controllers/`: Control algorithms (PID controllers) - - `dynamics/`: Dynamics and modeling (Euler-Lagrange) - - `estimators/`: Estimation algorithms (Linear Regression, Yule-Walker) + - `windowing/`: Window functions for spectral analysis + - `control_analysis/`: Control system analysis (Frequency Response, Root Locus) + - `controllers/`: Control algorithms (PID, LQR, MPC) + - `dynamics/`: Dynamics and modeling (Euler-Lagrange, Newton-Euler) + - `estimators/`: Estimation algorithms + - `offline/`: Batch estimators (Linear Regression, Yule-Walker) + - `online/`: Streaming estimators (Recursive Least Squares) - `filters/`: Digital filters (FIR, IIR, Kalman) + - `kinematics/`: Forward/inverse kinematics - `math/`: Mathematical foundations (QNumber, Matrix, Complex, Trigonometric functions) - - `neural_network/`: Neural network components (layers, activations, optimizers) - - `solvers/`: Numerical solvers (Levinson-Durbin) - - `windowing/`: Window functions for signal processing + - `neural_network/`: Neural network components (layers, activations, losses, model) + - `optimization/`: General-purpose optimizers (Gradient Descent) + - `regularization/`: Regularization techniques (L1, L2) + - `solvers/`: Numerical solvers (Levinson-Durbin, Gaussian Elimination, DARE) - **doc/**: Comprehensive documentation for each algorithm with mathematical background - **embedded-infra-lib/**: Submodule containing infrastructure foundations and utilities for embedded systems @@ -61,7 +67,7 @@ Place code here when it is: - Estimators and solvers - Neural network components - Hardware-agnostic and reusable across projects -- Organized by domain (analysis, controllers, dynamics, filters, estimators, math, neural_network, solvers, windowing) +- Organized by domain (analysis, control_analysis, controllers, dynamics, estimators, filters, kinematics, math, neural_network, optimization, regularization, solvers) ### Documentation (`doc/`) @@ -285,6 +291,7 @@ class Algorithm - **INTERFACES**: Define interfaces (pure virtual classes) for testability and flexibility - **NAMESPACE**: Use appropriate namespaces by domain: - `analysis::` - Signal analysis algorithms + - `control_analysis::` - Control system analysis (Frequency Response, Root Locus) - `controllers::` - Control system algorithms - `dynamics::` - Dynamics and modeling algorithms - `estimators::` - Estimation algorithms @@ -292,8 +299,10 @@ class Algorithm - `filters::active::` - Active filters (Kalman) - `math::` - Mathematical utilities and functions - `neural_network::` - Neural network components + - `optimization::` - General-purpose optimizers + - `regularization::` - Regularization techniques - `solvers::` - Numerical solvers - - `windowing::` - Window functions + - `windowing::` - Window functions (under `analysis/windowing/`) - **SELF-DOCUMENTING CODE**: Write clear, self-explanatory code with descriptive names - **UNITS**: Be explicit about units (radians, Hz, samples, normalized) in variable names or comments - **NUMERICAL TYPES**: Support multiple numeric representations: diff --git a/README.md b/README.md index 18a10f30..5be62051 100644 --- a/README.md +++ b/README.md @@ -16,15 +16,17 @@ Refer to the documentation to quickly integrate and utilize the library's signal | Category | Description | |--------------------------------------------------------------------|----------------------------------------------------------------------| -| [Analysis](doc/analysis/README.md) | FFT, Power Spectral Density, DCT, Root Locus | -| [Controllers](doc/controllers/README.md) | PID, LQR | +| [Analysis](doc/analysis/README.md) | FFT, Power Spectral Density, DCT, Window Functions | +| [Control Analysis](doc/control_analysis/README.md) | Frequency Response, Root Locus | +| [Controllers](doc/controllers/README.md) | PID, LQR, MPC | | [Dynamics](doc/dynamics/README.md) | Euler-Lagrange, Newton-Euler, Recursive Newton-Euler, ABA | -| [Estimators](doc/estimators/README.md) | Linear Regression, Yule-Walker | +| [Estimators](doc/estimators/README.md) | Linear Regression, Yule-Walker (offline), Recursive Least Squares (online) | | [Filters](doc/filters/README.md) | Kalman, Extended Kalman, Unscented Kalman, FIR, IIR | | [Kinematics](doc/kinematics/README.md) | Forward Kinematics | -| [Neural Network](doc/neural_network/README.md) | Layers, activations, losses, optimizers, regularization | +| [Neural Network](doc/neural_network/README.md) | Layers, activations, losses, model | +| [Optimization](doc/optimization/README.md) | Gradient Descent | +| [Regularization](doc/regularization/README.md) | L1 (Lasso), L2 (Ridge) | | [Solvers](doc/solvers/README.md) | Gaussian Elimination, Levinson-Durbin, Durand-Kerner, Cholesky, DARE | -| [Windowing](doc/windowing/README.md) | Rectangular, Hamming, Hann, Blackman | | [Performance Optimization](doc/performance-optimization/README.md) | Compiler optimizations, SIMD | Each category page lists its algorithms with a brief description and links to the detailed documentation. diff --git a/doc/analysis/README.md b/doc/analysis/README.md index 4cb27e57..ecc005b7 100644 --- a/doc/analysis/README.md +++ b/doc/analysis/README.md @@ -1,6 +1,6 @@ # Analysis -Signal analysis algorithms for frequency-domain decomposition, spectral estimation, and system characterization. +Signal analysis algorithms for frequency-domain decomposition and spectral estimation. ## Algorithms @@ -9,4 +9,11 @@ Signal analysis algorithms for frequency-domain decomposition, spectral estimati | [Fast Fourier Transform](FastFourierTransform.md) | Efficient computation of the Discrete Fourier Transform using the Cooley-Tukey radix-2 algorithm | | [Power Spectral Density](PowerDensitySpectrum.md) | Estimation of signal power distribution across frequencies using Welch's method | | [Discrete Cosine Transform](DiscreteCosineTransform.md) | Real-valued frequency decomposition via cosine basis functions, computed through FFT | -| [Root Locus](RootLocus.md) | Closed-loop pole trajectory analysis as a function of loop gain | + +## Sub-domains + +| Sub-domain | Description | +|-------------------------------------|----------------------------------------------------------------------------------| +| [Windowing](../windowing/README.md) | Window functions (Rectangular, Hamming, Hanning, Blackman) for FFT preprocessing | + +> **Note:** For control system analysis tools (Frequency Response, Root Locus), see [Control Analysis](../control_analysis/README.md). diff --git a/doc/analysis/FrequencyResponse.md b/doc/control_analysis/FrequencyResponse.md similarity index 100% rename from doc/analysis/FrequencyResponse.md rename to doc/control_analysis/FrequencyResponse.md diff --git a/doc/control_analysis/README.md b/doc/control_analysis/README.md new file mode 100644 index 00000000..b65c29f3 --- /dev/null +++ b/doc/control_analysis/README.md @@ -0,0 +1,10 @@ +# Control Analysis + +Control system analysis tools for characterizing dynamic systems and feedback loop behavior. + +## Algorithms + +| Algorithm | Description | +|--------------------------------------------|-------------------------------------------------------------------------------| +| [Frequency Response](FrequencyResponse.md) | Magnitude and phase response of digital filters across the frequency spectrum | +| [Root Locus](RootLocus.md) | Closed-loop pole trajectory analysis as a function of loop gain | diff --git a/doc/analysis/RootLocus.md b/doc/control_analysis/RootLocus.md similarity index 100% rename from doc/analysis/RootLocus.md rename to doc/control_analysis/RootLocus.md diff --git a/doc/estimators/README.md b/doc/estimators/README.md index 631cc95e..7204399f 100644 --- a/doc/estimators/README.md +++ b/doc/estimators/README.md @@ -2,9 +2,15 @@ Statistical estimation algorithms for fitting models to observed data and making predictions. -## Algorithms +## Offline Estimators (Batch) | Algorithm | Description | |------------------------------------------|-------------------------------------------------------------------------| | [Linear Regression](LinearRegression.md) | Ordinary least-squares regression using the normal equation | | [Yule-Walker](YuleWalker.md) | Autoregressive model parameter estimation via the Yule-Walker equations | + +## Online Estimators (Streaming) + +| Algorithm | Description | +|-----------------------------------------------------|--------------------------------------------------------------------------| +| [Recursive Least Squares](RecursiveLeastSquares.md) | Sample-by-sample parameter estimation with exponential forgetting factor | diff --git a/doc/neural_network/NeuralNetwork.md b/doc/neural_network/NeuralNetwork.md index 09ffec75..b8792e08 100644 --- a/doc/neural_network/NeuralNetwork.md +++ b/doc/neural_network/NeuralNetwork.md @@ -104,7 +104,7 @@ graph LR - **Dead neurons.** ReLU neurons that receive only negative inputs output zero forever. LeakyReLU mitigates this. - **Fixed-point saturation.** In Q15/Q31, activations and gradients must stay within $[-1, 1)$. Scale inputs and learning rates accordingly. - **Learning rate sensitivity.** Too high → divergence; too low → no progress. Start with $\eta = 0.01$ and adjust. -- **Overfitting.** Small embedded datasets are easily memorized. Apply [regularization](regularization/Regularization.md) (L2 weight decay). +- **Overfitting.** Small embedded datasets are easily memorized. Apply [regularization](../regularization/Regularization.md) (L2 weight decay). ## Variants & Generalizations @@ -151,8 +151,8 @@ graph TD | [Dense Layer](layer/Layer.md) | The fundamental building block; computes affine transformations | | [Activation Functions](activation/Activation.md) | Introduce non-linearity after each layer | | [Loss Functions](losses/Loss.md) | Define the training objective | -| [Optimizer](optimizer/Optimizer.md) | Drives parameter updates via gradient descent | -| [Regularization](regularization/Regularization.md) | Penalizes complexity to prevent overfitting | +| [Optimizer](../optimization/Optimizer.md) | Drives parameter updates via gradient descent | +| [Regularization](../regularization/Regularization.md) | Penalizes complexity to prevent overfitting | | [Model](model/Model.md) | Composes layers into a trainable pipeline | | [Linear Regression](../estimators/LinearRegression.md) | Special case: single layer, identity activation, MSE loss | diff --git a/doc/neural_network/README.md b/doc/neural_network/README.md index 21f3569f..0604db4c 100644 --- a/doc/neural_network/README.md +++ b/doc/neural_network/README.md @@ -10,6 +10,6 @@ Components for building, training, and evaluating feed-forward neural networks e | [Layers](layer/Layer.md) | Dense (fully connected) layer with forward and backward pass | | [Activation Functions](activation/Activation.md) | Non-linear element-wise transforms: ReLU, LeakyReLU, Sigmoid, Tanh, Softmax | | [Loss Functions](losses/Loss.md) | Objective functions: MSE, MAE, Binary Cross-Entropy, Categorical Cross-Entropy | -| [Optimizers](optimizer/Optimizer.md) | Parameter update strategies: Gradient Descent | -| [Regularization](regularization/Regularization.md) | Complexity penalties: L1 (Lasso) and L2 (Ridge) | | [Model](model/Model.md) | Variadic-template model composing layers, optimizer, and loss into a trainable pipeline | + +> **See also:** [Optimization](../optimization/README.md) for optimizers (Gradient Descent) and [Regularization](../regularization/README.md) for weight penalties (L1, L2) — these are general-purpose domains used by neural networks and other algorithms. diff --git a/doc/neural_network/layer/Layer.md b/doc/neural_network/layer/Layer.md index 85ef9da6..6ffe46ec 100644 --- a/doc/neural_network/layer/Layer.md +++ b/doc/neural_network/layer/Layer.md @@ -117,7 +117,7 @@ graph TD |-----------------------------------------------------------|----------------------------------------------------------------------------------------| | [Activation Functions](../activation/Activation.md) | Applied element-wise after the affine transformation | | [Model](../model/Model.md) | Chains multiple dense layers into a network | -| [Optimizer](../optimizer/Optimizer.md) | Updates $W$ and $b$ using the computed gradients | +| [Optimizer](../../optimization/Optimizer.md) | Updates $W$ and $b$ using the computed gradients | | [Linear Regression](../../estimators/LinearRegression.md) | A dense layer with identity activation and MSE loss is equivalent to linear regression | ## References & Further Reading diff --git a/doc/neural_network/losses/Loss.md b/doc/neural_network/losses/Loss.md index db3f0ea5..ff4e8965 100644 --- a/doc/neural_network/losses/Loss.md +++ b/doc/neural_network/losses/Loss.md @@ -128,8 +128,8 @@ graph TD | Component | Relationship | |-----------------------------------------------------------|------------------------------------------------------------------------------------------------------| | [Activation Functions](../activation/Activation.md) | Output activation must match: Sigmoid ↔ BCE, Softmax ↔ CCE, identity ↔ MSE | -| [Optimizer](../optimizer/Optimizer.md) | Uses $\nabla \mathcal{L}$ to update parameters | -| [Regularization](../regularization/Regularization.md) | Adds a penalty term to the loss: $\mathcal{L}_{\text{total}} = \mathcal{L} + \lambda \Omega(\theta)$ | +| [Optimizer](../../optimization/Optimizer.md) | Uses $\nabla \mathcal{L}$ to update parameters | +| [Regularization](../../regularization/Regularization.md) | Adds a penalty term to the loss: $\mathcal{L}_{\text{total}} = \mathcal{L} + \lambda \Omega(\theta)$ | | [Linear Regression](../../estimators/LinearRegression.md) | Solved analytically when the loss is MSE and the model is linear | ## References & Further Reading diff --git a/doc/neural_network/model/Model.md b/doc/neural_network/model/Model.md index 007c5204..f7602cb8 100644 --- a/doc/neural_network/model/Model.md +++ b/doc/neural_network/model/Model.md @@ -6,7 +6,7 @@ A **Model** composes a sequence of [dense layers](../layer/Layer.md) into a sing 1. Chains layers so the output of each feeds into the next (**forward pass**). 2. Propagates gradients backward through the chain (**backward pass**). -3. Flattens all layer parameters into a single vector for the [optimizer](../optimizer/Optimizer.md). +3. Flattens all layer parameters into a single vector for the [optimizer](../../optimization/Optimizer.md). 4. Verifies dimensional compatibility **at compile time** using variadic templates. In this library, the Model is fully statically typed — layer dimensions, parameter counts, and memory footprints are all known at compile time, enabling zero-overhead abstraction on embedded targets. @@ -144,8 +144,8 @@ graph TD |-------------------------------------------------------|--------------------------------------------------------------------------------------------| | [Dense Layer](../layer/Layer.md) | The Model is a sequence of layers stored in a `std::tuple` | | [Loss Functions](../losses/Loss.md) | Measures prediction error; the Model delegates loss computation to a Loss object | -| [Optimizer](../optimizer/Optimizer.md) | Receives the flat parameter/gradient vectors from the Model and returns updated parameters | -| [Regularization](../regularization/Regularization.md) | Added to the loss before optimization | +| [Optimizer](../../optimization/Optimizer.md) | Receives the flat parameter/gradient vectors from the Model and returns updated parameters | +| [Regularization](../../regularization/Regularization.md) | Added to the loss before optimization | ## References & Further Reading diff --git a/doc/neural_network/optimizer/OptimizationMethods.svg b/doc/optimization/OptimizationMethods.svg similarity index 100% rename from doc/neural_network/optimizer/OptimizationMethods.svg rename to doc/optimization/OptimizationMethods.svg diff --git a/doc/neural_network/optimizer/Optimizer.md b/doc/optimization/Optimizer.md similarity index 100% rename from doc/neural_network/optimizer/Optimizer.md rename to doc/optimization/Optimizer.md diff --git a/doc/optimization/README.md b/doc/optimization/README.md new file mode 100644 index 00000000..47d18349 --- /dev/null +++ b/doc/optimization/README.md @@ -0,0 +1,9 @@ +# Optimization + +General-purpose optimization algorithms for parameter fitting, training, and control. + +## Algorithms + +| Algorithm | Description | +|----------------------------------|----------------------------------------------------------------| +| [Gradient Descent](Optimizer.md) | Iterative batch optimization via gradient-based weight updates | diff --git a/doc/regularization/README.md b/doc/regularization/README.md new file mode 100644 index 00000000..86f723d3 --- /dev/null +++ b/doc/regularization/README.md @@ -0,0 +1,9 @@ +# Regularization + +General-purpose regularization techniques for preventing overfitting in parameter estimation and training. + +## Algorithms + +| Algorithm | Description | +|-------------------------------------|--------------------------------------------------| +| [Regularization](Regularization.md) | L1 (Lasso) and L2 (Ridge) weight penalty methods | diff --git a/doc/neural_network/regularization/Regularization.md b/doc/regularization/Regularization.md similarity index 100% rename from doc/neural_network/regularization/Regularization.md rename to doc/regularization/Regularization.md diff --git a/doc/neural_network/regularization/RegularizationMethods.svg b/doc/regularization/RegularizationMethods.svg similarity index 100% rename from doc/neural_network/regularization/RegularizationMethods.svg rename to doc/regularization/RegularizationMethods.svg diff --git a/doc/solvers/DurandKerner.md b/doc/solvers/DurandKerner.md index 47dea80b..89e19bf8 100644 --- a/doc/solvers/DurandKerner.md +++ b/doc/solvers/DurandKerner.md @@ -76,7 +76,7 @@ After ~15–20 iterations the roots converge to $z \approx \{1, 2, 3\}$ (imagina - **Leading coefficient must be non-zero.** The polynomial degree is determined by the first coefficient. - **Complex arithmetic required.** This algorithm operates entirely in $\mathbb{C}$, so it is limited to floating-point types (`float`, `double`). Fixed-point types are not supported. - **No convergence guarantee for all polynomials.** Wilkinson's polynomial and other pathological cases may require higher precision or alternative methods. -- **Root ordering.** Results are sorted by real part (ascending), which may not correspond to meaningful branch ordering in applications like [Root Locus](../analysis/RootLocus.md). +- **Root ordering.** Results are sorted by real part (ascending), which may not correspond to meaningful branch ordering in applications like [Root Locus](../control_analysis/RootLocus.md). ## Variants & Generalizations @@ -90,7 +90,7 @@ After ~15–20 iterations the roots converge to $z \approx \{1, 2, 3\}$ (imagina ## Applications -- **Root locus analysis** — The [Root Locus](../analysis/RootLocus.md) algorithm calls Durand-Kerner at each gain step to find the closed-loop poles. +- **Root locus analysis** — The [Root Locus](../control_analysis/RootLocus.md) algorithm calls Durand-Kerner at each gain step to find the closed-loop poles. - **Stability analysis** — Determining whether all roots of a characteristic polynomial lie inside the unit circle (discrete) or left half-plane (continuous). - **Filter design** — Finding pole and zero locations of transfer functions. - **Control system design** — Evaluating characteristic equations to check stability margins. @@ -108,7 +108,7 @@ graph LR | Algorithm | Relationship | |------------------------------------------------|-------------------------------------------------------------------------------------------------------| -| [Root Locus](../analysis/RootLocus.md) | Primary consumer — calls Durand-Kerner to find characteristic polynomial roots at each gain step | +| [Root Locus](../control_analysis/RootLocus.md) | Primary consumer — calls Durand-Kerner to find characteristic polynomial roots at each gain step | | [Gaussian Elimination](GaussianElimination.md) | Alternative approach: form the companion matrix and compute eigenvalues (requires a different solver) | ## References & Further Reading diff --git a/doc/windowing/README.md b/doc/windowing/README.md index 20d26440..d0256ba7 100644 --- a/doc/windowing/README.md +++ b/doc/windowing/README.md @@ -1,6 +1,6 @@ # Windowing -Window functions for reducing spectral leakage in frequency-domain analysis. +Window functions for reducing spectral leakage in frequency-domain analysis. Part of the [Analysis](../analysis/README.md) domain. ## Algorithms diff --git a/numerical/CMakeLists.txt b/numerical/CMakeLists.txt index 9d095f36..a4af3f1a 100644 --- a/numerical/CMakeLists.txt +++ b/numerical/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(analysis) +add_subdirectory(control_analysis) add_subdirectory(controllers) add_subdirectory(dynamics) add_subdirectory(estimators) @@ -6,5 +7,6 @@ add_subdirectory(kinematics) add_subdirectory(filters) add_subdirectory(math) add_subdirectory(neural_network) +add_subdirectory(optimization) +add_subdirectory(regularization) add_subdirectory(solvers) -add_subdirectory(windowing) diff --git a/numerical/analysis/CMakeLists.txt b/numerical/analysis/CMakeLists.txt index 20e00711..8194db45 100644 --- a/numerical/analysis/CMakeLists.txt +++ b/numerical/analysis/CMakeLists.txt @@ -7,24 +7,21 @@ target_include_directories(numerical.analysis ${NUMERICAL_VISIBILITY} target_link_libraries(numerical.analysis ${NUMERICAL_VISIBILITY} infra.util + numerical.analysis.windowing numerical.math - numerical.solver ) target_sources(numerical.analysis PRIVATE DiscreteCosineTransform.hpp FastFourierTransform.hpp FastFourierTransformRadix2Impl.hpp - FrequencyResponse.hpp PowerDensitySpectrum.hpp - RootLocus.hpp ) numerical_add_coverage_sources(numerical.analysis FastFourierTransformRadix2Impl.cpp - FrequencyResponse.cpp PowerDensitySpectrum.cpp - RootLocus.cpp ) add_subdirectory(test) +add_subdirectory(windowing) diff --git a/numerical/analysis/PowerDensitySpectrum.hpp b/numerical/analysis/PowerDensitySpectrum.hpp index b7c365a7..5e732627 100644 --- a/numerical/analysis/PowerDensitySpectrum.hpp +++ b/numerical/analysis/PowerDensitySpectrum.hpp @@ -5,10 +5,10 @@ #endif #include "numerical/analysis/FastFourierTransform.hpp" +#include "numerical/analysis/windowing/Windowing.hpp" #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/ComplexNumber.hpp" #include "numerical/math/QNumber.hpp" -#include "numerical/windowing/Windowing.hpp" #ifdef NUMERICAL_TOOLBOX_COVERAGE_BUILD #include "numerical/analysis/test/PowerDensitySpectrumTestSupport.hpp" diff --git a/numerical/analysis/RootLocus.cpp b/numerical/analysis/RootLocus.cpp deleted file mode 100644 index 1197e315..00000000 --- a/numerical/analysis/RootLocus.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "numerical/analysis/RootLocus.hpp" - -namespace analysis -{ - template class RootLocus; -} diff --git a/numerical/analysis/test/CMakeLists.txt b/numerical/analysis/test/CMakeLists.txt index b4a9a3a3..43dee991 100644 --- a/numerical/analysis/test/CMakeLists.txt +++ b/numerical/analysis/test/CMakeLists.txt @@ -11,7 +11,5 @@ target_link_libraries(numerical.analysis_test PUBLIC target_sources(numerical.analysis_test PRIVATE TestDiscreteCosineTransform.cpp TestFastFourierTransformRadix2Impl.cpp - TestFrequencyResponse.cpp TestPowerDensitySpectrum.cpp - TestRootLocus.cpp ) diff --git a/numerical/analysis/test/PowerDensitySpectrumTestSupport.hpp b/numerical/analysis/test/PowerDensitySpectrumTestSupport.hpp index a5c1e473..8f9a9b41 100644 --- a/numerical/analysis/test/PowerDensitySpectrumTestSupport.hpp +++ b/numerical/analysis/test/PowerDensitySpectrumTestSupport.hpp @@ -1,7 +1,7 @@ #pragma once #include "numerical/analysis/FastFourierTransform.hpp" -#include "numerical/windowing/Windowing.hpp" +#include "numerical/analysis/windowing/Windowing.hpp" namespace analysis::test { diff --git a/numerical/analysis/windowing/CMakeLists.txt b/numerical/analysis/windowing/CMakeLists.txt new file mode 100644 index 00000000..e513e14c --- /dev/null +++ b/numerical/analysis/windowing/CMakeLists.txt @@ -0,0 +1,20 @@ +numerical_add_header_library(numerical.analysis.windowing) + +target_include_directories(numerical.analysis.windowing ${NUMERICAL_VISIBILITY} + "$" + "$" +) + +target_link_libraries(numerical.analysis.windowing ${NUMERICAL_VISIBILITY} + numerical.math +) + +target_sources(numerical.analysis.windowing PRIVATE + Windowing.hpp +) + +numerical_add_coverage_sources(numerical.analysis.windowing + Windowing.cpp +) + +add_subdirectory(test) diff --git a/numerical/windowing/Windowing.cpp b/numerical/analysis/windowing/Windowing.cpp similarity index 91% rename from numerical/windowing/Windowing.cpp rename to numerical/analysis/windowing/Windowing.cpp index 6239b339..0b0ff71c 100644 --- a/numerical/windowing/Windowing.cpp +++ b/numerical/analysis/windowing/Windowing.cpp @@ -1,4 +1,4 @@ -#include "numerical/windowing/Windowing.hpp" +#include "numerical/analysis/windowing/Windowing.hpp" #include "numerical/math/QNumber.hpp" namespace windowing diff --git a/numerical/windowing/Windowing.hpp b/numerical/analysis/windowing/Windowing.hpp similarity index 100% rename from numerical/windowing/Windowing.hpp rename to numerical/analysis/windowing/Windowing.hpp diff --git a/numerical/analysis/windowing/test/CMakeLists.txt b/numerical/analysis/windowing/test/CMakeLists.txt new file mode 100644 index 00000000..5b209d60 --- /dev/null +++ b/numerical/analysis/windowing/test/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(numerical.analysis.windowing_test) +emil_build_for(numerical.analysis.windowing_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) +emil_add_test(numerical.analysis.windowing_test) + +target_link_libraries(numerical.analysis.windowing_test PUBLIC + gmock_main + numerical.analysis.windowing +) + +target_sources(numerical.analysis.windowing_test PRIVATE + TestWindowing.cpp +) diff --git a/numerical/windowing/test/TestWindowing.cpp b/numerical/analysis/windowing/test/TestWindowing.cpp similarity index 98% rename from numerical/windowing/test/TestWindowing.cpp rename to numerical/analysis/windowing/test/TestWindowing.cpp index 5a54bf97..3a1f1af1 100644 --- a/numerical/windowing/test/TestWindowing.cpp +++ b/numerical/analysis/windowing/test/TestWindowing.cpp @@ -1,5 +1,5 @@ +#include "numerical/analysis/windowing/Windowing.hpp" #include "numerical/math/QNumber.hpp" -#include "numerical/windowing/Windowing.hpp" #include namespace diff --git a/numerical/control_analysis/CMakeLists.txt b/numerical/control_analysis/CMakeLists.txt new file mode 100644 index 00000000..465e31f8 --- /dev/null +++ b/numerical/control_analysis/CMakeLists.txt @@ -0,0 +1,24 @@ +numerical_add_header_library(numerical.control_analysis) + +target_include_directories(numerical.control_analysis ${NUMERICAL_VISIBILITY} + "$" + "$" +) + +target_link_libraries(numerical.control_analysis ${NUMERICAL_VISIBILITY} + infra.util + numerical.math + numerical.solver +) + +target_sources(numerical.control_analysis PRIVATE + FrequencyResponse.hpp + RootLocus.hpp +) + +numerical_add_coverage_sources(numerical.control_analysis + FrequencyResponse.cpp + RootLocus.cpp +) + +add_subdirectory(test) diff --git a/numerical/analysis/FrequencyResponse.cpp b/numerical/control_analysis/FrequencyResponse.cpp similarity index 54% rename from numerical/analysis/FrequencyResponse.cpp rename to numerical/control_analysis/FrequencyResponse.cpp index a6109686..3829927f 100644 --- a/numerical/analysis/FrequencyResponse.cpp +++ b/numerical/control_analysis/FrequencyResponse.cpp @@ -1,6 +1,6 @@ -#include "numerical/analysis/FrequencyResponse.hpp" +#include "numerical/control_analysis/FrequencyResponse.hpp" -namespace analysis +namespace control_analysis { template class FrequencyResponse; template class FrequencyResponse; diff --git a/numerical/analysis/FrequencyResponse.hpp b/numerical/control_analysis/FrequencyResponse.hpp similarity index 99% rename from numerical/analysis/FrequencyResponse.hpp rename to numerical/control_analysis/FrequencyResponse.hpp index 80232ddf..2169665a 100644 --- a/numerical/analysis/FrequencyResponse.hpp +++ b/numerical/control_analysis/FrequencyResponse.hpp @@ -13,7 +13,7 @@ #include #include -namespace analysis +namespace control_analysis { template class FrequencyResponse diff --git a/numerical/control_analysis/RootLocus.cpp b/numerical/control_analysis/RootLocus.cpp new file mode 100644 index 00000000..c9406d7e --- /dev/null +++ b/numerical/control_analysis/RootLocus.cpp @@ -0,0 +1,6 @@ +#include "numerical/control_analysis/RootLocus.hpp" + +namespace control_analysis +{ + template class RootLocus; +} diff --git a/numerical/analysis/RootLocus.hpp b/numerical/control_analysis/RootLocus.hpp similarity index 99% rename from numerical/analysis/RootLocus.hpp rename to numerical/control_analysis/RootLocus.hpp index 93a57d80..6f4bb923 100644 --- a/numerical/analysis/RootLocus.hpp +++ b/numerical/control_analysis/RootLocus.hpp @@ -16,7 +16,7 @@ #include #include -namespace analysis +namespace control_analysis { template class RootLocus diff --git a/numerical/control_analysis/test/CMakeLists.txt b/numerical/control_analysis/test/CMakeLists.txt new file mode 100644 index 00000000..4ad27de9 --- /dev/null +++ b/numerical/control_analysis/test/CMakeLists.txt @@ -0,0 +1,14 @@ +add_executable(numerical.control_analysis_test) +emil_build_for(numerical.control_analysis_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) +emil_add_test(numerical.control_analysis_test) + +target_link_libraries(numerical.control_analysis_test PUBLIC + gmock_main + numerical.control_analysis + numerical.math_test_helper +) + +target_sources(numerical.control_analysis_test PRIVATE + TestFrequencyResponse.cpp + TestRootLocus.cpp +) diff --git a/numerical/analysis/test/TestFrequencyResponse.cpp b/numerical/control_analysis/test/TestFrequencyResponse.cpp similarity index 87% rename from numerical/analysis/test/TestFrequencyResponse.cpp rename to numerical/control_analysis/test/TestFrequencyResponse.cpp index a10d01f8..eda267cb 100644 --- a/numerical/analysis/test/TestFrequencyResponse.cpp +++ b/numerical/control_analysis/test/TestFrequencyResponse.cpp @@ -1,4 +1,4 @@ -#include "numerical/analysis/FrequencyResponse.hpp" +#include "numerical/control_analysis/FrequencyResponse.hpp" #include #include #include @@ -18,7 +18,7 @@ TEST_F(TestFrequencyResponse, unity_system_has_zero_db_response) std::array b = { 1.0f }; std::array a = { 1.0f }; - analysis::FrequencyResponse freqResponse( + control_analysis::FrequencyResponse freqResponse( infra::MakeRange(b), infra::MakeRange(a), sampleFrequency); auto [frequencies, magnitudes, phases] = freqResponse.Calculate(); @@ -36,7 +36,7 @@ TEST_F(TestFrequencyResponse, frequencies_are_within_nyquist_range) std::array b = { 1.0f }; std::array a = { 1.0f }; - analysis::FrequencyResponse freqResponse( + control_analysis::FrequencyResponse freqResponse( infra::MakeRange(b), infra::MakeRange(a), sampleFrequency); auto [frequencies, magnitudes, phases] = freqResponse.Calculate(); @@ -55,7 +55,7 @@ TEST_F(TestFrequencyResponse, frequencies_are_monotonically_increasing) std::array b = { 0.5f, 0.5f }; std::array a = { 1.0f }; - analysis::FrequencyResponse freqResponse( + control_analysis::FrequencyResponse freqResponse( infra::MakeRange(b), infra::MakeRange(a), sampleFrequency); auto [frequencies, magnitudes, phases] = freqResponse.Calculate(); @@ -71,7 +71,7 @@ TEST_F(TestFrequencyResponse, lowpass_filter_attenuates_high_frequencies) std::array b = { 0.5f, 0.5f }; std::array a = { 1.0f }; - analysis::FrequencyResponse freqResponse( + control_analysis::FrequencyResponse freqResponse( infra::MakeRange(b), infra::MakeRange(a), sampleFrequency); auto [frequencies, magnitudes, phases] = freqResponse.Calculate(); @@ -89,7 +89,7 @@ TEST_F(TestFrequencyResponse, phase_response_is_computed) std::array b = { 0.5f, 0.5f }; std::array a = { 1.0f }; - analysis::FrequencyResponse freqResponse( + control_analysis::FrequencyResponse freqResponse( infra::MakeRange(b), infra::MakeRange(a), sampleFrequency); auto [frequencies, magnitudes, phases] = freqResponse.Calculate(); @@ -108,7 +108,7 @@ TEST_F(TestFrequencyResponse, output_sizes_match_for_multi_coefficient_system) std::array b = { 0.25f, 0.5f, 0.25f }; std::array a = { 1.0f, -0.5f, 0.1f }; - analysis::FrequencyResponse freqResponse( + control_analysis::FrequencyResponse freqResponse( infra::MakeRange(b), infra::MakeRange(a), sampleFrequency); auto [frequencies, magnitudes, phases] = freqResponse.Calculate(); diff --git a/numerical/analysis/test/TestRootLocus.cpp b/numerical/control_analysis/test/TestRootLocus.cpp similarity index 97% rename from numerical/analysis/test/TestRootLocus.cpp rename to numerical/control_analysis/test/TestRootLocus.cpp index 8fe9f3a8..054724f8 100644 --- a/numerical/analysis/test/TestRootLocus.cpp +++ b/numerical/control_analysis/test/TestRootLocus.cpp @@ -1,4 +1,4 @@ -#include "numerical/analysis/RootLocus.hpp" +#include "numerical/control_analysis/RootLocus.hpp" #include #include #include @@ -8,7 +8,7 @@ namespace class TestRootLocus : public ::testing::Test { protected: - analysis::RootLocus rootLocus; + control_analysis::RootLocus rootLocus; }; } diff --git a/numerical/estimators/CMakeLists.txt b/numerical/estimators/CMakeLists.txt index 3ce1d3a2..54d8c090 100644 --- a/numerical/estimators/CMakeLists.txt +++ b/numerical/estimators/CMakeLists.txt @@ -1,27 +1,2 @@ -numerical_add_header_library(numerical.estimators) - -target_include_directories(numerical.estimators ${NUMERICAL_VISIBILITY} - "$" - "$" -) - -target_link_libraries(numerical.estimators ${NUMERICAL_VISIBILITY} - infra.util - numerical.math - numerical.solver -) - -target_sources(numerical.estimators PRIVATE - Estimator.hpp - LinearRegression.hpp - RecursiveLeastSquares.hpp - YuleWalker.hpp -) - -numerical_add_coverage_sources(numerical.estimators - LinearRegression.cpp - RecursiveLeastSquares.cpp - YuleWalker.cpp -) - -add_subdirectory(test) +add_subdirectory(offline) +add_subdirectory(online) diff --git a/numerical/estimators/offline/CMakeLists.txt b/numerical/estimators/offline/CMakeLists.txt new file mode 100644 index 00000000..ed632abb --- /dev/null +++ b/numerical/estimators/offline/CMakeLists.txt @@ -0,0 +1,24 @@ +numerical_add_header_library(numerical.estimators.offline) + +target_include_directories(numerical.estimators.offline ${NUMERICAL_VISIBILITY} + "$" + "$" +) + +target_link_libraries(numerical.estimators.offline ${NUMERICAL_VISIBILITY} + infra.util + numerical.math + numerical.solver +) + +target_sources(numerical.estimators.offline PRIVATE + LinearRegression.hpp + YuleWalker.hpp +) + +numerical_add_coverage_sources(numerical.estimators.offline + LinearRegression.cpp + YuleWalker.cpp +) + +add_subdirectory(test) diff --git a/numerical/estimators/LinearRegression.cpp b/numerical/estimators/offline/LinearRegression.cpp similarity index 55% rename from numerical/estimators/LinearRegression.cpp rename to numerical/estimators/offline/LinearRegression.cpp index 1afdbd29..36938cfa 100644 --- a/numerical/estimators/LinearRegression.cpp +++ b/numerical/estimators/offline/LinearRegression.cpp @@ -1,4 +1,4 @@ -#include "numerical/estimators/LinearRegression.hpp" +#include "numerical/estimators/offline/LinearRegression.hpp" namespace estimators { diff --git a/numerical/estimators/LinearRegression.hpp b/numerical/estimators/offline/LinearRegression.hpp similarity index 100% rename from numerical/estimators/LinearRegression.hpp rename to numerical/estimators/offline/LinearRegression.hpp diff --git a/numerical/estimators/YuleWalker.cpp b/numerical/estimators/offline/YuleWalker.cpp similarity index 68% rename from numerical/estimators/YuleWalker.cpp rename to numerical/estimators/offline/YuleWalker.cpp index 6c0660a9..24991bdd 100644 --- a/numerical/estimators/YuleWalker.cpp +++ b/numerical/estimators/offline/YuleWalker.cpp @@ -1,4 +1,4 @@ -#include "numerical/estimators/YuleWalker.hpp" +#include "numerical/estimators/offline/YuleWalker.hpp" namespace estimators { diff --git a/numerical/estimators/YuleWalker.hpp b/numerical/estimators/offline/YuleWalker.hpp similarity index 100% rename from numerical/estimators/YuleWalker.hpp rename to numerical/estimators/offline/YuleWalker.hpp diff --git a/numerical/estimators/offline/test/CMakeLists.txt b/numerical/estimators/offline/test/CMakeLists.txt new file mode 100644 index 00000000..e275fb67 --- /dev/null +++ b/numerical/estimators/offline/test/CMakeLists.txt @@ -0,0 +1,13 @@ +add_executable(numerical.estimators.offline_test) +emil_build_for(numerical.estimators.offline_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) +emil_add_test(numerical.estimators.offline_test) + +target_link_libraries(numerical.estimators.offline_test PUBLIC + gmock_main + numerical.estimators.offline +) + +target_sources(numerical.estimators.offline_test PRIVATE + TestLinearRegression.cpp + TestYuleWalker.cpp +) diff --git a/numerical/estimators/test/TestLinearRegression.cpp b/numerical/estimators/offline/test/TestLinearRegression.cpp similarity index 98% rename from numerical/estimators/test/TestLinearRegression.cpp rename to numerical/estimators/offline/test/TestLinearRegression.cpp index 5c136272..a71830fd 100644 --- a/numerical/estimators/test/TestLinearRegression.cpp +++ b/numerical/estimators/offline/test/TestLinearRegression.cpp @@ -1,4 +1,4 @@ -#include "numerical/estimators/LinearRegression.hpp" +#include "numerical/estimators/offline/LinearRegression.hpp" #include namespace diff --git a/numerical/estimators/test/TestYuleWalker.cpp b/numerical/estimators/offline/test/TestYuleWalker.cpp similarity index 98% rename from numerical/estimators/test/TestYuleWalker.cpp rename to numerical/estimators/offline/test/TestYuleWalker.cpp index 60643aed..f7a7c0e5 100644 --- a/numerical/estimators/test/TestYuleWalker.cpp +++ b/numerical/estimators/offline/test/TestYuleWalker.cpp @@ -1,4 +1,4 @@ -#include "numerical/estimators/YuleWalker.hpp" +#include "numerical/estimators/offline/YuleWalker.hpp" #include "numerical/math/QNumber.hpp" #include diff --git a/numerical/estimators/online/CMakeLists.txt b/numerical/estimators/online/CMakeLists.txt new file mode 100644 index 00000000..afbf95e8 --- /dev/null +++ b/numerical/estimators/online/CMakeLists.txt @@ -0,0 +1,21 @@ +numerical_add_header_library(numerical.estimators.online) + +target_include_directories(numerical.estimators.online ${NUMERICAL_VISIBILITY} + "$" + "$" +) + +target_link_libraries(numerical.estimators.online ${NUMERICAL_VISIBILITY} + infra.util + numerical.math +) + +target_sources(numerical.estimators.online PRIVATE + RecursiveLeastSquares.hpp +) + +numerical_add_coverage_sources(numerical.estimators.online + RecursiveLeastSquares.cpp +) + +add_subdirectory(test) diff --git a/numerical/estimators/RecursiveLeastSquares.cpp b/numerical/estimators/online/RecursiveLeastSquares.cpp similarity index 73% rename from numerical/estimators/RecursiveLeastSquares.cpp rename to numerical/estimators/online/RecursiveLeastSquares.cpp index a14d41e0..619cf62b 100644 --- a/numerical/estimators/RecursiveLeastSquares.cpp +++ b/numerical/estimators/online/RecursiveLeastSquares.cpp @@ -1,4 +1,4 @@ -#include "numerical/estimators/RecursiveLeastSquares.hpp" +#include "numerical/estimators/online/RecursiveLeastSquares.hpp" namespace estimators { diff --git a/numerical/estimators/RecursiveLeastSquares.hpp b/numerical/estimators/online/RecursiveLeastSquares.hpp similarity index 100% rename from numerical/estimators/RecursiveLeastSquares.hpp rename to numerical/estimators/online/RecursiveLeastSquares.hpp diff --git a/numerical/estimators/online/test/CMakeLists.txt b/numerical/estimators/online/test/CMakeLists.txt new file mode 100644 index 00000000..a8fbcce9 --- /dev/null +++ b/numerical/estimators/online/test/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(numerical.estimators.online_test) +emil_build_for(numerical.estimators.online_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) +emil_add_test(numerical.estimators.online_test) + +target_link_libraries(numerical.estimators.online_test PUBLIC + gmock_main + numerical.estimators.online +) + +target_sources(numerical.estimators.online_test PRIVATE + TestRecursiveLeastSquares.cpp +) diff --git a/numerical/estimators/test/TestRecursiveLeastSquares.cpp b/numerical/estimators/online/test/TestRecursiveLeastSquares.cpp similarity index 99% rename from numerical/estimators/test/TestRecursiveLeastSquares.cpp rename to numerical/estimators/online/test/TestRecursiveLeastSquares.cpp index 05929991..663ed4f7 100644 --- a/numerical/estimators/test/TestRecursiveLeastSquares.cpp +++ b/numerical/estimators/online/test/TestRecursiveLeastSquares.cpp @@ -1,4 +1,4 @@ -#include "numerical/estimators/RecursiveLeastSquares.hpp" +#include "numerical/estimators/online/RecursiveLeastSquares.hpp" #include #include diff --git a/numerical/estimators/test/CMakeLists.txt b/numerical/estimators/test/CMakeLists.txt deleted file mode 100644 index f59f583d..00000000 --- a/numerical/estimators/test/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -add_executable(numerical.estimators_test) -emil_build_for(numerical.estimators_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) -emil_add_test(numerical.estimators_test) - -target_link_libraries(numerical.estimators_test PUBLIC - gmock_main - numerical.estimators -) - -target_sources(numerical.estimators_test PRIVATE - TestLinearRegression.cpp - TestRecursiveLeastSquares.cpp - TestYuleWalker.cpp -) diff --git a/numerical/neural_network/CMakeLists.txt b/numerical/neural_network/CMakeLists.txt index 89c7b511..9e3b3676 100644 --- a/numerical/neural_network/CMakeLists.txt +++ b/numerical/neural_network/CMakeLists.txt @@ -2,5 +2,3 @@ add_subdirectory(activation) add_subdirectory(layer) add_subdirectory(losses) add_subdirectory(model) -add_subdirectory(optimizer) -add_subdirectory(regularization) diff --git a/numerical/neural_network/layer/test/TestDense.cpp b/numerical/neural_network/layer/test/TestDense.cpp index 37347afd..79706dec 100644 --- a/numerical/neural_network/layer/test/TestDense.cpp +++ b/numerical/neural_network/layer/test/TestDense.cpp @@ -1,7 +1,7 @@ #include "numerical/math/QNumber.hpp" #include "numerical/neural_network/activation/ActivationFunction.hpp" #include "numerical/neural_network/layer/Dense.hpp" -#include "numerical/neural_network/optimizer/Optimizer.hpp" +#include "numerical/optimization/Optimizer.hpp" #include "gmock/gmock.h" namespace @@ -28,10 +28,10 @@ namespace template class MockOptimizer - : public neural_network::Optimizer + : public optimization::Optimizer { public: - using Result = typename neural_network::Optimizer::Result; + using Result = typename optimization::Optimizer::Result; using Vector = typename neural_network::Loss::Vector; const Result& Minimize(const Vector& initialGuess, neural_network::Loss& loss) override @@ -190,7 +190,7 @@ TYPED_TEST(TestDense, OptimizationWithMockedOptimizer) for (std::size_t i = 0; i < TotalParams; ++i) optimizedParams[i] = T(0.05f); - optimizer.result = typename neural_network::Optimizer::Result( + optimizer.result = typename optimization::Optimizer::Result( optimizedParams, T(0.4f), 3); MockLoss loss; diff --git a/numerical/neural_network/losses/BinaryCrossEntropy.hpp b/numerical/neural_network/losses/BinaryCrossEntropy.hpp index fd4976e8..67b2aac7 100644 --- a/numerical/neural_network/losses/BinaryCrossEntropy.hpp +++ b/numerical/neural_network/losses/BinaryCrossEntropy.hpp @@ -6,7 +6,7 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/neural_network/losses/Loss.hpp" -#include "numerical/neural_network/regularization/Regularization.hpp" +#include "numerical/regularization/Regularization.hpp" #include namespace neural_network @@ -18,13 +18,13 @@ namespace neural_network public: using Vector = typename Loss::Vector; - BinaryCrossEntropy(const Vector& target, Regularization& regularization); + BinaryCrossEntropy(const Vector& target, regularization::Regularization& regularization); QNumberType Cost(const Vector& parameters) override; Vector Gradient(const Vector& parameters) override; private: Vector target; - Regularization& regularization; + regularization::Regularization& regularization; }; // Implementation // @@ -32,7 +32,7 @@ namespace neural_network template BinaryCrossEntropy::BinaryCrossEntropy( const Vector& target, - Regularization& regularization) + regularization::Regularization& regularization) : target(target) , regularization(regularization) {} diff --git a/numerical/neural_network/losses/CMakeLists.txt b/numerical/neural_network/losses/CMakeLists.txt index d2229f2c..49e103a3 100644 --- a/numerical/neural_network/losses/CMakeLists.txt +++ b/numerical/neural_network/losses/CMakeLists.txt @@ -9,7 +9,7 @@ target_link_libraries(numerical.neural_network.losses ${NUMERICAL_VISIBILITY} infra.util numerical.math numerical.neural_network.activation - numerical.neural_network.regularization + numerical.regularization ) target_sources(numerical.neural_network.losses PRIVATE diff --git a/numerical/neural_network/losses/CategoricalCrossEntropy.hpp b/numerical/neural_network/losses/CategoricalCrossEntropy.hpp index 168bd58f..8eaf6894 100644 --- a/numerical/neural_network/losses/CategoricalCrossEntropy.hpp +++ b/numerical/neural_network/losses/CategoricalCrossEntropy.hpp @@ -7,7 +7,7 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/neural_network/activation/Softmax.hpp" #include "numerical/neural_network/losses/Loss.hpp" -#include "numerical/neural_network/regularization/Regularization.hpp" +#include "numerical/regularization/Regularization.hpp" #include namespace neural_network @@ -19,13 +19,13 @@ namespace neural_network public: using Vector = typename Loss::Vector; - CategoricalCrossEntropy(const Vector& target, Regularization& regularization); + CategoricalCrossEntropy(const Vector& target, regularization::Regularization& regularization); QNumberType Cost(const Vector& parameters) override; Vector Gradient(const Vector& parameters) override; private: Vector target; - Regularization& regularization; + regularization::Regularization& regularization; Softmax softmax; Vector ComputeSoftmaxProbabilities(const Vector& x) const; @@ -36,7 +36,7 @@ namespace neural_network template CategoricalCrossEntropy::CategoricalCrossEntropy( const Vector& target, - Regularization& regularization) + regularization::Regularization& regularization) : target(target) , regularization(regularization) {} diff --git a/numerical/neural_network/losses/MeanAbsoluteError.hpp b/numerical/neural_network/losses/MeanAbsoluteError.hpp index 630bfe40..e92392ac 100644 --- a/numerical/neural_network/losses/MeanAbsoluteError.hpp +++ b/numerical/neural_network/losses/MeanAbsoluteError.hpp @@ -6,7 +6,7 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/neural_network/losses/Loss.hpp" -#include "numerical/neural_network/regularization/Regularization.hpp" +#include "numerical/regularization/Regularization.hpp" namespace neural_network { @@ -17,19 +17,19 @@ namespace neural_network public: using Vector = typename Loss::Vector; - MeanAbsoluteError(const Vector& target, Regularization& regularization); + MeanAbsoluteError(const Vector& target, regularization::Regularization& regularization); QNumberType Cost(const Vector& parameters) override; Vector Gradient(const Vector& parameters) override; private: Vector target; - Regularization& regularization; + regularization::Regularization& regularization; }; // Implementation // template - MeanAbsoluteError::MeanAbsoluteError(const Vector& target, Regularization& regularization) + MeanAbsoluteError::MeanAbsoluteError(const Vector& target, regularization::Regularization& regularization) : target(target) , regularization(regularization) {} diff --git a/numerical/neural_network/losses/MeanSquaredError.hpp b/numerical/neural_network/losses/MeanSquaredError.hpp index 2d832900..33003ff7 100644 --- a/numerical/neural_network/losses/MeanSquaredError.hpp +++ b/numerical/neural_network/losses/MeanSquaredError.hpp @@ -6,7 +6,7 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/neural_network/losses/Loss.hpp" -#include "numerical/neural_network/regularization/Regularization.hpp" +#include "numerical/regularization/Regularization.hpp" namespace neural_network { @@ -17,20 +17,20 @@ namespace neural_network public: using Vector = typename Loss::Vector; - MeanSquaredError(const Vector& target, Regularization& regularization); + MeanSquaredError(const Vector& target, regularization::Regularization& regularization); QNumberType Cost(const Vector& parameters) override; Vector Gradient(const Vector& parameters) override; private: Vector target; - Regularization& regularization; + regularization::Regularization& regularization; }; // Implementation // template - MeanSquaredError::MeanSquaredError(const Vector& target, Regularization& regularization) + MeanSquaredError::MeanSquaredError(const Vector& target, regularization::Regularization& regularization) : target(target) , regularization(regularization) {} diff --git a/numerical/neural_network/losses/test/TestBinaryCrossEntropy.cpp b/numerical/neural_network/losses/test/TestBinaryCrossEntropy.cpp index d3619ac2..05a7515f 100644 --- a/numerical/neural_network/losses/test/TestBinaryCrossEntropy.cpp +++ b/numerical/neural_network/losses/test/TestBinaryCrossEntropy.cpp @@ -5,10 +5,10 @@ namespace { template class MockRegularization - : public neural_network::Regularization + : public regularization::Regularization { public: - using Vector = typename neural_network::Regularization::Vector; + using Vector = typename regularization::Regularization::Vector; MOCK_METHOD(QNumberType, Calculate, (const Vector& parameters), (const, override)); MOCK_METHOD(Vector, Gradient, (const Vector& parameters), (const, override)); }; diff --git a/numerical/neural_network/losses/test/TestCategoricalCrossEntropy.cpp b/numerical/neural_network/losses/test/TestCategoricalCrossEntropy.cpp index 26a3131b..fdf08319 100644 --- a/numerical/neural_network/losses/test/TestCategoricalCrossEntropy.cpp +++ b/numerical/neural_network/losses/test/TestCategoricalCrossEntropy.cpp @@ -6,10 +6,10 @@ namespace { template class MockRegularization - : public neural_network::Regularization + : public regularization::Regularization { public: - using Vector = typename neural_network::Regularization::Vector; + using Vector = typename regularization::Regularization::Vector; MOCK_METHOD(QNumberType, Calculate, (const Vector& parameters), (const, override)); MOCK_METHOD(Vector, Gradient, (const Vector& parameters), (const, override)); }; diff --git a/numerical/neural_network/losses/test/TestMeanAbsoluteError.cpp b/numerical/neural_network/losses/test/TestMeanAbsoluteError.cpp index 54e4c538..2ea448b3 100644 --- a/numerical/neural_network/losses/test/TestMeanAbsoluteError.cpp +++ b/numerical/neural_network/losses/test/TestMeanAbsoluteError.cpp @@ -5,10 +5,10 @@ namespace { template class MockRegularization - : public neural_network::Regularization + : public regularization::Regularization { public: - using Vector = typename neural_network::Regularization::Vector; + using Vector = typename regularization::Regularization::Vector; MOCK_METHOD(QNumberType, Calculate, (const Vector& parameters), (const, override)); MOCK_METHOD(Vector, Gradient, (const Vector& parameters), (const, override)); }; diff --git a/numerical/neural_network/losses/test/TestMeanSquaredError.cpp b/numerical/neural_network/losses/test/TestMeanSquaredError.cpp index bb262f8a..830f51a1 100644 --- a/numerical/neural_network/losses/test/TestMeanSquaredError.cpp +++ b/numerical/neural_network/losses/test/TestMeanSquaredError.cpp @@ -5,10 +5,10 @@ namespace { template class MockRegularization - : public neural_network::Regularization + : public regularization::Regularization { public: - using Vector = typename neural_network::Regularization::Vector; + using Vector = typename regularization::Regularization::Vector; MOCK_METHOD(QNumberType, Calculate, (const Vector& parameters), (const, override)); MOCK_METHOD(Vector, Gradient, (const Vector& parameters), (const, override)); }; diff --git a/numerical/neural_network/model/CMakeLists.txt b/numerical/neural_network/model/CMakeLists.txt index 6a7b8f5f..35ea07ab 100644 --- a/numerical/neural_network/model/CMakeLists.txt +++ b/numerical/neural_network/model/CMakeLists.txt @@ -11,7 +11,7 @@ target_link_libraries(numerical.neural_network.model ${NUMERICAL_VISIBILITY} numerical.neural_network.activation numerical.neural_network.layer numerical.neural_network.losses - numerical.neural_network.optimizer + numerical.optimization ) target_sources(numerical.neural_network.model PRIVATE diff --git a/numerical/neural_network/model/Model.hpp b/numerical/neural_network/model/Model.hpp index d7219208..8b1d0145 100644 --- a/numerical/neural_network/model/Model.hpp +++ b/numerical/neural_network/model/Model.hpp @@ -4,12 +4,11 @@ #pragma GCC optimize("O3", "fast-math") #endif -#include "numerical/math/CompilerOptimizations.hpp" - #include "infra/util/BoundedVector.hpp" +#include "numerical/math/CompilerOptimizations.hpp" #include "numerical/neural_network/layer/Layer.hpp" #include "numerical/neural_network/losses/Loss.hpp" -#include "numerical/neural_network/optimizer/Optimizer.hpp" +#include "numerical/optimization/Optimizer.hpp" #include #include #include @@ -117,7 +116,7 @@ namespace neural_network OutputVector Forward(const InputVector& input); InputVector Backward(const OutputVector& output_gradient); - void Train(Optimizer& optimizer, Loss& loss, const ParameterVector& initialParameters); + void Train(optimization::Optimizer& optimizer, Loss& loss, const ParameterVector& initialParameters); void SetParameters(const ParameterVector& parameters); ParameterVector GetParameters() const; @@ -174,7 +173,7 @@ namespace neural_network template void Model::Train( - Optimizer& optimizer, + optimization::Optimizer& optimizer, Loss& loss, const ParameterVector& initialParameters) { diff --git a/numerical/neural_network/optimizer/CMakeLists.txt b/numerical/neural_network/optimizer/CMakeLists.txt deleted file mode 100644 index a5cf8930..00000000 --- a/numerical/neural_network/optimizer/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -numerical_add_header_library(numerical.neural_network.optimizer) - -target_include_directories(numerical.neural_network.optimizer ${NUMERICAL_VISIBILITY} - "$" - "$" -) - -target_link_libraries(numerical.neural_network.optimizer ${NUMERICAL_VISIBILITY} - infra.util - numerical.math - numerical.neural_network.losses -) - -target_sources(numerical.neural_network.optimizer PRIVATE - GradientDescent.hpp - Optimizer.hpp -) - -numerical_add_coverage_sources(numerical.neural_network.optimizer - GradientDescent.cpp -) - -add_subdirectory(test) diff --git a/numerical/neural_network/optimizer/test/CMakeLists.txt b/numerical/neural_network/optimizer/test/CMakeLists.txt deleted file mode 100644 index 29d3c8d3..00000000 --- a/numerical/neural_network/optimizer/test/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -add_executable(numerical.neural_network.optimizer_test) -emil_build_for(numerical.neural_network.optimizer_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) -emil_add_test(numerical.neural_network.optimizer_test) - -target_link_libraries(numerical.neural_network.optimizer_test PUBLIC - gmock_main - numerical.neural_network.optimizer -) - -target_sources(numerical.neural_network.optimizer_test PRIVATE - TestGradientDescent.cpp -) diff --git a/numerical/neural_network/regularization/CMakeLists.txt b/numerical/neural_network/regularization/CMakeLists.txt deleted file mode 100644 index 6eb923fa..00000000 --- a/numerical/neural_network/regularization/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -numerical_add_header_library(numerical.neural_network.regularization) - -target_include_directories(numerical.neural_network.regularization ${NUMERICAL_VISIBILITY} - "$" - "$" -) - -target_link_libraries(numerical.neural_network.regularization ${NUMERICAL_VISIBILITY} - infra.util - numerical.math -) - -target_sources(numerical.neural_network.regularization PRIVATE - L1.hpp - L2.hpp - Regularization.hpp -) - -numerical_add_coverage_sources(numerical.neural_network.regularization - L1.cpp - L2.cpp -) - -add_subdirectory(test) diff --git a/numerical/neural_network/regularization/test/CMakeLists.txt b/numerical/neural_network/regularization/test/CMakeLists.txt deleted file mode 100644 index 93129e92..00000000 --- a/numerical/neural_network/regularization/test/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -add_executable(numerical.neural_network.regularization_test) -emil_build_for(numerical.neural_network.regularization_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) -emil_add_test(numerical.neural_network.regularization_test) - -target_link_libraries(numerical.neural_network.regularization_test PUBLIC - gmock_main - numerical.neural_network.regularization -) - -target_sources(numerical.neural_network.regularization_test PRIVATE - TestL1.cpp - TestL2.cpp -) diff --git a/numerical/optimization/CMakeLists.txt b/numerical/optimization/CMakeLists.txt new file mode 100644 index 00000000..4a7e1662 --- /dev/null +++ b/numerical/optimization/CMakeLists.txt @@ -0,0 +1,23 @@ +numerical_add_header_library(numerical.optimization) + +target_include_directories(numerical.optimization ${NUMERICAL_VISIBILITY} + "$" + "$" +) + +target_link_libraries(numerical.optimization ${NUMERICAL_VISIBILITY} + infra.util + numerical.math + numerical.neural_network.losses +) + +target_sources(numerical.optimization PRIVATE + GradientDescent.hpp + Optimizer.hpp +) + +numerical_add_coverage_sources(numerical.optimization + GradientDescent.cpp +) + +add_subdirectory(test) diff --git a/numerical/neural_network/optimizer/GradientDescent.cpp b/numerical/optimization/GradientDescent.cpp similarity index 62% rename from numerical/neural_network/optimizer/GradientDescent.cpp rename to numerical/optimization/GradientDescent.cpp index 180efab5..742dcd78 100644 --- a/numerical/neural_network/optimizer/GradientDescent.cpp +++ b/numerical/optimization/GradientDescent.cpp @@ -1,6 +1,6 @@ -#include "numerical/neural_network/optimizer/GradientDescent.hpp" +#include "numerical/optimization/GradientDescent.hpp" -namespace neural_network +namespace optimization { template class GradientDescent; template class GradientDescent; diff --git a/numerical/neural_network/optimizer/GradientDescent.hpp b/numerical/optimization/GradientDescent.hpp similarity index 84% rename from numerical/neural_network/optimizer/GradientDescent.hpp rename to numerical/optimization/GradientDescent.hpp index 7c058345..432e4770 100644 --- a/numerical/neural_network/optimizer/GradientDescent.hpp +++ b/numerical/optimization/GradientDescent.hpp @@ -5,10 +5,10 @@ #endif #include "numerical/math/CompilerOptimizations.hpp" -#include "numerical/neural_network/optimizer/Optimizer.hpp" +#include "numerical/optimization/Optimizer.hpp" #include -namespace neural_network +namespace optimization { template class GradientDescent @@ -19,7 +19,7 @@ namespace neural_network public: using Result = typename Optimizer::Result; - using Vector = typename Loss::Vector; + using Vector = typename neural_network::Loss::Vector; struct Parameters { @@ -28,7 +28,7 @@ namespace neural_network }; explicit GradientDescent(const Parameters& params); - const Result& Minimize(const Vector& initialGuess, Loss& loss) override; + const Result& Minimize(const Vector& initialGuess, neural_network::Loss& loss) override; private: Parameters parameters; @@ -46,7 +46,7 @@ namespace neural_network } template - OPTIMIZE_FOR_SPEED const typename GradientDescent::Result& GradientDescent::Minimize(const Vector& initialGuess, Loss& loss) + OPTIMIZE_FOR_SPEED const typename GradientDescent::Result& GradientDescent::Minimize(const Vector& initialGuess, neural_network::Loss& loss) { auto currentParams = initialGuess; auto currentCost = loss.Cost(currentParams); diff --git a/numerical/neural_network/optimizer/Optimizer.hpp b/numerical/optimization/Optimizer.hpp similarity index 81% rename from numerical/neural_network/optimizer/Optimizer.hpp rename to numerical/optimization/Optimizer.hpp index 26d2e4d4..14ffec7c 100644 --- a/numerical/neural_network/optimizer/Optimizer.hpp +++ b/numerical/optimization/Optimizer.hpp @@ -3,7 +3,7 @@ #include "numerical/math/QNumber.hpp" #include "numerical/neural_network/losses/Loss.hpp" -namespace neural_network +namespace optimization { template class Optimizer @@ -12,7 +12,7 @@ namespace neural_network "Optimizer can only be instantiated with math::QNumber types."); public: - using Vector = typename Loss::Vector; + using Vector = typename neural_network::Loss::Vector; struct Result { @@ -27,6 +27,6 @@ namespace neural_network std::size_t iterations; }; - virtual const Result& Minimize(const Vector& initialGuess, Loss& loss) = 0; + virtual const Result& Minimize(const Vector& initialGuess, neural_network::Loss& loss) = 0; }; } diff --git a/numerical/optimization/test/CMakeLists.txt b/numerical/optimization/test/CMakeLists.txt new file mode 100644 index 00000000..a07d1c19 --- /dev/null +++ b/numerical/optimization/test/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(numerical.optimization_test) +emil_build_for(numerical.optimization_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) +emil_add_test(numerical.optimization_test) + +target_link_libraries(numerical.optimization_test PUBLIC + gmock_main + numerical.optimization +) + +target_sources(numerical.optimization_test PRIVATE + TestGradientDescent.cpp +) diff --git a/numerical/neural_network/optimizer/test/TestGradientDescent.cpp b/numerical/optimization/test/TestGradientDescent.cpp similarity index 92% rename from numerical/neural_network/optimizer/test/TestGradientDescent.cpp rename to numerical/optimization/test/TestGradientDescent.cpp index c251f3d1..99e33190 100644 --- a/numerical/neural_network/optimizer/test/TestGradientDescent.cpp +++ b/numerical/optimization/test/TestGradientDescent.cpp @@ -1,5 +1,5 @@ #include "numerical/math/QNumber.hpp" -#include "numerical/neural_network/optimizer/GradientDescent.hpp" +#include "numerical/optimization/GradientDescent.hpp" #include "gmock/gmock.h" namespace @@ -57,7 +57,7 @@ namespace params.maxIterations = 100; } - typename neural_network::GradientDescent::Parameters params; + typename optimization::GradientDescent::Parameters params; MockLoss loss; Vector MakeVector(float x, float y) @@ -94,7 +94,7 @@ TYPED_TEST(TestGradientDescent, performs_expected_number_of_iterations) .Times(this->params.maxIterations) .WillRepeatedly(::testing::Return(gradientResult)); - neural_network::GradientDescent::Features> + optimization::GradientDescent::Features> optimizer(this->params); auto result = optimizer.Minimize(initialGuess, this->loss); @@ -130,7 +130,7 @@ TYPED_TEST(TestGradientDescent, calls_methods_in_correct_order) } this->params.maxIterations = 2; - neural_network::GradientDescent::Features> + optimization::GradientDescent::Features> optimizer(this->params); optimizer.Minimize(initialGuess, this->loss); diff --git a/numerical/regularization/CMakeLists.txt b/numerical/regularization/CMakeLists.txt new file mode 100644 index 00000000..6116012d --- /dev/null +++ b/numerical/regularization/CMakeLists.txt @@ -0,0 +1,24 @@ +numerical_add_header_library(numerical.regularization) + +target_include_directories(numerical.regularization ${NUMERICAL_VISIBILITY} + "$" + "$" +) + +target_link_libraries(numerical.regularization ${NUMERICAL_VISIBILITY} + infra.util + numerical.math +) + +target_sources(numerical.regularization PRIVATE + L1.hpp + L2.hpp + Regularization.hpp +) + +numerical_add_coverage_sources(numerical.regularization + L1.cpp + L2.cpp +) + +add_subdirectory(test) diff --git a/numerical/neural_network/regularization/L1.cpp b/numerical/regularization/L1.cpp similarity index 57% rename from numerical/neural_network/regularization/L1.cpp rename to numerical/regularization/L1.cpp index 975bb0b3..0e2d1996 100644 --- a/numerical/neural_network/regularization/L1.cpp +++ b/numerical/regularization/L1.cpp @@ -1,6 +1,6 @@ -#include "numerical/neural_network/regularization/L1.hpp" +#include "numerical/regularization/L1.hpp" -namespace neural_network +namespace regularization { template class L1; template class L1; diff --git a/numerical/neural_network/regularization/L1.hpp b/numerical/regularization/L1.hpp similarity index 95% rename from numerical/neural_network/regularization/L1.hpp rename to numerical/regularization/L1.hpp index e3f0a723..ede57df1 100644 --- a/numerical/neural_network/regularization/L1.hpp +++ b/numerical/regularization/L1.hpp @@ -5,9 +5,9 @@ #endif #include "numerical/math/CompilerOptimizations.hpp" -#include "numerical/neural_network/regularization/Regularization.hpp" +#include "numerical/regularization/Regularization.hpp" -namespace neural_network +namespace regularization { template class L1 diff --git a/numerical/neural_network/regularization/L2.cpp b/numerical/regularization/L2.cpp similarity index 57% rename from numerical/neural_network/regularization/L2.cpp rename to numerical/regularization/L2.cpp index 4e161826..feb43357 100644 --- a/numerical/neural_network/regularization/L2.cpp +++ b/numerical/regularization/L2.cpp @@ -1,6 +1,6 @@ -#include "numerical/neural_network/regularization/L2.hpp" +#include "numerical/regularization/L2.hpp" -namespace neural_network +namespace regularization { template class L2; template class L2; diff --git a/numerical/neural_network/regularization/L2.hpp b/numerical/regularization/L2.hpp similarity index 94% rename from numerical/neural_network/regularization/L2.hpp rename to numerical/regularization/L2.hpp index 55b67072..e397e889 100644 --- a/numerical/neural_network/regularization/L2.hpp +++ b/numerical/regularization/L2.hpp @@ -5,9 +5,9 @@ #endif #include "numerical/math/CompilerOptimizations.hpp" -#include "numerical/neural_network/regularization/Regularization.hpp" +#include "numerical/regularization/Regularization.hpp" -namespace neural_network +namespace regularization { template class L2 diff --git a/numerical/neural_network/regularization/Regularization.hpp b/numerical/regularization/Regularization.hpp similarity index 93% rename from numerical/neural_network/regularization/Regularization.hpp rename to numerical/regularization/Regularization.hpp index 97d5e8d4..0e46b6c7 100644 --- a/numerical/neural_network/regularization/Regularization.hpp +++ b/numerical/regularization/Regularization.hpp @@ -2,7 +2,7 @@ #include "numerical/math/Matrix.hpp" -namespace neural_network +namespace regularization { template class Regularization diff --git a/numerical/regularization/test/CMakeLists.txt b/numerical/regularization/test/CMakeLists.txt new file mode 100644 index 00000000..f69139a9 --- /dev/null +++ b/numerical/regularization/test/CMakeLists.txt @@ -0,0 +1,13 @@ +add_executable(numerical.regularization_test) +emil_build_for(numerical.regularization_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) +emil_add_test(numerical.regularization_test) + +target_link_libraries(numerical.regularization_test PUBLIC + gmock_main + numerical.regularization +) + +target_sources(numerical.regularization_test PRIVATE + TestL1.cpp + TestL2.cpp +) diff --git a/numerical/neural_network/regularization/test/TestL1.cpp b/numerical/regularization/test/TestL1.cpp similarity index 82% rename from numerical/neural_network/regularization/test/TestL1.cpp rename to numerical/regularization/test/TestL1.cpp index 6025ef07..918b0bc8 100644 --- a/numerical/neural_network/regularization/test/TestL1.cpp +++ b/numerical/regularization/test/TestL1.cpp @@ -1,4 +1,4 @@ -#include "numerical/neural_network/regularization/L1.hpp" +#include "numerical/regularization/L1.hpp" #include "gmock/gmock.h" #include #include @@ -12,7 +12,7 @@ namespace public: static constexpr std::size_t Size = 4; - neural_network::L1 regularization{ T(0.001f) }; + regularization::L1 regularization{ T(0.001f) }; }; using TestedTypes = ::testing::Types; @@ -21,7 +21,7 @@ namespace TYPED_TEST(TestL1, CalculateZeroVector) { - using Vector = typename neural_network::L1::Vector; + using Vector = typename regularization::L1::Vector; Vector parameters{}; TypeParam result = TestFixture::regularization.Calculate(parameters); @@ -30,7 +30,7 @@ TYPED_TEST(TestL1, CalculateZeroVector) TYPED_TEST(TestL1, CalculateMixedValues) { - using Vector = typename neural_network::L1::Vector; + using Vector = typename regularization::L1::Vector; Vector parameters; parameters[0] = TypeParam(0.025f); @@ -46,9 +46,9 @@ TYPED_TEST(TestL1, CalculateMixedValues) TYPED_TEST(TestL1, DifferentLambdaValue) { - using Vector = typename neural_network::L1::Vector; + using Vector = typename regularization::L1::Vector; - neural_network::L1 regularization(TypeParam(0.01f)); + regularization::L1 regularization(TypeParam(0.01f)); Vector parameters; parameters[0] = TypeParam(0.01f); @@ -64,7 +64,7 @@ TYPED_TEST(TestL1, DifferentLambdaValue) TYPED_TEST(TestL1, GradientPositiveValues) { - using Vector = typename neural_network::L1::Vector; + using Vector = typename regularization::L1::Vector; Vector parameters; parameters[0] = TypeParam(0.1f); parameters[1] = TypeParam(0.2f); @@ -79,7 +79,7 @@ TYPED_TEST(TestL1, GradientPositiveValues) TYPED_TEST(TestL1, GradientMixedValues) { - using Vector = typename neural_network::L1::Vector; + using Vector = typename regularization::L1::Vector; Vector parameters; parameters[0] = TypeParam(0.1f); parameters[1] = TypeParam(-0.2f); diff --git a/numerical/neural_network/regularization/test/TestL2.cpp b/numerical/regularization/test/TestL2.cpp similarity index 84% rename from numerical/neural_network/regularization/test/TestL2.cpp rename to numerical/regularization/test/TestL2.cpp index 743e7501..ede2eb05 100644 --- a/numerical/neural_network/regularization/test/TestL2.cpp +++ b/numerical/regularization/test/TestL2.cpp @@ -1,4 +1,4 @@ -#include "numerical/neural_network/regularization/L2.hpp" +#include "numerical/regularization/L2.hpp" #include "gmock/gmock.h" #include #include @@ -12,7 +12,7 @@ namespace public: static constexpr std::size_t Size = 4; - neural_network::L2 regularization{ T(0.001f) }; + regularization::L2 regularization{ T(0.001f) }; }; using TestedTypes = ::testing::Types; @@ -21,7 +21,7 @@ namespace TYPED_TEST(TestL2, CalculateZeroVector) { - using Vector = typename neural_network::L2::Vector; + using Vector = typename regularization::L2::Vector; Vector parameters{}; TypeParam result = TestFixture::regularization.Calculate(parameters); @@ -30,7 +30,7 @@ TYPED_TEST(TestL2, CalculateZeroVector) TYPED_TEST(TestL2, CalculatePositiveValues) { - using Vector = typename neural_network::L2::Vector; + using Vector = typename regularization::L2::Vector; Vector parameters; parameters[0] = TypeParam(0.01f); @@ -47,7 +47,7 @@ TYPED_TEST(TestL2, CalculatePositiveValues) TYPED_TEST(TestL2, CalculateMixedValues) { - using Vector = typename neural_network::L2::Vector; + using Vector = typename regularization::L2::Vector; Vector parameters; parameters[0] = TypeParam(0.025f); @@ -64,9 +64,9 @@ TYPED_TEST(TestL2, CalculateMixedValues) TYPED_TEST(TestL2, DifferentLambdaValue) { - using Vector = typename neural_network::L2::Vector; + using Vector = typename regularization::L2::Vector; - neural_network::L2 regularization(TypeParam(0.01f)); + regularization::L2 regularization(TypeParam(0.01f)); Vector parameters; parameters[0] = TypeParam(0.01f); @@ -83,7 +83,7 @@ TYPED_TEST(TestL2, DifferentLambdaValue) TYPED_TEST(TestL2, GradientPositiveValues) { - using Vector = typename neural_network::L2::Vector; + using Vector = typename regularization::L2::Vector; Vector parameters; parameters[0] = TypeParam(0.1f); parameters[1] = TypeParam(0.2f); @@ -98,7 +98,7 @@ TYPED_TEST(TestL2, GradientPositiveValues) TYPED_TEST(TestL2, GradientMixedValues) { - using Vector = typename neural_network::L2::Vector; + using Vector = typename regularization::L2::Vector; Vector parameters; parameters[0] = TypeParam(0.1f); parameters[1] = TypeParam(-0.2f); diff --git a/numerical/windowing/CMakeLists.txt b/numerical/windowing/CMakeLists.txt deleted file mode 100644 index 8d30325c..00000000 --- a/numerical/windowing/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -numerical_add_header_library(numerical.windowing) - -target_include_directories(numerical.windowing ${NUMERICAL_VISIBILITY} - "$" - "$" -) - -target_link_libraries(numerical.windowing ${NUMERICAL_VISIBILITY} - numerical.math -) - -target_sources(numerical.windowing PRIVATE - Windowing.hpp -) - -numerical_add_coverage_sources(numerical.windowing - Windowing.cpp -) - -add_subdirectory(test) diff --git a/numerical/windowing/test/CMakeLists.txt b/numerical/windowing/test/CMakeLists.txt deleted file mode 100644 index 7548b1e9..00000000 --- a/numerical/windowing/test/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -add_executable(numerical.windowing_test) -emil_build_for(numerical.windowing_test BOOL NUMERICAL_TOOLBOX_BUILD_TESTS) -emil_add_test(numerical.windowing_test) - -target_link_libraries(numerical.windowing_test PUBLIC - gmock_main - numerical.windowing -) - -target_sources(numerical.windowing_test PRIVATE - TestWindowing.cpp -) diff --git a/simulator/analysis/FastFourierTransform/application/CMakeLists.txt b/simulator/analysis/FastFourierTransform/application/CMakeLists.txt index 744cc53a..4c9cf6a2 100644 --- a/simulator/analysis/FastFourierTransform/application/CMakeLists.txt +++ b/simulator/analysis/FastFourierTransform/application/CMakeLists.txt @@ -7,7 +7,7 @@ target_include_directories(numerical.simulator.analysis.fft.application PUBLIC target_link_libraries(numerical.simulator.analysis.fft.application PUBLIC numerical.analysis - numerical.windowing + numerical.analysis.windowing numerical.simulator.utils ) diff --git a/simulator/analysis/FastFourierTransform/application/FftSimulator.cpp b/simulator/analysis/FastFourierTransform/application/FftSimulator.cpp index 55b23f09..11478c42 100644 --- a/simulator/analysis/FastFourierTransform/application/FftSimulator.cpp +++ b/simulator/analysis/FastFourierTransform/application/FftSimulator.cpp @@ -1,6 +1,6 @@ #include "simulator/analysis/FastFourierTransform/application/FftSimulator.hpp" #include "numerical/analysis/FastFourierTransformRadix2Impl.hpp" -#include "numerical/windowing/Windowing.hpp" +#include "numerical/analysis/windowing/Windowing.hpp" #include "simulator/utils/TwiddleFactorsTable.hpp" #include #include diff --git a/simulator/analysis/PowerDensitySpectrum/application/CMakeLists.txt b/simulator/analysis/PowerDensitySpectrum/application/CMakeLists.txt index 17c4ae74..a09c0b41 100644 --- a/simulator/analysis/PowerDensitySpectrum/application/CMakeLists.txt +++ b/simulator/analysis/PowerDensitySpectrum/application/CMakeLists.txt @@ -7,7 +7,7 @@ target_include_directories(numerical.simulator.analysis.psd.application PUBLIC target_link_libraries(numerical.simulator.analysis.psd.application PUBLIC numerical.analysis - numerical.windowing + numerical.analysis.windowing numerical.simulator.utils ) diff --git a/simulator/analysis/PowerDensitySpectrum/application/PsdSimulator.cpp b/simulator/analysis/PowerDensitySpectrum/application/PsdSimulator.cpp index 22aaac15..61c791dc 100644 --- a/simulator/analysis/PowerDensitySpectrum/application/PsdSimulator.cpp +++ b/simulator/analysis/PowerDensitySpectrum/application/PsdSimulator.cpp @@ -1,7 +1,7 @@ #include "simulator/analysis/PowerDensitySpectrum/application/PsdSimulator.hpp" #include "numerical/analysis/FastFourierTransformRadix2Impl.hpp" #include "numerical/analysis/PowerDensitySpectrum.hpp" -#include "numerical/windowing/Windowing.hpp" +#include "numerical/analysis/windowing/Windowing.hpp" #include "simulator/utils/TwiddleFactorsTable.hpp" #include #include diff --git a/simulator/controllers/PidController/application/CMakeLists.txt b/simulator/controllers/PidController/application/CMakeLists.txt index 46bf9ddb..10df0624 100644 --- a/simulator/controllers/PidController/application/CMakeLists.txt +++ b/simulator/controllers/PidController/application/CMakeLists.txt @@ -7,6 +7,7 @@ target_include_directories(numerical.simulator.controllers.pid.application PUBLI target_link_libraries(numerical.simulator.controllers.pid.application PUBLIC numerical.analysis + numerical.control_analysis numerical.controllers.implementations numerical.simulator.controllers.common numerical.solver diff --git a/simulator/controllers/PidController/application/PidSimulator.cpp b/simulator/controllers/PidController/application/PidSimulator.cpp index 88e39162..ecb5157c 100644 --- a/simulator/controllers/PidController/application/PidSimulator.cpp +++ b/simulator/controllers/PidController/application/PidSimulator.cpp @@ -1,6 +1,6 @@ #include "simulator/controllers/PidController/application/PidSimulator.hpp" -#include "numerical/analysis/FrequencyResponse.hpp" -#include "numerical/analysis/RootLocus.hpp" +#include "numerical/control_analysis/FrequencyResponse.hpp" +#include "numerical/control_analysis/RootLocus.hpp" #include "numerical/controllers/implementations/PidIncremental.hpp" #include #include @@ -168,7 +168,7 @@ namespace simulator::controllers std::vector numCoeffs = discrete.numerator; std::vector denCoeffs = discrete.denominator; - analysis::FrequencyResponse freqResponse( + control_analysis::FrequencyResponse freqResponse( infra::MemoryRange(numCoeffs), infra::MemoryRange(denCoeffs), fs); @@ -218,7 +218,7 @@ namespace simulator::controllers auto openNum = PolyMultiply(pidTf.numerator, plantTf.numerator); auto openDen = PolyMultiply(pidTf.denominator, plantTf.denominator); - analysis::RootLocus rootLocus; + control_analysis::RootLocus rootLocus; auto rlResult = rootLocus.Calculate( infra::MemoryRange(openNum), infra::MemoryRange(openDen),