From 2f833e4298e3386ec4f782e8a2b0e1c6cfa69cde Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Mon, 30 Jun 2025 19:17:26 +0000
Subject: [PATCH 01/16] feat: add blas/ext/base/ndarray/sindex-of
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
---
.../blas/ext/base/ndarray/sindex-of/README.md | 155 +++++++++++++++++
.../ndarray/sindex-of/benchmark/benchmark.js | 112 +++++++++++++
.../ext/base/ndarray/sindex-of/docs/repl.txt | 34 ++++
.../ndarray/sindex-of/docs/types/index.d.ts | 56 +++++++
.../base/ndarray/sindex-of/docs/types/test.ts | 70 ++++++++
.../base/ndarray/sindex-of/examples/index.js | 45 +++++
.../ext/base/ndarray/sindex-of/lib/index.js | 54 ++++++
.../ext/base/ndarray/sindex-of/lib/main.js | 99 +++++++++++
.../ext/base/ndarray/sindex-of/package.json | 65 +++++++
.../ext/base/ndarray/sindex-of/test/test.js | 158 ++++++++++++++++++
10 files changed, 848 insertions(+)
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/README.md
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/benchmark/benchmark.js
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/repl.txt
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/types/index.d.ts
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/types/test.ts
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/examples/index.js
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/lib/index.js
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/lib/main.js
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/package.json
create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/test/test.js
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/README.md
new file mode 100644
index 000000000000..3bb1a1a87e37
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/README.md
@@ -0,0 +1,155 @@
+
+
+# sindexOf
+
+> Return the first index of a search element in a one-dimensional single-precision floating-point ndarray.
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var sindexOf = require( '@stdlib/blas/ext/base/ndarray/sindex-of' );
+```
+
+#### sindexOf( arrays )
+
+Returns the first index of a specified search element in a one-dimensional single-precision floating-point ndarray.
+
+```javascript
+var Float32Array = require( '@stdlib/array/float32' );
+var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+
+var xbuf = new Float32Array( [ 1.0, 3.0, 4.0, 2.0 ] );
+var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
+
+var searchElement = scalar2ndarray( 2.0, {
+ 'dtype': 'float32'
+});
+
+var fromIndex = scalar2ndarray( 0, {
+ 'dtype': 'generic'
+});
+
+var idx = sindexOf( [ x, searchElement, fromIndex ] );
+// returns 3
+```
+
+The function has the following parameters:
+
+- **arrays**: array-like object containing a one-dimensional input ndarray, a zero-dimensional ndarray containing the search element and a zero-dimensional ndarray containing the from index.
+
+If the function is unable to find a search element, the function returns `-1`.
+
+```javascript
+var Float32Array = require( '@stdlib/array/float32' );
+var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+
+var xbuf = new Float32Array( [ 1.0, 3.0, 4.0, 2.0 ] );
+var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
+
+var searchElement = scalar2ndarray( 10.0, {
+ 'dtype': 'float32'
+});
+
+var fromIndex = scalar2ndarray( 0, {
+ 'dtype': 'generic'
+});
+
+var idx = sindexOf( [ x, searchElement, fromIndex ] );
+// returns -1
+```
+
+
+
+
+
+
+
+## Notes
+
+- When searching for a search element, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same.
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' );
+var sindexOf = require( '@stdlib/blas/ext/base/ndarray/sindex-of' );
+
+var xbuf = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float32'
+});
+var x = new ndarray( 'float32', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
+console.log( ndarray2array( x ) );
+
+var searchElement = scalar2ndarray( 80.0, {
+ 'dtype': 'float32'
+});
+console.log( 'Search Element:', ndarraylike2scalar( searchElement ) );
+
+var fromIndex = scalar2ndarray( 0, {
+ 'dtype': 'generic'
+});
+console.log( 'From Index:', ndarray2array( fromIndex ) );
+
+var idx = sindexOf( [ x, searchElement, fromIndex ] );
+console.log( idx );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/benchmark/benchmark.js
new file mode 100644
index 000000000000..0d1078cf601a
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/benchmark/benchmark.js
@@ -0,0 +1,112 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var uniform = require( '@stdlib/random/array/uniform' );
+var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;
+var pow = require( '@stdlib/math/base/special/pow' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+var pkg = require( './../package.json' ).name;
+var sindexOf = require( './../lib' );
+
+
+// VARIABLES //
+
+var options = {
+ 'dtype': 'float32'
+};
+
+
+// FUNCTIONS //
+
+/**
+* Creates a benchmark function.
+*
+* @private
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( len ) {
+ var searchElement;
+ var fromIndex;
+ var xbuf;
+ var x;
+
+ xbuf = uniform( len, 0.0, 100.0, options );
+ x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' );
+
+ searchElement = scalar2ndarray( -10.0, {
+ 'dtype': 'float32'
+ });
+ fromIndex = scalar2ndarray( 0, {
+ 'dtype': 'generic'
+ });
+
+ return benchmark;
+
+ function benchmark( b ) {
+ var idx;
+ var i;
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ idx = sindexOf( [ x, searchElement, fromIndex ] );
+ if ( !isInteger( idx ) ) {
+ b.fail( 'should return an integer' );
+ }
+ }
+ b.toc();
+ if ( !isInteger( idx ) ) {
+ b.fail( 'should return an integer' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+ }
+}
+
+
+// MAIN //
+
+/**
+* Main execution sequence.
+*
+* @private
+*/
+function main() {
+ var len;
+ var min;
+ var max;
+ var f;
+ var i;
+
+ min = 1; // 10^min
+ max = 6; // 10^max
+
+ for ( i = min; i <= max; i++ ) {
+ len = pow( 10, i );
+ f = createBenchmark( len );
+ bench( pkg+':len='+len, f );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/repl.txt
new file mode 100644
index 000000000000..640c282f2ffa
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/repl.txt
@@ -0,0 +1,34 @@
+
+{{alias}}( arrays )
+ Returns the first index of a search element in a one-dimensional
+ single-precision floating-point ndarray.
+
+ Parameters
+ ----------
+ arrays: ArrayLikeObject
+ Array-like object containing a one-dimensional input ndarray,
+ a zero-dimensional ndarray containing the search element and
+ a zero-dimensional ndarray containing the from index.
+
+ Returns
+ -------
+ out: integer
+ Index.
+
+ Examples
+ --------
+ > var xbuf = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] );
+ > var dt = 'float32';
+ > var sh = [ xbuf.length ];
+ > var sx = [ 1 ];
+ > var ox = 0;
+ > var ord = 'row-major';
+ > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord );
+ > var searchElement = {{alias:@stdlib/ndarray/from-scalar}}( 2.0, { 'dtype': 'float32' });
+ > var fromIndex = {{alias:@stdlib/ndarray/from-scalar}}( 0, { 'dtype': 'generic' });
+ > {{alias}}( [ x, searchElement, fromIndex ] )
+ 1
+
+ See Also
+ --------
+
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/types/index.d.ts
new file mode 100644
index 000000000000..dcb7b753d8cb
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/types/index.d.ts
@@ -0,0 +1,56 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 4.1
+
+///
+
+import { typedndarray } from '@stdlib/types/ndarray';
+
+/**
+* Return the first index of a search element in a one-dimensional single-precision floating-point ndarray.
+*
+* @param arrays - array-like object containing an input ndarray, a search element ndarray and a from index ndarray.
+* @returns index
+*
+* @example
+* var Float32Array = require( '@stdlib/array/float32' );
+* var ndarray = require( '@stdlib/ndarray/base/ctor' );
+* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+* var sindexOf = require( '@stdlib/blas/ext/base/ndarray/sindex-of' );
+*
+* var xbuf = new Float32Array( [ 1.0, 3.0, 4.0, 2.0 ] );
+* var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
+*
+* var searchElement = scalar2ndarray( 2.0, {
+* 'dtype': 'float32'
+* });
+*
+* var fromIndex = scalar2ndarray( 0, {
+* 'dtype': 'generic'
+* });
+*
+* var v = sindexOf( [ x, searchElement, fromIndex ] );
+* // returns 3
+*/
+declare function sindexOf = typedndarray>( arrays: [ T, T, T ] ): number;
+
+
+// EXPORTS //
+
+export = sindexOf;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/types/test.ts
new file mode 100644
index 000000000000..605065cab5ae
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/docs/types/test.ts
@@ -0,0 +1,70 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/* eslint-disable space-in-parens */
+
+import zeros = require( '@stdlib/ndarray/zeros' );
+import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+import sindexOf = require( './index' );
+
+
+// TESTS //
+
+// The function returns a number...
+{
+ const x = zeros( [ 10 ], {
+ 'dtype': 'float32'
+ });
+ const searchElement = scalar2ndarray( 0.0, {
+ 'dtype': 'float32'
+ });
+ const fromIndex = scalar2ndarray( 0, {
+ 'dtype': 'generic'
+ });
+
+ sindexOf( [ x, searchElement, fromIndex ] ); // $ExpectType number
+}
+
+// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays...
+{
+ sindexOf( '10' ); // $ExpectError
+ sindexOf( 10 ); // $ExpectError
+ sindexOf( true ); // $ExpectError
+ sindexOf( false ); // $ExpectError
+ sindexOf( null ); // $ExpectError
+ sindexOf( undefined ); // $ExpectError
+ sindexOf( [] ); // $ExpectError
+ sindexOf( {} ); // $ExpectError
+ sindexOf( ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ const x = zeros( [ 10 ], {
+ 'dtype': 'float32'
+ });
+ const searchElement = scalar2ndarray( 0.0, {
+ 'dtype': 'float32'
+ });
+ const fromIndex = scalar2ndarray( 0, {
+ 'dtype': 'generic'
+ });
+
+ sindexOf(); // $ExpectError
+ sindexOf( [ x, searchElement, fromIndex ], {} ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/examples/index.js
new file mode 100644
index 000000000000..42496dd072ab
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/examples/index.js
@@ -0,0 +1,45 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
+var ndarray = require( '@stdlib/ndarray/base/ctor' );
+var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+var ndarray2array = require( '@stdlib/ndarray/to-array' );
+var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' );
+var sindexOf = require( './../lib' );
+
+var xbuf = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float32'
+});
+var x = new ndarray( 'float32', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
+console.log( ndarray2array( x ) );
+
+var searchElement = scalar2ndarray( 80.0, {
+ 'dtype': 'float32'
+});
+console.log( 'Search Element:', ndarraylike2scalar( searchElement ) );
+
+var fromIndex = scalar2ndarray( 0, {
+ 'dtype': 'generic'
+});
+console.log( 'From Index:', ndarraylike2scalar( fromIndex ) );
+
+var idx = sindexOf( [ x, searchElement, fromIndex ] );
+console.log( idx );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/lib/index.js
new file mode 100644
index 000000000000..5ed07125048d
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/lib/index.js
@@ -0,0 +1,54 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+* Return the first index of a search element in a one-dimensional single-precision floating-point ndarray.
+*
+* @module @stdlib/blas/ext/base/ndarray/sindex-of
+*
+* @example
+* var Float32Array = require( '@stdlib/array/float32' );
+* var ndarray = require( '@stdlib/ndarray/base/ctor' );
+* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
+* var sindexOf = require( '@stdlib/blas/ext/base/ndarray/sindex-of' );
+*
+* var xbuf = new Float32Array( [ 1.0, 3.0, 4.0, 2.0 ] );
+* var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
+*
+* var searchElement = scalar2ndarray( 2.0, {
+* 'dtype': 'float32'
+* });
+*
+* var fromIndex = scalar2ndarray( 0, {
+* 'dtype': 'generic'
+* });
+*
+* var v = sindexOf( [ x, searchElement, fromIndex ] );
+* // returns 3
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/lib/main.js
new file mode 100644
index 000000000000..75eb28e6c244
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sindex-of/lib/main.js
@@ -0,0 +1,99 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' );
+var getStride = require( '@stdlib/ndarray/base/stride' );
+var getOffset = require( '@stdlib/ndarray/base/offset' );
+var getData = require( '@stdlib/ndarray/base/data-buffer' );
+var strided = require( '@stdlib/blas/ext/base/sindex-of' ).ndarray;
+var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' );
+
+
+// MAIN //
+
+/**
+* Return the first index of a search element in a one-dimensional single-precision floating-point ndarray.
+*
+* @param {ArrayLikeObject