diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/README.md b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/README.md
index 7594cda0311c..fa8189d856e4 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/README.md
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/README.md
@@ -32,7 +32,7 @@ var dsort2sh = require( '@stdlib/blas/ext/base/dsort2sh' );
#### dsort2sh( N, order, x, strideX, y, strideY )
-Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array `x` using Shellsort.
+Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using Shellsort.
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -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 [`Float64Array`][@stdlib/array/float64].
-- **strideX**: `x` index increment.
+- **strideX**: `x` stride length.
- **y**: second input [`Float64Array`][@stdlib/array/float64].
-- **strideY**: `y` index increment.
+- **strideY**: `y` stride length.
-The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to sort every other element
+The `N` and stride parameters determine which elements in `x` and `y` are accessed at runtime. For example, to sort every other element:
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -100,7 +100,7 @@ console.log( y0 );
#### dsort2sh.ndarray( N, order, x, strideX, offsetX, y, strideY, offsetY )
-Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array `x` using Shellsort and alternative indexing semantics.
+Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using Shellsort and alternative indexing semantics.
```javascript
var Float64Array = require( '@stdlib/array/float64' );
@@ -122,7 +122,7 @@ The function has the following additional parameters:
- **offsetX**: `x` starting index.
- **offsetY**: `y` starting index.
-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 Float64Array = require( '@stdlib/array/float64' );
@@ -166,30 +166,15 @@ console.log( y );
```javascript
-var round = require( '@stdlib/math/base/special/round' );
-var randu = require( '@stdlib/random/base/randu' );
-var Float64Array = require( '@stdlib/array/float64' );
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var dsort2sh = require( '@stdlib/blas/ext/base/dsort2sh' );
-var rand;
-var sign;
-var x;
-var y;
-var i;
-
-x = new Float64Array( 10 );
-y = new Float64Array( 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': 'float64'
+});
+var y = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float64'
+});
console.log( x );
console.log( y );
@@ -212,6 +197,131 @@ console.log( y );
- Sedgewick, Robert. 1986. "A new upper bound for Shellsort." _Journal of Algorithms_ 7 (2): 159–73. doi:[10.1016/0196-6774(86)90001-5][@sedgewick:1986a].
- Ciura, Marcin. 2001. "Best Increments for the Average Case of Shellsort." In _Fundamentals of Computation Theory_, 106–17. Springer Berlin Heidelberg. doi:[10.1007/3-540-44669-9_12][@ciura:2001a].
+
+
+## C APIs
+
+
+
+
+
+
+
+
+
+
+
+### Usage
+
+```c
+#include "stdlib/blas/ext/base/dsort2sh.h"
+```
+
+#### stdlib_strided_dsort2sh( N, order, \*X, strideX, \*Y, strideY )
+
+Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using Shellsort.
+
+```c
+double x[] = { 1.0, -2.0, 3.0, -4.0 };
+double y[] = { 0.0, 1.0, 2.0, 3.0 };
+
+stdlib_strided_dsort2sh( 4, 1, x, 1, y, 1 );
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **order**: `[in] CBLAS_INT` 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] double*` input array.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **Y**: `[inout] double*` input array.
+- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
+
+```c
+stdlib_strided_dsort2sh( const CBLAS_INT N, const CBLAS_INT order, double *X, CBLAS_INT strideX, double *Y, CBLAS_INT strideY );
+```
+
+
+
+#### stdlib_strided_dsort2sh_ndarray( N, order, \*X, strideX, offsetX, \*Y, strideY, offsetY )
+
+
+
+Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using Shellsort and alternative indexing semantics.
+
+```c
+double x[] = { 1.0, -2.0, 3.0, -4.0 };
+double y[] = { 0.0, 1.0, 2.0, 3.0 };
+
+stdlib_strided_dsort2sh_ndarray( 4, 1, x, 1, 0, y, 1, 0 );
+```
+
+The function accepts the following arguments:
+
+- **N**: `[in] CBLAS_INT` number of indexed elements.
+- **order**: `[in] CBLAS_INT` sort order.
+- **X**: `[inout] double*` input array. 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.
+- **strideX**: `[in] CBLAS_INT` stride length for `X`.
+- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
+- **Y**: `[inout] double*` input array.
+- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
+- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
+
+```c
+stdlib_strided_dsort2sh_ndarray( const CBLAS_INT N, const CBLAS_INT order, double *X, CBLAS_INT strideX, CBLAS_INT offsetX, double *Y, CBLAS_INT strideY, CBLAS_INT offsetY );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+### Examples
+
+```c
+#include "stdlib/blas/ext/base/dsort2sh.h"
+#include
+
+int main( void ) {
+ // Create strided arrays:
+ double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 };
+ double y[] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 };
+
+ // Specify the number of elements:
+ int N = 8;
+
+ // Specify the strides:
+ int strideX = 1;
+ int strideY = 1;
+
+ // Sort the arrays:
+ stdlib_strided_dsort2sh( N, 1.0, x, strideX, y, strideY );
+
+ // Print the result:
+ for ( int i = 0; i < 8; i++ ) {
+ printf( "x[ %i ] = %lf\n", i, x[ i ] );
+ printf( "y[ %i ] = %lf\n", i, y[ i ] );
+ }
+}
+```
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/benchmark/c/Makefile
new file mode 100644
index 000000000000..25ced822f96a
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/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 := example.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 examples.
+#
+# @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/dsort2sh/benchmark/c/benchmark.unsorted_random.length.c b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/benchmark/c/benchmark.unsorted_random.length.c
new file mode 100644
index 000000000000..292f4095d25f
--- /dev/null
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/benchmark/c/benchmark.unsorted_random.length.c
@@ -0,0 +1,195 @@
+/**
+* @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/dsort2sh.h"
+#include
+#include
+#include
+#include
+#include
+
+#define NAME "dsort2sh"
+#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_double( void ) {
+ int r = rand();
+ return (double)r / ( (double)RAND_MAX + 1.0 );
+}
+
+/**
+* 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 x[ len ];
+ double y[ len ];
+ double t;
+ int i;
+
+ for ( i = 0; i < len; i++ ) {
+ x[ i ] = ( rand_double()*20.0 ) - 10.0;
+ y[ i ] = ( rand_double()*20.0 ) - 10.0;
+ }
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ stdlib_strided_dsort2sh( len, 1, 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" );
+ }
+ 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 x[ len ];
+ double y[ len ];
+ double t;
+ int i;
+
+ for ( i = 0; i < len; i++ ) {
+ x[ i ] = ( rand_double()*20.0 ) - 10.0;
+ y[ i ] = ( rand_double()*20.0 ) - 10.0;
+ }
+ t = tic();
+ for ( i = 0; i < iterations; i++ ) {
+ stdlib_strided_dsort2sh_ndarray( len, 1, 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" );
+ }
+ 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/dsort2sh/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/docs/repl.txt
index 3d325f6b0139..fb53536e26b7 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/docs/repl.txt
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/docs/repl.txt
@@ -44,18 +44,18 @@
First input array.
strideX: integer
- Index increment for `x`.
+ Stride length for `x`.
y: Float64Array
Second input array.
strideY: integer
- Index increment for `y`.
+ Stride length for `y`.
Returns
-------
x: Float64Array
- Input array `x`.
+ Output Array.
Examples
--------
@@ -81,22 +81,22 @@
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0 ] );
> var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 );
- > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
- > {{alias}}( N, 1, x1, 2, y1, 2 )
+ > {{alias}}( 2, 1, x1, 2, y1, 2 )
[ -4.0, 3.0, -2.0 ]
> x0
[ 1.0, -4.0, 3.0, -2.0 ]
> y0
[ 0.0, 3.0, 2.0, 1.0 ]
+
{{alias}}.ndarray( N, order, x, strideX, offsetX, y, strideY, offsetY )
Simultaneously sorts two double-precision floating-point strided arrays
based on the sort order of the first array using Shellsort and 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
----------
@@ -111,7 +111,7 @@
First input array.
strideX: integer
- Index increment for `x`.
+ Stride length for `x`.
offsetX: integer
Starting index of `x`.
@@ -120,7 +120,7 @@
Second input array.
strideY: integer
- Index increment for `y`.
+ Stride length for `y`.
offsetY: integer
Starting index of `y`.
@@ -128,7 +128,7 @@
Returns
-------
x: Float64Array
- Input array `x`.
+ Output Array.
Examples
--------
@@ -143,8 +143,7 @@
// Using an index offset:
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] );
> y = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0 ] );
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
- > {{alias}}.ndarray( N, 1, x, 2, 1, y, 2, 1 )
+ > {{alias}}.ndarray( 2, 1, x, 2, 1, y, 2, 1 )
[ 1.0, -4.0, 3.0, -2.0 ]
> y
[ 0.0, 3.0, 2.0, 1.0 ]
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/examples/c/example.c
index 3606aa72d3b8..8dd8f3ba788e 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/examples/c/example.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/examples/c/example.c
@@ -18,7 +18,6 @@
#include "stdlib/blas/ext/base/dsort2sh.h"
#include
-#include
int main( void ) {
// Create strided arrays:
@@ -33,11 +32,11 @@ int main( void ) {
int strideY = 1;
// Sort the arrays:
- c_dsort2sh( N, 1.0, x, strideX, y, strideY );
+ stdlib_strided_dsort2sh( N, 1.0, x, strideX, y, strideY );
// Print the result:
for ( int i = 0; i < 8; i++ ) {
printf( "x[ %i ] = %lf\n", i, x[ i ] );
- printf( "y[ %i ] = %"PRId64"\n", i, (int64_t)y[ i ] );
+ printf( "y[ %i ] = %lf\n", i, y[ i ] );
}
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/examples/index.js
index 0373db629a7c..a264de2339bf 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/examples/index.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/examples/index.js
@@ -18,34 +18,15 @@
'use strict';
-var round = require( '@stdlib/math/base/special/round' );
-var randu = require( '@stdlib/random/base/randu' );
-var Float64Array = require( '@stdlib/array/float64' );
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var dsort2sh = require( './../lib' );
-var rand;
-var sign;
-var x;
-var y;
-var i;
-
-x = new Float64Array( 10 );
-y = new Float64Array( 10 ); // index array
-for ( i = 0; i < x.length; i++ ) {
- if ( randu() < 0.2 ) {
- x[ i ] = NaN;
- } else {
- 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': 'float64'
+});
+var y = discreteUniform( 10, -100, 100, {
+ 'dtype': 'float64'
+});
console.log( x );
console.log( y );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/include/stdlib/blas/ext/base/dsort2sh.h b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/include/stdlib/blas/ext/base/dsort2sh.h
index c1a0bc600b6b..37a2e734ae76 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/include/stdlib/blas/ext/base/dsort2sh.h
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/include/stdlib/blas/ext/base/dsort2sh.h
@@ -19,7 +19,7 @@
#ifndef STDLIB_BLAS_EXT_BASE_DSORT2SH_H
#define STDLIB_BLAS_EXT_BASE_DSORT2SH_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 double-precision floating-point strided arrays based on the sort order of the first array using Shellsort.
*/
-void c_dsort2sh( const int64_t N, const double order, double *X, const int64_t strideX, double *Y, const int64_t strideY );
+void API_SUFFIX(stdlib_strided_dsort2sh)( const CBLAS_INT N, const CBLAS_INT order, double *X, CBLAS_INT strideX, double *Y, CBLAS_INT strideY );
+
+/**
+* Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using Shellsort and alternative indexing semantics.
+*/
+void API_SUFFIX(stdlib_strided_dsort2sh_ndarray)( const CBLAS_INT N, const CBLAS_INT order, double *X, CBLAS_INT strideX, CBLAS_INT offsetX, double *Y, CBLAS_INT strideY, CBLAS_INT offsetY );
#ifdef __cplusplus
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/dsort2sh.js b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/dsort2sh.js
index 327614db7af3..19674e3c7b23 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/dsort2sh.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/dsort2sh.js
@@ -20,14 +20,8 @@
// MODULES //
-var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' );
-var isnan = require( '@stdlib/math/base/assert/is-nan' );
-var GAPS = require( './gaps.json' );
-
-
-// VARIABLES //
-
-var NGAPS = GAPS.length;
+var stride2offset = require( '@stdlib/strided/base/stride2offset' );
+var ndarray = require( './ndarray.js' );
// MAIN //
@@ -47,9 +41,9 @@ var NGAPS = GAPS.length;
* @param {PositiveInteger} N - number of indexed elements
* @param {number} order - sort order
* @param {Float64Array} x - first input array
-* @param {integer} strideX - `x` index increment
+* @param {integer} strideX - `x` stride length
* @param {Float64Array} y - second input array
-* @param {integer} strideY - `y` index increment
+* @param {integer} strideY - `y` stride length
* @returns {Float64Array} `x`
*
* @example
@@ -69,59 +63,10 @@ var NGAPS = GAPS.length;
function dsort2sh( N, order, x, strideX, y, strideY ) {
var offsetX;
var offsetY;
- var flg;
- var gap;
- var vx;
- var vy;
- var ux;
- var i;
- var j;
- var k;
-
- 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 ( strideX < 0 ) {
- offsetX = (1-N) * strideX;
- } else {
- offsetX = 0;
- }
- if ( strideY < 0 ) {
- offsetY = (1-N) * strideY;
- } else {
- offsetY = 0;
- }
- for ( i = 0; i < NGAPS; i++ ) {
- gap = GAPS[ i ];
- for ( j = gap; j < N; j++ ) {
- vx = x[ offsetX+(j*strideX) ];
-
- // If `NaN`, the current value is already sorted to its place...
- if ( isnan( vx ) ) {
- continue;
- }
- vy = y[ offsetY+(j*strideY) ];
- // Perform insertion sort on the "gapped" subarray...
- flg = isNegativeZero( vx );
- for ( k = j; k >= gap; k -= gap ) {
- ux = x[ offsetX+((k-gap)*strideX) ];
- if ( ux <= vx && !(flg && ux === vx) ) {
- break;
- }
- x[ offsetX+(k*strideX) ] = ux;
- y[ offsetY+(k*strideY) ] = y[ offsetY+((k-gap)*strideY) ];
- }
- x[ offsetX+(k*strideX) ] = vx;
- y[ offsetY+(k*strideY) ] = vy;
- }
- }
- return x;
+ offsetX = stride2offset( N, strideX );
+ offsetY = stride2offset( N, strideY );
+ return ndarray( N, order, x, strideX, offsetX, y, strideY, offsetY );
}
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/dsort2sh.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/dsort2sh.native.js
index 0a34b608ee7a..f3e54b832ab1 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/dsort2sh.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/dsort2sh.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 {Float64Array} x - first input array
-* @param {integer} strideX - `x` index increment
+* @param {integer} strideX - `x` stride length
* @param {Float64Array} y - second input array
-* @param {integer} strideY - `y` index increment
+* @param {integer} strideY - `y` stride length
* @returns {Float64Array} `x`
*
* @example
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/ndarray.js
index 38db7a1c4f79..b9da0d1e5e71 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/ndarray.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/ndarray.js
@@ -47,10 +47,10 @@ var NGAPS = GAPS.length;
* @param {PositiveInteger} N - number of indexed elements
* @param {number} order - sort order
* @param {Float64Array} x - first input array
-* @param {integer} strideX - `x` index increment
+* @param {integer} strideX - `x` stride length
* @param {NonNegativeInteger} offsetX - `x` starting index
* @param {Float64Array} y - second input array
-* @param {integer} strideY - `y` index increment
+* @param {integer} strideY - `y` stride length
* @param {NonNegativeInteger} offsetY - `y` starting index
* @returns {Float64Array} `x`
*
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/ndarray.native.js
index 3ff32081d74d..bebdfa06cd08 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/ndarray.native.js
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/lib/ndarray.native.js
@@ -20,8 +20,7 @@
// MODULES //
-var offsetView = require( '@stdlib/strided/base/offset-view' );
-var addon = require( './dsort2sh.native.js' );
+var addon = require( './../src/addon.node' );
// MAIN //
@@ -32,10 +31,10 @@ var addon = require( './dsort2sh.native.js' );
* @param {PositiveInteger} N - number of indexed elements
* @param {number} order - sort order
* @param {Float64Array} x - first input array
-* @param {integer} strideX - `x` index increment
+* @param {integer} strideX - `x` stride length
* @param {NonNegativeInteger} offsetX - `x` starting index
* @param {Float64Array} y - second input array
-* @param {integer} strideY - `y` index increment
+* @param {integer} strideY - `y` stride length
* @param {NonNegativeInteger} offsetY - `y` starting index
* @returns {Float64Array} `x`
*
@@ -54,23 +53,7 @@ var addon = require( './dsort2sh.native.js' );
* // => [ 3.0, 1.0, 0.0, 2.0 ]
*/
function dsort2sh( N, order, x, strideX, offsetX, y, strideY, offsetY ) {
- var viewX;
- var viewY;
- var flg;
-
- flg = 1.0;
- if ( strideX < 0 ) {
- flg *= -1.0; // reversing order
- order *= -1.0;
- strideX *= -1;
- offsetX -= (N-1) * strideX;
- }
- if ( strideY < 0 ) {
- offsetY += (N-1) * strideY;
- }
- 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/dsort2sh/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/manifest.json
index a63a8d3c54a5..ead1a778ac69 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/manifest.json
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/manifest.json
@@ -28,14 +28,12 @@
{
"task": "build",
"src": [
- "./src/dsort2sh.c"
+ "./src/main.c"
],
"include": [
"./include"
],
- "libraries": [
- "-lm"
- ],
+ "libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/napi/export",
@@ -44,13 +42,15 @@
"@stdlib/napi/argv",
"@stdlib/napi/argv-int64",
"@stdlib/napi/argv-double",
- "@stdlib/napi/argv-strided-float64array"
+ "@stdlib/napi/argv-strided-float64array",
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/blas/base/shared"
]
},
{
- "task": "benchmark",
+ "task": "examples",
"src": [
- "./src/dsort2sh.c"
+ "./src/main.c"
],
"include": [
"./include"
@@ -59,13 +59,15 @@
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nan",
- "@stdlib/math/base/assert/is-negative-zero"
+ "@stdlib/math/base/assert/is-negative-zero",
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/blas/base/shared"
]
},
{
- "task": "examples",
+ "task": "benchmark",
"src": [
- "./src/dsort2sh.c"
+ "./src/main.c"
],
"include": [
"./include"
@@ -74,7 +76,9 @@
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nan",
- "@stdlib/math/base/assert/is-negative-zero"
+ "@stdlib/strided/base/stride2offset",
+ "@stdlib/math/base/assert/is-negative-zero",
+ "@stdlib/blas/base/shared"
]
}
]
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/addon.c
index 3a298b3cca01..70215aaef583 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/addon.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/addon.c
@@ -39,10 +39,29 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, order, argv, 4 );
STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 );
+ API_SUFFIX(stdlib_strided_dsort2sh)( N, order, X, strideX, Y, strideY );
+ return NULL;
+}
- c_dsort2sh( N, order, X, strideX, Y, strideY );
-
+/**
+* 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_INT64( 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_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 5 );
+ API_SUFFIX(stdlib_strided_dsort2sh_ndarray)( N, order, X, strideX, offsetX, Y, strideY, offsetY );
return NULL;
}
-STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
+STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method );
diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/dsort2sh.c b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/main.c
similarity index 63%
rename from lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/dsort2sh.c
rename to lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/main.c
index d78274d68e80..12b0ae9f9900 100644
--- a/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/dsort2sh.c
+++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2sh/src/main.c
@@ -19,6 +19,8 @@
#include "stdlib/blas/ext/base/dsort2sh.h"
#include "stdlib/math/base/assert/is_negative_zero.h"
#include "stdlib/math/base/assert/is_nan.h"
+#include "stdlib/blas/base/shared.h"
+#include "stdlib/strided/base/stride2offset.h"
#include
#include
@@ -41,15 +43,30 @@
* @param Y second input array
* @param strideY `Y` index increment
*/
-void c_dsort2sh( const int64_t N, const double order, double *X, const int64_t strideX, double *Y, const int64_t strideY ) {
- int64_t offsetX;
- int64_t offsetY;
- int64_t gap;
- int64_t sx;
- int64_t sy;
- int64_t i;
- int64_t j;
- int64_t k;
+void API_SUFFIX(stdlib_strided_dsort2sh)( const CBLAS_INT N, const CBLAS_INT order, double *X, CBLAS_INT strideX, double *Y, CBLAS_INT strideY ) {
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
+ CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY );
+ API_SUFFIX(stdlib_strided_dsort2sh_ndarray)( N, order, X, strideX, ox, Y, strideY, oy );
+}
+
+
+/**
+* Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using Shellsort and alternative indexing semantics.
+*
+* @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 Y second input array
+* @param strideY `Y` stride length
+* @param offsetY `Y` starting index
+*/
+void API_SUFFIX(stdlib_strided_dsort2sh_ndarray)( const CBLAS_INT N, const CBLAS_INT order, double *X, CBLAS_INT strideX, CBLAS_INT offsetX, double *Y, CBLAS_INT strideY, CBLAS_INT offsetY ) {
+ CBLAS_INT gap;
+ CBLAS_INT i;
+ CBLAS_INT j;
+ CBLAS_INT k;
double vx;
double vy;
double ux;
@@ -64,45 +81,34 @@ void c_dsort2sh( const int64_t N, const double order, double *X, const int64_t s
}
// 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 ) {
- sx = -strideX;
- sy = -strideY;
- } else {
- sx = strideX;
- sy = strideY;
- }
- if ( sx < 0 ) {
- offsetX = (1-N) * sx;
- } else {
- offsetX = 0;
- }
- if ( sy < 0 ) {
- offsetY = (1-N) * sy;
- } else {
- offsetY = 0;
+ strideX *= -1;
+ strideY *= -1;
+ offsetX -= (N-1) * strideX;
+ offsetY -= (N-1) * strideY;
}
for ( i = 0; i < NGAPS; i++ ) {
gap = GAPS[ i ];
for ( j = gap; j < N; j++ ) {
- vx = X[ offsetX+(j*sx) ];
+ vx = X[ offsetX+(j*strideX) ];
// If `NaN`, the current value is already sorted to its place...
if ( stdlib_base_is_nan( vx ) ) {
continue;
}
- vy = Y[ offsetY+(j*sy) ];
+ vy = Y[ offsetY+(j*strideY) ];
// Perform insertion sort on the "gapped" subarray...
flg = stdlib_base_is_negative_zero( vx );
for ( k = j; k >= gap; k -= gap ) {
- ux = X[ offsetX+((k-gap)*sx) ];
+ ux = X[ offsetX+((k-gap)*strideX) ];
if ( ux <= vx && !(flg && ux == vx) ) {
break;
}
- X[ offsetX+(k*sx) ] = ux;
- Y[ offsetY+(k*sy) ] = Y[ offsetY+((k-gap)*sy) ];
+ X[ offsetX+(k*strideX) ] = ux;
+ Y[ offsetY+(k*strideY) ] = Y[ offsetY+((k-gap)*strideY) ];
}
- X[ offsetX+(k*sx) ] = vx;
- Y[ offsetY+(k*sy) ] = vy;
+ X[ offsetX+(k*strideX) ] = vx;
+ Y[ offsetY+(k*strideY) ] = vy;
}
}
return;