Repository navigation
feat: add C implementation for blas/ext/base/ndarray/scircshift - #16502
Open
utkarshpatwa393-sys wants to merge 2 commits into
Open
utkarshpatwa393-sys wants to merge 2 commits into
utkarshpatwa393-sys wants to merge 2 commits into
Conversation
Signed-off-by: Utkarsh patwa <utkarshpatwa393@gmail.com>
3 tasks done
…lementation Signed-off-by: Utkarsh patwa <utkarshpatwa393@gmail.com>
ujjwalv01
reviewed
Nov 5, 2026
| var k; | ||
|
|
||
| x = uniform( [ len ], 0.0, 100.0, options ); | ||
| k = scalar2ndarray( 3, options ); |
Member
There was a problem hiding this comment.
Suggested change
| k = scalar2ndarray( 3, { | |
| 'dtype': 'int32' | |
| }); |
ujjwalv01
reviewed
Nov 5, 2026
Comment on lines
+23
to
+30
| var resolve = require( 'path' ).resolve; | ||
| var bench = require( '@stdlib/bench' ); | ||
| var uniform = require( '@stdlib/random/uniform' ); | ||
| var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); | ||
| var pow = require( '@stdlib/math/base/special/pow' ); | ||
| var format = require( '@stdlib/string/format' ); | ||
| var tryRequire = require( '@stdlib/utils/try-require' ); | ||
| var pkg = require( './../package.json' ).name; |
Member
There was a problem hiding this comment.
benchmark.native.js should be the same as benchmark.js, plus the native wiring.
Suggested change
| var resolve = require( 'path' ).resolve; | |
| var bench = require( '@stdlib/bench' ); | |
| var uniform = require( '@stdlib/random/uniform' ); | |
| var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); | |
| var pow = require( '@stdlib/math/base/special/pow' ); | |
| var format = require( '@stdlib/string/format' ); | |
| var tryRequire = require( '@stdlib/utils/try-require' ); | |
| var pkg = require( './../package.json' ).name; | |
| var resolve = require( 'path' ).resolve; | |
| var bench = require( '@stdlib/bench' ); | |
| var uniform = require( '@stdlib/random/uniform' ); | |
| var pow = require( '@stdlib/math/base/special/pow' ); | |
| var format = require( '@stdlib/string/format' ); | |
| var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); | |
| var tryRequire = require( '@stdlib/utils/try-require' ); | |
| var pkg = require( './../package.json' ).name; |
ujjwalv01
reviewed
Nov 5, 2026
| * Creates a benchmark function. | ||
| * | ||
| * @private | ||
| * @param {PositiveInteger} len - ndarray length |
Member
There was a problem hiding this comment.
Suggested change
| * @param {PositiveInteger} len - ndarray length | |
| * @param {PositiveInteger} len - array length |
ujjwalv01
reviewed
Nov 5, 2026
Comment on lines
+54
to
+57
| var x = uniform( [ len ], -100.0, 100.0, options ); | ||
| var k = scalar2ndarray( 2, { | ||
| 'dtype': 'int64' | ||
| }); |
Member
There was a problem hiding this comment.
Suggested change
| var x = uniform( [ len ], -100.0, 100.0, options ); | |
| var k = scalar2ndarray( 2, { | |
| 'dtype': 'int64' | |
| }); | |
| var x; | |
| var k; | |
| x = uniform( [ len ], 0.0, 100.0, options ); | |
| k = scalar2ndarray( 3, { | |
| 'dtype': 'int32' | |
| }); | |
ujjwalv01
reviewed
Nov 5, 2026
Comment on lines
+39
to
+49
| int64_t k; | ||
|
|
||
| const CBLAS_INT N = stdlib_ndarray_dimension( x, 0 ); | ||
| const CBLAS_INT strideX = stdlib_ndarray_stride_elements( x, 0 ); | ||
| const CBLAS_INT offsetX = stdlib_ndarray_offset_elements( x ); | ||
|
|
||
| float *dataX = (float *)stdlib_ndarray_data( x ); | ||
|
|
||
| stdlib_ndarray_get_int64( arrays[ 1 ], NULL, &k ); | ||
|
|
||
| API_SUFFIX(stdlib_strided_scircshift_ndarray)( N, (CBLAS_INT)k, dataX, strideX, offsetX ); |
Member
There was a problem hiding this comment.
Read k as int32 (same as ztril), so no cast is needed, and read the scalar first as in the other packages.
Suggested change
| int64_t k; | |
| const CBLAS_INT N = stdlib_ndarray_dimension( x, 0 ); | |
| const CBLAS_INT strideX = stdlib_ndarray_stride_elements( x, 0 ); | |
| const CBLAS_INT offsetX = stdlib_ndarray_offset_elements( x ); | |
| float *dataX = (float *)stdlib_ndarray_data( x ); | |
| stdlib_ndarray_get_int64( arrays[ 1 ], NULL, &k ); | |
| API_SUFFIX(stdlib_strided_scircshift_ndarray)( N, (CBLAS_INT)k, dataX, strideX, offsetX ); | |
| int32_t k; | |
| stdlib_ndarray_get_int32( arrays[ 1 ], NULL, &k ); | |
| const CBLAS_INT N = stdlib_ndarray_dimension( x, 0 ); | |
| const CBLAS_INT strideX = stdlib_ndarray_stride_elements( x, 0 ); | |
| const CBLAS_INT offsetX = stdlib_ndarray_offset_elements( x ); | |
| float *dataX = (float *)stdlib_ndarray_data( x ); | |
| API_SUFFIX(stdlib_strided_scircshift_ndarray)( N, k, dataX, strideX, offsetX ); |
ujjwalv01
reviewed
Nov 5, 2026
ujjwalv01
left a comment
Member
There was a problem hiding this comment.
@utkarshpatwa393-sys! Same as #16501 (dcircshift): k should be int32 throughout the package rather than converted to int64 in native.js; Please apply the same changes suggested there , here as well. Left suggestions for the files that differ here.
This branch has not been deployed
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.
Description
This PR adds the native C implementation for
@stdlib/blas/ext/base/ndarray/scircshift(circularly shift the elements of a one-dimensional single-precision floating-point ndarray by a specified number of positions).Part of #14819.
Changes
src/main.c,src/addon.c,src/Makefileinclude/stdlib/blas/ext/base/ndarray/scircshift.hmanifest.json,binding.gyp,include.gypilib/native.jsand updatedlib/index.jstest/test.main.jsandtest/test.native.jsexamples/c/example.candexamples/c/Makefilebenchmark/c/(withsrandseeding and TAP format) andbenchmark/benchmark.native.jsREADME.mdwith C APIs documentation and usage examplespackage.jsonwithbrowser,gypfile, and directory mappingsChecklist
git commit -s).