@stdlib/blas-ext-base-dsortins 0.2.2 → 0.3.1

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
@@ -53,9 +53,9 @@ npm install @stdlib/blas-ext-base-dsortins
53
53
  var dsortins = require( '@stdlib/blas-ext-base-dsortins' );
54
54
  ```
55
55
 
56
- #### dsortins( N, order, x, stride )
56
+ #### dsortins( N, order, x, strideX )
57
57
 
58
- Sorts a double-precision floating-point strided array `x` using insertion sort.
58
+ Sorts a double-precision floating-point strided array using insertion sort.
59
59
 
60
60
  ```javascript
61
61
  var Float64Array = require( '@stdlib/array-float64' );
@@ -71,9 +71,9 @@ The function has the following parameters:
71
71
  - **N**: number of indexed elements.
72
72
  - **order**: sort order. If `order < 0.0`, the input strided array is sorted in **decreasing** order. If `order > 0.0`, the input strided array is sorted in **increasing** order. If `order == 0.0`, the input strided array is left unchanged.
73
73
  - **x**: input [`Float64Array`][@stdlib/array/float64].
74
- - **stride**: index increment.
74
+ - **strideX**: stride length.
75
75
 
76
- The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to sort every other element
76
+ The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to sort every other element:
77
77
 
78
78
  ```javascript
79
79
  var Float64Array = require( '@stdlib/array-float64' );
@@ -100,9 +100,9 @@ dsortins( 2, -1.0, x1, 2 );
100
100
  // x0 => <Float64Array>[ 1.0, 4.0, 3.0, 2.0 ]
101
101
  ```
102
102
 
103
- #### dsortins.ndarray( N, order, x, stride, offset )
103
+ #### dsortins.ndarray( N, order, x, strideX, offsetX )
104
104
 
105
- Sorts a double-precision floating-point strided array `x` using insertion sort and alternative indexing semantics.
105
+ Sorts a double-precision floating-point strided array using insertion sort and alternative indexing semantics.
106
106
 
107
107
  ```javascript
108
108
  var Float64Array = require( '@stdlib/array-float64' );
@@ -115,9 +115,9 @@ dsortins.ndarray( x.length, 1.0, x, 1, 0 );
115
115
 
116
116
  The function has the following additional parameters:
117
117
 
118
- - **offset**: starting index.
118
+ - **offsetX**: starting index.
119
119
 
120
- 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`
120
+ 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:
121
121
 
122
122
  ```javascript
123
123
  var Float64Array = require( '@stdlib/array-float64' );
@@ -155,11 +155,12 @@ dsortins.ndarray( 3, 1.0, x, 1, x.length-3 );
155
155
  <!-- eslint no-undef: "error" -->
156
156
 
157
157
  ```javascript
158
- var filledarrayBy = require( '@stdlib/array-filled-by' );
159
- var uniform = require( '@stdlib/random-base-uniform' ).factory;
158
+ var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
160
159
  var dsortins = require( '@stdlib/blas-ext-base-dsortins' );
161
160
 
162
- var x = filledarrayBy( 100, 'float64', uniform( -100.0, 100.0 ) );
161
+ var x = discreteUniform( 10, -100, 100, {
162
+ 'dtype': 'float64'
163
+ });
163
164
  console.log( x );
164
165
 
165
166
  dsortins( x.length, -1.0, x, -1 );
@@ -170,6 +171,129 @@ console.log( x );
170
171
 
171
172
  <!-- /.examples -->
172
173
 
174
+ <!-- C interface documentation. -->
175
+
176
+ * * *
177
+
178
+ <section class="c">
179
+
180
+ ## C APIs
181
+
182
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
183
+
184
+ <section class="intro">
185
+
186
+ </section>
187
+
188
+ <!-- /.intro -->
189
+
190
+ <!-- C usage documentation. -->
191
+
192
+ <section class="usage">
193
+
194
+ ### Usage
195
+
196
+ ```c
197
+ #include "stdlib/blas/ext/base/dsortins.h"
198
+ ```
199
+
200
+ #### stdlib_strided_dsortins( N, order, \*X, strideX )
201
+
202
+ Sorts a double-precision floating-point strided array using insertion sort.
203
+
204
+ ```c
205
+ double x[] = { 1.0, -2.0, 3.0, -4.0 };
206
+
207
+ stdlib_strided_dsortins( 2, -1.0, x, 1 );
208
+ ```
209
+
210
+ The function accepts the following arguments:
211
+
212
+ - **N**: `[in] CBLAS_INT` number of indexed elements.
213
+ - **order**: `[in] double` sort order. If `order < 0.0`, the input strided array is sorted in **decreasing** order. If `order > 0.0`, the input strided array is sorted in **increasing** order. If `order == 0.0`, the input strided array is left unchanged.
214
+ - **X**: `[inout] double*` input array.
215
+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
216
+
217
+ ```c
218
+ stdlib_strided_dsortins( const CBLAS_INT N, const double order, double *X, const CBLAS_INT strideX );
219
+ ```
220
+
221
+ <!--lint disable maximum-heading-length-->
222
+
223
+ #### stdlib_strided_dsortins_ndarray( N, order, \*X, strideX, offsetX )
224
+
225
+ <!--lint enable maximum-heading-length-->
226
+
227
+ Sorts a double-precision floating-point strided array using insertion sort and alternative indexing semantics.
228
+
229
+ ```c
230
+ double x[] = { 1.0, -2.0, 3.0, -4.0 };
231
+
232
+ stdlib_strided_dsortins_ndarray( 4, 1.0, x, 1, 0 );
233
+ ```
234
+
235
+ The function accepts the following arguments:
236
+
237
+ - **N**: `[in] CBLAS_INT` number of indexed elements.
238
+ - **order**: `[in] double` sort order. If `order < 0.0`, the input strided array is sorted in **decreasing** order. If `order > 0.0`, the input strided array is sorted in **increasing** order. If `order == 0.0`, the input strided array is left unchanged.
239
+ - **X**: `[inout] double*` input array.
240
+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
241
+ - **offsetX**: `[in] CBLAS_INT` starting index for `X`.
242
+
243
+ ```c
244
+ stdlib_strided_dsortins_ndarray( const CBLAS_INT N, const double order, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
245
+ ```
246
+
247
+ </section>
248
+
249
+ <!-- /.usage -->
250
+
251
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
252
+
253
+ <section class="notes">
254
+
255
+ </section>
256
+
257
+ <!-- /.notes -->
258
+
259
+ <!-- C API usage examples. -->
260
+
261
+ <section class="examples">
262
+
263
+ ### Examples
264
+
265
+ ```c
266
+ #include "stdlib/blas/ext/base/dsortins.h"
267
+ #include <stdio.h>
268
+
269
+ int main( void ) {
270
+ // Create a strided array:
271
+ double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 };
272
+
273
+ // Specify the number of elements:
274
+ int N = 8;
275
+
276
+ // Specify a stride:
277
+ int strideX = 1;
278
+
279
+ // Sort the array:
280
+ stdlib_strided_dsortins( N, 1.0, x, strideX );
281
+
282
+ // Print the result:
283
+ for ( int i = 0; i < 8; i++ ) {
284
+ printf( "x[ %i ] = %lf\n", i, x[ i ] );
285
+ }
286
+ }
287
+ ```
288
+
289
+ </section>
290
+
291
+ <!-- /.examples -->
292
+
293
+ </section>
294
+
295
+ <!-- /.c -->
296
+
173
297
  <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
174
298
 
175
299
  <section class="related">
@@ -212,7 +336,7 @@ See [LICENSE][stdlib-license].
212
336
 
213
337
  ## Copyright
214
338
 
215
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
339
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
216
340
 
217
341
  </section>
218
342
 
@@ -225,8 +349,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
225
349
  [npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsortins.svg
226
350
  [npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsortins
227
351
 
228
- [test-image]: https://github.com/stdlib-js/blas-ext-base-dsortins/actions/workflows/test.yml/badge.svg?branch=v0.2.2
229
- [test-url]: https://github.com/stdlib-js/blas-ext-base-dsortins/actions/workflows/test.yml?query=branch:v0.2.2
352
+ [test-image]: https://github.com/stdlib-js/blas-ext-base-dsortins/actions/workflows/test.yml/badge.svg?branch=v0.3.1
353
+ [test-url]: https://github.com/stdlib-js/blas-ext-base-dsortins/actions/workflows/test.yml?query=branch:v0.3.1
230
354
 
231
355
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsortins/main.svg
232
356
  [coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsortins?branch=main
@@ -238,8 +362,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
238
362
 
239
363
  -->
240
364
 
241
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
242
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
365
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
366
+ [chat-url]: https://stdlib.zulipchat.com
243
367
 
244
368
  [stdlib]: https://github.com/stdlib-js/stdlib
245
369
 
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- "use strict";var p=function(l,q){return function(){return q||l((q={exports:{}}).exports,q),q.exports}};var y=p(function(K,k){
2
- var c=require('@stdlib/math-base-assert-is-negative-zero/dist'),g=require('@stdlib/math-base-assert-is-nan/dist');function A(l,q,a,r){var h,i,e,v,o,n,f,u;if(l<=0||q===0)return a;if(q<0&&(r*=-1),r<0){for(v=(1-l)*r,o=0,i=v+r,u=1;u<l;u++)if(n=a[i],g(n)){for(e=i;e>o;)a[e]=a[e+r],e+=r;a[o]=n}else{for(h=c(n),e=i-r;e<=v&&(f=a[e],!(f<=n&&!(h&&f===n&&c(f)===!1)));)a[e+r]=f,e-=r;a[e+r]=n,i+=r}return a}for(v=0,o=(l-1)*r,i=v+r,u=1;u<l;u++)if(n=a[i],g(n)){for(e=i;e<o;)a[e]=a[e+r],e+=r;a[o]=n}else{for(h=c(n),e=i-r;e>=v&&(f=a[e],!(f<=n&&!(h&&f===n&&c(f)===!1)));)a[e+r]=f,e-=r;a[e+r]=n,i+=r}return a}k.exports=A
3
- });var Z=p(function(L,R){
4
- var j=require('@stdlib/math-base-assert-is-negative-zero/dist'),m=require('@stdlib/math-base-assert-is-nan/dist');function B(l,q,a,r,h){var i,e,v,o,n,f,u,w;if(l<=0||q===0)return a;if(q<0&&(r*=-1,h-=(l-1)*r),o=h,n=o+(l-1)*r,e=o+r,r<0){for(w=1;w<l;w++)if(f=a[e],m(f)){for(v=e;v>n;)a[v]=a[v+r],v+=r;a[n]=f}else{for(i=j(f),v=e-r;v<=o&&(u=a[v],!(u<=f&&!(i&&u===f&&j(u)===!1)));)a[v+r]=u,v-=r;a[v+r]=f,e+=r}return a}for(w=1;w<l;w++)if(f=a[e],m(f)){for(v=e;v<n;)a[v]=a[v+r],v+=r;a[n]=f}else{for(i=j(f),v=e-r;v>=o&&(u=a[v],!(u<=f&&!(i&&u===f&&j(u)===!1)));)a[v+r]=u,v-=r;a[v+r]=f,e+=r}return a}R.exports=B
5
- });var O=p(function(M,E){
6
- var C=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),_=y(),D=Z();C(_,"ndarray",D);E.exports=_
7
- });var F=require("path").join,G=require('@stdlib/utils-try-require/dist'),H=require('@stdlib/assert-is-error/dist'),I=O(),b,z=G(F(__dirname,"./native.js"));H(z)?b=I:b=z;module.exports=b;
1
+ "use strict";var c=function(v,u){return function(){return u||v((u={exports:{}}).exports,u),u.exports}};var p=c(function(I,w){
2
+ var t=require('@stdlib/math-base-assert-is-negative-zero/dist'),j=require('@stdlib/math-base-assert-is-nan/dist');function E(v,u,a,r,h){var s,f,e,l,q,i,n,o;if(v<=0||u===0)return a;if(u<0&&(r*=-1,h-=(v-1)*r),l=h,q=l+(v-1)*r,f=l+r,r<0){for(o=1;o<v;o++)if(i=a[f],j(i)){for(e=f;e>q;)a[e]=a[e+r],e+=r;a[q]=i}else{for(s=t(i),e=f-r;e<=l&&(n=a[e],!(n<=i&&!(s&&n===i&&t(n)===!1)));)a[e+r]=n,e-=r;a[e+r]=i,f+=r}return a}for(o=1;o<v;o++)if(i=a[f],j(i)){for(e=f;e<q;)a[e]=a[e+r],e+=r;a[q]=i}else{for(s=t(i),e=f-r;e>=l&&(n=a[e],!(n<=i&&!(s&&n===i&&t(n)===!1)));)a[e+r]=n,e-=r;a[e+r]=i,f+=r}return a}w.exports=E
3
+ });var b=c(function(J,m){
4
+ var O=require('@stdlib/strided-base-stride2offset/dist'),Z=p();function z(v,u,a,r){return Z(v,u,a,r,O(v,r))}m.exports=z
5
+ });var R=c(function(K,k){
6
+ var A=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),g=b(),B=p();A(g,"ndarray",B);k.exports=g
7
+ });var C=require("path").join,D=require('@stdlib/utils-try-require/dist'),F=require('@stdlib/assert-is-error/dist'),G=R(),y,_=D(C(__dirname,"./native.js"));F(_)?y=G:y=_;module.exports=y;
8
8
  /** @license Apache-2.0 */
9
9
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../lib/dsortins.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* Sorts a double-precision floating-point strided array using insertion sort.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} order - sort order\n* @param {Float64Array} x - input array\n* @param {integer} stride - index increment\n* @returns {Float64Array} input array\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*\n* dsortins( x.length, 1.0, x, 1 );\n* // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*/\nfunction dsortins( N, order, x, stride ) {\n\tvar flg;\n\tvar ix;\n\tvar jx;\n\tvar fx;\n\tvar lx;\n\tvar v;\n\tvar u;\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\tstride *= -1;\n\t}\n\tif ( stride < 0 ) {\n\t\t// Traverse the strided array from right-to-left...\n\t\tfx = (1-N) * stride; // first index\n\t\tlx = 0; // last index\n\t\tix = fx + stride;\n\n\t\t// Sort in increasing order...\n\t\tfor ( i = 1; i < N; i++ ) {\n\t\t\tv = x[ ix ];\n\n\t\t\t// Sort `NaN` values to the end (i.e., the left)...\n\t\t\tif ( isnan( v ) ) {\n\t\t\t\tjx = ix;\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+stride ];\n\t\t\t\t\tjx += stride;\n\t\t\t\t}\n\t\t\t\tx[ lx ] = v;\n\t\t\t} else {\n\t\t\t\tflg = isNegativeZero( v );\n\t\t\t\tjx = ix - stride;\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\tu = x[ jx ];\n\t\t\t\t\tif ( u <= v && !(flg && u === v && isNegativeZero( u ) === 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+stride ] = u;\n\t\t\t\t\tjx -= stride;\n\t\t\t\t}\n\t\t\t\tx[ jx+stride ] = v;\n\t\t\t\tix += stride;\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) * stride; // last index\n\tix = fx + stride;\n\n\t// Sort in increasing order...\n\tfor ( i = 1; i < N; i++ ) {\n\t\tv = x[ ix ];\n\n\t\t// Sort `NaN` values to the end...\n\t\tif ( isnan( v ) ) {\n\t\t\tjx = ix;\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+stride ];\n\t\t\t\tjx += stride;\n\t\t\t}\n\t\t\tx[ lx ] = v;\n\t\t} else {\n\t\t\tflg = isNegativeZero( v );\n\t\t\tjx = ix - stride;\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\tu = x[ jx ];\n\t\t\t\tif ( u <= v && !(flg && u === v && isNegativeZero( u ) === 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+stride ] = u;\n\t\t\t\tjx -= stride;\n\t\t\t}\n\t\t\tx[ jx+stride ] = v;\n\t\t\tix += stride;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsortins;\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* Sorts a double-precision floating-point strided array using insertion sort.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} order - sort order\n* @param {Float64Array} x - input array\n* @param {integer} stride - index increment\n* @param {NonNegativeInteger} offset - starting index\n* @returns {Float64Array} input array\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*\n* dsortins( x.length, 1.0, x, 1, 0 );\n* // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*/\nfunction dsortins( N, order, x, stride, offset ) {\n\tvar flg;\n\tvar ix;\n\tvar jx;\n\tvar fx;\n\tvar lx;\n\tvar v;\n\tvar u;\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\tstride *= -1;\n\t\toffset -= (N-1) * stride;\n\t}\n\tfx = offset; // first index\n\tlx = fx + ((N-1)*stride); // last index\n\tix = fx + stride;\n\n\tif ( stride < 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\tv = x[ ix ];\n\n\t\t\t// Sort `NaN` values to the end (i.e., the left)...\n\t\t\tif ( isnan( v ) ) {\n\t\t\t\tjx = ix;\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+stride ];\n\t\t\t\t\tjx += stride;\n\t\t\t\t}\n\t\t\t\tx[ lx ] = v;\n\t\t\t} else {\n\t\t\t\tflg = isNegativeZero( v );\n\t\t\t\tjx = ix - stride;\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\tu = x[ jx ];\n\t\t\t\t\tif ( u <= v && !(flg && u === v && isNegativeZero( u ) === 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+stride ] = u;\n\t\t\t\t\tjx -= stride;\n\t\t\t\t}\n\t\t\t\tx[ jx+stride ] = v;\n\t\t\t\tix += stride;\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\tv = x[ ix ];\n\n\t\t// Sort `NaN` values to the end...\n\t\tif ( isnan( v ) ) {\n\t\t\tjx = ix;\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+stride ];\n\t\t\t\tjx += stride;\n\t\t\t}\n\t\t\tx[ lx ] = v;\n\t\t} else {\n\t\t\tflg = isNegativeZero( v );\n\t\t\tjx = ix - stride;\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\tu = x[ jx ];\n\t\t\t\tif ( u <= v && !(flg && u === v && isNegativeZero( u ) === 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+stride ] = u;\n\t\t\t\tjx -= stride;\n\t\t\t}\n\t\t\tx[ jx+stride ] = v;\n\t\t\tix += stride;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsortins;\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 dsortins = require( './dsortins.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsortins, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsortins;\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* Sort a double-precision floating-point strided array using insertion sort.\n*\n* @module @stdlib/blas-ext-base-dsortins\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsortins = require( '@stdlib/blas-ext-base-dsortins' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n*\n* dsortins( x.length, 1.0, x, 1 );\n* // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsortins = require( '@stdlib/blas-ext-base-dsortins' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n*\n* dsortins.ndarray( x.length, 1.0, x, 1, 0 );\n* // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.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 dsortins;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsortins = main;\n} else {\n\tdsortins = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsortins;\n\n// exports: { \"ndarray\": \"dsortins.ndarray\" }\n"],
5
- "mappings": "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",
6
- "names": ["require_dsortins", "__commonJSMin", "exports", "module", "isNegativeZero", "isnan", "dsortins", "N", "order", "x", "stride", "flg", "ix", "jx", "fx", "lx", "v", "u", "i", "require_ndarray", "__commonJSMin", "exports", "module", "isNegativeZero", "isnan", "dsortins", "N", "order", "x", "stride", "offset", "flg", "ix", "jx", "fx", "lx", "v", "i", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsortins", "ndarray", "join", "tryRequire", "isError", "main", "dsortins", "tmp"]
3
+ "sources": ["../lib/ndarray.js", "../lib/dsortins.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* Sorts a double-precision floating-point strided array using insertion sort.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} order - sort order\n* @param {Float64Array} x - input array\n* @param {integer} strideX - stride length\n* @param {NonNegativeInteger} offsetX - starting index\n* @returns {Float64Array} input array\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*\n* dsortins( x.length, 1.0, x, 1, 0 );\n* // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*/\nfunction dsortins( N, order, x, strideX, offsetX ) {\n\tvar flg;\n\tvar ix;\n\tvar jx;\n\tvar fx;\n\tvar lx;\n\tvar v;\n\tvar u;\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\toffsetX -= (N-1) * strideX;\n\t}\n\tfx = offsetX; // first index\n\tlx = fx + ((N-1)*strideX); // last index\n\tix = fx + strideX;\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\tv = x[ ix ];\n\n\t\t\t// Sort `NaN` values to the end (i.e., the left)...\n\t\t\tif ( isnan( v ) ) {\n\t\t\t\tjx = ix;\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\tjx += strideX;\n\t\t\t\t}\n\t\t\t\tx[ lx ] = v;\n\t\t\t} else {\n\t\t\t\tflg = isNegativeZero( v );\n\t\t\t\tjx = ix - strideX;\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\tu = x[ jx ];\n\t\t\t\t\tif ( u <= v && !(flg && u === v && isNegativeZero( u ) === 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 ] = u;\n\t\t\t\t\tjx -= strideX;\n\t\t\t\t}\n\t\t\t\tx[ jx+strideX ] = v;\n\t\t\t\tix += strideX;\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\tv = x[ ix ];\n\n\t\t// Sort `NaN` values to the end...\n\t\tif ( isnan( v ) ) {\n\t\t\tjx = ix;\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\tjx += strideX;\n\t\t\t}\n\t\t\tx[ lx ] = v;\n\t\t} else {\n\t\t\tflg = isNegativeZero( v );\n\t\t\tjx = ix - strideX;\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\tu = x[ jx ];\n\t\t\t\tif ( u <= v && !(flg && u === v && isNegativeZero( u ) === 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 ] = u;\n\t\t\t\tjx -= strideX;\n\t\t\t}\n\t\t\tx[ jx+strideX ] = v;\n\t\t\tix += strideX;\n\t\t}\n\t}\n\treturn x;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsortins;\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 stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\n/**\n* Sorts a double-precision floating-point strided array using insertion sort.\n*\n* @param {PositiveInteger} N - number of indexed elements\n* @param {number} order - sort order\n* @param {Float64Array} x - input array\n* @param {integer} strideX - stride length\n* @returns {Float64Array} input array\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*\n* dsortins( x.length, 1.0, x, 1 );\n* // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*/\nfunction dsortins( N, order, x, strideX ) {\n\treturn ndarray( N, order, x, strideX, stride2offset( N, strideX ) );\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsortins;\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 dsortins = require( './dsortins.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( dsortins, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = dsortins;\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* Sort a double-precision floating-point strided array using insertion sort.\n*\n* @module @stdlib/blas-ext-base-dsortins\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsortins = require( '@stdlib/blas-ext-base-dsortins' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n*\n* dsortins( x.length, 1.0, x, 1 );\n* // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var dsortins = require( '@stdlib/blas-ext-base-dsortins' );\n*\n* var x = new Float64Array( [ 1.0, -2.0, 3.0, -4.0 ] );\n*\n* dsortins.ndarray( x.length, 1.0, x, 1, 0 );\n* // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.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 dsortins;\nvar tmp = tryRequire( join( __dirname, './native.js' ) );\nif ( isError( tmp ) ) {\n\tdsortins = main;\n} else {\n\tdsortins = tmp;\n}\n\n\n// EXPORTS //\n\nmodule.exports = dsortins;\n\n// exports: { \"ndarray\": \"dsortins.ndarray\" }\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,2CAA4C,EACtEC,EAAQ,QAAS,iCAAkC,EAuBvD,SAASC,EAAUC,EAAGC,EAAOC,EAAGC,EAASC,EAAU,CAClD,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKZ,GAAK,GAAKC,IAAU,EACxB,OAAOC,EAWR,GARKD,EAAQ,IACZE,GAAW,GACXC,IAAYJ,EAAE,GAAKG,GAEpBK,EAAKJ,EACLK,EAAKD,GAAOR,EAAE,GAAGG,EACjBG,EAAKE,EAAKL,EAELA,EAAU,EAAI,CAIlB,IAAMS,EAAI,EAAGA,EAAIZ,EAAGY,IAInB,GAHAF,EAAIR,EAAGI,CAAG,EAGLR,EAAOY,CAAE,EAAI,CAIjB,IAHAH,EAAKD,EAGGC,EAAKE,GACZP,EAAGK,CAAG,EAAIL,EAAGK,EAAGJ,CAAQ,EACxBI,GAAMJ,EAEPD,EAAGO,CAAG,EAAIC,CACX,KAAO,CAKN,IAJAL,EAAMR,EAAgBa,CAAE,EACxBH,EAAKD,EAAKH,EAGFI,GAAMC,IACbG,EAAIT,EAAGK,CAAG,EACL,EAAAI,GAAKD,GAAK,EAAEL,GAAOM,IAAMD,GAAKb,EAAgBc,CAAE,IAAM,OAI3DT,EAAGK,EAAGJ,CAAQ,EAAIQ,EAClBJ,GAAMJ,EAEPD,EAAGK,EAAGJ,CAAQ,EAAIO,EAClBJ,GAAMH,CACP,CAED,OAAOD,CACR,CAIA,IAAMU,EAAI,EAAGA,EAAIZ,EAAGY,IAInB,GAHAF,EAAIR,EAAGI,CAAG,EAGLR,EAAOY,CAAE,EAAI,CAIjB,IAHAH,EAAKD,EAGGC,EAAKE,GACZP,EAAGK,CAAG,EAAIL,EAAGK,EAAGJ,CAAQ,EACxBI,GAAMJ,EAEPD,EAAGO,CAAG,EAAIC,CACX,KAAO,CAKN,IAJAL,EAAMR,EAAgBa,CAAE,EACxBH,EAAKD,EAAKH,EAGFI,GAAMC,IACbG,EAAIT,EAAGK,CAAG,EACL,EAAAI,GAAKD,GAAK,EAAEL,GAAOM,IAAMD,GAAKb,EAAgBc,CAAE,IAAM,OAI3DT,EAAGK,EAAGJ,CAAQ,EAAIQ,EAClBJ,GAAMJ,EAEPD,EAAGK,EAAGJ,CAAQ,EAAIO,EAClBJ,GAAMH,CACP,CAED,OAAOD,CACR,CAKAN,EAAO,QAAUG,ICjJjB,IAAAc,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,oCAAqC,EAC9DC,EAAU,IAsBd,SAASC,EAAUC,EAAGC,EAAOC,EAAGC,EAAU,CACzC,OAAOL,EAASE,EAAGC,EAAOC,EAAGC,EAASN,EAAeG,EAAGG,CAAQ,CAAE,CACnE,CAKAP,EAAO,QAAUG,ICpDjB,IAAAK,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAW,IACXC,EAAU,IAKdF,EAAaC,EAAU,UAAWC,CAAQ,EAK1CH,EAAO,QAAUE,ICYjB,IAAIE,EAAO,QAAS,MAAO,EAAE,KACzBC,EAAa,QAAS,2BAA4B,EAClDC,EAAU,QAAS,yBAA0B,EAC7CC,EAAO,IAKPC,EACAC,EAAMJ,EAAYD,EAAM,UAAW,aAAc,CAAE,EAClDE,EAASG,CAAI,EACjBD,EAAWD,EAEXC,EAAWC,EAMZ,OAAO,QAAUD",
6
+ "names": ["require_ndarray", "__commonJSMin", "exports", "module", "isNegativeZero", "isnan", "dsortins", "N", "order", "x", "strideX", "offsetX", "flg", "ix", "jx", "fx", "lx", "v", "u", "i", "require_dsortins", "__commonJSMin", "exports", "module", "stride2offset", "ndarray", "dsortins", "N", "order", "x", "strideX", "require_main", "__commonJSMin", "exports", "module", "setReadOnly", "dsortins", "ndarray", "join", "tryRequire", "isError", "main", "dsortins", "tmp"]
7
7
  }
@@ -28,7 +28,7 @@ interface Routine {
28
28
  * @param N - number of indexed elements
29
29
  * @param order - sort order
30
30
  * @param x - input array
31
- * @param stride - stride length
31
+ * @param strideX - stride length
32
32
  * @returns `x`
33
33
  *
34
34
  * @example
@@ -39,7 +39,7 @@ interface Routine {
39
39
  * dsortins( x.length, 1, x, 1 );
40
40
  * // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]
41
41
  */
42
- ( N: number, order: number, x: Float64Array, stride: number ): Float64Array;
42
+ ( N: number, order: number, x: Float64Array, strideX: number ): Float64Array;
43
43
 
44
44
  /**
45
45
  * Sorts a double-precision floating-point strided array using insertion sort and alternative indexing semantics.
@@ -47,8 +47,8 @@ interface Routine {
47
47
  * @param N - number of indexed elements
48
48
  * @param order - sort order
49
49
  * @param x - input array
50
- * @param stride - stride length
51
- * @param offset - starting index
50
+ * @param strideX - stride length
51
+ * @param offsetX - starting index
52
52
  * @returns `x`
53
53
  *
54
54
  * @example
@@ -59,7 +59,7 @@ interface Routine {
59
59
  * dsortins.ndarray( x.length, 1, x, 1, 0 );
60
60
  * // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]
61
61
  */
62
- ndarray( N: number, order: number, x: Float64Array, stride: number, offset: number ): Float64Array;
62
+ ndarray( N: number, order: number, x: Float64Array, strideX: number, offsetX: number ): Float64Array;
63
63
  }
64
64
 
65
65
  /**
@@ -68,7 +68,7 @@ interface Routine {
68
68
  * @param N - number of indexed elements
69
69
  * @param order - sort order
70
70
  * @param x - input array
71
- * @param stride - stride length
71
+ * @param strideX - stride length
72
72
  * @returns `x`
73
73
  *
74
74
  * @example
@@ -16,13 +16,10 @@
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_DSORTINS_H
23
20
  #define STDLIB_BLAS_EXT_BASE_DSORTINS_H
24
21
 
25
- #include <stdint.h>
22
+ #include "stdlib/blas/base/shared.h"
26
23
 
27
24
  /*
28
25
  * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
@@ -34,7 +31,12 @@ extern "C" {
34
31
  /**
35
32
  * Sorts a double-precision floating-point strided array using insertion sort.
36
33
  */
37
- void c_dsortins( const int64_t N, const double order, double *X, const int64_t stride );
34
+ void API_SUFFIX(stdlib_strided_dsortins)( const CBLAS_INT N, const double order, double *X, const CBLAS_INT strideX );
35
+
36
+ /**
37
+ * Sorts a double-precision floating-point strided array using insertion sort and alternative indexing semantics.
38
+ */
39
+ void API_SUFFIX(stdlib_strided_dsortins_ndarray)( const CBLAS_INT N, const double order, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
38
40
 
39
41
  #ifdef __cplusplus
40
42
  }
package/lib/dsortins.js CHANGED
@@ -20,8 +20,8 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
- var isNegativeZero = require( '@stdlib/math-base-assert-is-negative-zero' );
24
- var isnan = require( '@stdlib/math-base-assert-is-nan' );
23
+ var stride2offset = require( '@stdlib/strided-base-stride2offset' );
24
+ var ndarray = require( './ndarray.js' );
25
25
 
26
26
 
27
27
  // MAIN //
@@ -32,7 +32,7 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
32
32
  * @param {PositiveInteger} N - number of indexed elements
33
33
  * @param {number} order - sort order
34
34
  * @param {Float64Array} x - input array
35
- * @param {integer} stride - index increment
35
+ * @param {integer} strideX - stride length
36
36
  * @returns {Float64Array} input array
37
37
  *
38
38
  * @example
@@ -43,101 +43,8 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
43
43
  * dsortins( x.length, 1.0, x, 1 );
44
44
  * // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]
45
45
  */
46
- function dsortins( N, order, x, stride ) {
47
- var flg;
48
- var ix;
49
- var jx;
50
- var fx;
51
- var lx;
52
- var v;
53
- var u;
54
- var i;
55
-
56
- if ( N <= 0 || order === 0.0 ) {
57
- return x;
58
- }
59
- // 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...
60
- if ( order < 0.0 ) {
61
- stride *= -1;
62
- }
63
- if ( stride < 0 ) {
64
- // Traverse the strided array from right-to-left...
65
- fx = (1-N) * stride; // first index
66
- lx = 0; // last index
67
- ix = fx + stride;
68
-
69
- // Sort in increasing order...
70
- for ( i = 1; i < N; i++ ) {
71
- v = x[ ix ];
72
-
73
- // Sort `NaN` values to the end (i.e., the left)...
74
- if ( isnan( v ) ) {
75
- jx = ix;
76
-
77
- // Shift all values (including NaNs) to the left of the current element to the right...
78
- while ( jx > lx ) {
79
- x[ jx ] = x[ jx+stride ];
80
- jx += stride;
81
- }
82
- x[ lx ] = v;
83
- } else {
84
- flg = isNegativeZero( v );
85
- jx = ix - stride;
86
-
87
- // Shift all larger values to the right of the current element to the left...
88
- while ( jx <= fx ) {
89
- u = x[ jx ];
90
- if ( u <= v && !(flg && u === v && isNegativeZero( u ) === false) ) { // eslint-disable-line max-len
91
- // Note: positive zeros (and NaNs (e.g., when last element is NaN)) are sorted to the left
92
- break;
93
- }
94
- x[ jx+stride ] = u;
95
- jx -= stride;
96
- }
97
- x[ jx+stride ] = v;
98
- ix += stride;
99
- }
100
- }
101
- return x;
102
- }
103
- // Traverse the strided array from left-to-right...
104
- fx = 0; // first index
105
- lx = (N-1) * stride; // last index
106
- ix = fx + stride;
107
-
108
- // Sort in increasing order...
109
- for ( i = 1; i < N; i++ ) {
110
- v = x[ ix ];
111
-
112
- // Sort `NaN` values to the end...
113
- if ( isnan( v ) ) {
114
- jx = ix;
115
-
116
- // Shift all values (including NaNs) to the right of the current element to the left...
117
- while ( jx < lx ) {
118
- x[ jx ] = x[ jx+stride ];
119
- jx += stride;
120
- }
121
- x[ lx ] = v;
122
- } else {
123
- flg = isNegativeZero( v );
124
- jx = ix - stride;
125
-
126
- // Shift all larger values to the left of the current element to the right...
127
- while ( jx >= fx ) {
128
- u = x[ jx ];
129
- if ( u <= v && !(flg && u === v && isNegativeZero( u ) === false) ) { // eslint-disable-line max-len
130
- // Note: positive zeros (and NaNs (e.g., when first element is NaN)) are sorted to the right
131
- break;
132
- }
133
- x[ jx+stride ] = u;
134
- jx -= stride;
135
- }
136
- x[ jx+stride ] = v;
137
- ix += stride;
138
- }
139
- }
140
- return x;
46
+ function dsortins( N, order, x, strideX ) {
47
+ return ndarray( N, order, x, strideX, stride2offset( N, strideX ) );
141
48
  }
142
49
 
143
50
 
@@ -31,7 +31,7 @@ var addon = require( './../src/addon.node' );
31
31
  * @param {PositiveInteger} N - number of indexed elements
32
32
  * @param {number} order - sort order
33
33
  * @param {Float64Array} x - input array
34
- * @param {integer} stride - index increment
34
+ * @param {integer} strideX - stride length
35
35
  * @returns {Float64Array} input array
36
36
  *
37
37
  * @example
@@ -42,8 +42,8 @@ var addon = require( './../src/addon.node' );
42
42
  * dsortins( x.length, 1.0, x, 1 );
43
43
  * // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]
44
44
  */
45
- function dsortins( N, order, x, stride ) {
46
- addon( N, order, x, stride );
45
+ function dsortins( N, order, x, strideX ) {
46
+ addon( N, order, x, strideX );
47
47
  return x;
48
48
  }
49
49
 
package/lib/ndarray.js CHANGED
@@ -32,8 +32,8 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
32
32
  * @param {PositiveInteger} N - number of indexed elements
33
33
  * @param {number} order - sort order
34
34
  * @param {Float64Array} x - input array
35
- * @param {integer} stride - index increment
36
- * @param {NonNegativeInteger} offset - starting index
35
+ * @param {integer} strideX - stride length
36
+ * @param {NonNegativeInteger} offsetX - starting index
37
37
  * @returns {Float64Array} input array
38
38
  *
39
39
  * @example
@@ -44,7 +44,7 @@ var isnan = require( '@stdlib/math-base-assert-is-nan' );
44
44
  * dsortins( x.length, 1.0, x, 1, 0 );
45
45
  * // x => <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]
46
46
  */
47
- function dsortins( N, order, x, stride, offset ) {
47
+ function dsortins( N, order, x, strideX, offsetX ) {
48
48
  var flg;
49
49
  var ix;
50
50
  var jx;
@@ -59,14 +59,14 @@ function dsortins( N, order, x, stride, offset ) {
59
59
  }
60
60
  // 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...
61
61
  if ( order < 0.0 ) {
62
- stride *= -1;
63
- offset -= (N-1) * stride;
62
+ strideX *= -1;
63
+ offsetX -= (N-1) * strideX;
64
64
  }
65
- fx = offset; // first index
66
- lx = fx + ((N-1)*stride); // last index
67
- ix = fx + stride;
65
+ fx = offsetX; // first index
66
+ lx = fx + ((N-1)*strideX); // last index
67
+ ix = fx + strideX;
68
68
 
69
- if ( stride < 0 ) {
69
+ if ( strideX < 0 ) {
70
70
  // Traverse the strided array from right-to-left...
71
71
 
72
72
  // Sort in increasing order...
@@ -79,13 +79,13 @@ function dsortins( N, order, x, stride, offset ) {
79
79
 
80
80
  // Shift all values (including NaNs) to the left of the current element to the right...
81
81
  while ( jx > lx ) {
82
- x[ jx ] = x[ jx+stride ];
83
- jx += stride;
82
+ x[ jx ] = x[ jx+strideX ];
83
+ jx += strideX;
84
84
  }
85
85
  x[ lx ] = v;
86
86
  } else {
87
87
  flg = isNegativeZero( v );
88
- jx = ix - stride;
88
+ jx = ix - strideX;
89
89
 
90
90
  // Shift all larger values to the right of the current element to the left...
91
91
  while ( jx <= fx ) {
@@ -94,11 +94,11 @@ function dsortins( N, order, x, stride, offset ) {
94
94
  // Note: positive zeros (and NaNs (e.g., when last element is NaN)) are sorted to the left
95
95
  break;
96
96
  }
97
- x[ jx+stride ] = u;
98
- jx -= stride;
97
+ x[ jx+strideX ] = u;
98
+ jx -= strideX;
99
99
  }
100
- x[ jx+stride ] = v;
101
- ix += stride;
100
+ x[ jx+strideX ] = v;
101
+ ix += strideX;
102
102
  }
103
103
  }
104
104
  return x;
@@ -115,13 +115,13 @@ function dsortins( N, order, x, stride, offset ) {
115
115
 
116
116
  // Shift all values (including NaNs) to the right of the current element to the left...
117
117
  while ( jx < lx ) {
118
- x[ jx ] = x[ jx+stride ];
119
- jx += stride;
118
+ x[ jx ] = x[ jx+strideX ];
119
+ jx += strideX;
120
120
  }
121
121
  x[ lx ] = v;
122
122
  } else {
123
123
  flg = isNegativeZero( v );
124
- jx = ix - stride;
124
+ jx = ix - strideX;
125
125
 
126
126
  // Shift all larger values to the left of the current element to the right...
127
127
  while ( jx >= fx ) {
@@ -130,11 +130,11 @@ function dsortins( N, order, x, stride, offset ) {
130
130
  // Note: positive zeros (and NaNs (e.g., when first element is NaN)) are sorted to the right
131
131
  break;
132
132
  }
133
- x[ jx+stride ] = u;
134
- jx -= stride;
133
+ x[ jx+strideX ] = u;
134
+ jx -= strideX;
135
135
  }
136
- x[ jx+stride ] = v;
137
- ix += stride;
136
+ x[ jx+strideX ] = v;
137
+ ix += strideX;
138
138
  }
139
139
  }
140
140
  return x;
@@ -20,8 +20,7 @@
20
20
 
21
21
  // MODULES //
22
22
 
23
- var offsetView = require( '@stdlib/strided-base-offset-view' );
24
- var addon = require( './dsortins.native.js' );
23
+ var addon = require( './../src/addon.node' );
25
24
 
26
25
 
27
26
  // MAIN //
@@ -32,8 +31,8 @@ var addon = require( './dsortins.native.js' );
32
31
  * @param {PositiveInteger} N - number of indexed elements
33
32
  * @param {number} order - sort order
34
33
  * @param {Float64Array} x - input array
35
- * @param {integer} stride - index increment
36
- * @param {NonNegativeInteger} offset - starting index
34
+ * @param {integer} strideX - stride length
35
+ * @param {NonNegativeInteger} offsetX - starting index
37
36
  * @returns {Float64Array} input array
38
37
  *
39
38
  * @example
@@ -43,15 +42,8 @@ var addon = require( './dsortins.native.js' );
43
42
  *
44
43
  * dsortins( x.length, 1.0, x, 1, 0 );
45
44
  */
46
- function dsortins( N, order, x, stride, offset ) {
47
- var view;
48
- if ( stride < 0 ) {
49
- order *= -1.0;
50
- stride *= -1;
51
- offset -= (N-1) * stride;
52
- }
53
- view = offsetView( x, offset );
54
- addon( N, order, view, stride );
45
+ function dsortins( N, order, x, strideX, offsetX ) {
46
+ addon.ndarray( N, order, x, strideX, offsetX );
55
47
  return x;
56
48
  }
57
49
 
package/manifest.json CHANGED
@@ -28,40 +28,57 @@
28
28
  {
29
29
  "task": "build",
30
30
  "src": [
31
- "./src/dsortins.c"
31
+ "./src/main.c"
32
32
  ],
33
33
  "include": [
34
34
  "./include"
35
35
  ],
36
- "libraries": [
37
- "-lm"
36
+ "libraries": [],
37
+ "libpath": [],
38
+ "dependencies": [
39
+ "@stdlib/napi-argv-double",
40
+ "@stdlib/napi-argv-int64",
41
+ "@stdlib/napi-export",
42
+ "@stdlib/napi-argv",
43
+ "@stdlib/napi-argv-strided-float64array",
44
+ "@stdlib/math-base-assert-is-nan",
45
+ "@stdlib/math-base-assert-is-negative-zero",
46
+ "@stdlib/strided-base-stride2offset",
47
+ "@stdlib/blas-base-shared"
48
+ ]
49
+ },
50
+ {
51
+ "task": "benchmark",
52
+ "src": [
53
+ "./src/main.c"
38
54
  ],
55
+ "include": [
56
+ "./include"
57
+ ],
58
+ "libraries": [],
39
59
  "libpath": [],
40
60
  "dependencies": [
41
61
  "@stdlib/math-base-assert-is-nan",
42
62
  "@stdlib/math-base-assert-is-negative-zero",
43
- "@stdlib/napi-argv",
44
- "@stdlib/napi-argv-int64",
45
- "@stdlib/napi-argv-double",
46
- "@stdlib/napi-argv-strided-float64array",
47
- "@stdlib/napi-export"
63
+ "@stdlib/strided-base-stride2offset",
64
+ "@stdlib/blas-base-shared"
48
65
  ]
49
66
  },
50
67
  {
51
68
  "task": "examples",
52
69
  "src": [
53
- "./src/dsortins.c"
70
+ "./src/main.c"
54
71
  ],
55
72
  "include": [
56
73
  "./include"
57
74
  ],
58
- "libraries": [
59
- "-lm"
60
- ],
75
+ "libraries": [],
61
76
  "libpath": [],
62
77
  "dependencies": [
78
+ "@stdlib/math-base-assert-is-nan",
63
79
  "@stdlib/math-base-assert-is-negative-zero",
64
- "@stdlib/math-base-assert-is-nan"
80
+ "@stdlib/strided-base-stride2offset",
81
+ "@stdlib/blas-base-shared"
65
82
  ]
66
83
  }
67
84
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/blas-ext-base-dsortins",
3
- "version": "0.2.2",
3
+ "version": "0.3.1",
4
4
  "description": "Sort a double-precision floating-point strided array using insertion sort.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -35,15 +35,17 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@stdlib/assert-is-error": "^0.2.2",
38
- "@stdlib/math-base-assert-is-nan": "^0.2.2",
39
- "@stdlib/math-base-assert-is-negative-zero": "^0.2.2",
40
- "@stdlib/napi-argv": "^0.2.2",
41
- "@stdlib/napi-argv-double": "^0.2.1",
42
- "@stdlib/napi-argv-int64": "^0.2.2",
43
- "@stdlib/napi-argv-strided-float64array": "^0.2.2",
44
- "@stdlib/napi-export": "^0.2.2",
45
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2",
46
- "@stdlib/utils-library-manifest": "^0.2.2",
38
+ "@stdlib/blas-base-shared": "^0.2.1",
39
+ "@stdlib/math-base-assert-is-nan": "^0.2.3",
40
+ "@stdlib/math-base-assert-is-negative-zero": "^0.2.3",
41
+ "@stdlib/napi-argv": "^0.2.3",
42
+ "@stdlib/napi-argv-double": "^0.2.2",
43
+ "@stdlib/napi-argv-int64": "^0.2.3",
44
+ "@stdlib/napi-argv-strided-float64array": "^0.2.3",
45
+ "@stdlib/napi-export": "^0.3.1",
46
+ "@stdlib/strided-base-stride2offset": "^0.1.1",
47
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3",
48
+ "@stdlib/utils-library-manifest": "^0.2.3",
47
49
  "@stdlib/utils-try-require": "^0.2.2"
48
50
  },
49
51
  "devDependencies": {},
@@ -81,7 +83,6 @@
81
83
  "double",
82
84
  "float64array"
83
85
  ],
84
- "__stdlib__": {},
85
86
  "funding": {
86
87
  "type": "opencollective",
87
88
  "url": "https://opencollective.com/stdlib"
package/src/addon.c CHANGED
@@ -36,10 +36,27 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
36
36
  STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
37
37
  STDLIB_NAPI_ARGV_DOUBLE( env, order, argv, 1 );
38
38
  STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
39
- STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, order, argv, 2 );
39
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
40
+ API_SUFFIX(stdlib_strided_dsortins)( N, order, X, strideX );
41
+ return NULL;
42
+ }
40
43
 
41
- c_dsortins( N, order, X, strideX );
44
+ /**
45
+ * Receives JavaScript callback invocation data.
46
+ *
47
+ * @param env environment under which the function is invoked
48
+ * @param info callback data
49
+ * @return Node-API value
50
+ */
51
+ static napi_value addon_method( napi_env env, napi_callback_info info ) {
52
+ STDLIB_NAPI_ARGV( env, info, argv, argc, 5 );
53
+ STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
54
+ STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 );
55
+ STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 );
56
+ STDLIB_NAPI_ARGV_DOUBLE( env, order, argv, 1 );
57
+ STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 );
58
+ API_SUFFIX(stdlib_strided_dsortins_ndarray)( N, order, X, strideX, offsetX );
42
59
  return NULL;
43
60
  }
44
61
 
45
- STDLIB_NAPI_MODULE_EXPORT_FCN( addon )
62
+ STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method );
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license Apache-2.0
3
3
  *
4
- * Copyright (c) 2020 The Stdlib Authors.
4
+ * Copyright (c) 2025 The Stdlib Authors.
5
5
  *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
@@ -19,7 +19,8 @@
19
19
  #include "stdlib/blas/ext/base/dsortins.h"
20
20
  #include "stdlib/math/base/assert/is_negative_zero.h"
21
21
  #include "stdlib/math/base/assert/is_nan.h"
22
- #include <stdint.h>
22
+ #include "stdlib/blas/base/shared.h"
23
+ #include "stdlib/strided/base/stride2offset.h"
23
24
  #include <stdbool.h>
24
25
 
25
26
  /**
@@ -28,15 +29,30 @@
28
29
  * @param N number of indexed elements
29
30
  * @param order sort order
30
31
  * @param X input array
31
- * @param stride index increment
32
+ * @param strideX index increment
32
33
  */
33
- void c_dsortins( const int64_t N, const double order, double *X, const int64_t stride ) {
34
- int64_t ix;
35
- int64_t jx;
36
- int64_t fx;
37
- int64_t lx;
38
- int64_t sx;
39
- int64_t i;
34
+ void API_SUFFIX(stdlib_strided_dsortins)( const CBLAS_INT N, const double order, double *X, const CBLAS_INT strideX ) {
35
+ CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
36
+ API_SUFFIX(stdlib_strided_dsortins_ndarray)( N, order, X, strideX, ox );
37
+ }
38
+
39
+ /**
40
+ * Sorts a double-precision floating-point strided array using insertion sort and alternative indexing semantics.
41
+ *
42
+ * @param N number of indexed elements
43
+ * @param order sort order
44
+ * @param X input array
45
+ * @param strideX index increment
46
+ * @param offsetX starting index
47
+ */
48
+ void API_SUFFIX(stdlib_strided_dsortins_ndarray)( const CBLAS_INT N, const double order, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
49
+ CBLAS_INT ix;
50
+ CBLAS_INT jx;
51
+ CBLAS_INT fx;
52
+ CBLAS_INT lx;
53
+ CBLAS_INT sx;
54
+ CBLAS_INT ox;
55
+ CBLAS_INT i;
40
56
  double v;
41
57
  double u;
42
58
  bool flg;
@@ -46,15 +62,17 @@ void c_dsortins( const int64_t N, const double order, double *X, const int64_t s
46
62
  }
47
63
  // 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...
48
64
  if ( order < 0.0 ) {
49
- sx = -stride;
65
+ sx = -strideX;
66
+ ox = offsetX - ( (N-1) * sx );
50
67
  } else {
51
- sx = stride;
68
+ sx = strideX;
69
+ ox = offsetX;
52
70
  }
71
+ fx = ox;
72
+ lx = fx + ( (N-1) * sx );
73
+ ix = fx + sx;
53
74
  if ( sx < 0 ) {
54
75
  // Traverse the strided array from right-to-left...
55
- fx = (1-N) * sx; // first index
56
- lx = 0; // last index
57
- ix = fx + sx;
58
76
 
59
77
  // Sort in increasing order...
60
78
  for ( i = 1; i < N; i++ ) {
@@ -90,9 +108,6 @@ void c_dsortins( const int64_t N, const double order, double *X, const int64_t s
90
108
  return;
91
109
  }
92
110
  // Traverse the strided array from left-to-right...
93
- fx = 0; // first index
94
- lx = (N-1) * sx; // last index
95
- ix = fx + sx;
96
111
 
97
112
  // Sort in increasing order...
98
113
  for ( i = 1; i < N; i++ ) {