diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsort2ins/README.md b/lib/node_modules/@stdlib/blas/ext/base/dsort2ins/README.md index 43385ef23133..3cf9d84fee32 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsort2ins/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dsort2ins/README.md @@ -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 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 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 of `x`: ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -166,28 +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 dsort2ins = require( '@stdlib/blas/ext/base/dsort2ins' ); -var rand; -var sign; -var i; - -var x = new Float64Array( 10 ); -var 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 ); @@ -200,6 +187,139 @@ console.log( y ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/dsort2ins.h" +``` + +#### stdlib_strided_dsort2ins( 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 insertion sort. + +```c +double x[] = { 1.0, -2.0, 3.0, -4.0 }; +double y[] = { 0.0, 1.0, 2.0, 3.0 }; + +stdlib_strided_dsort2ins( 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_dsort2ins( const CBLAS_INT N, const CBLAS_INT order, double *X, CBLAS_INT strideX, double *Y, CBLAS_INT strideY ); +``` + + + +#### stdlib_strided_dsort2ins_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 insertion sort 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_dsort2ins_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_dsort2ins_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/dsort2ins.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_dsort2ins( 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 ] ); + } +} +``` + +
+ + + +
+ + +