Add dot(), dot3(), and dot4() methods to SimdFloat and tests to existing dot product functions#491
Open
GrigoryEvko wants to merge 3 commits intorust-lang:masterfrom
Open
Add dot(), dot3(), and dot4() methods to SimdFloat and tests to existing dot product functions#491GrigoryEvko wants to merge 3 commits intorust-lang:masterfrom
GrigoryEvko wants to merge 3 commits intorust-lang:masterfrom
Conversation
Quality of life improvement for dot product operations. Entirely optional - feel free to reject if this adds unnecessary API surface. Methods: - dot(rhs) - Full dot product (sugar for (self * rhs).reduce_sum()) - dot3(rhs) - 3D dot product (first 3 elements, w component ignored) - dot4(rhs) - 4D dot product (first 4 elements only) Rationale: - dot3()/dot4() reduce boilerplate in graphics/physics code - dot() provides discoverability and matches industry libraries (NumPy, GLM, Eigen) - All methods are inline, zero-cost abstractions Implementation: - dot() delegates to (self * rhs).reduce_sum() - dot3()/dot4() use compile-time assertions for size safety - Zero allocations, pure SIMD register operations Testing (26 tests): - Mathematical properties (commutativity, distributivity, scaling) - Special values (infinity, NaN, MAX, MIN, subnormals) - Size variations (f32x2, f32x4, f32x8, f64x2, f64x4, f64x8) - Edge cases (orthogonal vectors, zero vectors, negative values) - w component correctly ignored in dot3() - Elements beyond index correctly ignored in dot3()/dot4() The decision to include this is completely up to maintainers. Happy to close if you feel it's not worth the API complexity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
ARM NEON uses flush-to-zero (FTZ) for subnormal values in SIMD operations. Updated tests to accept either the correct subnormal result or zero.
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.
Quality of life improvement for dot product operations. Entirely optional - feel free to reject if this adds
unnecessary API surface.
Methods:
dot(rhs)- Full dot product (alias for(self * rhs).reduce_sum())dot3(rhs)- 3D dot product (first 3 elements, w component ignored)dot4(rhs)- 4D dot product (first 4 elements only)Rationale:
dot3()/dot4()reduce boilerplate in graphics/physics codedot()provides discoverability and matches industry libraries (NumPy, GLM, Eigen)Implementation:
dot()delegates to(self * rhs).reduce_sum()dot3()/dot4()use compile-time assertions for size safetyTesting:
Happy to close if you feel it's not worth the API complexity.