@stdlib/blas-ext-base-dsort2ins 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -81,17 +81,15 @@ The function has the following parameters:
81
81
  - **y**: second input [`Float64Array`][@stdlib/array/float64].
82
82
  - **strideY**: `y` index increment.
83
83
 
84
- The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to sort every other element
84
+ The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to sort every other element
85
85
 
86
86
  ```javascript
87
87
  var Float64Array = require( '@stdlib/array-float64' );
88
- var floor = require( '@stdlib/math-base-special-floor' );
89
88
 
90
89
  var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );
91
90
  var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );
92
- var N = floor( x.length / 2 );
93
91
 
94
- dsort2ins( N, -1.0, x, 2, y, 2 );
92
+ dsort2ins( 2, -1.0, x, 2, y, 2 );
95
93
 
96
94
  console.log( x );
97
95
  // => <Float64Array>[ 3.0, -2.0, 1.0, -4.0 ]
@@ -104,7 +102,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [
104
102
 
105
103
  ```javascript
106
104
  var Float64Array = require( '@stdlib/array-float64' );
107
- var floor = require( '@stdlib/math-base-special-floor' );
108
105
 
109
106
  // Initial arrays...
110
107
  var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
@@ -113,10 +110,9 @@ var y0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );
113
110
  // Create offset views...
114
111
  var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
115
112
  var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
116
- var N = floor( x0.length/2 );
117
113
 
118
114
  // Sort every other element...
119
- dsort2ins( N, -1.0, x1, 2, y1, 2 );
115
+ dsort2ins( 2, -1.0, x1, 2, y1, 2 );
120
116
 
121
117
  console.log( x0 );
122
118
  // => <Float64Array>[ 1.0, 4.0, 3.0, 2.0 ]
@@ -149,7 +145,7 @@ The function has the following additional parameters:
149
145
  - **offsetX**: `x` starting index.
150
146
  - **offsetY**: `y` starting index.
151
147
 
152
- 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`
148
+ 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`
153
149
 
