Repository navigation
feat: add C implementation for blas/ext/base/ndarray/dnansumkbn - #14296
Shravani-Relekar wants to merge 3 commits into
Conversation
|
👋 Hi there! 👋 And thank you for opening your first pull request! We will review it shortly. 🏃 💨 Getting Started
Next Steps
Running Tests LocallyYou can use # Run tests for all packages in the math namespace:
make test TESTS_FILTER=".*/@stdlib/math/.*"
# Run benchmarks for a specific package:
make benchmark BENCHMARKS_FILTER=".*/@stdlib/math/base/special/sin/.*"If you haven't heard back from us within two weeks, please ping us by tagging the "reviewers" team in a comment on this PR. If you have any further questions while waiting for a response, please join our Zulip community to chat with project maintainers and other community members. We appreciate your contribution! Documentation Links |
|
@ujjwalv01 Mind taking a first review on this PR? |
| function vector(buffer, length, stride, offset) { | ||
| return new ndarray('float64', buffer, [length], [stride], offset, 'row-major'); | ||
| } |
There was a problem hiding this comment.
| function vector(buffer, length, stride, offset) { | |
| return new ndarray('float64', buffer, [length], [stride], offset, 'row-major'); | |
| } | |
| function vector( buffer, length, stride, offset ) { | |
| return new ndarray( 'float64', buffer, [ length ], [ stride ], offset, 'row-major' ); | |
| } |
| x = new Float64Array([1.0, -2.0, -4.0, 5.0, NaN, 0.0, 3.0]); | ||
| v = dnansumkbn([vector(x, 7, 1, 0)]); | ||
| t.strictEqual(v, 3.0, 'returns expected value'); |
There was a problem hiding this comment.
| x = new Float64Array([1.0, -2.0, -4.0, 5.0, NaN, 0.0, 3.0]); | |
| v = dnansumkbn([vector(x, 7, 1, 0)]); | |
| t.strictEqual(v, 3.0, 'returns expected value'); | |
| x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, NaN, 0.0, 3.0 ] ); | |
| v = dnansumkbn( [ vector( x, 7, 1, 0 ) ] ); | |
| t.strictEqual( v, 3.0, 'returns expected value' ); |
There was a problem hiding this comment.
@Shravani-Relekar , According to the stdlib style guidelines, there needs to be a space inside the array brackets for function arguments, as shown in the suggested change above.
I noticed this formatting is used throughout this entire file. Once you apply this suggestion, could you please do a quick find-and-replace to fix all the other instances in test.main.js?
There was a problem hiding this comment.
Similar to test.main.js, there is a minor style guideline issue with the array spacing here (see suggested change above).
Could you please ensure this spacing fix is also applied to all similar instances throughout this test.native.js file? Thanks!
| // Create an ndarray: | ||
| const double data[] = { 1.0, 0.0/0.0, 3.0, 4.0 }; | ||
| int64_t shape[] = { 4 }; | ||
| int64_t strides[] = { STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT }; | ||
| int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR }; | ||
|
|
||
| struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, 1, shape, strides, 0, STDLIB_NDARRAY_ROW_MAJOR, STDLIB_NDARRAY_INDEX_ERROR, 1, submodes ); | ||
|
|
||
| // Compute the sum: | ||
| const struct ndarray *arrays[] = { x }; | ||
| double v = stdlib_blas_ext_dnansumkbn( arrays ); | ||
| // returns 8.0 |
There was a problem hiding this comment.
Hi @kgryte , I noticed a small change in the examples across the languages.
The JS examples (lib/index.js, lib/main.js) use:
var x = new Float64Vector( [ 1.0, -2.0, NaN, 2.0 ] ); // returns 1.0But the C examples (header docs and README) use different values:
const double data[] = { 1.0, 0.0/0.0, 3.0, 4.0 }; // returns 8.0I noticed that the original dnansum package also uses different values for its JS vs C examples. Should we keep them different here to mirror what was done in dnansum, or should we update the C examples to match the JS ones ({ 1.0, -2.0, 0.0/0.0, 2.0 }) for consistency?
There was a problem hiding this comment.
It is fine if they differ slightly.
Done! Left a few minor spacing suggestions and question about C examples. |
Coverage ReportNo coverage information available. |
|
@Shravani-Relekar Mind addressing the lint failures? Looks like there are still spacing issues. |
There was a problem hiding this comment.
Just a heads-up on the CI failure there are a few file formatting issues that need to be fixed to get the tests passing:
- There are some spacing and indentation errors in
benchmark.js. - Both
package.jsonandmanifest.jsonare missing the required empty newline at the end of the file.
You'll need to fix those formatting issues so the CI can successfully pass;
Description
This pull request:
blas/ext/base/ndarray/dnansumkbnRelated Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers