feat: add scalar operations and sum reduction - #42
Merged
Conversation
Owner
|
for fun this time, try to ask copilot to review @YassineSamirX |
There was a problem hiding this comment.
Pull request overview
This PR extends the NdArray API with two additional operations (scalar addition and full-array sum reduction), and updates tests, documentation, and the demo to showcase the new functionality.
Changes:
- Add scalar overloads for
add(...)andaddInPlace(...)to apply a constant shift to all elements. - Introduce
sum()reduction to compute the total of all elements. - Update unit tests, README usage/examples, and the demo showcase accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/main/java/org/sadisamir/ndarray/NdArray.java |
Adds scalar addition overloads and sum() reduction to the core ndarray API. |
src/test/java/org/sadisamir/ndarray/NdArrayTest.java |
Adds unit tests covering scalar add/addInPlace behavior and sum() across shapes and empty arrays. |
src/main/java/org/sadisamir/ndarray/demo/NdArrayDemo.java |
Adds a demo section showcasing scalar addition and sum reduction. |
README.md |
Documents the new optional extensions and updates usage examples. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
26
to
+32
| Current snapshot date: 2026-04-04. | ||
|
|
||
| - 1D ndarray core with metadata (`ndim`, `shape`, `size`). | ||
| - 2D ndarray support with matrix validation. | ||
| - Creation helpers: `array`, `zeros`, `arange`. | ||
| - Addition operations: `add` and `addInPlace` with strict shape checks. | ||
| - Optional extensions: scalar addition and `sum()` reduction. |
There was a problem hiding this comment.
The README still states "Current snapshot date: 2026-04-04" even though this PR adds new user-facing functionality. Consider updating the snapshot date so the feature list and the stated snapshot date stay consistent.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
sMouaad
self-requested a review
April 6, 2026 10:55
10 tasks
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.
I added two optional ndarray features: scalar addition and sum() reduction. I also updated unit tests, README updates, and a small demo showcase.