From 2f8cefa8eeb61987c10e53d2882f933e9dc22fed Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 1 Oct 2026 05:52:10 +0000 Subject: [PATCH] fix: scope the O3/fast-math pragma to each header instead of leaking it Every algorithm header applied `#pragma GCC optimize("O3", "fast-math")` at file scope with no pop, so including any of them switched every function defined later in the translation unit to fast-math (folded NaN checks, reassociation). Bracket each header with push_options/pop_options at the same position the pragma used to be, so the library's own code generation is preserved while consumer code after the include is compiled with the consumer's flags. - 98 headers: push_options + optimize ... pop_options (GCC only; clang never honoured the pragma and warns on it). - ComplexNumber.hpp and TwiddleFactorsTable.hpp: add the scoped pragma; they previously only got fast-math by leaking from earlier headers. - Remove the pragma from four controller test TUs. - Update AGENTS.md, CLAUDE.md, copilot instructions, agent definitions, roadmap recipe and performance doc to the scoped pattern. Closes #334 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01N4pngRiBqeb1xiseKXNLG6 --- .claude/agents/algo-implementer.md | 2 +- .claude/agents/planner.md | 2 +- .claude/agents/reviewer.md | 2 +- .github/agents/algo-implementer.agent.md | 2 +- .github/agents/planner.agent.md | 2 +- .github/agents/reviewer.agent.md | 2 +- .github/copilot-instructions.md | 2 +- .github/instructions/numerical-cpp.instructions.md | 13 +++++++++++-- AGENTS.md | 14 +++++++++++++- CLAUDE.md | 2 +- ROADMAP.md | 2 +- doc/performance-optimization/README.md | 11 ++++++++--- numerical/analysis/ConvolutionCorrelation.hpp | 7 ++++++- numerical/analysis/Decibels.hpp | 7 ++++++- numerical/analysis/DiscreteCosineTransform.hpp | 7 ++++++- numerical/analysis/DiscreteWaveletTransform.hpp | 7 ++++++- .../analysis/FastFourierTransformRadix2Impl.hpp | 7 ++++++- numerical/analysis/GoertzelAlgorithm.hpp | 7 ++++++- numerical/analysis/HilbertTransform.hpp | 7 ++++++- numerical/analysis/PowerDensitySpectrum.hpp | 7 ++++++- numerical/analysis/RealFastFourierTransform.hpp | 7 ++++++- numerical/analysis/SignalDetectors.hpp | 7 ++++++- numerical/analysis/TwiddleFactorsTable.hpp | 9 +++++++++ numerical/analysis/windowing/Windowing.hpp | 7 ++++++- .../control_analysis/ContinuousToDiscrete.hpp | 7 ++++++- .../ControllabilityObservability.hpp | 7 ++++++- numerical/control_analysis/FrequencyResponse.hpp | 7 ++++++- numerical/control_analysis/RootLocus.hpp | 7 ++++++- .../TransferFunctionStateSpace.hpp | 7 ++++++- .../implementations/BangBangHysteresis.hpp | 7 ++++++- .../implementations/DeadbeatControl.hpp | 7 ++++++- .../implementations/Feedforward2Dof.hpp | 7 ++++++- .../implementations/GainScheduledController.hpp | 7 ++++++- .../implementations/IntegralStateFeedbackLqi.hpp | 7 ++++++- .../implementations/LeadLagCompensator.hpp | 7 ++++++- numerical/controllers/implementations/Lqg.hpp | 7 ++++++- numerical/controllers/implementations/Lqr.hpp | 7 ++++++- .../implementations/LuenbergerObserver.hpp | 7 ++++++- numerical/controllers/implementations/Mpc.hpp | 7 ++++++- .../controllers/implementations/PidIncremental.hpp | 7 ++++++- .../implementations/SaturationRateLimiter.hpp | 7 ++++++- .../implementations/test/TestDeadbeatControl.cpp | 4 ---- .../test/TestIntegralStateFeedbackLqi.cpp | 4 ---- .../controllers/implementations/test/TestLqg.cpp | 4 ---- .../test/TestStateFeedbackController.cpp | 4 ---- .../estimators/offline/ExpectationMaximization.hpp | 7 ++++++- numerical/estimators/offline/LinearRegression.hpp | 7 ++++++- numerical/estimators/offline/PolynomialFitting.hpp | 7 ++++++- numerical/estimators/offline/TotalLeastSquares.hpp | 7 ++++++- numerical/estimators/offline/YuleWalker.hpp | 7 ++++++- numerical/estimators/online/LmsAdaptiveFilter.hpp | 7 ++++++- .../estimators/online/RecursiveLeastSquares.hpp | 7 ++++++- numerical/filters/active/AhrsMadgwickMahony.hpp | 7 ++++++- numerical/filters/active/AlphaBetaFilter.hpp | 7 ++++++- numerical/filters/active/ComplementaryFilter.hpp | 7 ++++++- numerical/filters/active/ExtendedKalmanFilter.hpp | 7 ++++++- numerical/filters/active/KalmanFilter.hpp | 7 ++++++- numerical/filters/active/KalmanFilterBase.hpp | 7 ++++++- numerical/filters/active/KalmanSmoother.hpp | 7 ++++++- .../filters/active/SquareRootKalmanFilter.hpp | 7 ++++++- numerical/filters/active/UnscentedKalmanFilter.hpp | 7 ++++++- numerical/filters/passive/BiquadCascade.hpp | 7 ++++++- numerical/filters/passive/CicFilter.hpp | 7 ++++++- .../filters/passive/ExponentialMovingAverage.hpp | 7 ++++++- numerical/filters/passive/Fir.hpp | 7 ++++++- numerical/filters/passive/Iir.hpp | 7 ++++++- numerical/filters/passive/IirFilterDesign.hpp | 7 ++++++- numerical/filters/passive/MedianFilter.hpp | 7 ++++++- numerical/filters/passive/MovingAverage.hpp | 7 ++++++- numerical/filters/passive/NotchCombFilter.hpp | 7 ++++++- numerical/filters/passive/SavitzkyGolayFilter.hpp | 7 ++++++- numerical/math/CholeskyDecomposition.hpp | 7 ++++++- numerical/math/ComplexNumber.hpp | 9 +++++++++ numerical/math/ConsistencyMetrics.hpp | 7 ++++++- numerical/math/Cordic.hpp | 7 ++++++- numerical/math/Geometry3D.hpp | 7 ++++++- numerical/math/GivensRotation.hpp | 7 ++++++- numerical/math/HouseholderTransform.hpp | 7 ++++++- numerical/math/LinearTimeInvariant.hpp | 7 ++++++- numerical/math/Math.hpp | 7 ++++++- numerical/math/Matrix.hpp | 7 ++++++- numerical/math/MatrixExponential.hpp | 7 ++++++- numerical/math/MatrixNorms.hpp | 7 ++++++- numerical/math/MatrixOperations.hpp | 7 ++++++- numerical/math/QNumber.hpp | 7 ++++++- numerical/math/Quaternion.hpp | 7 ++++++- numerical/math/RecursiveBuffer.hpp | 7 ++++++- numerical/math/StepResponseMetrics.hpp | 7 ++++++- numerical/math/Toeplitz.hpp | 7 ++++++- numerical/math/Tolerance.hpp | 7 ++++++- numerical/math/TriangularSolve.hpp | 7 ++++++- numerical/math/platform/MathArm.hpp | 7 ++++++- .../nonlinear_control/BacksteppingControl.hpp | 7 ++++++- .../nonlinear_control/FeedbackLinearization.hpp | 7 ++++++- .../ModelReferenceAdaptiveControl.hpp | 7 ++++++- numerical/optimization/BayesianOptimization.hpp | 7 ++++++- numerical/optimization/GradientDescent.hpp | 7 ++++++- numerical/regularization/L1.hpp | 7 ++++++- numerical/regularization/L2.hpp | 7 ++++++- .../robust_control/ActiveDisturbanceRejection.hpp | 7 ++++++- numerical/robust_control/DisturbanceObserver.hpp | 7 ++++++- .../robust_control/HInfinityStateFeedback.hpp | 7 ++++++- numerical/robust_control/SlidingModeControl.hpp | 7 ++++++- numerical/solvers/ConditionNumber.hpp | 7 ++++++- .../solvers/DiscreteAlgebraicRiccatiEquation.hpp | 7 ++++++- numerical/solvers/DormandPrince45.hpp | 7 ++++++- numerical/solvers/DurandKerner.hpp | 7 ++++++- numerical/solvers/GaussianElimination.hpp | 7 ++++++- numerical/solvers/JacobiEigenSolver.hpp | 7 ++++++- numerical/solvers/LevinsonDurbin.hpp | 7 ++++++- numerical/solvers/LuDecomposition.hpp | 7 ++++++- numerical/solvers/LyapunovSylvester.hpp | 7 ++++++- numerical/solvers/QrDecomposition.hpp | 7 ++++++- numerical/solvers/RungeKuttaIntegrators.hpp | 7 ++++++- numerical/solvers/SingularValueDecomposition.hpp | 7 ++++++- numerical/solvers/SpectralRadius.hpp | 7 ++++++- roadmap/DEPLOYMENT.md | 4 ++-- roadmap/README.md | 7 ++++++- 118 files changed, 655 insertions(+), 132 deletions(-) diff --git a/.claude/agents/algo-implementer.md b/.claude/agents/algo-implementer.md index 054727fb..959dcf76 100644 --- a/.claude/agents/algo-implementer.md +++ b/.claude/agents/algo-implementer.md @@ -28,5 +28,5 @@ from its `roadmap///` spec into the codebase, following both exact - **No comments** (except license/`NOLINT`). Allman braces, brace-init. - **Tests**: `TEST_F` on `float`, `StrictMock` only, anonymous-namespace fixture; implement EXACTLY the spec's cases — no redundant or extra tests. -- **Embedded**: `#pragma GCC optimize` + `OPTIMIZE_FOR_SPEED` on hot paths. +- **Embedded**: scoped `#pragma GCC push_options`/`optimize`/`pop_options` + `OPTIMIZE_FOR_SPEED` on hot paths. - **Terse**: no preamble/postamble, no plan restatement, no narration; don't re-read files; batch reads. diff --git a/.claude/agents/planner.md b/.claude/agents/planner.md index ffbb4fa3..30fd10e0 100644 --- a/.claude/agents/planner.md +++ b/.claude/agents/planner.md @@ -25,7 +25,7 @@ Canonical rules: `AGENTS.md`. Produce plans only — no code edits. - [ ] No heap; no recursion; tests too - [ ] `template` + `static_assert(std::is_floating_point_v)`; `float` only - [ ] `TEST_F` on `float` — no `TYPED_TEST`; `StrictMock` only; never plain `TEST()` - - [ ] `#pragma GCC optimize` + `OPTIMIZE_FOR_SPEED` on hot paths + - [ ] scoped `#pragma GCC push_options`/`optimize`/`pop_options` + `OPTIMIZE_FOR_SPEED` on hot paths - [ ] `doc/` update planned **Terse**: no preamble/postamble, no plan restatement; don't re-read files; batch reads. diff --git a/.claude/agents/reviewer.md b/.claude/agents/reviewer.md index 28bfc3dc..7a64c59f 100644 --- a/.claude/agents/reviewer.md +++ b/.claude/agents/reviewer.md @@ -35,7 +35,7 @@ End with totals + verdict: APPROVE / REQUEST CHANGES. - [ ] `extern template` guarded by `#ifdef NUMERICAL_TOOLBOX_COVERAGE_BUILD`. **Embedded optimizations (WARNING)** -- [ ] `#pragma GCC optimize("O3","fast-math")` after `#pragma once` in algorithm headers. +- [ ] `#pragma GCC push_options` + `optimize("O3","fast-math")` after `#pragma once`, matching `pop_options` at end of algorithm headers (no TU leak; none in test `.cpp`). - [ ] `OPTIMIZE_FOR_SPEED` on `Filter/Compute/Update/Solve/Step`. **Namespaces (WARNING)** diff --git a/.github/agents/algo-implementer.agent.md b/.github/agents/algo-implementer.agent.md index 193b03d9..52855b94 100644 --- a/.github/agents/algo-implementer.agent.md +++ b/.github/agents/algo-implementer.agent.md @@ -31,5 +31,5 @@ Authoritative rules: `AGENTS.md`. Recipe: `roadmap/DEPLOYMENT.md`. Follow both e - **No comments** (except license/`NOLINT`). Allman braces, brace-init. - **Tests**: `TEST_F` on `float`, `StrictMock` only, anonymous-namespace fixture; implement EXACTLY the spec's cases — no redundant or extra tests. -- **Embedded**: `#pragma GCC optimize` + `OPTIMIZE_FOR_SPEED` on hot paths. +- **Embedded**: scoped `#pragma GCC push_options`/`optimize`/`pop_options` + `OPTIMIZE_FOR_SPEED` on hot paths. - **Terse**: no preamble/postamble, no plan restatement, no narration; don't re-read files; batch reads. diff --git a/.github/agents/planner.agent.md b/.github/agents/planner.agent.md index cf87337f..85c5c7ca 100644 --- a/.github/agents/planner.agent.md +++ b/.github/agents/planner.agent.md @@ -28,7 +28,7 @@ Canonical rules: `AGENTS.md`. Produce plans only — no code edits. - [ ] No heap; no recursion; tests too - [ ] `template` + `static_assert(std::is_floating_point_v)`; `float` only - [ ] `TEST_F` on `float` — no `TYPED_TEST`; `StrictMock` only; never plain `TEST()` - - [ ] `#pragma GCC optimize` + `OPTIMIZE_FOR_SPEED` on hot paths + - [ ] scoped `#pragma GCC push_options`/`optimize`/`pop_options` + `OPTIMIZE_FOR_SPEED` on hot paths - [ ] `doc/` update planned **Terse**: no preamble/postamble, no plan restatement; don't re-read files; batch reads. diff --git a/.github/agents/reviewer.agent.md b/.github/agents/reviewer.agent.md index fab9c05b..64b6be26 100644 --- a/.github/agents/reviewer.agent.md +++ b/.github/agents/reviewer.agent.md @@ -41,7 +41,7 @@ End with totals + verdict: APPROVE / REQUEST CHANGES. - [ ] `extern template` guarded by `#ifdef NUMERICAL_TOOLBOX_COVERAGE_BUILD`. **Embedded optimizations (WARNING)** -- [ ] `#pragma GCC optimize("O3","fast-math")` after `#pragma once` in algorithm headers. +- [ ] `#pragma GCC push_options` + `optimize("O3","fast-math")` after `#pragma once`, matching `pop_options` at end of algorithm headers (no TU leak; none in test `.cpp`). - [ ] `OPTIMIZE_FOR_SPEED` on `Filter/Compute/Update/Solve/Step`. **Namespaces (WARNING)** diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index ecdbf36a..fbe7cdfb 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -6,7 +6,7 @@ Code-file specifics: `.github/instructions/` (applyTo-scoped). Deployment recipe Essentials (full detail in AGENTS.md): - **No heap** — bounded containers / `std::array` / `std::optional`; no recursion; tests too. - **Float-only** — generic `template` + `static_assert(std::is_floating_point_v)`; instantiate/test `float`; no Q15/Q31. -- **Embedded** — `#pragma GCC optimize("O3","fast-math")` + `OPTIMIZE_FOR_SPEED` on hot paths. +- **Embedded** — scoped `#pragma GCC push_options` / `optimize("O3","fast-math")` … `pop_options` (never leak to the TU) + `OPTIMIZE_FOR_SPEED` on hot paths. - **No comments** (except license/NOLINT). Allman braces, brace-init, PascalCase/camelCase. - **Tests** — `TEST_F` on `float`, `StrictMock` only, never plain `TEST()`, no redundant cases. - **No exceptions** — `std::optional`/status enums; interfaces `virtual ~I() = default`. diff --git a/.github/instructions/numerical-cpp.instructions.md b/.github/instructions/numerical-cpp.instructions.md index b156f9ad..442cf557 100644 --- a/.github/instructions/numerical-cpp.instructions.md +++ b/.github/instructions/numerical-cpp.instructions.md @@ -41,16 +41,25 @@ To replace a function with a platform-specific implementation, define the corres ## Embedded Optimizations -Every algorithm header MUST include: +Every algorithm header MUST bracket its body with a scoped pragma, so the options never leak into the including translation unit: ```cpp #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif + +// ... includes and header body ... + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif ``` +The `pop_options` block is the last thing in the header. Never use the pragma in test `.cpp` files. + Apply `OPTIMIZE_FOR_SPEED` (from `numerical/math/CompilerOptimizations.hpp`) on hot-path methods: `Compute()`, `Filter()`, `Calculate()`, `Solve()`, `Update()`, `Step()`. ## Naming diff --git a/AGENTS.md b/AGENTS.md index c97f4979..50bfcf99 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,12 +26,24 @@ resource-constrained embedded systems. Real-time, deterministic, no heap. ```cpp #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif #include "numerical/math/CompilerOptimizations.hpp" + +// ... header body ... + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif ``` +The `pop_options` block is the **last thing in the header**: the pragma must never leak into the +including translation unit (it would silently apply fast-math, e.g. folded NaN checks and +reassociation, to unrelated code). Use `math::IsFinite` for finiteness checks. Test `.cpp` files +never use the pragma. + `OPTIMIZE_FOR_SPEED` on hot paths (`Filter/Compute/Update/Solve/Step`). Pure interfaces exempt. ## Style diff --git a/CLAUDE.md b/CLAUDE.md index 55484d93..1e464645 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,7 +6,7 @@ Code-file specifics: `.github/instructions/`. Deployment recipe: `roadmap/DEPLOY Essentials (full detail in AGENTS.md): - **No heap** — bounded containers / `std::array` / `std::optional`; no recursion; tests too. - **Float-only** — generic `template` + `static_assert(std::is_floating_point_v)`; instantiate/test `float`; no Q15/Q31. -- **Embedded** — `#pragma GCC optimize("O3","fast-math")` + `OPTIMIZE_FOR_SPEED` on hot paths. +- **Embedded** — scoped `#pragma GCC push_options` / `optimize("O3","fast-math")` … `pop_options` (never leak to the TU) + `OPTIMIZE_FOR_SPEED` on hot paths. - **No comments** (except license/NOLINT). Allman braces, brace-init, PascalCase/camelCase. - **Tests** — `TEST_F` on `float`, `StrictMock` only, never plain `TEST()`, no redundant cases. - **No exceptions** — `std::optional`/status enums; interfaces `virtual ~I() = default`. diff --git a/ROADMAP.md b/ROADMAP.md index 7dab252d..69b4bd9b 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -52,7 +52,7 @@ on bounded `math::Vector`/`math::Matrix` inputs; tests are `TEST_F` on `float`. Every new component should follow the established repository conventions: - [ ] Header-only template supporting `float` / `math::Q15` / `math::Q31` (or *float-first* where noted) -- [ ] `#pragma GCC optimize("O3", "fast-math")` after `#pragma once`; `OPTIMIZE_FOR_SPEED` on hot paths +- [ ] Scoped `#pragma GCC push_options` / `optimize("O3", "fast-math")` after `#pragma once`, `pop_options` at end of file; `OPTIMIZE_FOR_SPEED` on hot paths - [ ] No heap, no recursion, bounded containers (`infra::BoundedVector`, `std::array`) - [ ] `static_assert` on supported types and dimensions - [ ] Typed tests (`TYPED_TEST`) for multi-type components; `TEST_F` for single-type; `StrictMock` only diff --git a/doc/performance-optimization/README.md b/doc/performance-optimization/README.md index b2f56734..adc2ef85 100644 --- a/doc/performance-optimization/README.md +++ b/doc/performance-optimization/README.md @@ -207,12 +207,17 @@ set(CMAKE_CXX_FLAGS_DEBUG "-Og -g" CACHE STRING "Debug flags" FORCE) ### Solution 2: Per-File Optimization Pragmas ```cpp -// At the top of performance-critical .cpp files -#if defined(__GNUC__) || defined(__clang__) +// Bracket the performance-critical code; never leave the options active for the rest of the TU +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif -// Rest of implementation... +// Performance-critical implementation... + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif ``` ### Solution 3: Per-Function Attributes diff --git a/numerical/analysis/ConvolutionCorrelation.hpp b/numerical/analysis/ConvolutionCorrelation.hpp index b9ad0662..9cc3e388 100644 --- a/numerical/analysis/ConvolutionCorrelation.hpp +++ b/numerical/analysis/ConvolutionCorrelation.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -158,3 +159,7 @@ namespace analysis FastFourierTransform&); #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/Decibels.hpp b/numerical/analysis/Decibels.hpp index 3a559f45..6574d284 100644 --- a/numerical/analysis/Decibels.hpp +++ b/numerical/analysis/Decibels.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -48,3 +49,7 @@ namespace analysis return ToDecibels(maxRatio) - ToDecibels(minRatio); } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/DiscreteCosineTransform.hpp b/numerical/analysis/DiscreteCosineTransform.hpp index 181916cc..9dbc51b4 100644 --- a/numerical/analysis/DiscreteCosineTransform.hpp +++ b/numerical/analysis/DiscreteCosineTransform.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -112,3 +113,7 @@ namespace analysis extern template class DiscreteCosineTransform; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/DiscreteWaveletTransform.hpp b/numerical/analysis/DiscreteWaveletTransform.hpp index bbc5976b..c54287e5 100644 --- a/numerical/analysis/DiscreteWaveletTransform.hpp +++ b/numerical/analysis/DiscreteWaveletTransform.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -260,3 +261,7 @@ namespace analysis extern template class DiscreteWaveletTransform; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/FastFourierTransformRadix2Impl.hpp b/numerical/analysis/FastFourierTransformRadix2Impl.hpp index a6f615ba..acc3392d 100644 --- a/numerical/analysis/FastFourierTransformRadix2Impl.hpp +++ b/numerical/analysis/FastFourierTransformRadix2Impl.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -143,3 +144,7 @@ namespace analysis extern template class FastFourierTransformRadix2Impl; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/GoertzelAlgorithm.hpp b/numerical/analysis/GoertzelAlgorithm.hpp index 31e4396d..ad08c6e9 100644 --- a/numerical/analysis/GoertzelAlgorithm.hpp +++ b/numerical/analysis/GoertzelAlgorithm.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -123,3 +124,7 @@ namespace analysis extern template class GoertzelAlgorithm; } #endif + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/HilbertTransform.hpp b/numerical/analysis/HilbertTransform.hpp index 7da9a0d3..8496b5bc 100644 --- a/numerical/analysis/HilbertTransform.hpp +++ b/numerical/analysis/HilbertTransform.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -164,3 +165,7 @@ namespace analysis extern template class HilbertFir; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/PowerDensitySpectrum.hpp b/numerical/analysis/PowerDensitySpectrum.hpp index 8901c5bd..f215c429 100644 --- a/numerical/analysis/PowerDensitySpectrum.hpp +++ b/numerical/analysis/PowerDensitySpectrum.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -128,3 +129,7 @@ namespace analysis extern template class PowerSpectralDensity, test::TwiddleFactorsStub, 0>; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/RealFastFourierTransform.hpp b/numerical/analysis/RealFastFourierTransform.hpp index 5b11f3c6..d4d45254 100644 --- a/numerical/analysis/RealFastFourierTransform.hpp +++ b/numerical/analysis/RealFastFourierTransform.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -123,3 +124,7 @@ namespace analysis extern template class RealFastFourierTransform; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/SignalDetectors.hpp b/numerical/analysis/SignalDetectors.hpp index 07cc8610..b2422eec 100644 --- a/numerical/analysis/SignalDetectors.hpp +++ b/numerical/analysis/SignalDetectors.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -134,3 +135,7 @@ namespace analysis extern template class RmsEnvelope; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/TwiddleFactorsTable.hpp b/numerical/analysis/TwiddleFactorsTable.hpp index 0909fcb2..5a76d473 100644 --- a/numerical/analysis/TwiddleFactorsTable.hpp +++ b/numerical/analysis/TwiddleFactorsTable.hpp @@ -5,6 +5,11 @@ #include #include +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options +#pragma GCC optimize("O3", "fast-math") +#endif + namespace analysis { template @@ -37,3 +42,7 @@ namespace analysis extern template class TwiddleFactorsTable; } #endif + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/analysis/windowing/Windowing.hpp b/numerical/analysis/windowing/Windowing.hpp index 092b164d..3e915c11 100644 --- a/numerical/analysis/windowing/Windowing.hpp +++ b/numerical/analysis/windowing/Windowing.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -126,3 +127,7 @@ namespace windowing extern template class RectangularWindow; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/control_analysis/ContinuousToDiscrete.hpp b/numerical/control_analysis/ContinuousToDiscrete.hpp index c46297f5..bfc94833 100644 --- a/numerical/control_analysis/ContinuousToDiscrete.hpp +++ b/numerical/control_analysis/ContinuousToDiscrete.hpp @@ -1,5 +1,6 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif #include "numerical/math/CompilerOptimizations.hpp" @@ -178,3 +179,7 @@ namespace control_analysis extern template class ContinuousToDiscrete; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/control_analysis/ControllabilityObservability.hpp b/numerical/control_analysis/ControllabilityObservability.hpp index 0d55e084..9cc3ba06 100644 --- a/numerical/control_analysis/ControllabilityObservability.hpp +++ b/numerical/control_analysis/ControllabilityObservability.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -242,3 +243,7 @@ namespace control_analysis math::Matrix&, std::size_t, std::size_t, float); #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/control_analysis/FrequencyResponse.hpp b/numerical/control_analysis/FrequencyResponse.hpp index ff16d21d..69bd9e17 100644 --- a/numerical/control_analysis/FrequencyResponse.hpp +++ b/numerical/control_analysis/FrequencyResponse.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -109,3 +110,7 @@ namespace control_analysis extern template class FrequencyResponse; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/control_analysis/RootLocus.hpp b/numerical/control_analysis/RootLocus.hpp index 2ec5f73d..f55f07cc 100644 --- a/numerical/control_analysis/RootLocus.hpp +++ b/numerical/control_analysis/RootLocus.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -139,3 +140,7 @@ namespace control_analysis extern template class RootLocus; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/control_analysis/TransferFunctionStateSpace.hpp b/numerical/control_analysis/TransferFunctionStateSpace.hpp index ee653838..b2c3d6ae 100644 --- a/numerical/control_analysis/TransferFunctionStateSpace.hpp +++ b/numerical/control_analysis/TransferFunctionStateSpace.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -166,3 +167,7 @@ namespace control_analysis extern template class TransferFunctionStateSpace; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/BangBangHysteresis.hpp b/numerical/controllers/implementations/BangBangHysteresis.hpp index ac48b109..0f306b62 100644 --- a/numerical/controllers/implementations/BangBangHysteresis.hpp +++ b/numerical/controllers/implementations/BangBangHysteresis.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -73,3 +74,7 @@ namespace controllers extern template class BangBangHysteresis; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/DeadbeatControl.hpp b/numerical/controllers/implementations/DeadbeatControl.hpp index 9a9680a2..5d312ebb 100644 --- a/numerical/controllers/implementations/DeadbeatControl.hpp +++ b/numerical/controllers/implementations/DeadbeatControl.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -147,3 +148,7 @@ namespace controllers extern template class DeadbeatControl; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/Feedforward2Dof.hpp b/numerical/controllers/implementations/Feedforward2Dof.hpp index a2091251..05ecd276 100644 --- a/numerical/controllers/implementations/Feedforward2Dof.hpp +++ b/numerical/controllers/implementations/Feedforward2Dof.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -77,3 +78,7 @@ namespace controllers extern template class Feedforward2Dof; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/GainScheduledController.hpp b/numerical/controllers/implementations/GainScheduledController.hpp index 49b396b1..0b2b74d3 100644 --- a/numerical/controllers/implementations/GainScheduledController.hpp +++ b/numerical/controllers/implementations/GainScheduledController.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -93,3 +94,7 @@ namespace controllers extern template class GainScheduledController; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/IntegralStateFeedbackLqi.hpp b/numerical/controllers/implementations/IntegralStateFeedbackLqi.hpp index f5397d9a..03a2c66e 100644 --- a/numerical/controllers/implementations/IntegralStateFeedbackLqi.hpp +++ b/numerical/controllers/implementations/IntegralStateFeedbackLqi.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -171,3 +172,7 @@ namespace controllers extern template class IntegralStateFeedbackLqi; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/LeadLagCompensator.hpp b/numerical/controllers/implementations/LeadLagCompensator.hpp index 2c171333..6379cccc 100644 --- a/numerical/controllers/implementations/LeadLagCompensator.hpp +++ b/numerical/controllers/implementations/LeadLagCompensator.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -73,3 +74,7 @@ namespace controllers extern template class LeadLagCompensator; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/Lqg.hpp b/numerical/controllers/implementations/Lqg.hpp index 1453e239..3189e9d8 100644 --- a/numerical/controllers/implementations/Lqg.hpp +++ b/numerical/controllers/implementations/Lqg.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -102,3 +103,7 @@ namespace controllers extern template class Lqg; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/Lqr.hpp b/numerical/controllers/implementations/Lqr.hpp index 2b671386..516f9288 100644 --- a/numerical/controllers/implementations/Lqr.hpp +++ b/numerical/controllers/implementations/Lqr.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -144,3 +145,7 @@ namespace controllers extern template class Lqr; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/LuenbergerObserver.hpp b/numerical/controllers/implementations/LuenbergerObserver.hpp index fde6ccc9..8fdf914a 100644 --- a/numerical/controllers/implementations/LuenbergerObserver.hpp +++ b/numerical/controllers/implementations/LuenbergerObserver.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -142,3 +143,7 @@ namespace controllers extern template class LuenbergerObserver; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/Mpc.hpp b/numerical/controllers/implementations/Mpc.hpp index 2333f59c..0ca8b159 100644 --- a/numerical/controllers/implementations/Mpc.hpp +++ b/numerical/controllers/implementations/Mpc.hpp @@ -8,7 +8,8 @@ #include #include -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -308,3 +309,7 @@ namespace controllers extern template class Mpc; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/PidIncremental.hpp b/numerical/controllers/implementations/PidIncremental.hpp index 3885aba0..23189204 100644 --- a/numerical/controllers/implementations/PidIncremental.hpp +++ b/numerical/controllers/implementations/PidIncremental.hpp @@ -4,7 +4,8 @@ #include "numerical/controllers/interfaces/PidDriver.hpp" #include "numerical/math/CompilerOptimizations.hpp" -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -234,3 +235,7 @@ namespace controllers extern template class PidIncrementalSynchronous; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/SaturationRateLimiter.hpp b/numerical/controllers/implementations/SaturationRateLimiter.hpp index 5f2f0d4c..bf24b81b 100644 --- a/numerical/controllers/implementations/SaturationRateLimiter.hpp +++ b/numerical/controllers/implementations/SaturationRateLimiter.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -100,3 +101,7 @@ namespace controllers extern template class SlewLimitedSaturation; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/controllers/implementations/test/TestDeadbeatControl.cpp b/numerical/controllers/implementations/test/TestDeadbeatControl.cpp index 48f736b4..38063c07 100644 --- a/numerical/controllers/implementations/test/TestDeadbeatControl.cpp +++ b/numerical/controllers/implementations/test/TestDeadbeatControl.cpp @@ -1,7 +1,3 @@ -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/controllers/implementations/DeadbeatControl.hpp" #include "numerical/math/LinearTimeInvariant.hpp" #include "numerical/math/Tolerance.hpp" diff --git a/numerical/controllers/implementations/test/TestIntegralStateFeedbackLqi.cpp b/numerical/controllers/implementations/test/TestIntegralStateFeedbackLqi.cpp index f46a08e2..fe6a367c 100644 --- a/numerical/controllers/implementations/test/TestIntegralStateFeedbackLqi.cpp +++ b/numerical/controllers/implementations/test/TestIntegralStateFeedbackLqi.cpp @@ -1,7 +1,3 @@ -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/controllers/implementations/IntegralStateFeedbackLqi.hpp" #include "numerical/math/LinearTimeInvariant.hpp" #include "numerical/math/Tolerance.hpp" diff --git a/numerical/controllers/implementations/test/TestLqg.cpp b/numerical/controllers/implementations/test/TestLqg.cpp index ae8e7c2f..ef3d6a42 100644 --- a/numerical/controllers/implementations/test/TestLqg.cpp +++ b/numerical/controllers/implementations/test/TestLqg.cpp @@ -1,7 +1,3 @@ -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/controllers/implementations/Lqg.hpp" #include "numerical/math/Tolerance.hpp" #include diff --git a/numerical/controllers/implementations/test/TestStateFeedbackController.cpp b/numerical/controllers/implementations/test/TestStateFeedbackController.cpp index 9386a124..b324c8e0 100644 --- a/numerical/controllers/implementations/test/TestStateFeedbackController.cpp +++ b/numerical/controllers/implementations/test/TestStateFeedbackController.cpp @@ -1,7 +1,3 @@ -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC optimize("O3", "fast-math") -#endif - #include "numerical/controllers/implementations/Lqr.hpp" #include "numerical/controllers/implementations/Mpc.hpp" #include "numerical/controllers/interfaces/StateFeedbackController.hpp" diff --git a/numerical/estimators/offline/ExpectationMaximization.hpp b/numerical/estimators/offline/ExpectationMaximization.hpp index 323949ff..bb0c89aa 100644 --- a/numerical/estimators/offline/ExpectationMaximization.hpp +++ b/numerical/estimators/offline/ExpectationMaximization.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -226,3 +227,7 @@ namespace estimators extern template class ExpectationMaximization<4, 2, 20>; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/estimators/offline/LinearRegression.hpp b/numerical/estimators/offline/LinearRegression.hpp index 550719ec..d624a34d 100644 --- a/numerical/estimators/offline/LinearRegression.hpp +++ b/numerical/estimators/offline/LinearRegression.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -76,3 +77,7 @@ namespace estimators extern template class LinearRegression; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/estimators/offline/PolynomialFitting.hpp b/numerical/estimators/offline/PolynomialFitting.hpp index 93f5d5c2..d9f630fd 100644 --- a/numerical/estimators/offline/PolynomialFitting.hpp +++ b/numerical/estimators/offline/PolynomialFitting.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -72,3 +73,7 @@ namespace estimators extern template class PolynomialFitting; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/estimators/offline/TotalLeastSquares.hpp b/numerical/estimators/offline/TotalLeastSquares.hpp index 24c12683..655d42e0 100644 --- a/numerical/estimators/offline/TotalLeastSquares.hpp +++ b/numerical/estimators/offline/TotalLeastSquares.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -83,3 +84,7 @@ namespace estimators extern template class TotalLeastSquares; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/estimators/offline/YuleWalker.hpp b/numerical/estimators/offline/YuleWalker.hpp index 490f576d..7fe8411b 100644 --- a/numerical/estimators/offline/YuleWalker.hpp +++ b/numerical/estimators/offline/YuleWalker.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -124,3 +125,7 @@ namespace estimators extern template class YuleWalker; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/estimators/online/LmsAdaptiveFilter.hpp b/numerical/estimators/online/LmsAdaptiveFilter.hpp index 6ab8398b..49bffdc0 100644 --- a/numerical/estimators/online/LmsAdaptiveFilter.hpp +++ b/numerical/estimators/online/LmsAdaptiveFilter.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -120,3 +121,7 @@ namespace estimators extern template class LmsAdaptiveFilter; } #endif + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/estimators/online/RecursiveLeastSquares.hpp b/numerical/estimators/online/RecursiveLeastSquares.hpp index c42a1ab0..1e8a38cc 100644 --- a/numerical/estimators/online/RecursiveLeastSquares.hpp +++ b/numerical/estimators/online/RecursiveLeastSquares.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -146,3 +147,7 @@ namespace estimators extern template class RecursiveLeastSquares; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/active/AhrsMadgwickMahony.hpp b/numerical/filters/active/AhrsMadgwickMahony.hpp index 7f1091e0..bffa68df 100644 --- a/numerical/filters/active/AhrsMadgwickMahony.hpp +++ b/numerical/filters/active/AhrsMadgwickMahony.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -299,3 +300,7 @@ namespace filters extern template class AhrsFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/active/AlphaBetaFilter.hpp b/numerical/filters/active/AlphaBetaFilter.hpp index 4f5a17b4..7b1de441 100644 --- a/numerical/filters/active/AlphaBetaFilter.hpp +++ b/numerical/filters/active/AlphaBetaFilter.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -152,3 +153,7 @@ namespace filters extern template class AlphaBetaFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/active/ComplementaryFilter.hpp b/numerical/filters/active/ComplementaryFilter.hpp index 108c584e..a45fdcca 100644 --- a/numerical/filters/active/ComplementaryFilter.hpp +++ b/numerical/filters/active/ComplementaryFilter.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -107,3 +108,7 @@ namespace filters extern template class ComplementaryFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/active/ExtendedKalmanFilter.hpp b/numerical/filters/active/ExtendedKalmanFilter.hpp index 1c97122d..5698a204 100644 --- a/numerical/filters/active/ExtendedKalmanFilter.hpp +++ b/numerical/filters/active/ExtendedKalmanFilter.hpp @@ -5,7 +5,8 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/MatrixOperations.hpp" -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -125,3 +126,7 @@ namespace filters extern template class ExtendedKalmanFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/active/KalmanFilter.hpp b/numerical/filters/active/KalmanFilter.hpp index 5c5d1d02..bf1e45a2 100644 --- a/numerical/filters/active/KalmanFilter.hpp +++ b/numerical/filters/active/KalmanFilter.hpp @@ -5,7 +5,8 @@ #include "numerical/math/LinearTimeInvariant.hpp" #include "numerical/math/MatrixOperations.hpp" -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -135,3 +136,7 @@ namespace filters extern template class KalmanFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/active/KalmanFilterBase.hpp b/numerical/filters/active/KalmanFilterBase.hpp index f0636fb5..1b2db1db 100644 --- a/numerical/filters/active/KalmanFilterBase.hpp +++ b/numerical/filters/active/KalmanFilterBase.hpp @@ -5,7 +5,8 @@ #include "numerical/math/MatrixOperations.hpp" #include "numerical/solvers/GaussianElimination.hpp" -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -175,3 +176,7 @@ namespace filters extern template class KalmanFilterBase; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/active/KalmanSmoother.hpp b/numerical/filters/active/KalmanSmoother.hpp index 3d20e1cd..416513c1 100644 --- a/numerical/filters/active/KalmanSmoother.hpp +++ b/numerical/filters/active/KalmanSmoother.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -248,3 +249,7 @@ namespace filters extern template class KalmanSmoother<4, 2, 20>; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/active/SquareRootKalmanFilter.hpp b/numerical/filters/active/SquareRootKalmanFilter.hpp index d7a44425..a1c7ae18 100644 --- a/numerical/filters/active/SquareRootKalmanFilter.hpp +++ b/numerical/filters/active/SquareRootKalmanFilter.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -223,3 +224,7 @@ namespace filters extern template class SquareRootKalmanFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/active/UnscentedKalmanFilter.hpp b/numerical/filters/active/UnscentedKalmanFilter.hpp index f641eb1b..71a87b5f 100644 --- a/numerical/filters/active/UnscentedKalmanFilter.hpp +++ b/numerical/filters/active/UnscentedKalmanFilter.hpp @@ -10,7 +10,8 @@ #include #include -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -283,3 +284,7 @@ namespace filters extern template class UnscentedKalmanFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/BiquadCascade.hpp b/numerical/filters/passive/BiquadCascade.hpp index 82febac2..0b0c4993 100644 --- a/numerical/filters/passive/BiquadCascade.hpp +++ b/numerical/filters/passive/BiquadCascade.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -203,3 +204,7 @@ namespace filters::passive extern template class BiquadCascade; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/CicFilter.hpp b/numerical/filters/passive/CicFilter.hpp index 9ebcf7b6..c456a57b 100644 --- a/numerical/filters/passive/CicFilter.hpp +++ b/numerical/filters/passive/CicFilter.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -120,3 +121,7 @@ namespace filters::passive extern template class CicDecimator; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/ExponentialMovingAverage.hpp b/numerical/filters/passive/ExponentialMovingAverage.hpp index 7a6526a8..a167dd94 100644 --- a/numerical/filters/passive/ExponentialMovingAverage.hpp +++ b/numerical/filters/passive/ExponentialMovingAverage.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -72,3 +73,7 @@ namespace filters::passive extern template class ExponentialMovingAverage; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/Fir.hpp b/numerical/filters/passive/Fir.hpp index d1e2a55c..7dfbeaf7 100644 --- a/numerical/filters/passive/Fir.hpp +++ b/numerical/filters/passive/Fir.hpp @@ -3,7 +3,8 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/RecursiveBuffer.hpp" -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -59,3 +60,7 @@ namespace filters::passive extern template class Fir; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/Iir.hpp b/numerical/filters/passive/Iir.hpp index f873178b..700f0125 100644 --- a/numerical/filters/passive/Iir.hpp +++ b/numerical/filters/passive/Iir.hpp @@ -3,7 +3,8 @@ #include "numerical/math/CompilerOptimizations.hpp" #include "numerical/math/RecursiveBuffer.hpp" -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -70,3 +71,7 @@ namespace filters::passive extern template class Iir; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/IirFilterDesign.hpp b/numerical/filters/passive/IirFilterDesign.hpp index c0a7f151..9cb59047 100644 --- a/numerical/filters/passive/IirFilterDesign.hpp +++ b/numerical/filters/passive/IirFilterDesign.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -511,3 +512,7 @@ namespace filters::passive extern template class IirFilterDesign; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/MedianFilter.hpp b/numerical/filters/passive/MedianFilter.hpp index dc7e6ec5..cc4c51b7 100644 --- a/numerical/filters/passive/MedianFilter.hpp +++ b/numerical/filters/passive/MedianFilter.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -72,3 +73,7 @@ namespace filters::passive extern template class MedianFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/MovingAverage.hpp b/numerical/filters/passive/MovingAverage.hpp index 2759a096..437b16e2 100644 --- a/numerical/filters/passive/MovingAverage.hpp +++ b/numerical/filters/passive/MovingAverage.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -64,3 +65,7 @@ namespace filters::passive extern template class MovingAverage; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/NotchCombFilter.hpp b/numerical/filters/passive/NotchCombFilter.hpp index 095a6d4f..f1cec4eb 100644 --- a/numerical/filters/passive/NotchCombFilter.hpp +++ b/numerical/filters/passive/NotchCombFilter.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -126,3 +127,7 @@ namespace filters::passive extern template class CombFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/filters/passive/SavitzkyGolayFilter.hpp b/numerical/filters/passive/SavitzkyGolayFilter.hpp index 16c5b05e..68ca7306 100644 --- a/numerical/filters/passive/SavitzkyGolayFilter.hpp +++ b/numerical/filters/passive/SavitzkyGolayFilter.hpp @@ -1,7 +1,8 @@ // Copyright 2024 Numerical Toolbox Contributors. All rights reserved. #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -127,3 +128,7 @@ namespace filters::passive extern template class SavitzkyGolayFilter; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/CholeskyDecomposition.hpp b/numerical/math/CholeskyDecomposition.hpp index 5322ac4a..4424f4d3 100644 --- a/numerical/math/CholeskyDecomposition.hpp +++ b/numerical/math/CholeskyDecomposition.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -117,3 +118,7 @@ namespace math extern template class CholeskyDecomposition; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/ComplexNumber.hpp b/numerical/math/ComplexNumber.hpp index 2638b537..3a22cab6 100644 --- a/numerical/math/ComplexNumber.hpp +++ b/numerical/math/ComplexNumber.hpp @@ -3,6 +3,11 @@ #include "numerical/math/QNumber.hpp" #include +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options +#pragma GCC optimize("O3", "fast-math") +#endif + namespace math { template @@ -135,3 +140,7 @@ namespace math extern template class Complex; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/ConsistencyMetrics.hpp b/numerical/math/ConsistencyMetrics.hpp index 5f598127..06c369d7 100644 --- a/numerical/math/ConsistencyMetrics.hpp +++ b/numerical/math/ConsistencyMetrics.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -107,3 +108,7 @@ namespace math extern template class ConsistencyMetrics; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/Cordic.hpp b/numerical/math/Cordic.hpp index 1307ff14..86b08735 100644 --- a/numerical/math/Cordic.hpp +++ b/numerical/math/Cordic.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -182,3 +183,7 @@ namespace math extern template class Cordic; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/Geometry3D.hpp b/numerical/math/Geometry3D.hpp index f1083c83..a02be99a 100644 --- a/numerical/math/Geometry3D.hpp +++ b/numerical/math/Geometry3D.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -89,3 +90,7 @@ namespace math return math::Sqrt(DotProduct(v, v)); } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/GivensRotation.hpp b/numerical/math/GivensRotation.hpp index 4f91abea..114f6985 100644 --- a/numerical/math/GivensRotation.hpp +++ b/numerical/math/GivensRotation.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -53,3 +54,7 @@ namespace math y = newY; } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/HouseholderTransform.hpp b/numerical/math/HouseholderTransform.hpp index cd3494cd..e9b906c1 100644 --- a/numerical/math/HouseholderTransform.hpp +++ b/numerical/math/HouseholderTransform.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -81,3 +82,7 @@ namespace math } } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/LinearTimeInvariant.hpp b/numerical/math/LinearTimeInvariant.hpp index 7c5d76c3..c89a325e 100644 --- a/numerical/math/LinearTimeInvariant.hpp +++ b/numerical/math/LinearTimeInvariant.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -69,3 +70,7 @@ namespace math }; } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/Math.hpp b/numerical/math/Math.hpp index 30135049..89628483 100644 --- a/numerical/math/Math.hpp +++ b/numerical/math/Math.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -330,3 +331,7 @@ namespace math #endif #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/Matrix.hpp b/numerical/math/Matrix.hpp index 4eb95101..f0b0bf15 100644 --- a/numerical/math/Matrix.hpp +++ b/numerical/math/Matrix.hpp @@ -5,7 +5,8 @@ #include #include -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -367,3 +368,7 @@ namespace math extern template class Matrix; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/MatrixExponential.hpp b/numerical/math/MatrixExponential.hpp index a9aa1086..ae68792f 100644 --- a/numerical/math/MatrixExponential.hpp +++ b/numerical/math/MatrixExponential.hpp @@ -1,5 +1,6 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif #include "numerical/math/CompilerOptimizations.hpp" @@ -186,3 +187,7 @@ namespace math extern template class MatrixExponential; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/MatrixNorms.hpp b/numerical/math/MatrixNorms.hpp index b26ecfcd..738a9478 100644 --- a/numerical/math/MatrixNorms.hpp +++ b/numerical/math/MatrixNorms.hpp @@ -1,5 +1,6 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif #include "numerical/math/CompilerOptimizations.hpp" @@ -95,3 +96,7 @@ namespace math return result; } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/MatrixOperations.hpp b/numerical/math/MatrixOperations.hpp index d3c0d148..a38d185e 100644 --- a/numerical/math/MatrixOperations.hpp +++ b/numerical/math/MatrixOperations.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -25,3 +26,7 @@ namespace math return a * m * a.Transpose(); } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/QNumber.hpp b/numerical/math/QNumber.hpp index e0106bad..a94f5f30 100644 --- a/numerical/math/QNumber.hpp +++ b/numerical/math/QNumber.hpp @@ -7,7 +7,8 @@ #include #include -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -265,3 +266,7 @@ namespace math extern template class QNumber; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/Quaternion.hpp b/numerical/math/Quaternion.hpp index c9dedda8..d6e03f70 100644 --- a/numerical/math/Quaternion.hpp +++ b/numerical/math/Quaternion.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -291,3 +292,7 @@ namespace math extern template class Quaternion; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/RecursiveBuffer.hpp b/numerical/math/RecursiveBuffer.hpp index 179ada36..c602884b 100644 --- a/numerical/math/RecursiveBuffer.hpp +++ b/numerical/math/RecursiveBuffer.hpp @@ -4,7 +4,8 @@ #include #include -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -101,3 +102,7 @@ namespace math extern template class RecursiveBuffer; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/StepResponseMetrics.hpp b/numerical/math/StepResponseMetrics.hpp index 0de1df29..ee404210 100644 --- a/numerical/math/StepResponseMetrics.hpp +++ b/numerical/math/StepResponseMetrics.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -114,3 +115,7 @@ namespace math return reference - tailMean; } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/Toeplitz.hpp b/numerical/math/Toeplitz.hpp index 3a04d57a..a6d304f5 100644 --- a/numerical/math/Toeplitz.hpp +++ b/numerical/math/Toeplitz.hpp @@ -4,7 +4,8 @@ #include "numerical/math/Math.hpp" #include "numerical/math/Matrix.hpp" -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -168,3 +169,7 @@ namespace math extern template class ToeplitzMatrix; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/Tolerance.hpp b/numerical/math/Tolerance.hpp index a2c04174..d0d71684 100644 --- a/numerical/math/Tolerance.hpp +++ b/numerical/math/Tolerance.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -12,3 +13,7 @@ namespace math return 1e-3f; } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/TriangularSolve.hpp b/numerical/math/TriangularSolve.hpp index 230a908a..f2a3461e 100644 --- a/numerical/math/TriangularSolve.hpp +++ b/numerical/math/TriangularSolve.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -84,3 +85,7 @@ namespace math return x; } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/math/platform/MathArm.hpp b/numerical/math/platform/MathArm.hpp index 4c0886b9..195436a7 100644 --- a/numerical/math/platform/MathArm.hpp +++ b/numerical/math/platform/MathArm.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -756,3 +757,7 @@ namespace math #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/nonlinear_control/BacksteppingControl.hpp b/numerical/nonlinear_control/BacksteppingControl.hpp index 9f53f952..65dc0abd 100644 --- a/numerical/nonlinear_control/BacksteppingControl.hpp +++ b/numerical/nonlinear_control/BacksteppingControl.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -105,3 +106,7 @@ namespace nonlinear_control extern template class BacksteppingControl; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/nonlinear_control/FeedbackLinearization.hpp b/numerical/nonlinear_control/FeedbackLinearization.hpp index 910b17a6..20028745 100644 --- a/numerical/nonlinear_control/FeedbackLinearization.hpp +++ b/numerical/nonlinear_control/FeedbackLinearization.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -74,3 +75,7 @@ namespace nonlinear_control extern template class FeedbackLinearization; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/nonlinear_control/ModelReferenceAdaptiveControl.hpp b/numerical/nonlinear_control/ModelReferenceAdaptiveControl.hpp index 296cd8a0..c39a2673 100644 --- a/numerical/nonlinear_control/ModelReferenceAdaptiveControl.hpp +++ b/numerical/nonlinear_control/ModelReferenceAdaptiveControl.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -126,3 +127,7 @@ namespace nonlinear_control extern template class ModelReferenceAdaptiveControl; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/optimization/BayesianOptimization.hpp b/numerical/optimization/BayesianOptimization.hpp index be00529f..b1b5cd30 100644 --- a/numerical/optimization/BayesianOptimization.hpp +++ b/numerical/optimization/BayesianOptimization.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -313,3 +314,7 @@ namespace optimization extern template class BayesianOptimization<2, 20, 100>; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/optimization/GradientDescent.hpp b/numerical/optimization/GradientDescent.hpp index 243ef9c4..75c32d0d 100644 --- a/numerical/optimization/GradientDescent.hpp +++ b/numerical/optimization/GradientDescent.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -73,3 +74,7 @@ namespace optimization extern template class GradientDescent; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/regularization/L1.hpp b/numerical/regularization/L1.hpp index 157eb53d..3e6c350a 100644 --- a/numerical/regularization/L1.hpp +++ b/numerical/regularization/L1.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -64,3 +65,7 @@ namespace regularization extern template class L1; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/regularization/L2.hpp b/numerical/regularization/L2.hpp index 579e7775..8a363fa4 100644 --- a/numerical/regularization/L2.hpp +++ b/numerical/regularization/L2.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -57,3 +58,7 @@ namespace regularization extern template class L2; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/robust_control/ActiveDisturbanceRejection.hpp b/numerical/robust_control/ActiveDisturbanceRejection.hpp index 6bce2377..a2ba72b3 100644 --- a/numerical/robust_control/ActiveDisturbanceRejection.hpp +++ b/numerical/robust_control/ActiveDisturbanceRejection.hpp @@ -3,7 +3,8 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -158,3 +159,7 @@ namespace robust_control extern template class ActiveDisturbanceRejectionControl; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/robust_control/DisturbanceObserver.hpp b/numerical/robust_control/DisturbanceObserver.hpp index c30eaf44..c122907b 100644 --- a/numerical/robust_control/DisturbanceObserver.hpp +++ b/numerical/robust_control/DisturbanceObserver.hpp @@ -1,7 +1,8 @@ // Copyright (c) 2024, Numerical Toolbox Contributors. All rights reserved. #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -162,3 +163,7 @@ namespace robust_control extern template class DisturbanceObserver; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/robust_control/HInfinityStateFeedback.hpp b/numerical/robust_control/HInfinityStateFeedback.hpp index 6bc2bce4..cc5ba3d1 100644 --- a/numerical/robust_control/HInfinityStateFeedback.hpp +++ b/numerical/robust_control/HInfinityStateFeedback.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -277,3 +278,7 @@ namespace robust_control extern template class HInfinityStateFeedback; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/robust_control/SlidingModeControl.hpp b/numerical/robust_control/SlidingModeControl.hpp index 9c03cf0c..35148388 100644 --- a/numerical/robust_control/SlidingModeControl.hpp +++ b/numerical/robust_control/SlidingModeControl.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -127,3 +128,7 @@ namespace robust_control extern template class SlidingModeControl; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/ConditionNumber.hpp b/numerical/solvers/ConditionNumber.hpp index 103be878..d6f057d8 100644 --- a/numerical/solvers/ConditionNumber.hpp +++ b/numerical/solvers/ConditionNumber.hpp @@ -1,5 +1,6 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif #include "numerical/math/CompilerOptimizations.hpp" @@ -36,3 +37,7 @@ namespace solvers return normA * normInv; } } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/DiscreteAlgebraicRiccatiEquation.hpp b/numerical/solvers/DiscreteAlgebraicRiccatiEquation.hpp index f356aa42..895834bb 100644 --- a/numerical/solvers/DiscreteAlgebraicRiccatiEquation.hpp +++ b/numerical/solvers/DiscreteAlgebraicRiccatiEquation.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -123,3 +124,7 @@ namespace solvers extern template class DiscreteAlgebraicRiccatiEquation; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/DormandPrince45.hpp b/numerical/solvers/DormandPrince45.hpp index 265bcb7f..96a8361e 100644 --- a/numerical/solvers/DormandPrince45.hpp +++ b/numerical/solvers/DormandPrince45.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -253,3 +254,7 @@ namespace solvers extern template class DormandPrince45; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/DurandKerner.hpp b/numerical/solvers/DurandKerner.hpp index 0befef76..2402f454 100644 --- a/numerical/solvers/DurandKerner.hpp +++ b/numerical/solvers/DurandKerner.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -172,3 +173,7 @@ namespace solvers extern template class DurandKerner; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/GaussianElimination.hpp b/numerical/solvers/GaussianElimination.hpp index 136c41f2..71c9e5a0 100644 --- a/numerical/solvers/GaussianElimination.hpp +++ b/numerical/solvers/GaussianElimination.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -184,3 +185,7 @@ namespace solvers extern template class GaussianElimination; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/JacobiEigenSolver.hpp b/numerical/solvers/JacobiEigenSolver.hpp index 09605220..0cf89d5b 100644 --- a/numerical/solvers/JacobiEigenSolver.hpp +++ b/numerical/solvers/JacobiEigenSolver.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -168,3 +169,7 @@ namespace solvers extern template class JacobiEigenSolver; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/LevinsonDurbin.hpp b/numerical/solvers/LevinsonDurbin.hpp index d9137ca1..c1cc0ee9 100644 --- a/numerical/solvers/LevinsonDurbin.hpp +++ b/numerical/solvers/LevinsonDurbin.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -105,3 +106,7 @@ namespace solvers extern template class LevinsonDurbin; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/LuDecomposition.hpp b/numerical/solvers/LuDecomposition.hpp index b9cb8994..b8a3bfce 100644 --- a/numerical/solvers/LuDecomposition.hpp +++ b/numerical/solvers/LuDecomposition.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -175,3 +176,7 @@ namespace solvers extern template class LuDecomposition; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/LyapunovSylvester.hpp b/numerical/solvers/LyapunovSylvester.hpp index 5f2cdeed..94ce15ce 100644 --- a/numerical/solvers/LyapunovSylvester.hpp +++ b/numerical/solvers/LyapunovSylvester.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -146,3 +147,7 @@ namespace solvers extern template class SylvesterSolver; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/QrDecomposition.hpp b/numerical/solvers/QrDecomposition.hpp index 24ed8a85..1215913e 100644 --- a/numerical/solvers/QrDecomposition.hpp +++ b/numerical/solvers/QrDecomposition.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -172,3 +173,7 @@ namespace solvers extern template class QrDecomposition; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/RungeKuttaIntegrators.hpp b/numerical/solvers/RungeKuttaIntegrators.hpp index a8249c23..a1b6fb73 100644 --- a/numerical/solvers/RungeKuttaIntegrators.hpp +++ b/numerical/solvers/RungeKuttaIntegrators.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -89,3 +90,7 @@ namespace solvers extern template class RungeKutta4; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/SingularValueDecomposition.hpp b/numerical/solvers/SingularValueDecomposition.hpp index bc78799b..50a5debc 100644 --- a/numerical/solvers/SingularValueDecomposition.hpp +++ b/numerical/solvers/SingularValueDecomposition.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -532,3 +533,7 @@ namespace solvers extern template class SingularValueDecomposition; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/numerical/solvers/SpectralRadius.hpp b/numerical/solvers/SpectralRadius.hpp index 11599ce4..3755bc36 100644 --- a/numerical/solvers/SpectralRadius.hpp +++ b/numerical/solvers/SpectralRadius.hpp @@ -1,6 +1,7 @@ #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif @@ -97,3 +98,7 @@ namespace solvers extern template class SpectralRadius; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif diff --git a/roadmap/DEPLOYMENT.md b/roadmap/DEPLOYMENT.md index 01bfb5ef..6933ebbe 100644 --- a/roadmap/DEPLOYMENT.md +++ b/roadmap/DEPLOYMENT.md @@ -4,8 +4,8 @@ Turn one `roadmap///` spec into shipped code. Rules: `../AGENTS.md Read the spec's three files first (`implementation.md`, `tests.md`, `explanation.md`), then: 1. **Header** `numerical//.hpp` - - `#pragma once` → `#pragma GCC optimize("O3","fast-math")` (GCC/Clang guard) → - `#include "numerical/math/CompilerOptimizations.hpp"`. + - `#pragma once` → `#pragma GCC push_options` + `#pragma GCC optimize("O3","fast-math")` (GCC-only guard) → + `#include "numerical/math/CompilerOptimizations.hpp"`; end the file with `#pragma GCC pop_options`. - `template` with `static_assert(std::is_floating_point_v, " supports floating-point types");`. - Implement per `implementation.md`; `OPTIMIZE_FOR_SPEED` on the hot path(s). diff --git a/roadmap/README.md b/roadmap/README.md index 77dad4a5..65f94079 100644 --- a/roadmap/README.md +++ b/roadmap/README.md @@ -37,7 +37,8 @@ Header shape (mirroring existing components such as `Fir.hpp`): ```cpp #pragma once -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC push_options #pragma GCC optimize("O3", "fast-math") #endif #include "numerical/math/CompilerOptimizations.hpp" @@ -56,6 +57,10 @@ namespace extern template class ; #endif } + +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC pop_options +#endif ``` Coverage `.cpp`: