Repository navigation
perf(math): build matrix results without zero-filling them first - #349
Merged
Merged
Conversation
Contributor
✅
|
| Descriptor | Linter | Files | Fixed | Errors | Max errors | Warnings | Elapsed time |
|---|---|---|---|---|---|---|---|
| ✅ ACTION | actionlint | 7 | 0 | 0 | 0.53s | ||
| ✅ CPP | clang-format | 430 | 11 | 0 | 0 | 5.05s | |
| ✅ CPP | cppcheck | 430 | 0 | 0 | 9.3s | ||
| ✅ DOCKERFILE | hadolint | 1 | 0 | 0 | 0.75s | ||
| ✅ JSON | jsonlint | 8 | 0 | 0 | 0.13s | ||
| ✅ JSON | prettier | 8 | 8 | 0 | 0 | 0.47s | |
| markdownlint | 132 | 3 | 178 | 0 | 4.02s | ||
| ✅ MARKDOWN | markdown-table-formatter | 132 | 24 | 0 | 0 | 0.35s | |
| lychee | 241 | 23 | 0 | 23.35s | |||
| ✅ YAML | prettier | 12 | 3 | 0 | 0 | 0.67s | |
| ✅ YAML | yamllint | 12 | 0 | 0 | 0.63s |
Detailed Issues
⚠️ SPELL / lychee - 23 errors
📝 Summary
---------------------
🔍 Total..........567
🔗 Unique.........436
✅ Successful.....532
⏳ Timeouts.........0
🔀 Redirected.....152
👻 Excluded........11
❓ Unknown..........0
🚫 Errors..........23
⛔ Unsupported.....23
Errors in .github/workflows/static-analysis.yml
[403] https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$ (at 37:21) | Rejected status code: 403 Forbidden
Errors in CHANGELOG.md
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/12 (at 221:8) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/13 (at 220:7) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/15 (at 215:18) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/2 (at 213:34) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/24 (at 210:19) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/27 (at 208:23) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/3 (at 204:35) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/4 (at 214:34) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/6 (at 212:53) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/7 (at 209:32) | Rejected status code: 404 Not Found
[404] https://github.com/embedded-pro/embedded-numerical-toolbox/issues/9 (at 207:15) | Rejected status code: 404 Not Found
Errors in doc/filters/active/AhrsMadgwickMahony.md
[ERROR] file://doc/filters/ComplementaryFilter.md (at 131:3) | File not found. Check if file exists and path is correct
Errors in doc/filters/active/ExtendedKalmanFilter.md
[ERROR] file://doc/dynamics/EulerLagrange.md (at 130:3) | File not found. Check if file exists and path is correct
Errors in doc/filters/active/KalmanFilter.md
[ERROR] file://doc/filters/controllers/Lqr.md (at 114:77) | File not found. Check if file exists and path is correct
[ERROR] file://doc/filters/controllers/Lqr.md (at 133:3) | File not found. Check if file exists and path is correct
[ERROR] file://doc/filters/controllers/Pid.md (at 135:3) | File not found. Check if file exists and path is correct
[ERROR] file://doc/filters/solvers/DiscreteAlgebraicRiccatiEquation.md (at 134:3) | File not found. Check if file exists and path is correct
Errors in doc/performance-optimization/README.md
[403] https://developer.arm.com/documentation/100166/latest/ (at 472:3) | Rejected status code: 403 Forbidden
[403] https://developer.arm.com/documentation/dui0473/latest (at 474:3) | Rejected status code: 403 Forbidden
Errors in README.md
[ERROR] file:///releases/latest (at 38:14) | File not found. Check if file exists and path is correct
[404] https://embedded-pro.github.io/embedded-dsp-control/ (at 37:1) | Rejected status code: 404 Not Found
Errors in roadmap/README.md
[ERROR] file://roadmap/filters/passive/ExponentialMovingAverage/implementation.md (at 24:1) | File not found. Check if file exists and path is correct
Hint: Followed 152 redirects. You might want to consider replacing redirecting URLs with the resolved URLs. Use verbose mode (`-v`/`-vv`) to see redirection details.
Hint: You can configure accepted/rejected response codes with `-a` or `--accept`
⚠️ MARKDOWN / markdownlint - 178 errors
rithm.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 492]
doc/analysis/GoertzelAlgorithm.md:107:401 error MD013/line-length Line length [Expected: 400; Actual: 451]
doc/analysis/HilbertTransform.md:31:34 error MD056/table-column-count Table column count [Expected: 2; Actual: 4; Too many cells, extra data will be missing]
doc/analysis/PowerDensitySpectrum.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 509]
doc/analysis/PowerDensitySpectrum.md:104:20 error MD056/table-column-count Table column count [Expected: 2; Actual: 6; Too many cells, extra data will be missing]
doc/analysis/PowerDensitySpectrum.md:104:17 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/analysis/PowerDensitySpectrum.md:104:20 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/analysis/PowerDensitySpectrum.md:104:32 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/analysis/PowerDensitySpectrum.md:104:38 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/analysis/PowerDensitySpectrum.md:104:45 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/analysis/PowerDensitySpectrum.md:104:135 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/analysis/SignalDetectors.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 481]
doc/control_analysis/FrequencyResponse.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 469]
doc/control_analysis/README.md:11:68 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/control_analysis/README.md:11:147 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/control_analysis/README.md:12:53 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/control_analysis/README.md:12:172 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/control_analysis/README.md:13:68 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/control_analysis/README.md:13:151 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/control_analysis/RootLocus.md:69 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
doc/control_analysis/TransferFunctionStateSpace.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 589]
doc/controllers/Feedforward2Dof.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 627]
doc/controllers/GainScheduledController.md:7:401 error MD013/line-length Line length [Expected: 400; Actual: 454]
doc/controllers/LeadLagCompensator.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 639]
doc/controllers/Lqg.md:7:401 error MD013/line-length Line length [Expected: 400; Actual: 428]
doc/controllers/SaturationRateLimiter.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 451]
doc/controllers/SaturationRateLimiter.md:7:401 error MD013/line-length Line length [Expected: 400; Actual: 477]
doc/estimators/ExpectationMaximization.md:104:103 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/estimators/LmsAdaptiveFilter.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 547]
doc/estimators/README.md:11:122 error MD056/table-column-count Table column count [Expected: 2; Actual: 3; Too many cells, extra data will be missing]
doc/estimators/README.md:11:122 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/AhrsMadgwickMahony.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 538]
doc/filters/active/AhrsMadgwickMahony.md:7:401 error MD013/line-length Line length [Expected: 400; Actual: 554]
doc/filters/active/AlphaBetaFilter.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 419]
doc/filters/active/AlphaBetaFilter.md:7:401 error MD013/line-length Line length [Expected: 400; Actual: 451]
doc/filters/active/KalmanSmoother.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 421]
doc/filters/active/KalmanSmoother.md:111:28 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:111:61 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:111:110 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:122:19 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:122:27 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:122:67 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:123:19 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:123:27 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:123:67 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:124:19 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:124:27 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:124:67 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:125:19 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:125:27 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/KalmanSmoother.md:125:67 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/UnscentedKalmanFilter.md:11:401 error MD013/line-length Line length [Expected: 400; Actual: 468]
doc/filters/active/UnscentedKalmanFilter.md:149:65 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/active/UnscentedKalmanFilter.md:149:153 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/passive/MedianFilter.md:69:25 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/passive/MedianFilter.md:69:43 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/passive/MedianFilter.md:70:51 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/passive/MedianFilter.md:70:96 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:13:74 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:13:179 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:14:74 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:14:179 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:15:74 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:15:179 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:16:74 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:16:179 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:17:74 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/filters/README.md:17:179 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/GivensRotation.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 429]
doc/math/HouseholderTransform.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 455]
doc/math/MatrixExponential.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 555]
doc/math/MatrixNorms.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 452]
doc/math/MatrixNorms.md:42:67 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/MatrixNorms.md:43:67 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/MatrixNorms.md:44:67 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/MatrixNorms.md:45:67 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/MatrixNorms.md:46:67 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:9:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:9:151 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:10:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:10:151 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:11:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:11:151 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:12:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:12:151 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:13:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:13:151 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:14:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:14:159 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:15:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:15:153 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:16:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:16:152 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:17:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:17:172 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:18:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:18:171 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:19:55 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/README.md:19:174 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/math/StepResponseMetrics.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 514]
doc/math/StepResponseMetrics.md:61 error MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
doc/nonlinear_control/BacksteppingControl.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 594]
doc/nonlinear_control/FeedbackLinearization.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 533]
doc/nonlinear_control/FeedbackLinearization.md:15:401 error MD013/line-length Line length [Expected: 400; Actual: 491]
doc/nonlinear_control/ModelReferenceAdaptiveControl.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 587]
doc/nonlinear_control/README.md:9:80 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/nonlinear_control/README.md:9:258 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/nonlinear_control/README.md:10:80 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/nonlinear_control/README.md:10:258 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/nonlinear_control/README.md:11:80 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/nonlinear_control/README.md:11:270 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/regularization/Regularization.md:100:32 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/regularization/Regularization.md:100:135 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/robust_control/ActiveDisturbanceRejection.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 699]
doc/robust_control/ActiveDisturbanceRejection.md:85:401 error MD013/line-length Line length [Expected: 400; Actual: 575]
doc/robust_control/ActiveDisturbanceRejection.md:93:401 error MD013/line-length Line length [Expected: 400; Actual: 622]
doc/robust_control/DisturbanceObserver.md:7:401 error MD013/line-length Line length [Expected: 400; Actual: 476]
doc/robust_control/README.md:12:259 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/robust_control/SlidingModeControl.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 644]
doc/solvers/ConditionNumber.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 461]
doc/solvers/ConditionNumber.md:51:401 error MD013/line-length Line length [Expected: 400; Actual: 425]
doc/solvers/JacobiEigenSolver.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 443]
doc/solvers/JacobiEigenSolver.md:7:401 error MD013/line-length Line length [Expected: 400; Actual: 609]
doc/solvers/JacobiEigenSolver.md:45:401 error MD013/line-length Line length [Expected: 400; Actual: 427]
doc/solvers/README.md:16:163 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/solvers/README.md:17:163 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/solvers/README.md:18:167 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/solvers/README.md:19:184 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/solvers/README.md:20:184 error MD060/table-column-style Table column style [Table pipe does not align with header for style "aligned"]
doc/solvers/RungeKuttaIntegrators.md:9:401 error MD013/line-length Line length [Expected: 400; Actual: 509]
doc/solvers/SpectralRadius.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 665]
doc/windowing/window.md:5:401 error MD013/line-length Line length [Expected: 400; Actual: 415]
README.md:1 error MD041/first-line-heading/first-line-h1 First line in a file should be a top-level heading [Context: "[
Notices
REPOSITORY_GITLEAKS, REPOSITORY_KICS. See Removed linters to find their replacements.
See detailed reports in MegaLinter artifacts
Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)
- Documentation: Custom Flavors
- Command:
npx mega-linter-runner@10.1.0 --custom-flavor-setup --custom-flavor-linters ACTION_ACTIONLINT,CPP_CPPCHECK,CPP_CLANG_FORMAT,DOCKERFILE_HADOLINT,JSON_JSONLINT,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,SPELL_LYCHEE,YAML_PRETTIER,YAML_YAMLLINT

