diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/README.md b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/README.md
index 6bd9409cd2aa..a27caef39dde 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/README.md
@@ -32,7 +32,7 @@ var ssort2ins = require( '@stdlib/blas/ext/base/ssort2ins' );
#### ssort2ins( N, order, x, strideX, y, strideY )
-Simultaneously sorts two single-precision floating-point strided arrays based on the sort order of the first array `x` using insertion sort.
+Simultaneously sorts two single-precision floating-point strided arrays based on the sort order of the first array using insertion sort.
```javascript
var Float32Array = require( '@stdlib/array/float32' );
@@ -54,11 +54,11 @@ The function has the following parameters:
- **N**: number of indexed elements.
- **order**: sort order. If `order < 0.0`, the input strided array `x` is sorted in **decreasing** order. If `order > 0.0`, the input strided array `x` is sorted in **increasing** order. If `order == 0.0`, the input strided arrays are left unchanged.
- **x**: first input [`Float32Array`][@stdlib/array/float32].
-- **strideX**: `x` index increment.
+- **strideX**: stride length for `x`.
- **y**: second input [`Float32Array`][@stdlib/array/float32].
-- **strideY**: `y` index increment.
+- **strideY**: stride length for `y`.
-The `N` and `stride` parameters determine which elements in the strided arrays are accessed at runtime. For example, to sort every other element
+The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to sort every other element:
```javascript
var Float32Array = require( '@stdlib/array/float32' );
@@ -118,10 +118,10 @@ console.log( y );
The function has the following additional parameters:
-- **offsetX**: `x` starting index.
-- **offsetY**: `y` starting index.
+- **offsetX**: starting index for `x`.
+- **offsetY**: starting index for `y`.
-While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x`.
+While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to access only the last three elements:
```javascript
var Float32Array = require( '@stdlib/array/float32' );
@@ -165,30 +165,16 @@ console.log( y );
```javascript
-var round = require( '@stdlib/math/base/special/round' );
-var randu = require( '@stdlib/random/base/randu' );
-var Float32Array = require( '@stdlib/array/float32' );
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var ssort2ins = require( '@stdlib/blas/ext/base/ssort2ins' );
-var rand;
-var sign;
-var x;
-var y;
-var i;
-
-x = new Float32Array( 10 );
-y = new Float32Array( 10 ); // index array
-for ( i = 0; i < x.length; i++ ) {
- rand = round( randu()*100.0 );
- sign = randu();
- if ( sign < 0.5 ) {
- sign = -1.0;
- } else {
- sign = 1.0;
- }
- x[ i ] = sign * rand;
- y[ i ] = i;
-}
+var x = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float32'
+});
+var y = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float32'
+});
+
console.log( x );
console.log( y );
@@ -207,6 +193,137 @@ console.log( y );
* * *
+
+
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/ext/base/ssort2ins.h"
+```
+
+#### stdlib_strided_ssort2ins( N, order, \*X, strideX, \*Y, strideY )
+
+Simultaneously sorts two single-precision floating-point strided arrays based on the sort order of the first array using insertion sort.
+
+```c
+float x[] = { 1.0f, -2.0f, 3.0f, -4.0f };
+float y[] = { 0.0f, 1.0f, 2.0f, 3.0f };
+
+stdlib_strided_ssort2ins( 4, 1.0f, x, 1, y, 1 );
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **order**: `[in] float` sort order. If `order < 0.0`, the input strided array `x` is sorted in **decreasing** order. If `order > 0.0`, the input strided array `x` is sorted in **increasing** order. If `order == 0.0`, the input strided arrays are left unchanged.
+- **X**: `[inout] float*` first input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **Y**: `[inout] float*` second input array.
+- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
+
+```c
+stdlib_strided_ssort2ins( const CBLAS_INT N, const float order, float *X, CBLAS_INT strideX, float *Y, CBLAS_INT strideY );
+```
+
+
+
+#### stdlib_strided_ssort2ins_ndarray( N, order, \*X, strideX, offsetX, \*Y, strideY, offsetY )
+
+
+
+Simultaneously sorts two single-precision floating-point strided arrays based on the sort order of the first array using insertion sort and alternative indexing semantics.
+
+```c
+float x[] = { 1.0f, -2.0f, 3.0f, -4.0f };
+float y[] = { 0.0f, 1.0f, 2.0f, 3.0f };
+
+stdlib_strided_ssort2ins_ndarray( 4, 1.0f, x, 1, 0, y, 1, 0 );
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **order**: `[in] float` sort order. If `order < 0.0`, the input strided array `x` is sorted in **decreasing** order. If `order > 0.0`, the input strided array `x` is sorted in **increasing** order. If `order == 0.0`, the input strided arrays are left unchanged.
+- **X**: `[inout] float*` first input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+- **Y**: `[inout] float*` second input array.
+- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
+- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
+
+```c
+stdlib_strided_ssort2ins_ndarray( const CBLAS_INT N, const float order, float *X, CBLAS_INT strideX, CBLAS_INT offsetX, float *Y, CBLAS_INT strideY, CBLAS_INT offsetY );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/blas/ext/base/ssort2ins.h"
+#include
+
+int main( void ) {
+ // Create strided arrays:
+ float x[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f };
+ float y[] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f };
+
+ // Specify the number of elements:
+ int N = 8;
+
+ // Specify the strides:
+ int strideX = 1;
+ int strideY = 1;
+
+ // Sort the arrays:
+ stdlib_strided_ssort2ins( N, 1.0f, x, strideX, y, strideY );
+
+ // Print the result:
+ for ( int i = 0; i < 8; i++ ) {
+ printf( "x[ %i ] = %f\n", i, x[ i ] );
+ printf( "y[ %i ] = %f\n", i, y[ i ] );
+ }
+}
+```
+
+
+
+
+
+
+
+
+
## See Also
- [`@stdlib/blas/ext/base/dsort2ins`][@stdlib/blas/ext/base/dsort2ins]: simultaneously sort two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/benchmark/c/Makefile
new file mode 100644
index 000000000000..88c218ce50fa
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/benchmark/c/Makefile
@@ -0,0 +1,146 @@
+#/
+# @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.
+#/
+
+# VARIABLES #
+
+ifndef VERBOSE
+ QUIET := @
+else
+ QUIET :=
+endif
+
+# Determine the OS ([1][1], [2][2]).
+#
+# [1]: https://en.wikipedia.org/wiki/Uname#Examples
+# [2]: http://stackoverflow.com/a/27776822/2225624
+OS ?= $(shell uname)
+ifneq (, $(findstring MINGW,$(OS)))
+ OS := WINNT
+else
+ifneq (, $(findstring MSYS,$(OS)))
+ OS := WINNT
+else
+ifneq (, $(findstring CYGWIN,$(OS)))
+ OS := WINNT
+else
+ifneq (, $(findstring Windows_NT,$(OS)))
+ OS := WINNT
+endif
+endif
+endif
+endif
+
+# Define the program used for compiling C source files:
+ifdef C_COMPILER
+ CC := $(C_COMPILER)
+else
+ CC := gcc
+endif
+
+# Define the command-line options when compiling C files:
+CFLAGS ?= \
+ -std=c99 \
+ -O3 \
+ -Wall \
+ -pedantic
+
+# Determine whether to generate position independent code ([1][1], [2][2]).
+#
+# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options
+# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option
+ifeq ($(OS), WINNT)
+ fPIC ?=
+else
+ fPIC ?= -fPIC
+endif
+
+# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`):
+INCLUDE ?=
+
+# List of source files:
+SOURCE_FILES ?=
+
+# List of libraries (e.g., `-lopenblas -lpthread`):
+LIBRARIES ?=
+
+# List of library paths (e.g., `-L /foo/bar -L /beep/boop`):
+LIBPATH ?=
+
+# List of C targets:
+c_targets := benchmark.unsorted_random.length.out
+
+
+# RULES #
+
+#/
+# Compiles source files.
+#
+# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
+# @param {string} [CFLAGS] - C compiler options
+# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
+# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`)
+# @param {string} [SOURCE_FILES] - list of source files
+# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
+# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`)
+#
+# @example
+# make
+#
+# @example
+# make all
+#/
+all: $(c_targets)
+
+.PHONY: all
+
+#/
+# Compiles C source files.
+#
+# @private
+# @param {string} CC - C compiler (e.g., `gcc`)
+# @param {string} CFLAGS - C compiler options
+# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
+# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`)
+# @param {string} SOURCE_FILES - list of source files
+# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`)
+# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`)
+#/
+$(c_targets): %.out: %.c
+ $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)
+
+#/
+# Runs compiled benchmarks.
+#
+# @example
+# make run
+#/
+run: $(c_targets)
+ $(QUIET) ./$<
+
+.PHONY: run
+
+#/
+# Removes generated files.
+#
+# @example
+# make clean
+#/
+clean:
+ $(QUIET) -rm -f *.o *.out
+
+.PHONY: clean
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/benchmark/c/benchmark.unsorted_random.length.c b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/benchmark/c/benchmark.unsorted_random.length.c
new file mode 100644
index 000000000000..4babb3d30dc3
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/benchmark/c/benchmark.unsorted_random.length.c
@@ -0,0 +1,203 @@
+/**
+* @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.
+*/
+
+#include "stdlib/blas/ext/base/ssort2ins.h"
+#include
+#include
+#include
+#include
+#include
+
+#define NAME "ssort2ins"
+#define ITERATIONS 10000000
+#define REPEATS 3
+#define MIN 1
+#define MAX 6
+
+/**
+* Prints the TAP version.
+*/
+static void print_version( void ) {
+ printf( "TAP version 13\n" );
+}
+
+/**
+* Prints the TAP summary.
+*
+* @param total total number of tests
+* @param passing total number of passing tests
+*/
+static void print_summary( int total, int passing ) {
+ printf( "#\n" );
+ printf( "1..%d\n", total ); // TAP plan
+ printf( "# total %d\n", total );
+ printf( "# pass %d\n", passing );
+ printf( "#\n" );
+ printf( "# ok\n" );
+}
+
+/**
+* Prints benchmarks results.
+*
+* @param iterations number of iterations
+* @param elapsed elapsed time in seconds
+*/
+static void print_results( int iterations, double elapsed ) {
+ double rate = (double)iterations / elapsed;
+ printf( " ---\n" );
+ printf( " iterations: %d\n", iterations );
+ printf( " elapsed: %0.9f\n", elapsed );
+ printf( " rate: %0.9f\n", rate );
+ printf( " ...\n" );
+}
+
+/**
+* Returns a clock time.
+*
+* @return clock time
+*/
+static double tic( void ) {
+ struct timeval now;
+ gettimeofday( &now, NULL );
+ return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
+}
+
+/**
+* Generates a random number on the interval [0,1).
+*
+* @return random number
+*/
+static double rand_float( void ) {
+ int r = rand();
+ return (float)r / ( (float)RAND_MAX + 1.0f );
+}
+
+/**
+* Runs a benchmark.
+*
+* @param iterations number of iterations
+* @param len array length
+* @return elapsed time in seconds
+*/
+static double benchmark1( int iterations, int len ) {
+ double elapsed;
+ double t;
+ float *x;
+ float *y;
+ int i;
+
+ x = (float *)malloc( len * sizeof(float) );
+ y = (float *)malloc( len * sizeof(float) );
+ for ( i = 0; i < len; i++ ) {
+ x[ i ] = ( rand_float()*20.0f ) - 10.0f;
+ y[ i ] = ( rand_float()*20.0f ) - 10.0f;
+ }
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ stdlib_strided_ssort2ins( len, 1.0f, x, 1, y, 1 );
+ if ( y[ 0 ] != y[ 0 ] ) {
+ printf( "should not return NaN\n" );
+ break;
+ }
+ }
+ elapsed = tic() - t;
+ if ( y[ 0 ] != y[ 0 ] ) {
+ printf( "should not return NaN\n" );
+ }
+ free( x );
+ free( y );
+ return elapsed;
+}
+
+/**
+* Runs a benchmark.
+*
+* @param iterations number of iterations
+* @param len array length
+* @return elapsed time in seconds
+*/
+static double benchmark2( int iterations, int len ) {
+ double elapsed;
+ double t;
+ float *x;
+ float *y;
+ int i;
+
+ x = (float *)malloc( len * sizeof(float) );
+ y = (float *)malloc( len * sizeof(float) );
+ for ( i = 0; i < len; i++ ) {
+ x[ i ] = ( rand_float()*20.0f ) - 10.0f;
+ y[ i ] = ( rand_float()*20.0f ) - 10.0f;
+ }
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ stdlib_strided_ssort2ins_ndarray( len, 1.0f, x, 1, 0, y, 1, 0 );
+ if ( y[ 0 ] != y[ 0 ] ) {
+ printf( "should not return NaN\n" );
+ break;
+ }
+ }
+ elapsed = tic() - t;
+ if ( y[ 0 ] != y[ 0 ] ) {
+ printf( "should not return NaN\n" );
+ }
+ free( x );
+ free( y );
+ return elapsed;
+}
+
+/**
+* Main execution sequence.
+*/
+int main( void ) {
+ double elapsed;
+ int count;
+ int iter;
+ int len;
+ int i;
+ int j;
+
+ // Use the current time to seed the random number generator:
+ srand( time( NULL ) );
+
+ print_version();
+ count = 0;
+ for ( i = MIN; i <= MAX; i++ ) {
+ len = pow( 10, i );
+ iter = ITERATIONS / pow( 10, i-1 );
+ for ( j = 0; j < REPEATS; j++ ) {
+ count += 1;
+ printf( "# c::%s:unsorted,random:len=%d\n", NAME, len );
+ elapsed = benchmark1( iter, len );
+ print_results( iter, elapsed );
+ printf( "ok %d benchmark finished\n", count );
+ }
+ }
+ for ( i = MIN; i <= MAX; i++ ) {
+ len = pow( 10, i );
+ iter = ITERATIONS / pow( 10, i-1 );
+ for ( j = 0; j < REPEATS; j++ ) {
+ count += 1;
+ printf( "# c::%s:ndarray:unsorted,random:len=%d\n", NAME, len );
+ elapsed = benchmark2( iter, len );
+ print_results( iter, elapsed );
+ printf( "ok %d benchmark finished\n", count );
+ }
+ }
+ print_summary( count, count );
+}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/docs/repl.txt
index 846f02d70ca1..fe9ac86ae1b6 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/docs/repl.txt
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/docs/repl.txt
@@ -3,8 +3,8 @@
Simultaneously sorts two single-precision floating-point strided arrays
based on the sort order of the first array using insertion sort.
- The `N` and stride parameters determine which elements in the strided
- arrays are accessed at runtime.
+ The `N` and stride parameters determine which elements in the strided arrays
+ are accessed at runtime.
Indexing is relative to the first index. To introduce an offset, use typed
array views.
@@ -47,13 +47,13 @@
First input array.
strideX: integer
- Index increment for `x`.
+ Stride length for `x`.
y: Float32Array
Second input array.
strideY: integer
- Index increment for `y`.
+ Stride length for `y`.
Returns
-------
@@ -97,8 +97,8 @@
alternative indexing semantics.
While typed array views mandate a view offset based on the underlying
- buffer, the offset parameter supports indexing semantics based on a
- starting index.
+ buffer, the offset parameters support indexing semantics based on starting
+ indices.
Parameters
----------
@@ -113,19 +113,19 @@
First input array.
strideX: integer
- Index increment for `x`.
+ Stride length for `x`.
offsetX: integer
- Starting index of `x`.
+ Starting index for `x`.
y: Float32Array
Second input array.
strideY: integer
- Index increment for `y`.
+ Stride length for `y`.
offsetY: integer
- Starting index of `y`.
+ Starting index for `y`.
Returns
-------
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/docs/types/index.d.ts
index 7483cac46674..d9ac58d6080a 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/docs/types/index.d.ts
@@ -28,9 +28,9 @@ interface Routine {
* @param N - number of indexed elements
* @param order - sort order
* @param x - first input array
- * @param strideX - `x` stride length
+ * @param strideX - stride length for `x`
* @param y - second input array
- * @param strideY - `y` stride length
+ * @param strideY - stride length for `y`
* @returns first input array
*
* @example
@@ -55,11 +55,11 @@ interface Routine {
* @param N - number of indexed elements
* @param order - sort order
* @param x - first input array
- * @param strideX - `x` stride length
- * @param offsetX - `x` starting index
+ * @param strideX - stride length for `x`
+ * @param offsetX - starting index for `x`
* @param y - second input array
- * @param strideY - `y` stride length
- * @param offsetY - `y` starting index
+ * @param strideY - stride length for `y`
+ * @param offsetY - starting index for `y`
* @returns first input array
*
* @example
@@ -85,9 +85,9 @@ interface Routine {
* @param N - number of indexed elements
* @param order - sort order
* @param x - first input array
-* @param strideX - `x` stride length
+* @param strideX - stride length for `x`
* @param y - second input array
-* @param strideY - `y` stride length
+* @param strideY - stride length for `y`
* @returns first input array
*
* @example
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/examples/c/example.c
index f66e8c59235c..384c12e7adc8 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/examples/c/example.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/examples/c/example.c
@@ -18,12 +18,11 @@
#include "stdlib/blas/ext/base/ssort2ins.h"
#include
-#include
int main( void ) {
// Create strided arrays:
- float x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 };
- float y[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
+ float x[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f };
+ float y[] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f };
// Specify the number of elements:
int N = 8;
@@ -33,12 +32,12 @@ int main( void ) {
int strideY = 1;
// Sort the arrays:
- c_ssort2ins( N, 1.0f, x, strideX, y, strideY );
+ stdlib_strided_ssort2ins( N, 1.0f, x, strideX, y, strideY );
// Print the result:
for ( int i = 0; i < 8; i++ ) {
printf( "x[ %i ] = %f\n", i, x[ i ] );
- printf( "y[ %i ] = %"PRId64"\n", i, (int64_t)y[ i ] );
+ printf( "y[ %i ] = %f\n", i, y[ i ] );
}
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/examples/index.js
index 668d48895f2e..c39a1fa4e4bb 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/examples/index.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/examples/index.js
@@ -18,14 +18,17 @@
'use strict';
-var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
-var filledarrayBy = require( '@stdlib/array/filled-by' );
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var ssort2ins = require( './../lib' );
-var x = filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) );
-console.log( x );
+var x = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float32'
+});
+var y = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float32'
+});
-var y = filledarrayBy( x.length, 'float32', discreteUniform( 0, 10 ) );
+console.log( x );
console.log( y );
ssort2ins( x.length, -1.0, x, -1, y, -1 );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/include/stdlib/blas/ext/base/ssort2ins.h b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/include/stdlib/blas/ext/base/ssort2ins.h
index d4f8cd85d136..db94ab5a6e33 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/include/stdlib/blas/ext/base/ssort2ins.h
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/include/stdlib/blas/ext/base/ssort2ins.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_BLAS_EXT_BASE_SSORT2INS_H
#define STDLIB_BLAS_EXT_BASE_SSORT2INS_H
-#include
+#include "stdlib/blas/base/shared.h"
/*
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
@@ -31,7 +31,12 @@ extern "C" {
/**
* Simultaneously sorts two single-precision floating-point strided arrays based on the sort order of the first array using insertion sort.
*/
-void c_ssort2ins( const int64_t N, const float order, float *X, const int64_t strideX, float *Y, const int64_t strideY );
+void API_SUFFIX(stdlib_strided_ssort2ins)( const CBLAS_INT N, const float order, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY );
+
+/**
+* Simultaneously sorts two single-precision floating-point strided arrays based on the sort order of the first array using insertion sort and alternative indexing semantics.
+*/
+void API_SUFFIX(stdlib_strided_ssort2ins_ndarray)( const CBLAS_INT N, const float order, float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, float *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ndarray.js
index 0f344263a6cf..35e53b3ed785 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ndarray.js
@@ -32,11 +32,11 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} order - sort order
* @param {Float32Array} x - first input array
-* @param {integer} strideX - `x` index increment
-* @param {NonNegativeInteger} offsetX - `x` starting index
+* @param {integer} strideX - stride length for `x`
+* @param {NonNegativeInteger} offsetX - starting index for `x`
* @param {Float32Array} y - second input array
-* @param {integer} strideY - `y` index increment
-* @param {NonNegativeInteger} offsetY - `y` starting index
+* @param {integer} strideY - stride length for `y`
+* @param {NonNegativeInteger} offsetY - starting index for `y`
* @returns {Float32Array} `x`
*
* @example
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ndarray.native.js
index 100c8e2d4e3c..9c24287ff6ad 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ndarray.native.js
@@ -20,9 +20,7 @@
// MODULES //
-var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' );
-var offsetView = require( '@stdlib/strided/base/offset-view' );
-var addon = require( './ssort2ins.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -33,11 +31,11 @@ var addon = require( './ssort2ins.native.js' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} order - sort order
* @param {Float32Array} x - first input array
-* @param {integer} strideX - `x` index increment
-* @param {NonNegativeInteger} offsetX - `x` starting index
+* @param {integer} strideX - stride length for `y`
+* @param {NonNegativeInteger} offsetX - starting index for `x`
* @param {Float32Array} y - second input array
-* @param {integer} strideY - `y` index increment
-* @param {NonNegativeInteger} offsetY - `y` starting index
+* @param {integer} strideY - stride length for `y`
+* @param {NonNegativeInteger} offsetY - starting index for `y`
* @returns {Float32Array} `x`
*
* @example
@@ -55,22 +53,7 @@ var addon = require( './ssort2ins.native.js' );
* // => [ 3.0, 1.0, 0.0, 2.0 ]
*/
function ssort2ins( N, order, x, strideX, offsetX, y, strideY, offsetY ) {
- var viewX;
- var viewY;
- var flg = 1.0;
-
- offsetX = minViewBufferIndex( N, strideX, offsetX );
- offsetY = minViewBufferIndex( N, strideY, offsetY );
- if ( strideX < 0 ) {
- flg *= -1.0; // reversing order
- order *= -1.0;
- strideX *= -1;
- }
-
- viewX = offsetView( x, offsetX );
- viewY = offsetView( y, offsetY );
-
- addon( N, order, viewX, strideX, viewY, flg*strideY );
+ addon.ndarray( N, order, x, strideX, offsetX, y, strideY, offsetY );
return x;
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ssort2ins.js b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ssort2ins.js
index 3fe9927a3647..77b4d921fb44 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ssort2ins.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ssort2ins.js
@@ -20,8 +20,8 @@
// MODULES //
-var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' );
-var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -32,9 +32,9 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} order - sort order
* @param {Float32Array} x - first input array
-* @param {integer} strideX - `x` index increment
+* @param {integer} strideX - stride length for `x`
* @param {Float32Array} y - second input array
-* @param {integer} strideY - `y` index increment
+* @param {integer} strideY - stride length for `y`
* @returns {Float32Array} `x`
*
* @example
@@ -52,135 +52,7 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
* // => [ 3.0, 1.0, 0.0, 2.0 ]
*/
function ssort2ins( N, order, x, strideX, y, strideY ) {
- var flg;
- var ix;
- var jx;
- var fx;
- var lx;
- var iy;
- var jy;
- var fy;
- var ly;
- var vx;
- var vy;
- var ux;
- var i;
-
- if ( N <= 0 || order === 0.0 ) {
- return x;
- }
- // For a positive stride, sorting in decreasing order is equivalent to providing a negative stride and sorting in increasing order, and, for a negative stride, sorting in decreasing order is equivalent to providing a positive stride and sorting in increasing order...
- if ( order < 0.0 ) {
- strideX *= -1;
- strideY *= -1;
- }
- if ( strideY < 0 ) {
- fy = (1-N) * strideY;
- ly = 0;
- } else {
- fy = 0;
- ly = (N-1) * strideY;
- }
- iy = fy + strideY;
-
- if ( strideX < 0 ) {
- // Traverse the strided array from right-to-left...
- fx = (1-N) * strideX; // first index
- lx = 0; // last index
- ix = fx + strideX;
-
- // Sort in increasing order...
- for ( i = 1; i < N; i++ ) {
- vx = x[ ix ];
- vy = y[ iy ];
-
- // Sort `NaN` values to the end (i.e., the left)...
- if ( isnanf( vx ) ) {
- jx = ix;
- jy = iy;
-
- // Shift all values (including NaNs) to the left of the current element to the right...
- while ( jx > lx ) {
- x[ jx ] = x[ jx+strideX ];
- y[ jy ] = y[ jy+strideY ];
- jx += strideX;
- jy += strideY;
- }
- x[ lx ] = vx;
- y[ ly ] = vy;
- } else {
- flg = isNegativeZerof( vx );
- jx = ix - strideX;
- jy = iy - strideY;
-
- // Shift all larger values to the right of the current element to the left...
- while ( jx <= fx ) {
- ux = x[ jx ];
- if ( ux <= vx && !(flg && ux === vx && isNegativeZerof( ux ) === false) ) { // eslint-disable-line max-len
- // Note: positive zeros (and NaNs (e.g., when last element is NaN)) are sorted to the left
- break;
- }
- x[ jx+strideX ] = ux;
- y[ jy+strideY ] = y[ jy ];
- jx -= strideX;
- jy -= strideY;
- }
- x[ jx+strideX ] = vx;
- y[ jy+strideY ] = vy;
- ix += strideX;
- iy += strideY;
- }
- }
- return x;
- }
- // Traverse the strided array from left-to-right...
- fx = 0; // first index
- lx = (N-1) * strideX; // last index
- ix = fx + strideX;
-
- // Sort in increasing order...
- for ( i = 1; i < N; i++ ) {
- vx = x[ ix ];
- vy = y[ iy ];
-
- // Sort `NaN` values to the end...
- if ( isnanf( vx ) ) {
- jx = ix;
- jy = iy;
-
- // Shift all values (including NaNs) to the right of the current element to the left...
- while ( jx < lx ) {
- x[ jx ] = x[ jx+strideX ];
- y[ jy ] = y[ jy+strideY ];
- jx += strideX;
- jy += strideY;
- }
- x[ lx ] = vx;
- y[ ly ] = vy;
- } else {
- flg = isNegativeZerof( vx );
- jx = ix - strideX;
- jy = iy - strideY;
-
- // Shift all larger values to the left of the current element to the right...
- while ( jx >= fx ) {
- ux = x[ jx ];
- if ( ux <= vx && !(flg && ux === vx && isNegativeZerof( ux ) === false) ) { // eslint-disable-line max-len
- // Note: positive zeros (and NaNs (e.g., when first element is NaN)) are sorted to the right
- break;
- }
- x[ jx+strideX ] = ux;
- y[ jy+strideY ] = y[ jy ];
- jx -= strideX;
- jy -= strideY;
- }
- x[ jx+strideX ] = vx;
- y[ jy+strideY ] = vy;
- ix += strideX;
- iy += strideY;
- }
- }
- return x;
+ return ndarray( N, order, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ) ); // eslint-disable-line max-len
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ssort2ins.native.js b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ssort2ins.native.js
index 1adcd11dc5ee..d75baba26ca5 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ssort2ins.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/lib/ssort2ins.native.js
@@ -31,9 +31,9 @@ var addon = require( './../src/addon.node' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} order - sort order
* @param {Float32Array} x - first input array
-* @param {integer} strideX - `x` index increment
+* @param {integer} strideX - stride length for `x`
* @param {Float32Array} y - second input array
-* @param {integer} strideY - `y` index increment
+* @param {integer} strideY - stride length for `y`
* @returns {Float32Array} `x`
*
* @example
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/manifest.json
index e73e72a8f4a2..0b3fc6abb88b 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/manifest.json
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/manifest.json
@@ -28,57 +28,57 @@
{
"task": "build",
"src": [
- "./src/ssort2ins.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
+ "@stdlib/math/base/assert/is-nanf",
+ "@stdlib/math/base/assert/is-negative-zerof",
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/blas/base/shared",
"@stdlib/napi/export",
"@stdlib/napi/argv",
- "@stdlib/napi/argv-int64",
"@stdlib/napi/argv-float",
- "@stdlib/napi/argv-strided-float32array",
- "@stdlib/math/base/assert/is-nanf",
- "@stdlib/math/base/assert/is-negative-zerof"
+ "@stdlib/napi/argv-int64",
+ "@stdlib/napi/argv-strided-float32array"
]
},
{
"task": "benchmark",
"src": [
- "./src/ssort2ins.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nanf",
- "@stdlib/math/base/assert/is-negative-zerof"
+ "@stdlib/math/base/assert/is-negative-zerof",
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/blas/base/shared"
]
},
{
"task": "examples",
"src": [
- "./src/ssort2ins.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nanf",
- "@stdlib/math/base/assert/is-negative-zerof"
+ "@stdlib/math/base/assert/is-negative-zerof",
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/blas/base/shared"
]
}
]
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/addon.c
index c8207f3b83de..c523c3c2b60d 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/addon.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/addon.c
@@ -17,10 +17,11 @@
*/
#include "stdlib/blas/ext/base/ssort2ins.h"
+#include "stdlib/blas/base/shared.h"
#include "stdlib/napi/export.h"
#include "stdlib/napi/argv.h"
#include "stdlib/napi/argv_int64.h"
-#include "stdlib/napi/argv_double.h"
+#include "stdlib/napi/argv_float.h"
#include "stdlib/napi/argv_strided_float32array.h"
#include
@@ -39,9 +40,29 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 4 );
- c_ssort2ins( N, order, X, strideX, Y, strideY );
+ API_SUFFIX(stdlib_strided_ssort2ins)( N, order, X, strideX, Y, strideY );
return NULL;
}
-STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
+/**
+* Receives JavaScript callback invocation data.
+*
+* @param env environment under which the function is invoked
+* @param info callback data
+* @return Node-API value
+*/
+static napi_value addon_method( napi_env env, napi_callback_info info ) {
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 8 );
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
+ STDLIB_NAPI_ARGV_FLOAT( env, order, argv, 1 );
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
+ STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 );
+ STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 6 );
+ STDLIB_NAPI_ARGV_INT64( env, offsetY, argv, 7 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 2 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, Y, N, strideY, argv, 5 );
+ API_SUFFIX(stdlib_strided_ssort2ins_ndarray)( N, order, X, strideX, offsetX, Y, strideY, offsetY );
+ return NULL;
+}
+STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/ssort2ins.c b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/main.c
similarity index 67%
rename from lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/ssort2ins.c
rename to lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/main.c
index 37c7ce2608a1..0516027f1480 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/ssort2ins.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/ssort2ins/src/main.c
@@ -1,7 +1,7 @@
/**
* @license Apache-2.0
*
-* Copyright (c) 2020 The Stdlib Authors.
+* 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.
@@ -19,7 +19,8 @@
#include "stdlib/blas/ext/base/ssort2ins.h"
#include "stdlib/math/base/assert/is_negative_zerof.h"
#include "stdlib/math/base/assert/is_nanf.h"
-#include
+#include "stdlib/strided/base/stride2offset.h"
+#include "stdlib/blas/base/shared.h"
#include
/**
@@ -28,22 +29,43 @@
* @param N number of indexed elements
* @param order sort order
* @param X first input array
-* @param strideX `X` index increment
+* @param strideX stride length for `X`
* @param Y second input array
-* @param strideY `Y` index increment
+* @param strideY stride length for `Y`
*/
-void c_ssort2ins( const int64_t N, const float order, float *X, const int64_t strideX, float *Y, const int64_t strideY ) {
- int64_t sx;
- int64_t sy;
- int64_t ix;
- int64_t jx;
- int64_t fx;
- int64_t lx;
- int64_t iy;
- int64_t jy;
- int64_t fy;
- int64_t ly;
- int64_t i;
+void API_SUFFIX(stdlib_strided_ssort2ins)( const CBLAS_INT N, const float order, float *X, const CBLAS_INT strideX, float *Y, const CBLAS_INT strideY ) {
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY );
+ API_SUFFIX(stdlib_strided_ssort2ins_ndarray)( N, order, X, strideX, ox, Y, strideY, oy );
+}
+
+
+/**
+* Simultaneously sorts two signle-precision floating-point strided arrays based on the sort order of the first array using insertion sort and alternative indexing semantics.
+*
+* @param N number of indexed elements
+* @param order sort order
+* @param X first input array
+* @param strideX stride length for `X`
+* @param offsetX starting index for `X`
+* @param Y second input array
+* @param strideY stride length for `Y`
+* @param offsetY starting index for `Y`
+*/
+void API_SUFFIX(stdlib_strided_ssort2ins_ndarray)( const CBLAS_INT N, const float order, float *X, CBLAS_INT strideX, CBLAS_INT offsetX, float *Y, CBLAS_INT strideY, CBLAS_INT offsetY ) {
+ CBLAS_INT sx;
+ CBLAS_INT sy;
+ CBLAS_INT ox;
+ CBLAS_INT oy;
+ CBLAS_INT ix;
+ CBLAS_INT jx;
+ CBLAS_INT fx;
+ CBLAS_INT lx;
+ CBLAS_INT iy;
+ CBLAS_INT jy;
+ CBLAS_INT fy;
+ CBLAS_INT ly;
+ CBLAS_INT i;
float vx;
float vy;
float ux;
@@ -54,26 +76,26 @@ void c_ssort2ins( const int64_t N, const float order, float *X, const int64_t st
}
// For a positive stride, sorting in decreasing order is equivalent to providing a negative stride and sorting in increasing order, and, for a negative stride, sorting in decreasing order is equivalent to providing a positive stride and sorting in increasing order...
if ( order < 0.0f ) {
- sx = -strideX;
- sy = -strideY;
+ sx = strideX * -1;
+ sy = strideY * -1;
+ ox = offsetX - ( (N-1) * sx );
+ oy = offsetY - ( (N-1) * sy );
} else {
sx = strideX;
sy = strideY;
+ ox = offsetX;
+ oy = offsetY;
}
- if ( sy < 0 ) {
- fy = (1-N) * sy;
- ly = 0;
- } else {
- fy = 0;
- ly = (N-1) * sy;
- }
+ fx = ox; // first index
+ lx = fx + ( (N-1)*sx ); // last index
+ ix = fx + sx;
+
+ fy = oy; // first index
+ ly = fy + ( (N-1)*sy ); // last index
iy = fy + sy;
if ( sx < 0 ) {
// Traverse the strided array from right-to-left...
- fx = (1-N) * sx; // first index
- lx = 0; // last index
- ix = fx + sx;
// Sort in increasing order...
for ( i = 1; i < N; i++ ) {
@@ -120,9 +142,6 @@ void c_ssort2ins( const int64_t N, const float order, float *X, const int64_t st
return;
}
// Traverse the strided array from left-to-right...
- fx = 0; // first index
- lx = (N-1) * sx; // last index
- ix = fx + sx;
// Sort in increasing order...
for ( i = 1; i < N; i++ ) {