[Type] Array/Vec: small refresh for modern C++#5907
Open
fredroy wants to merge 4 commits intosofa-framework:masterfrom
Open
[Type] Array/Vec: small refresh for modern C++#5907fredroy wants to merge 4 commits intosofa-framework:masterfrom
fredroy wants to merge 4 commits intosofa-framework:masterfrom
Conversation
Contributor
Author
|
[ci-build][with-all-tests] |
alxbilger
reviewed
Jan 29, 2026
| for (Size i=1; i<N; i++) | ||
| r += this->elems[i]*this->elems[i]; | ||
| return r; | ||
| return std::inner_product(elems.begin(), elems.end(), elems.begin(), ValueType{}); |
Contributor
There was a problem hiding this comment.
We can ask the question of the performances...
Contributor
Author
There was a problem hiding this comment.
We can ask the question of the performances...
Usually people (and IA...) advise to use stl functions because it may help the compiler more (vectorization and stuff). But of course it depends of the implementation of the libstl itself... I will try to do some bench tho
Contributor
Author
There was a problem hiding this comment.
https://quick-bench.com/q/WGEPcgHll4O2cAl8Ms-VoyRBn7I
At -O3, all config (clang/gcc & libstdc++/libc++) give same result. But will less optimization the loop is faster.
Should I roll back the implementation ?
th-skam
reviewed
Jan 29, 2026
fredroy
commented
Jan 30, 2026
| for (Size i=0; i<N; i++) | ||
| sum += this->elems[i]; | ||
| return sum; | ||
| return std::accumulate(elems.begin(), elems.end(), ValueType{}); |
Contributor
Author
There was a problem hiding this comment.
3a0abbe to
84f6e2f
Compare
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.
using std algos, clamp, etc and some keywords noexcept.
and fixed_array_algo, removing some useless templates
and some (generated but modified) unit tests for vec ,as there were almost none ? 🤔
Note that fixed_array_algo is only used in RGBAColor, at least in the standard code base.
[with-all-tests]
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if