154
150
  ```javascript
155
151
  var Float64Array = require( '@stdlib/array-float64' );
@@ -200,12 +196,10 @@ var dsort2ins = require( '@stdlib/blas-ext-base-dsort2ins' );
200
196
 
201
197
  var rand;
202
198
  var sign;
203
- var x;
204
- var y;
205
199
  var i;
206
200
 
207
- x = new Float64Array( 10 );
208
- y = new Float64Array( 10 ); // index array
201
+ var x = new Float64Array( 10 );
202
+ var y = new Float64Array( 10 ); // index array
209
203
  for ( i = 0; i < x.length; i++ ) {
210
204
  rand = round( randu()*100.0 );
211
205
  sign = randu();
@@ -271,7 +265,7 @@ See [LICENSE][stdlib-license].
271
265
 
272
266
  ## Copyright
273
267
 
274
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
268
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
275
269
 
276
270
  </section>
277
271
 
@@ -284,8 +278,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
284
278
  [npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsort2ins.svg
285
279
  [npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsort2ins
286
280
 
287
- [test-image]: https://github.com/stdlib-js/blas-ext-base-dsort2ins/actions/workflows/test.yml/badge.svg?branch=v0.2.2
288
- [test-url]: https://github.com/stdlib-js/blas-ext-base-dsort2ins/actions/workflows/test.yml?query=branch:v0.2.2
281
+ [test-image]: https://github.com/stdlib-js/blas-ext-base-dsort2ins/actions/workflows/test.yml/badge.svg?branch=v0.2.3
282
+ [test-url]: https://github.com/stdlib-js/blas-ext-base-dsort2ins/actions/workflows/test.yml?query=branch:v0.2.3
289
283
 
290
284
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsort2ins/main.svg
291
285
  [coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsort2ins?branch=main
@@ -297,8 +291,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
297
291
 
298
292
  -->
299
293
 
300
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
301
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
294
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
295
+ [chat-url]: https://stdlib.zulipchat.com
302
296
 
303
297
  [stdlib]: https://github.com/stdlib-js/stdlib
304
298
 
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/dsort2ins.js", "../lib/ndarray.js", "../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} order - sort order\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` index increment\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` index increment\n* @returns {Float64Array} `x`\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n* var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );\n*\n* dsort2ins( x.length, 1.0, x, 1, y, 1 );\n*\n* console.log( x );\n* // => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* console.log( y );\n* // => <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]\n*/\nfunction dsort2ins( N, order, x, strideX, y, strideY ) {\n\tvar flg;\n\tvar ix;\n\tvar jx;\n\tvar fx;\n\tvar lx;\n\tvar iy;\n\tvar jy;\n\tvar fy;\n\tvar ly;\n\tvar vx;\n\tvar vy;\n\tvar ux;\n\tvar i;\n\n\tif ( N <= 0 || order === 0.0 ) {\n\t\treturn x;\n\t}\n\t// 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...\n\tif ( order < 0.0 ) {\n\t\tstrideX *= -1;\n\t\tstrideY *= -1;\n\t}\n\tif ( strideY < 0 ) {\n\t\tfy = (1-N) * strideY;\n\t\tly = 0;\n\t} else {\n\t\tfy = 0;\n\t\tly = (N-1) * strideY;\n\t}\n\tiy = fy + strideY;\n\n\tif ( strideX < 0 ) {\n\t\t// Traverse the strided array from right-to-left...\n\t\tfx = (1-N) * strideX; // first index\n\t\tlx = 0; // last index\n\t\tix = fx + strideX;\n\n\t\t// Sort in increasing order...\n\t\tfor ( i = 1; i < N; i++ ) {\n\t\t\tvx = x[ ix ];\n\t\t\tvy = y[ iy ];\n\n\t\t\t// Sort `NaN` values to the end (i.e., the left)...\n\t\t\tif ( isnan( vx ) ) {\n\t\t\t\tjx = ix;\n\t\t\t\tjy = iy;\n\n\t\t\t\t// Shift all values (including NaNs) to the left of the current element to the right...\n\t\t\t\twhile ( jx > lx ) {\n\t\t\t\t\tx[ jx ] = x[ jx+strideX ];\n\t\t\t\t\ty[ jy ] = y[ jy+strideY ];\n\t\t\t\t\tjx += strideX;\n\t\t\t\t\tjy += strideY;\n\t\t\t\t}\n\t\t\t\tx[ lx ] = vx;\n\t\t\t\ty[ ly ] = vy;\n\t\t\t} else {\n\t\t\t\tflg = isNegativeZero( vx );\n\t\t\t\tjx = ix - strideX;\n\t\t\t\tjy = iy - strideY;\n\n\t\t\t\t// Shift all larger values to the right of the current element to the left...\n\t\t\t\twhile ( jx <= fx ) {\n\t\t\t\t\tux = x[ jx ];\n\t\t\t\t\tif ( ux <= vx && !(flg && ux === vx && isNegativeZero( ux ) === false) ) { // eslint-disable-line max-len\n\t\t\t\t\t\t// Note: positive zeros (and NaNs (e.g., when last element is NaN)) are sorted to the left\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tx[ jx+strideX ] = ux;\n\t\t\t\t\ty[ jy+strideY ] = y[ jy ];\n\t\t\t\t\tjx -= strideX;\n\t\t\t\t\tjy -= strideY;\n\t\t\t\t}\n\t\t\t\tx[ jx+strideX ] = vx;\n\t\t\t\ty[ jy+strideY ] = vy;\n\t\t\t\tix += strideX;\n\t\t\t\tiy += strideY;\n\t\t\t}\n\t\t}\n\t\treturn x;\n\t}\n\t// Traverse the strided array from left-to-right...\n\tfx = 0; // first index\n\tlx = (N-1) * strideX; // last index\n\tix = fx + strideX;\n\n\t// Sort in increasing order...\n\tfor ( i = 1; i < N; i++ ) {\n\t\tvx = x[ ix ];\n\t\tvy = y[ iy ];\n\n\t\t// Sort `NaN` values to the end...\n\t\tif ( isnan( vx ) ) {\n\t\t\tjx = ix;\n\t\t\tjy = iy;\n\n\t\t\t// Shift all values (including NaNs) to the right of the current element to the left...\n\t\t\twhile ( jx < lx ) {\n\t\t\t\tx[ jx ] = x[ jx+strideX ];\n\t\t\t\ty[ jy ] = y[ jy+strideY ];\n\t\t\t\tjx += strideX;\n\t\t\t\tjy += strideY;\n\t\t\t}\n\t\t\tx[ lx ] = vx;\n\t\t\ty[ ly ] = vy;\n\t\t} else {\n\t\t\tflg = isNegativeZero( vx );\n\t\t\tjx = ix - strideX;\n\t\t\tjy = iy - strideY;\n\n\t\t\t// Shift all larger values to the left of the current element to the right...\n\t\t\twhile ( jx >= fx ) {\n\t\t\t\tux = x[ jx ];\n\t\t\t\tif ( ux <= vx && !(flg && ux === vx && isNegativeZero( ux ) === false) ) { // eslint-disable-line max-len\n\t\t\t\t\t// Note: positive zeros (and NaNs (e.g., when first element is NaN)) are sorted to the right\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tx[ jx+strideX ] = ux;\n\t\t\t\ty[ jy+strideY ] = y[ jy ];\n\t\t\t\tjx -= strideX;\n\t\t\t\tjy -= strideY;\n\t\t\t}\n\t\t\tx[ jx+strideX ] = vx;\n\t\t\ty[ jy+strideY ] = vy;\n\t\t\tix += strideX;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsort2ins;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} order - sort order\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` index increment\n* @param {NonNegativeInteger} offsetX - `x` starting index\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` index increment\n* @param {NonNegativeInteger} offsetY - `y` starting index\n* @returns {Float64Array} `x`\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n* var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );\n*\n* dsort2ins( x.length, 1.0, x, 1, 0, y, 1, 0 );\n*\n* console.log( x );\n* // => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* console.log( y );\n* // => <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]\n*/\nfunction dsort2ins( N, order, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar flg;\n\tvar ix;\n\tvar jx;\n\tvar fx;\n\tvar lx;\n\tvar iy;\n\tvar jy;\n\tvar fy;\n\tvar ly;\n\tvar vx;\n\tvar vy;\n\tvar ux;\n\tvar i;\n\n\tif ( N <= 0 || order === 0.0 ) {\n\t\treturn x;\n\t}\n\t// 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...\n\tif ( order < 0.0 ) {\n\t\tstrideX *= -1;\n\t\tstrideY *= -1;\n\t\toffsetX -= (N-1) * strideX;\n\t\toffsetY -= (N-1) * strideY;\n\t}\n\tfx = offsetX; // first index\n\tlx = fx + ((N-1)*strideX); // last index\n\tix = fx + strideX;\n\n\tfy = offsetY; // first index\n\tly = fy + ((N-1)*strideY); // last index\n\tiy = fy + strideY;\n\n\tif ( strideX < 0 ) {\n\t\t// Traverse the strided array from right-to-left...\n\n\t\t// Sort in increasing order...\n\t\tfor ( i = 1; i < N; i++ ) {\n\t\t\tvx = x[ ix ];\n\t\t\tvy = y[ iy ];\n\n\t\t\t// Sort `NaN` values to the end (i.e., the left)...\n\t\t\tif ( isnan( vx ) ) {\n\t\t\t\tjx = ix;\n\t\t\t\tjy = iy;\n\n\t\t\t\t// Shift all values (including NaNs) to the left of the current element to the right...\n\t\t\t\twhile ( jx > lx ) {\n\t\t\t\t\tx[ jx ] = x[ jx+strideX ];\n\t\t\t\t\ty[ jy ] = y[ jy+strideY ];\n\t\t\t\t\tjx += strideX;\n\t\t\t\t\tjy += strideY;\n\t\t\t\t}\n\t\t\t\tx[ lx ] = vx;\n\t\t\t\ty[ ly ] = vy;\n\t\t\t} else {\n\t\t\t\tflg = isNegativeZero( vx );\n\t\t\t\tjx = ix - strideX;\n\t\t\t\tjy = iy - strideY;\n\n\t\t\t\t// Shift all larger values to the right of the current element to the left...\n\t\t\t\twhile ( jx <= fx ) {\n\t\t\t\t\tux = x[ jx ];\n\t\t\t\t\tif ( ux <= vx && !(flg && ux === vx && isNegativeZero( ux ) === false) ) { // eslint-disable-line max-len\n\t\t\t\t\t\t// Note: positive zeros (and NaNs (e.g., when last element is NaN)) are sorted to the left\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tx[ jx+strideX ] = ux;\n\t\t\t\t\ty[ jy+strideY ] = y[ jy ];\n\t\t\t\t\tjx -= strideX;\n\t\t\t\t\tjy -= strideY;\n\t\t\t\t}\n\t\t\t\tx[ jx+strideX ] = vx;\n\t\t\t\ty[ jy+strideY ] = vy;\n\t\t\t\tix += strideX;\n\t\t\t\tiy += strideY;\n\t\t\t}\n\t\t}\n\t\treturn x;\n\t}\n\t// Traverse the strided array from left-to-right...\n\n\t// Sort in increasing order...\n\tfor ( i = 1; i < N; i++ ) {\n\t\tvx = x[ ix ];\n\t\tvy = y[ iy ];\n\n\t\t// Sort `NaN` values to the end...\n\t\tif ( isnan( vx ) ) {\n\t\t\tjx = ix;\n\t\t\tjy = iy;\n\n\t\t\t// Shift all values (including NaNs) to the right of the current element to the left...\n\t\t\twhile ( jx < lx ) {\n\t\t\t\tx[ jx ] = x[ jx+strideX ];\n\t\t\t\ty[ jy ] = y[ jy+strideY ];\n\t\t\t\tjx += strideX;\n\t\t\t\tjy += strideY;\n\t\t\t}\n\t\t\tx[ lx ] = vx;\n\t\t\ty[ ly ] = vy;\n\t\t} else {\n\t\t\tflg = isNegativeZero( vx );\n\t\t\tjx = ix - strideX;\n\t\t\tjy = iy - strideY;\n\n\t\t\t// Shift all larger values to the left of the current element to the right...\n\t\t\twhile ( jx >= fx ) {\n\t\t\t\tux = x[ jx ];\n\t\t\t\tif ( ux <= vx && !(flg && ux === vx && isNegativeZero( ux ) === false) ) { // eslint-disable-line max-len\n\t\t\t\t\t// Note: positive zeros (and NaNs (e.g., when first element is NaN)) are sorted to the right\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tx[ jx+strideX ] = ux;\n\t\t\t\ty[ jy+strideY ] = y[ jy ];\n\t\t\t\tjx -= strideX;\n\t\t\t\tjy -= strideY;\n\t\t\t}\n\t\t\tx[ jx+strideX ] = vx;\n\t\t\ty[ jy+strideY ] = vy;\n\t\t\tix += strideX;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsort2ins;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar dsort2ins = require( './dsort2ins.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsort2ins, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsort2ins;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Simultaneously sort two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.\n*\n* @module @stdlib/blas-ext-base-dsort2ins\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsort2ins = require( '@stdlib/blas-ext-base-dsort2ins' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n* var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );\n*\n* dsort2ins( x.length, 1.0, x, 1, y, 1 );\n*\n* console.log( x );\n* // => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* console.log( y );\n* // => <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsort2ins = require( '@stdlib/blas-ext-base-dsort2ins' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n* var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );\n*\n* dsort2ins( x.length, 1.0, x, 1, 0, y, 1, 0 );\n*\n* console.log( x );\n* // => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* console.log( y );\n* // => <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]\n*/\n\n// MODULES //\n\nvar join = require( 'path' ).join;\nvar tryRequire = require( '@stdlib/utils-try-require' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nvar dsort2ins;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsort2ins = main;\n} else {\n\tdsort2ins = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsort2ins;\n\n// exports: { \"ndarray\": \"dsort2ins.ndarray\" }\n"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} order - sort order\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` index increment\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` index increment\n* @returns {Float64Array} `x`\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n* var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );\n*\n* dsort2ins( x.length, 1.0, x, 1, y, 1 );\n*\n* console.log( x );\n* // => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* console.log( y );\n* // => <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]\n*/\nfunction dsort2ins( N, order, x, strideX, y, strideY ) {\n\tvar flg;\n\tvar ix;\n\tvar jx;\n\tvar fx;\n\tvar lx;\n\tvar iy;\n\tvar jy;\n\tvar fy;\n\tvar ly;\n\tvar vx;\n\tvar vy;\n\tvar ux;\n\tvar i;\n\n\tif ( N <= 0 || order === 0.0 ) {\n\t\treturn x;\n\t}\n\t// 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...\n\tif ( order < 0.0 ) {\n\t\tstrideX *= -1;\n\t\tstrideY *= -1;\n\t}\n\tif ( strideY < 0 ) {\n\t\tfy = (1-N) * strideY;\n\t\tly = 0;\n\t} else {\n\t\tfy = 0;\n\t\tly = (N-1) * strideY;\n\t}\n\tiy = fy + strideY;\n\n\tif ( strideX < 0 ) {\n\t\t// Traverse the strided array from right-to-left...\n\t\tfx = (1-N) * strideX; // first index\n\t\tlx = 0; // last index\n\t\tix = fx + strideX;\n\n\t\t// Sort in increasing order...\n\t\tfor ( i = 1; i < N; i++ ) {\n\t\t\tvx = x[ ix ];\n\t\t\tvy = y[ iy ];\n\n\t\t\t// Sort `NaN` values to the end (i.e., the left)...\n\t\t\tif ( isnan( vx ) ) {\n\t\t\t\tjx = ix;\n\t\t\t\tjy = iy;\n\n\t\t\t\t// Shift all values (including NaNs) to the left of the current element to the right...\n\t\t\t\twhile ( jx > lx ) {\n\t\t\t\t\tx[ jx ] = x[ jx+strideX ];\n\t\t\t\t\ty[ jy ] = y[ jy+strideY ];\n\t\t\t\t\tjx += strideX;\n\t\t\t\t\tjy += strideY;\n\t\t\t\t}\n\t\t\t\tx[ lx ] = vx;\n\t\t\t\ty[ ly ] = vy;\n\t\t\t} else {\n\t\t\t\tflg = isNegativeZero( vx );\n\t\t\t\tjx = ix - strideX;\n\t\t\t\tjy = iy - strideY;\n\n\t\t\t\t// Shift all larger values to the right of the current element to the left...\n\t\t\t\twhile ( jx <= fx ) {\n\t\t\t\t\tux = x[ jx ];\n\t\t\t\t\tif ( ux <= vx && !(flg && ux === vx && isNegativeZero( ux ) === false) ) { // eslint-disable-line max-len\n\t\t\t\t\t\t// Note: positive zeros (and NaNs (e.g., when last element is NaN)) are sorted to the left\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tx[ jx+strideX ] = ux;\n\t\t\t\t\ty[ jy+strideY ] = y[ jy ];\n\t\t\t\t\tjx -= strideX;\n\t\t\t\t\tjy -= strideY;\n\t\t\t\t}\n\t\t\t\tx[ jx+strideX ] = vx;\n\t\t\t\ty[ jy+strideY ] = vy;\n\t\t\t\tix += strideX;\n\t\t\t\tiy += strideY;\n\t\t\t}\n\t\t}\n\t\treturn x;\n\t}\n\t// Traverse the strided array from left-to-right...\n\tfx = 0; // first index\n\tlx = (N-1) * strideX; // last index\n\tix = fx + strideX;\n\n\t// Sort in increasing order...\n\tfor ( i = 1; i < N; i++ ) {\n\t\tvx = x[ ix ];\n\t\tvy = y[ iy ];\n\n\t\t// Sort `NaN` values to the end...\n\t\tif ( isnan( vx ) ) {\n\t\t\tjx = ix;\n\t\t\tjy = iy;\n\n\t\t\t// Shift all values (including NaNs) to the right of the current element to the left...\n\t\t\twhile ( jx < lx ) {\n\t\t\t\tx[ jx ] = x[ jx+strideX ];\n\t\t\t\ty[ jy ] = y[ jy+strideY ];\n\t\t\t\tjx += strideX;\n\t\t\t\tjy += strideY;\n\t\t\t}\n\t\t\tx[ lx ] = vx;\n\t\t\ty[ ly ] = vy;\n\t\t} else {\n\t\t\tflg = isNegativeZero( vx );\n\t\t\tjx = ix - strideX;\n\t\t\tjy = iy - strideY;\n\n\t\t\t// Shift all larger values to the left of the current element to the right...\n\t\t\twhile ( jx >= fx ) {\n\t\t\t\tux = x[ jx ];\n\t\t\t\tif ( ux <= vx && !(flg && ux === vx && isNegativeZero( ux ) === false) ) { // eslint-disable-line max-len\n\t\t\t\t\t// Note: positive zeros (and NaNs (e.g., when first element is NaN)) are sorted to the right\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tx[ jx+strideX ] = ux;\n\t\t\t\ty[ jy+strideY ] = y[ jy ];\n\t\t\t\tjx -= strideX;\n\t\t\t\tjy -= strideY;\n\t\t\t}\n\t\t\tx[ jx+strideX ] = vx;\n\t\t\ty[ jy+strideY ] = vy;\n\t\t\tix += strideX;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsort2ins;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );\nvar isnan = require( '@stdlib/math-base-assert-is-nan' );\n\n\n// MAIN //\n\n/**\n* Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} order - sort order\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` index increment\n* @param {NonNegativeInteger} offsetX - `x` starting index\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` index increment\n* @param {NonNegativeInteger} offsetY - `y` starting index\n* @returns {Float64Array} `x`\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n* var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );\n*\n* dsort2ins( x.length, 1.0, x, 1, 0, y, 1, 0 );\n*\n* console.log( x );\n* // => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* console.log( y );\n* // => <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]\n*/\nfunction dsort2ins( N, order, x, strideX, offsetX, y, strideY, offsetY ) {\n\tvar flg;\n\tvar ix;\n\tvar jx;\n\tvar fx;\n\tvar lx;\n\tvar iy;\n\tvar jy;\n\tvar fy;\n\tvar ly;\n\tvar vx;\n\tvar vy;\n\tvar ux;\n\tvar i;\n\n\tif ( N <= 0 || order === 0.0 ) {\n\t\treturn x;\n\t}\n\t// 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...\n\tif ( order < 0.0 ) {\n\t\tstrideX *= -1;\n\t\tstrideY *= -1;\n\t\toffsetX -= (N-1) * strideX;\n\t\toffsetY -= (N-1) * strideY;\n\t}\n\tfx = offsetX; // first index\n\tlx = fx + ((N-1)*strideX); // last index\n\tix = fx + strideX;\n\n\tfy = offsetY; // first index\n\tly = fy + ((N-1)*strideY); // last index\n\tiy = fy + strideY;\n\n\tif ( strideX < 0 ) {\n\t\t// Traverse the strided array from right-to-left...\n\n\t\t// Sort in increasing order...\n\t\tfor ( i = 1; i < N; i++ ) {\n\t\t\tvx = x[ ix ];\n\t\t\tvy = y[ iy ];\n\n\t\t\t// Sort `NaN` values to the end (i.e., the left)...\n\t\t\tif ( isnan( vx ) ) {\n\t\t\t\tjx = ix;\n\t\t\t\tjy = iy;\n\n\t\t\t\t// Shift all values (including NaNs) to the left of the current element to the right...\n\t\t\t\twhile ( jx > lx ) {\n\t\t\t\t\tx[ jx ] = x[ jx+strideX ];\n\t\t\t\t\ty[ jy ] = y[ jy+strideY ];\n\t\t\t\t\tjx += strideX;\n\t\t\t\t\tjy += strideY;\n\t\t\t\t}\n\t\t\t\tx[ lx ] = vx;\n\t\t\t\ty[ ly ] = vy;\n\t\t\t} else {\n\t\t\t\tflg = isNegativeZero( vx );\n\t\t\t\tjx = ix - strideX;\n\t\t\t\tjy = iy - strideY;\n\n\t\t\t\t// Shift all larger values to the right of the current element to the left...\n\t\t\t\twhile ( jx <= fx ) {\n\t\t\t\t\tux = x[ jx ];\n\t\t\t\t\tif ( ux <= vx && !(flg && ux === vx && isNegativeZero( ux ) === false) ) { // eslint-disable-line max-len\n\t\t\t\t\t\t// Note: positive zeros (and NaNs (e.g., when last element is NaN)) are sorted to the left\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tx[ jx+strideX ] = ux;\n\t\t\t\t\ty[ jy+strideY ] = y[ jy ];\n\t\t\t\t\tjx -= strideX;\n\t\t\t\t\tjy -= strideY;\n\t\t\t\t}\n\t\t\t\tx[ jx+strideX ] = vx;\n\t\t\t\ty[ jy+strideY ] = vy;\n\t\t\t\tix += strideX;\n\t\t\t\tiy += strideY;\n\t\t\t}\n\t\t}\n\t\treturn x;\n\t}\n\t// Traverse the strided array from left-to-right...\n\n\t// Sort in increasing order...\n\tfor ( i = 1; i < N; i++ ) {\n\t\tvx = x[ ix ];\n\t\tvy = y[ iy ];\n\n\t\t// Sort `NaN` values to the end...\n\t\tif ( isnan( vx ) ) {\n\t\t\tjx = ix;\n\t\t\tjy = iy;\n\n\t\t\t// Shift all values (including NaNs) to the right of the current element to the left...\n\t\t\twhile ( jx < lx ) {\n\t\t\t\tx[ jx ] = x[ jx+strideX ];\n\t\t\t\ty[ jy ] = y[ jy+strideY ];\n\t\t\t\tjx += strideX;\n\t\t\t\tjy += strideY;\n\t\t\t}\n\t\t\tx[ lx ] = vx;\n\t\t\ty[ ly ] = vy;\n\t\t} else {\n\t\t\tflg = isNegativeZero( vx );\n\t\t\tjx = ix - strideX;\n\t\t\tjy = iy - strideY;\n\n\t\t\t// Shift all larger values to the left of the current element to the right...\n\t\t\twhile ( jx >= fx ) {\n\t\t\t\tux = x[ jx ];\n\t\t\t\tif ( ux <= vx && !(flg && ux === vx && isNegativeZero( ux ) === false) ) { // eslint-disable-line max-len\n\t\t\t\t\t// Note: positive zeros (and NaNs (e.g., when first element is NaN)) are sorted to the right\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tx[ jx+strideX ] = ux;\n\t\t\t\ty[ jy+strideY ] = y[ jy ];\n\t\t\t\tjx -= strideX;\n\t\t\t\tjy -= strideY;\n\t\t\t}\n\t\t\tx[ jx+strideX ] = vx;\n\t\t\ty[ jy+strideY ] = vy;\n\t\t\tix += strideX;\n\t\t\tiy += strideY;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsort2ins;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar dsort2ins = require( './dsort2ins.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsort2ins, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsort2ins;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2020 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Simultaneously sort two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.\n*\n* @module @stdlib/blas-ext-base-dsort2ins\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsort2ins = require( '@stdlib/blas-ext-base-dsort2ins' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n* var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );\n*\n* dsort2ins( x.length, 1.0, x, 1, y, 1 );\n*\n* console.log( x );\n* // => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* console.log( y );\n* // => <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsort2ins = require( '@stdlib/blas-ext-base-dsort2ins' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n* var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );\n*\n* dsort2ins.ndarray( x.length, 1.0, x, 1, 0, y, 1, 0 );\n*\n* console.log( x );\n* // => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* console.log( y );\n* // => <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]\n*/\n\n// MODULES //\n\nvar join = require( 'path' ).join;\nvar tryRequire = require( '@stdlib/utils-try-require' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar main = require( './main.js' );\n\n\n// MAIN //\n\nvar dsort2ins;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsort2ins = main;\n} else {\n\tdsort2ins = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsort2ins;\n\n// exports: { \"ndarray\": \"dsort2ins.ndarray\" }\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dsort2ins", "__commonJSMin", "exports", "module", "isNegativeZero", "isnan", "dsort2ins", "N", "order", "x", "strideX", "y", "strideY", "flg", "ix", "jx", "fx", "lx", "iy", "jy", "fy", "ly", "vx", "vy", "ux", "i", "require_ndarray", "__commonJSMin", "exports", "module", "isNegativeZero", "isnan", "dsort2ins", "N", "order", "x", "strideX", "offsetX", "y", "strideY", "offsetY", "flg", "ix", "jx", "fx", "lx", "iy", "jy", "fy", "ly", "vx", "vy", "ux", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsort2ins", "ndarray", "join", "tryRequire", "isError", "main", "dsort2ins", "tmp"]
7
7
  }
@@ -28,9 +28,9 @@ interface Routine {
28
28
  * @param N - number of indexed elements
29
29
  * @param order - sort order
30
30
  * @param x - first input array
31
- * @param strideX - `x` stride length
31
+ * @param strideX - first stride length
32
32
  * @param y - second input array
33
- * @param strideY - `y` stride length
33
+ * @param strideY - second stride length
34
34
  * @returns `x`
35
35
  *
36
36
  * @example
@@ -16,9 +16,6 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- /**
20
- * Header file containing function declarations.
21
- */
22
19
  #ifndef STDLIB_BLAS_EXT_BASE_DSORT2INS_H
23
20
  #define STDLIB_BLAS_EXT_BASE_DSORT2INS_H
24
21
 
package/lib/index.js CHANGED
@@ -45,7 +45,7 @@
45
45
  * var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );
46
46
  * var y = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );
47
47
  *
48
- * dsort2ins( x.length, 1.0, x, 1, 0, y, 1, 0 );
48
+ * dsort2ins.ndarray( x.length, 1.0, x, 1, 0, y, 1, 0 );
49
49
  *
50
50
  * console.log( x );
51
51
  * // => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]
package/manifest.json CHANGED
@@ -1,43 +1,68 @@
1
1
  {
2
- "options": {},
3
- "fields": [
4
- {
5
- "field": "src",
6
- "resolve": true,
7
- "relative": true
8
- },
9
- {
10
- "field": "include",
11
- "resolve": true,
12
- "relative": true
13
- },
14
- {
15
- "field": "libraries",
16
- "resolve": false,
17
- "relative": false
18
- },
19
- {
20
- "field": "libpath",
21
- "resolve": true,
22
- "relative": false
23
- }
24
- ],
25
- "confs": [
26
- {
27
- "src": [
28
- "./src/dsort2ins.c"
29
- ],
30
- "include": [
31
- "./include"
32
- ],
33
- "libraries": [
34
- "-lm"
35
- ],
36
- "libpath": [],
37
- "dependencies": [
38
- "@stdlib/math-base-assert-is-nan",
39
- "@stdlib/math-base-assert-is-negative-zero"
40
- ]
41
- }
42
- ]
2
+ "options": {
3
+ "task": "build"
4
+ },
5
+ "fields": [
6
+ {
7
+ "field": "src",
8
+ "resolve": true,
9
+ "relative": true
10
+ },
11
+ {
12
+ "field": "include",
13
+ "resolve": true,
14
+ "relative": true
15
+ },
16
+ {
17
+ "field": "libraries",
18
+ "resolve": false,
19
+ "relative": false
20
+ },
21
+ {
22
+ "field": "libpath",
23
+ "resolve": true,
24
+ "relative": false
25
+ }
26
+ ],
27
+ "confs": [
28
+ {
29
+ "task": "build",
30
+ "src": [
31
+ "./src/dsort2ins.c"
32
+ ],
33
+ "include": [
34
+ "./include"
35
+ ],
36
+ "libraries": [
37
+ "-lm"
38
+ ],
39
+ "libpath": [],
40
+ "dependencies": [
41
+ "@stdlib/math-base-assert-is-negative-zero",
42
+ "@stdlib/math-base-assert-is-nan",
43
+ "@stdlib/napi-export",
44
+ "@stdlib/napi-argv",
45
+ "@stdlib/napi-argv-double",
46
+ "@stdlib/napi-argv-int64",
47
+ "@stdlib/napi-argv-strided-float64array"
48
+ ]
49
+ },
50
+ {
51
+ "task": "examples",
52
+ "src": [
53
+ "./src/dsort2ins.c"
54
+ ],
55
+ "include": [
56
+ "./include"
57
+ ],
58
+ "libraries": [
59
+ "-lm"
60
+ ],
61
+ "libpath": [],
62
+ "dependencies": [
63
+ "@stdlib/math-base-assert-is-nan",
64
+ "@stdlib/math-base-assert-is-negative-zero"
65
+ ]
66
+ }
67
+ ]
43
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/blas-ext-base-dsort2ins",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Simultaneously sort two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -35,10 +35,15 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@stdlib/assert-is-error": "^0.2.2",
38
- "@stdlib/math-base-assert-is-nan": "^0.2.1",
39
- "@stdlib/math-base-assert-is-negative-zero": "^0.2.1",
40
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
41
- "@stdlib/utils-library-manifest": "^0.2.1",
38
+ "@stdlib/math-base-assert-is-nan": "^0.2.3",
39
+ "@stdlib/math-base-assert-is-negative-zero": "^0.2.3",
40
+ "@stdlib/napi-argv": "^0.2.3",
41
+ "@stdlib/napi-argv-double": "^0.2.2",
42
+ "@stdlib/napi-argv-int64": "^0.2.3",
43
+ "@stdlib/napi-argv-strided-float64array": "^0.2.3",
44
+ "@stdlib/napi-export": "^0.3.1",
45
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3",
46
+ "@stdlib/utils-library-manifest": "^0.2.3",
42
47
  "@stdlib/utils-try-require": "^0.2.2"
43
48
  },
44
49
  "devDependencies": {},
@@ -76,7 +81,6 @@
76
81
  "double",
77
82
  "float64array"
78
83
  ],
79
- "__stdlib__": {},
80
84
  "funding": {
81
85
  "type": "opencollective",
82
86
  "url": "https://opencollective.com/stdlib"
package/src/addon.c ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ #include "stdlib/blas/ext/base/dsort2ins.h"
20
+ #include "stdlib/napi/export.h"
21
+ #include "stdlib/napi/argv.h"
22
+ #include "stdlib/napi/argv_int64.h"
23
+ #include "stdlib/napi/argv_double.h"
24
+ #include "stdlib/napi/argv_strided_float64array.h"
25
+ #include <node_api.h>
26
+
27
+ /**
28
+ * Receives JavaScript callback invocation data.
29
+ *
30
+ * @param env environment under which the function is invoked
31
+ * @param info callback data
32
+ * @return Node-API value
33
+ */
34
+ static napi_value addon( napi_env env, napi_callback_info info ) {
35
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 6 );
36
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
37
+ STDLIB_NAPI_ARGV_DOUBLE( env, order, argv, 1 );
38
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
39
+ STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 );
40
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
41
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 4 );
42
+ c_dsort2ins( N, order, X, strideX, Y, strideY );
43
+ return NULL;
44
+ }
45
+
46
+ STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
package/src/addon.cpp DELETED
@@ -1,164 +0,0 @@
1
- /**
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2020 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- #include "stdlib/blas/ext/base/dsort2ins.h"
20
- #include <node_api.h>
21
- #include <stdint.h>
22
- #include <stdlib.h>
23
- #include <stdbool.h>
24
- #include <assert.h>
25
-
26
- /**
27
- * Add-on namespace.
28
- */
29
- namespace stdlib_blas_ext_base_dsort2ins {
30
-
31
- /**
32
- * Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.
33
- *
34
- * ## Notes
35
- *
36
- * - When called from JavaScript, the function expects six arguments:
37
- *
38
- * - `N`: number of indexed elements
39
- * - `order`: sort order
40
- * - `X`: first input array
41
- * - `strideX`: `X` stride length
42
- * - `Y`: second input array
43
- * - `strideY`: `Y` stride length
44
- */
45
- napi_value node_dsort2ins( napi_env env, napi_callback_info info ) {
46
- napi_status status;
47
-
48
- size_t argc = 6;
49
- napi_value argv[ 6 ];
50
- status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
51
- assert( status == napi_ok );
52
-
53
- if ( argc < 6 ) {
54
- napi_throw_error( env, nullptr, "invalid invocation. Must provide 6 arguments." );
55
- return nullptr;
56
- }
57
-
58
- napi_valuetype vtype0;
59
- status = napi_typeof( env, argv[ 0 ], &vtype0 );
60
- assert( status == napi_ok );
61
- if ( vtype0 != napi_number ) {
62
- napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." );
63
- return nullptr;
64
- }
65
-
66
- napi_valuetype vtype1;
67
- status = napi_typeof( env, argv[ 1 ], &vtype1 );
68
- assert( status == napi_ok );
69
- if ( vtype1 != napi_number ) {
70
- napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." );
71
- return nullptr;
72
- }
73
-
74
- bool res2;
75
- status = napi_is_typedarray( env, argv[ 2 ], &res2 );
76
- assert( status == napi_ok );
77
- if ( res2 == false ) {
78
- napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." );
79
- return nullptr;
80
- }
81
-
82
- napi_valuetype vtype3;
83
- status = napi_typeof( env, argv[ 3 ], &vtype3 );
84
- assert( status == napi_ok );
85
- if ( vtype3 != napi_number ) {
86
- napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." );
87
- return nullptr;
88
- }
89
-
90
- bool res4;
91
- status = napi_is_typedarray( env, argv[ 4 ], &res4 );
92
- assert( status == napi_ok );
93
- if ( res4 == false ) {
94
- napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float64Array." );
95
- return nullptr;
96
- }
97
-
98
- napi_valuetype vtype5;
99
- status = napi_typeof( env, argv[ 5 ], &vtype5 );
100
- assert( status == napi_ok );
101
- if ( vtype5 != napi_number ) {
102
- napi_throw_type_error( env, nullptr, "invalid argument. Sixth argument must be a number." );
103
- return nullptr;
104
- }
105
-
106
- int64_t N;
107
- status = napi_get_value_int64( env, argv[ 0 ], &N );
108
- assert( status == napi_ok );
109
-
110
- double order;
111
- status = napi_get_value_double( env, argv[ 1 ], &order );
112
- assert( status == napi_ok );
113
-
114
- int64_t strideX;
115
- status = napi_get_value_int64( env, argv[ 3 ], &strideX );
116
- assert( status == napi_ok );
117
-
118
- int64_t strideY;
119
- status = napi_get_value_int64( env, argv[ 5 ], &strideY );
120
- assert( status == napi_ok );
121
-
122
- napi_typedarray_type vtype2;
123
- size_t xlen;
124
- void *X;
125
- status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr );
126
- assert( status == napi_ok );
127
- if ( vtype2 != napi_float64_array ) {
128
- napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." );
129
- return nullptr;
130
- }
131
- if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) {
132
- napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." );
133
- return nullptr;
134
- }
135
-
136
- napi_typedarray_type vtype4;
137
- size_t ylen;
138
- void *Y;
139
- status = napi_get_typedarray_info( env, argv[ 4 ], &vtype4, &ylen, &Y, nullptr, nullptr );
140
- assert( status == napi_ok );
141
- if ( vtype4 != napi_float64_array ) {
142
- napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float64Array." );
143
- return nullptr;
144
- }
145
- if ( (N-1)*llabs(strideY) >= (int64_t)ylen ) {
146
- napi_throw_range_error( env, nullptr, "invalid argument. Fifth argument has insufficient elements based on the associated stride and the number of indexed elements." );
147
- return nullptr;
148
- }
149
-
150
- c_dsort2ins( N, order, (double *)X, strideX, (double *)Y, strideY );
151
-
152
- return nullptr;
153
- }
154
-
155
- napi_value Init( napi_env env, napi_value exports ) {
156
- napi_status status;
157
- napi_value fcn;
158
- status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dsort2ins, NULL, &fcn );
159
- assert( status == napi_ok );
160
- return fcn;
161
- }
162
-
163
- NAPI_MODULE( NODE_GYP_MODULE_NAME, Init )
164
- } // end namespace stdlib_blas_ext_base_dsort2ins