Show us your support by starring ⭐ the repository
Every Matrix operator that returns a new matrix value-initialised its
result (data = {}) and then overwrote every element. Without the O3
pragmas #348 removed, a consumer that builds at -O2 keeps those loops
rolled, so the zeroing survives. For a 3x3 result it is a memset call,
and the Arm GNU toolchain's newlib-nano memset stores one byte at a
time.
e-foc runs an RLS update in the control interrupt during mechanical
identification. Its covariance update, (P - g g^T / d) / lambda,
builds four 3x3 temporaries. In e-foc's SIL scenario that times the
control interrupt through a full calibration, the slowest execution
rose from 237 to 377 cycles of the emulated 25 MHz clock
(arm-none-eabi-gcc 15.2.1). The four memset calls were 596 of its 1892
instructions.
- Matrix gains a private constructor that leaves the elements
uninitialised. operator+, operator-, the matrix and scalar products,
Transpose, GetBlock and GetColumn build their results with it, since
each writes every element.
- The default and initializer-list constructors still zero-fill, so a
default-constructed or partly listed matrix keeps its zeros.
- A test evaluates those operators in constant expressions, so a
compiler that checks (Clang does, GCC does not) rejects an operator
that leaves an element unwritten.
The RLS update keeps its matrix expression and now makes no memset
calls. The same scenario peaks at 250 cycles.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HKhRVwu8yvxdKJgNo17oNc
gabrielfrasantos
force-pushed
the
ccr-90fcd432-u9pqe7
branch
from
October 5, 2026 14:15
69a2fc5 to
e5ea80d
Compare
The matrix product is a friend function of its left operand's Matrix specialisation. It built its result, a Matrix of another shape, with that shape's private constructor. GCC and Clang allowed it, but MSVC rejects it (C2248): friendship goes to the Matrix specialisations, not to their friend functions. The operator now calls a private member function, Multiply, which builds the result in place, as Transpose, GetBlock and GetColumn already do. Members of every Matrix specialisation are friends of the others, so every compiler accepts it. A static helper that returned the uninitialised result was not used: GCC folds such an argument-less constexpr call into a zero-filled constant, which brings back the memset calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HKhRVwu8yvxdKJgNo17oNc
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
math::Matrix's operators now build the matrices they return without zero-filling them first. This follows up #348: without its O3 pragmas, a consumer that builds at-O2paid for every zeroed result with amemsetcall. The RLS update, and every other user of these operators, keeps its matrix expressions.This replaces the PR's first version, which rewrote the RLS covariance update as a hand-written element loop. That worked around
Matrixinstead of fixing it, and the loop lost the covariance's exact symmetry under-ffast-math(see below).Why
Each operator that returns a new matrix (
+,-, the matrix and scalar*,Transpose,GetBlock,GetColumn) declaredMatrix result;, value-initialised throughdata = {}, and then wrote every element. At O3 the loops were unrolled and the zeroing removed as dead stores. At-O2the loops stay rolled and the zeroing survives. For a 3×3 result it is a 36-bytememsetcall, and the Arm GNU toolchain's newlib-nanomemsetstores one byte at a time, about 150 instructions per call.e-foc runs an RLS update in the control interrupt during mechanical identification. Its covariance update,
(covariance - Px * Px.Transpose() * denominatorInv) * lambdaInverse, builds four 3×3 temporaries. e-foc's SIL scenario that times the control interrupt through a full calibration (embedded-pro/e-foc#333) measures the slowest execution, in cycles of the emulated 25 MHz clock (one cycle is five instructions retired):main(pragmas, O3)main(-O2)memsetcalls are 596 of its 1 892 instructionsmemsetUbuntu's newlib-nano
memsetstores 16 bytes per iteration, so the same dead zeroing cost less there. CI uses the Arm GNU toolchain, so CI failed the scenario and a local run did not.Change
Matrixgains a private constructor taking a private tag; it leaves the elements uninitialised. The listed operators build their results with it, since each writes every element. AllMatrixspecialisations are friends, so an operator can build a result of another shape.Matrix m;and a partly listed matrix keep their zeros.Identity()still starts from zeros.Multiply, that builds the result in place, asTranspose,GetBlockandGetColumndo. MSVC (C2248) does not let a friend function of one specialisation use another specialisation's private constructor; GCC and Clang did. A static helper returning the uninitialised result was tried and rejected: GCC folds that argument-lessconstexprcall into a zero-filled constant, and thememsetcalls came back (377 cycles again).RecursiveLeastSquaresis unchanged frommain.Tests
operators_write_every_element_of_their_resultevaluates the outer product, sum, difference, scalar product,GetBlockandGetColumnin constant expressions. A compiler that checks for uninitialised subobjects rejects any of them that leaves an element unwritten.operator+changed to skip its last element, the test fails to compile ("subobject '_M_elems' is not initialized").DefaultConstructorZeroInitializesandPartialInitializerListZeroFillsRemaindercover the zero-fill that remains.The first version
It computed
P(i,j)andP(j,i)in separate iterations. With-ffast-math, GCC 15 hoisteddenominatorInv·Px(i)out of the column loop and fused the subtraction, so the two elements rounded differently. Under the online mechanical estimator's forgetting factor (λ = 0.9995) that asymmetry grows by1/λper update, and e-foc's CI read REQ-CAL-014's online friction 71 % off the plant (limit 30 %). The matrix expression computes the outer productPx·Pxᵀfirst, andPx(i)·Px(j) = Px(j)·Px(i)exactly, so the covariance stays symmetric, as onmain.Validation
clang-format18 reports nothing on the changed files.host-single-Debug(GCC 13): the build is clean with no warnings, andctestpasses 14/14.ctestpasses 14/14.qemu-cortex-m4: the build succeeds, andctestpasses 15/15. Its only warnings are newlib's stub notices (_open,_gettimeofday,_getentropy"is not implemented"), as onmain.0e6a2fc, which pins this PR's head:main.memsetcall inRecursiveLeastSquares<float, 3>::Updateor in either e-foc function that inlines it.🤖 Generated with Claude Code
https://claude.ai/code/session_01HKhRVwu8yvxdKJgNo17oNc