Merged
Conversation
Closed
Agent-Logs-Url: https://github.com/Quafadas/vecxt/sessions/8f0a084a-c95f-4aa4-9af2-91115cebfc98 Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>
Agent-Logs-Url: https://github.com/Quafadas/vecxt/sessions/8f0a084a-c95f-4aa4-9af2-91115cebfc98 Co-authored-by: Quafadas <24899792+Quafadas@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add NDArray reduction operations for M4
NDArray M4: Reduction Operations
Apr 8, 2026
…s://github.com/Quafadas/vecxt into copilot/implement-ndarray-reduction-operations
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.
Implements Milestone 4 — reduction operations for
NDArray[Double]: full reductions, axis reductions, arg reductions, and linear algebra (dot/matmul), as specified in the design doc.New:
vecxt/src/ndarrayReductions.scalaFull reductions — return
Double, col-major fast path delegates to existing SIMD/BLASArray[Double]extensions:sum,mean,min,max,product,variance,normargmax,argmin(flat col-major index)Axis reductions — output shape removes the reduced dimension (NumPy
keepdims=Falsesemantics):sum(axis),mean(axis),min(axis),max(axis),product(axis),argmax(axis),argmin(axis)Linear algebra:
dot— 1-D only, delegates to BLASddoton col-major inputsmatmul/@@— 2-D × 2-D, materialises non-contiguous inputs then delegates to BLASdgemmviaMatrixImplementation notes
NDArrayDoubleOps.arrays.*extensions; no platform-specific code required.NDArrayReductionHelpersis a private top-level object (not nested insideNDArrayReductions) to work around a Scala 3 resolution issue where extension methods defined in an object shadow same-named extensions from imports, even for different receiver types.Other changes
vecxt/src/all.scala— exportsNDArrayReductions.*vecxt/test/src/helpers.forTests.scala— addsassertNDArrayShapeAndClosevecxt/test/src/ndarrayReductions.test.scala— cross-platform tests covering all operations, 2-D and 3-D axis reductions (with hand-verified values from the design doc), strided/transposed paths, and error cases