@stdlib/blas-ext-base-dsort2ins 0.0.9 → 0.1.0

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/CITATION.cff ADDED
@@ -0,0 +1,30 @@
1
+ cff-version: 1.2.0
2
+ title: stdlib
3
+ message: >-
4
+ If you use this software, please cite it using the
5
+ metadata from this file.
6
+
7
+ type: software
8
+
9
+ authors:
10
+ - name: The Stdlib Authors
11
+ url: https://github.com/stdlib-js/stdlib/graphs/contributors
12
+
13
+ repository-code: https://github.com/stdlib-js/stdlib
14
+ url: https://stdlib.io
15
+
16
+ abstract: |
17
+ Standard library for JavaScript and Node.js.
18
+
19
+ keywords:
20
+ - JavaScript
21
+ - Node.js
22
+ - TypeScript
23
+ - standard library
24
+ - scientific computing
25
+ - numerical computing
26
+ - statistical computing
27
+
28
+ license: Apache-2.0 AND BSL-1.0
29
+
30
+ date-released: 2016
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2022 The Stdlib Authors.
1
+ Copyright (c) 2016-2023 The Stdlib Authors.
package/README.md CHANGED
@@ -18,6 +18,17 @@ limitations under the License.
18
18
 
19
19
  -->
20
20
 
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
21
32
  # dsort2ins
22
33
 
23
34
  [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
@@ -226,9 +237,9 @@ console.log( y );
226
237
 
227
238
  ## See Also
228
239
 
229
- - <span class="package-name">[`@stdlib/blas/ext/base/dsortins`][@stdlib/blas/ext/base/dsortins]</span><span class="delimiter">: </span><span class="description">sort a double-precision floating-point strided array using insertion sort.</span>
230
- - <span class="package-name">[`@stdlib/blas/ext/base/gsort2ins`][@stdlib/blas/ext/base/gsort2ins]</span><span class="delimiter">: </span><span class="description">simultaneously sort two strided arrays based on the sort order of the first array using insertion sort.</span>
231
- - <span class="package-name">[`@stdlib/blas/ext/base/ssort2ins`][@stdlib/blas/ext/base/ssort2ins]</span><span class="delimiter">: </span><span class="description">simultaneously sort two single-precision floating-point strided arrays based on the sort order of the first array using insertion sort.</span>
240
+ - <span class="package-name">[`@stdlib/blas-ext/base/dsortins`][@stdlib/blas/ext/base/dsortins]</span><span class="delimiter">: </span><span class="description">sort a double-precision floating-point strided array using insertion sort.</span>
241
+ - <span class="package-name">[`@stdlib/blas-ext/base/gsort2ins`][@stdlib/blas/ext/base/gsort2ins]</span><span class="delimiter">: </span><span class="description">simultaneously sort two strided arrays based on the sort order of the first array using insertion sort.</span>
242
+ - <span class="package-name">[`@stdlib/blas-ext/base/ssort2ins`][@stdlib/blas/ext/base/ssort2ins]</span><span class="delimiter">: </span><span class="description">simultaneously sort two single-precision floating-point strided arrays based on the sort order of the first array using insertion sort.</span>
232
243
 
233
244
  </section>
234
245
 
@@ -260,7 +271,7 @@ See [LICENSE][stdlib-license].
260
271
 
261
272
  ## Copyright
262
273
 
263
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
274
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
264
275
 
265
276
  </section>
266
277
 
@@ -273,8 +284,8 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
273
284
  [npm-image]: http://img.shields.io/npm/v/@stdlib/blas-ext-base-dsort2ins.svg
274
285
  [npm-url]: https://npmjs.org/package/@stdlib/blas-ext-base-dsort2ins
275
286
 
276
- [test-image]: https://github.com/stdlib-js/blas-ext-base-dsort2ins/actions/workflows/test.yml/badge.svg?branch=v0.0.9
277
- [test-url]: https://github.com/stdlib-js/blas-ext-base-dsort2ins/actions/workflows/test.yml?query=branch:v0.0.9
287
+ [test-image]: https://github.com/stdlib-js/blas-ext-base-dsort2ins/actions/workflows/test.yml/badge.svg?branch=v0.1.0
288
+ [test-url]: https://github.com/stdlib-js/blas-ext-base-dsort2ins/actions/workflows/test.yml?query=branch:v0.1.0
278
289
 
279
290
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/blas-ext-base-dsort2ins/main.svg
280
291
  [coverage-url]: https://codecov.io/github/stdlib-js/blas-ext-base-dsort2ins?branch=main
@@ -287,7 +298,7 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
287
298
  -->
288
299
 
289
300
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
290
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
301
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
291
302
 
292
303
  [stdlib]: https://github.com/stdlib-js/stdlib
293
304
 
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import dsort2ins from '../docs/types/index';
3
+ export = dsort2ins;
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";var e=function(w,m){return function(){return m||w((m={exports:{}}).exports,m),m.exports}};var C=e(function($,B){
2
+ var E=require('@stdlib/math-base-assert-is-negative-zero/dist'),A=require('@stdlib/math-base-assert-is-nan/dist');function L(w,m,v,a,j,r){var o,b,n,c,f,p,l,g,q,h,R,u,k;if(w<=0||m===0)return v;if(m<0&&(a*=-1,r*=-1),r<0?(g=(1-w)*r,q=0):(g=0,q=(w-1)*r),p=g+r,a<0){for(c=(1-w)*a,f=0,b=c+a,k=1;k<w;k++)if(h=v[b],R=j[p],A(h)){for(n=b,l=p;n>f;)v[n]=v[n+a],j[l]=j[l+r],n+=a,l+=r;v[f]=h,j[q]=R}else{for(o=E(h),n=b-a,l=p-r;n<=c&&(u=v[n],!(u<=h&&!(o&&u===h&&E(u)===!1)));)v[n+a]=u,j[l+r]=j[l],n-=a,l-=r;v[n+a]=h,j[l+r]=R,b+=a,p+=r}return v}for(c=0,f=(w-1)*a,b=c+a,k=1;k<w;k++)if(h=v[b],R=j[p],A(h)){for(n=b,l=p;n<f;)v[n]=v[n+a],j[l]=j[l+r],n+=a,l+=r;v[f]=h,j[q]=R}else{for(o=E(h),n=b-a,l=p-r;n>=c&&(u=v[n],!(u<=h&&!(o&&u===h&&E(u)===!1)));)v[n+a]=u,j[l+r]=j[l],n-=a,l-=r;v[n+a]=h,j[l+r]=R,b+=a,p+=r}return v}B.exports=L
3
+ });var G=e(function(i,F){
4
+ var O=require('@stdlib/math-base-assert-is-negative-zero/dist'),D=require('@stdlib/math-base-assert-is-nan/dist');function M(w,m,v,a,j,r,o,b){var n,c,f,p,l,g,q,h,R,u,k,Z,_;if(w<=0||m===0)return v;if(m<0&&(a*=-1,o*=-1,j-=(w-1)*a,b-=(w-1)*o),p=j,l=p+(w-1)*a,c=p+a,h=b,R=h+(w-1)*o,g=h+o,a<0){for(_=1;_<w;_++)if(u=v[c],k=r[g],D(u)){for(f=c,q=g;f>l;)v[f]=v[f+a],r[q]=r[q+o],f+=a,q+=o;v[l]=u,r[R]=k}else{for(n=O(u),f=c-a,q=g-o;f<=p&&(Z=v[f],!(Z<=u&&!(n&&Z===u&&O(Z)===!1)));)v[f+a]=Z,r[q+o]=r[q],f-=a,q-=o;v[f+a]=u,r[q+o]=k,c+=a,g+=o}return v}for(_=1;_<w;_++)if(u=v[c],k=r[g],D(u)){for(f=c,q=g;f<l;)v[f]=v[f+a],r[q]=r[q+o],f+=a,q+=o;v[l]=u,r[R]=k}else{for(n=O(u),f=c-a,q=g-o;f>=p&&(Z=v[f],!(Z<=u&&!(n&&Z===u&&O(Z)===!1)));)v[f+a]=Z,r[q+o]=r[q],f-=a,q-=o;v[f+a]=u,r[q+o]=k,c+=a,g+=o}return v}F.exports=M
5
+ });var J=e(function(N,I){
6
+ var P=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),H=C(),Q=G();P(H,"ndarray",Q);I.exports=H
7
+ });var S=require("path").join,T=require('@stdlib/utils-try-require/dist'),U=require('@stdlib/assert-is-error/dist'),V=J(),z,K=T(S(__dirname,"./native.js"));U(K)?z=V:z=K;module.exports=z;
8
+ /** @license Apache-2.0 */
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,2CAA4C,EACtEC,EAAQ,QAAS,iCAAkC,EA8BvD,SAASC,EAAWC,EAAGC,EAAOC,EAAGC,EAASC,EAAGC,EAAU,CACtD,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAEJ,GAAKlB,GAAK,GAAKC,IAAU,EACxB,OAAOC,EAgBR,GAbKD,EAAQ,IACZE,GAAW,GACXE,GAAW,IAEPA,EAAU,GACdQ,GAAM,EAAEb,GAAKK,EACbS,EAAK,IAELD,EAAK,EACLC,GAAMd,EAAE,GAAKK,GAEdM,EAAKE,EAAKR,EAELF,EAAU,EAAI,CAOlB,IALAM,GAAM,EAAET,GAAKG,EACbO,EAAK,EACLH,EAAKE,EAAKN,EAGJe,EAAI,EAAGA,EAAIlB,EAAGkB,IAKnB,GAJAH,EAAKb,EAAGK,CAAG,EACXS,EAAKZ,EAAGO,CAAG,EAGNb,EAAOiB,CAAG,EAAI,CAKlB,IAJAP,EAAKD,EACLK,EAAKD,EAGGH,EAAKE,GACZR,EAAGM,CAAG,EAAIN,EAAGM,EAAGL,CAAQ,EACxBC,EAAGQ,CAAG,EAAIR,EAAGQ,EAAGP,CAAQ,EACxBG,GAAML,EACNS,GAAMP,EAEPH,EAAGQ,CAAG,EAAIK,EACVX,EAAGU,CAAG,EAAIE,CACX,KAAO,CAMN,IALAV,EAAMT,EAAgBkB,CAAG,EACzBP,EAAKD,EAAKJ,EACVS,EAAKD,EAAKN,EAGFG,GAAMC,IACbQ,EAAKf,EAAGM,CAAG,EACN,EAAAS,GAAMF,GAAM,EAAET,GAAOW,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AKPC,EACAC,EAAMJ,EAAYD,EAAM,UAAW,aAAc,CAAE,EAClDE,EAASG,CAAI,EACjBD,EAAYD,EAEZC,EAAYC,EAMb,OAAO,QAAUD",
6
+ "names": ["require_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
+ }
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /**
22
22
  * Interface describing `dsort2ins`.
package/lib/index.js CHANGED
@@ -58,6 +58,7 @@
58
58
 
59
59
  var join = require( 'path' ).join;
60
60
  var tryRequire = require( '@stdlib/utils-try-require' );
61
+ var isError = require( '@stdlib/assert-is-error' );
61
62
  var main = require( './main.js' );
62
63
 
63
64
 
@@ -65,7 +66,7 @@ var main = require( './main.js' );
65
66
 
66
67
  var dsort2ins;
67
68
  var tmp = tryRequire( join( __dirname, './native.js' ) );
68
- if ( tmp instanceof Error ) {
69
+ if ( isError( tmp ) ) {
69
70
  dsort2ins = main;
70
71
  } else {
71
72
  dsort2ins = tmp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/blas-ext-base-dsort2ins",
3
- "version": "0.0.9",
3
+ "version": "0.1.0",
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": {
@@ -41,29 +41,30 @@
41
41
  "url": "https://github.com/stdlib-js/stdlib/issues"
42
42
  },
43
43
  "dependencies": {
44
- "@stdlib/math-base-assert-is-nan": "^0.0.x",
45
- "@stdlib/math-base-assert-is-negative-zero": "^0.0.x",
46
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x",
47
- "@stdlib/utils-library-manifest": "^0.0.x",
48
- "@stdlib/utils-try-require": "^0.0.x"
44
+ "@stdlib/assert-is-error": "^0.1.0",
45
+ "@stdlib/math-base-assert-is-nan": "^0.1.0",
46
+ "@stdlib/math-base-assert-is-negative-zero": "^0.1.0",
47
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0",
48
+ "@stdlib/utils-library-manifest": "^0.1.0",
49
+ "@stdlib/utils-try-require": "^0.1.0"
49
50
  },
50
51
  "devDependencies": {
51
- "@stdlib/array-float64": "^0.0.x",
52
- "@stdlib/assert-is-browser": "^0.0.x",
53
- "@stdlib/bench": "^0.0.x",
54
- "@stdlib/blas-base-dcopy": "^0.0.x",
55
- "@stdlib/math-base-assert-is-positive-zero": "^0.0.x",
56
- "@stdlib/math-base-special-floor": "^0.0.x",
57
- "@stdlib/math-base-special-pow": "^0.0.x",
58
- "@stdlib/math-base-special-round": "^0.0.x",
59
- "@stdlib/math-base-special-sqrt": "^0.0.x",
60
- "@stdlib/random-base-discrete-uniform": "^0.0.x",
61
- "@stdlib/random-base-randu": "^0.0.x",
62
- "@stdlib/random-base-uniform": "^0.0.x",
52
+ "@stdlib/array-float64": "^0.0.6",
53
+ "@stdlib/assert-is-browser": "^0.1.0",
54
+ "@stdlib/bench": "^0.1.0",
55
+ "@stdlib/blas-base-dcopy": "^0.0.10",
56
+ "@stdlib/math-base-assert-is-positive-zero": "^0.1.0",
57
+ "@stdlib/math-base-special-floor": "^0.0.8",
58
+ "@stdlib/math-base-special-pow": "^0.0.7",
59
+ "@stdlib/math-base-special-round": "^0.1.0",
60
+ "@stdlib/math-base-special-sqrt": "^0.0.8",
61
+ "@stdlib/random-base-discrete-uniform": "^0.0.6",
62
+ "@stdlib/random-base-randu": "^0.0.8",
63
+ "@stdlib/random-base-uniform": "^0.0.6",
63
64
  "proxyquire": "^2.0.0",
64
65
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
65
66
  "istanbul": "^0.4.1",
66
- "tap-spec": "5.x.x"
67
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
67
68
  },
68
69
  "engines": {
69
70
  "node": ">=0.10.0",
@@ -101,7 +102,7 @@
101
102
  ],
102
103
  "__stdlib__": {},
103
104
  "funding": {
104
- "type": "patreon",
105
- "url": "https://www.patreon.com/athan"
105
+ "type": "opencollective",
106
+ "url": "https://opencollective.com/stdlib"
106
107
  }
107
108
  }
package/docs/repl.txt DELETED
@@ -1,156 +0,0 @@
1
-
2
- {{alias}}( N, order, x, strideX, y, strideY )
3
- Simultaneously sorts two double-precision floating-point strided arrays
4
- based on the sort order of the first array using insertion sort.
5
-
6
- The `N` and `stride` parameters determine which elements in `x` and `y` are
7
- accessed at runtime.
8
-
9
- Indexing is relative to the first index. To introduce an offset, use typed
10
- array views.
11
-
12
- If `N <= 0` or `order == 0`, the function leaves `x` and `y` unchanged.
13
-
14
- The algorithm distinguishes between `-0` and `+0`. When sorted in increasing
15
- order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is
16
- sorted after `+0`.
17
-
18
- The algorithm sorts `NaN` values to the end. When sorted in increasing
19
- order, `NaN` values are sorted last. When sorted in decreasing order, `NaN`
20
- values are sorted first.
21
-
22
- The algorithm has space complexity O(1) and worst case time complexity
23
- O(N^2).
24
-
25
- The algorithm is efficient for *small* strided arrays (typically N <= 20)
26
- and is particularly efficient for sorting strided arrays which are already
27
- substantially sorted.
28
-
29
- The algorithm is *stable*, meaning that the algorithm does *not* change the
30
- order of strided array elements which are equal or equivalent (e.g., `NaN`
31
- values).
32
-
33
- The input strided arrays are sorted *in-place* (i.e., the input strided
34
- arrays is *mutated*).
35
-
36
- Parameters
37
- ----------
38
- N: integer
39
- Number of indexed elements.
40
-
41
- order: number
42
- Sort order. If `order < 0`, the function sorts `x` in decreasing order.
43
- If `order > 0`, the function sorts `x` in increasing order.
44
-
45
- x: Float64Array
46
- First input array.
47
-
48
- strideX: integer
49
- Index increment for `x`.
50
-
51
- y: Float64Array
52
- Second input array.
53
-
54
- strideY: integer
55
- Index increment for `y`.
56
-
57
- Returns
58
- -------
59
- x: Float64Array
60
- Input array `x`.
61
-
62
- Examples
63
- --------
64
- // Standard Usage:
65
- > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] );
66
- > var y = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0 ] );
67
- > {{alias}}( x.length, 1, x, 1, y, 1 )
68
- <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]
69
- > y
70
- <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]
71
-
72
- // Using `N` and `stride` parameters:
73
- > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] );
74
- > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0 ] );
75
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
76
- > {{alias}}( N, -1, x, 2, y, 2 )
77
- <Float64Array>[ 3.0, -2.0, 1.0, -4.0 ]
78
- > y
79
- <Float64Array>[ 2.0, 1.0, 0.0, 3.0 ]
80
-
81
- // Using view offsets:
82
- > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] );
83
- > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
84
- > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0 ] );
85
- > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 );
86
- > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
87
- > {{alias}}( N, 1, x1, 2, y1, 2 )
88
- <Float64Array>[ -4.0, 3.0, -2.0 ]
89
- > x0
90
- <Float64Array>[ 1.0, -4.0, 3.0, -2.0 ]
91
- > y0
92
- <Float64Array>[ 0.0, 3.0, 2.0, 1.0 ]
93
-
94
- {{alias}}.ndarray( N, order, x, strideX, offsetX, y, strideY, offsetY )
95
- Simultaneously sorts two double-precision floating-point strided arrays
96
- based on the sort order of the first array using insertion sort and
97
- alternative indexing semantics.
98
-
99
- While typed array views mandate a view offset based on the underlying
100
- buffer, the `offset` parameter supports indexing semantics based on a
101
- starting index.
102
-
103
- Parameters
104
- ----------
105
- N: integer
106
- Number of indexed elements.
107
-
108
- order: number
109
- Sort order. If `order < 0`, the function sorts `x` in decreasing order.
110
- If `order > 0`, the function sorts `x` in increasing order.
111
-
112
- x: Float64Array
113
- First input array.
114
-
115
- strideX: integer
116
- Index increment for `x`.
117
-
118
- offsetX: integer
119
- Starting index of `x`.
120
-
121
- y: Float64Array
122
- Second input array.
123
-
124
- strideY: integer
125
- Index increment for `y`.
126
-
127
- offsetY: integer
128
- Starting index of `y`.
129
-
130
- Returns
131
- -------
132
- x: Float64Array
133
- Input array `x`.
134
-
135
- Examples
136
- --------
137
- // Standard Usage:
138
- > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] );
139
- > var y = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0 ] );
140
- > {{alias}}.ndarray( x.length, 1, x, 1, 0, y, 1, 0 )
141
- <Float64Array>[ -4.0, -2.0, 1.0, 3.0 ]
142
- > y
143
- <Float64Array>[ 3.0, 1.0, 0.0, 2.0 ]
144
-
145
- // Using an index offset:
146
- > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0 ] );
147
- > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0 ] );
148
- > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
149
- > {{alias}}.ndarray( N, 1, x, 2, 1, y, 2, 1 )
150
- <Float64Array>[ 1.0, -4.0, 3.0, -2.0 ]
151
- > y
152
- <Float64Array>[ 0.0, 3.0, 2.0, 1.0 ]
153
-
154
- See Also
155
- --------
156
-
@@ -1,280 +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
- import dsort2ins = require( './index' );
20
-
21
-
22
- // TESTS //
23
-
24
- // The function returns a Float64Array...
25
- {
26
- const x = new Float64Array( 10 );
27
- const y = new Float64Array( 10 );
28
-
29
- dsort2ins( x.length, 1, x, 1, y, 1 ); // $ExpectType Float64Array
30
- }
31
-
32
- // The compiler throws an error if the function is provided a first argument which is not a number...
33
- {
34
- const x = new Float64Array( 10 );
35
- const y = new Float64Array( 10 );
36
-
37
- dsort2ins( '10', 1, x, 1, y, 1 ); // $ExpectError
38
- dsort2ins( true, 1, x, 1, y, 1 ); // $ExpectError
39
- dsort2ins( false, 1, x, 1, y, 1 ); // $ExpectError
40
- dsort2ins( null, 1, x, 1, y, 1 ); // $ExpectError
41
- dsort2ins( undefined, 1, x, 1, y, 1 ); // $ExpectError
42
- dsort2ins( [], 1, x, 1, y, 1 ); // $ExpectError
43
- dsort2ins( {}, 1, x, 1, y, 1 ); // $ExpectError
44
- dsort2ins( ( x: number ): number => x, 1, x, 1, y, 1 ); // $ExpectError
45
- }
46
-
47
- // The compiler throws an error if the function is provided a second argument which is not a number...
48
- {
49
- const x = new Float64Array( 10 );
50
- const y = new Float64Array( 10 );
51
-
52
- dsort2ins( x.length, '10', x, 1, y, 1 ); // $ExpectError
53
- dsort2ins( x.length, true, x, 1, y, 1 ); // $ExpectError
54
- dsort2ins( x.length, false, x, 1, y, 1 ); // $ExpectError
55
- dsort2ins( x.length, null, x, 1, y, 1 ); // $ExpectError
56
- dsort2ins( x.length, undefined, x, 1, y, 1 ); // $ExpectError
57
- dsort2ins( x.length, [], x, 1, y, 1 ); // $ExpectError
58
- dsort2ins( x.length, {}, x, 1, y, 1 ); // $ExpectError
59
- dsort2ins( x.length, ( x: number ): number => x, x, 1, y, 1 ); // $ExpectError
60
- }
61
-
62
- // The compiler throws an error if the function is provided a third argument which is not a Float64Array...
63
- {
64
- const x = new Float64Array( 10 );
65
- const y = new Float64Array( 10 );
66
-
67
- dsort2ins( x.length, 1, 10, 1, y, 1 ); // $ExpectError
68
- dsort2ins( x.length, 1, '10', 1, y, 1 ); // $ExpectError
69
- dsort2ins( x.length, 1, true, 1, y, 1 ); // $ExpectError
70
- dsort2ins( x.length, 1, false, 1, y, 1 ); // $ExpectError
71
- dsort2ins( x.length, 1, null, 1, y, 1 ); // $ExpectError
72
- dsort2ins( x.length, 1, undefined, 1, y, 1 ); // $ExpectError
73
- dsort2ins( x.length, 1, [], 1, y, 1 ); // $ExpectError
74
- dsort2ins( x.length, 1, {}, 1, y, 1 ); // $ExpectError
75
- dsort2ins( x.length, 1, ( x: number ): number => x, 1, y, 1 ); // $ExpectError
76
- }
77
-
78
- // The compiler throws an error if the function is provided a fourth argument which is not a number...
79
- {
80
- const x = new Float64Array( 10 );
81
- const y = new Float64Array( 10 );
82
-
83
- dsort2ins( x.length, 1, x, '10', y, 1 ); // $ExpectError
84
- dsort2ins( x.length, 1, x, true, y, 1 ); // $ExpectError
85
- dsort2ins( x.length, 1, x, false, y, 1 ); // $ExpectError
86
- dsort2ins( x.length, 1, x, null, y, 1 ); // $ExpectError
87
- dsort2ins( x.length, 1, x, undefined, y, 1 ); // $ExpectError
88
- dsort2ins( x.length, 1, x, [], y, 1 ); // $ExpectError
89
- dsort2ins( x.length, 1, x, {}, y, 1 ); // $ExpectError
90
- dsort2ins( x.length, 1, x, ( x: number ): number => x, y, 1 ); // $ExpectError
91
- }
92
-
93
- // The compiler throws an error if the function is provided a fifth argument which is not a Float64Array...
94
- {
95
- const x = new Float64Array( 10 );
96
-
97
- dsort2ins( x.length, 1, x, 1, 10, 1 ); // $ExpectError
98
- dsort2ins( x.length, 1, x, 1, '10', 1 ); // $ExpectError
99
- dsort2ins( x.length, 1, x, 1, true, 1 ); // $ExpectError
100
- dsort2ins( x.length, 1, x, 1, false, 1 ); // $ExpectError
101
- dsort2ins( x.length, 1, x, 1, null, 1 ); // $ExpectError
102
- dsort2ins( x.length, 1, x, 1, undefined, 1 ); // $ExpectError
103
- dsort2ins( x.length, 1, x, 1, [], 1 ); // $ExpectError
104
- dsort2ins( x.length, 1, x, 1, {}, 1 ); // $ExpectError
105
- dsort2ins( x.length, 1, x, 1, ( x: number ): number => x, 1 ); // $ExpectError
106
- }
107
-
108
- // The compiler throws an error if the function is provided a sixth argument which is not a number...
109
- {
110
- const x = new Float64Array( 10 );
111
- const y = new Float64Array( 10 );
112
-
113
- dsort2ins( x.length, 1, x, 1, y, '10' ); // $ExpectError
114
- dsort2ins( x.length, 1, x, 1, y, true ); // $ExpectError
115
- dsort2ins( x.length, 1, x, 1, y, false ); // $ExpectError
116
- dsort2ins( x.length, 1, x, 1, y, null ); // $ExpectError
117
- dsort2ins( x.length, 1, x, 1, y, undefined ); // $ExpectError
118
- dsort2ins( x.length, 1, x, 1, y, [] ); // $ExpectError
119
- dsort2ins( x.length, 1, x, 1, y, {} ); // $ExpectError
120
- dsort2ins( x.length, 1, x, 1, y, ( x: number ): number => x ); // $ExpectError
121
- }
122
-
123
- // The compiler throws an error if the function is provided an unsupported number of arguments...
124
- {
125
- const x = new Float64Array( 10 );
126
- const y = new Float64Array( 10 );
127
-
128
- dsort2ins(); // $ExpectError
129
- dsort2ins( x.length ); // $ExpectError
130
- dsort2ins( x.length, 1 ); // $ExpectError
131
- dsort2ins( x.length, 1, x ); // $ExpectError
132
- dsort2ins( x.length, 1, x, 1 ); // $ExpectError
133
- dsort2ins( x.length, 1, x, 1, y ); // $ExpectError
134
- dsort2ins( x.length, 1, x, 1, y, 1, 10 ); // $ExpectError
135
- }
136
-
137
- // Attached to main export is an `ndarray` method which returns a Float64Array...
138
- {
139
- const x = new Float64Array( 10 );
140
- const y = new Float64Array( 10 );
141
-
142
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, 0 ); // $ExpectType Float64Array
143
- }
144
-
145
- // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
146
- {
147
- const x = new Float64Array( 10 );
148
- const y = new Float64Array( 10 );
149
-
150
- dsort2ins.ndarray( '10', 1, x, 1, 0, y, 1, 0 ); // $ExpectError
151
- dsort2ins.ndarray( true, 1, x, 1, 0, y, 1, 0 ); // $ExpectError
152
- dsort2ins.ndarray( false, 1, x, 1, 0, y, 1, 0 ); // $ExpectError
153
- dsort2ins.ndarray( null, 1, x, 1, 0, y, 1, 0 ); // $ExpectError
154
- dsort2ins.ndarray( undefined, 1, x, 1, 0, y, 1, 0 ); // $ExpectError
155
- dsort2ins.ndarray( [], 1, x, 1, 0, y, 1, 0 ); // $ExpectError
156
- dsort2ins.ndarray( {}, 1, x, 1, 0, y, 1, 0 ); // $ExpectError
157
- dsort2ins.ndarray( ( x: number ): number => x, 1, x, 1, 0, y, 1, 0 ); // $ExpectError
158
- }
159
-
160
- // The compiler throws an error if the `ndarray` method is provided a second argument which is not a number...
161
- {
162
- const x = new Float64Array( 10 );
163
- const y = new Float64Array( 10 );
164
-
165
- dsort2ins.ndarray( x.length, '10', x, 1, 0, y, 1, 0 ); // $ExpectError
166
- dsort2ins.ndarray( x.length, true, x, 1, 0, y, 1, 0 ); // $ExpectError
167
- dsort2ins.ndarray( x.length, false, x, 1, 0, y, 1, 0 ); // $ExpectError
168
- dsort2ins.ndarray( x.length, null, x, 1, 0, y, 1, 0 ); // $ExpectError
169
- dsort2ins.ndarray( x.length, undefined, x, 1, 0, y, 1, 0 ); // $ExpectError
170
- dsort2ins.ndarray( x.length, [], x, 1, 0, y, 1, 0 ); // $ExpectError
171
- dsort2ins.ndarray( x.length, {}, x, 1, 0, y, 1, 0 ); // $ExpectError
172
- dsort2ins.ndarray( x.length, ( x: number ): number => x, x, 1, 0, y, 1, 0 ); // $ExpectError
173
- }
174
-
175
- // The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array...
176
- {
177
- const x = new Float64Array( 10 );
178
- const y = new Float64Array( 10 );
179
-
180
- dsort2ins.ndarray( x.length, 1, 10, 1, 0, y, 1, 0 ); // $ExpectError
181
- dsort2ins.ndarray( x.length, 1, '10', 1, 0, y, 1, 0 ); // $ExpectError
182
- dsort2ins.ndarray( x.length, 1, true, 1, 0, y, 1, 0 ); // $ExpectError
183
- dsort2ins.ndarray( x.length, 1, false, 1, 0, y, 1, 0 ); // $ExpectError
184
- dsort2ins.ndarray( x.length, 1, null, 1, 0, y, 1, 0 ); // $ExpectError
185
- dsort2ins.ndarray( x.length, 1, undefined, 1, 0, y, 1, 0 ); // $ExpectError
186
- dsort2ins.ndarray( x.length, 1, [], 1, 0, y, 1, 0 ); // $ExpectError
187
- dsort2ins.ndarray( x.length, 1, {}, 1, 0, y, 1, 0 ); // $ExpectError
188
- dsort2ins.ndarray( x.length, 1, ( x: number ): number => x, 1, 0, y, 1, 0 ); // $ExpectError
189
- }
190
-
191
- // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number...
192
- {
193
- const x = new Float64Array( 10 );
194
- const y = new Float64Array( 10 );
195
-
196
- dsort2ins.ndarray( x.length, 1, x, '10', 0, y, 1, 0 ); // $ExpectError
197
- dsort2ins.ndarray( x.length, 1, x, true, 0, y, 1, 0 ); // $ExpectError
198
- dsort2ins.ndarray( x.length, 1, x, false, 0, y, 1, 0 ); // $ExpectError
199
- dsort2ins.ndarray( x.length, 1, x, null, 0, y, 1, 0 ); // $ExpectError
200
- dsort2ins.ndarray( x.length, 1, x, undefined, 0, y, 1, 0 ); // $ExpectError
201
- dsort2ins.ndarray( x.length, 1, x, [], 0, y, 1, 0 ); // $ExpectError
202
- dsort2ins.ndarray( x.length, 1, x, {}, 0, y, 1, 0 ); // $ExpectError
203
- dsort2ins.ndarray( x.length, 1, x, ( x: number ): number => x, 0, y, 1, 0 ); // $ExpectError
204
- }
205
-
206
- // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number...
207
- {
208
- const x = new Float64Array( 10 );
209
- const y = new Float64Array( 10 );
210
-
211
- dsort2ins.ndarray( x.length, 1, x, 1, '10', y, 1, 0 ); // $ExpectError
212
- dsort2ins.ndarray( x.length, 1, x, 1, true, y, 1, 0 ); // $ExpectError
213
- dsort2ins.ndarray( x.length, 1, x, 1, false, y, 1, 0 ); // $ExpectError
214
- dsort2ins.ndarray( x.length, 1, x, 1, null, y, 1, 0 ); // $ExpectError
215
- dsort2ins.ndarray( x.length, 1, x, 1, undefined, y, 1, 0 ); // $ExpectError
216
- dsort2ins.ndarray( x.length, 1, x, 1, [], y, 1, 0 ); // $ExpectError
217
- dsort2ins.ndarray( x.length, 1, x, 1, {}, y, 1, 0 ); // $ExpectError
218
- dsort2ins.ndarray( x.length, 1, x, 1, ( x: number ): number => x, y, 1, 0 ); // $ExpectError
219
- }
220
-
221
- // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a Float64Array...
222
- {
223
- const x = new Float64Array( 10 );
224
-
225
- dsort2ins.ndarray( x.length, 1, x, 1, 0, 10, 1, 0 ); // $ExpectError
226
- dsort2ins.ndarray( x.length, 1, x, 1, 0, '10', 1, 0 ); // $ExpectError
227
- dsort2ins.ndarray( x.length, 1, x, 1, 0, true, 1, 0 ); // $ExpectError
228
- dsort2ins.ndarray( x.length, 1, x, 1, 0, false, 1, 0 ); // $ExpectError
229
- dsort2ins.ndarray( x.length, 1, x, 1, 0, null, 1, 0 ); // $ExpectError
230
- dsort2ins.ndarray( x.length, 1, x, 1, 0, undefined, 1, 0 ); // $ExpectError
231
- dsort2ins.ndarray( x.length, 1, x, 1, 0, [], 1, 0 ); // $ExpectError
232
- dsort2ins.ndarray( x.length, 1, x, 1, 0, {}, 1, 0 ); // $ExpectError
233
- dsort2ins.ndarray( x.length, 1, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError
234
- }
235
-
236
- // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number...
237
- {
238
- const x = new Float64Array( 10 );
239
- const y = new Float64Array( 10 );
240
-
241
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, '10', 0 ); // $ExpectError
242
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, true, 0 ); // $ExpectError
243
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, false, 0 ); // $ExpectError
244
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, null, 0 ); // $ExpectError
245
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, undefined, 0 ); // $ExpectError
246
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, [], 0 ); // $ExpectError
247
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, {}, 0 ); // $ExpectError
248
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, ( x: number ): number => x, 0 ); // $ExpectError
249
- }
250
-
251
- // The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number...
252
- {
253
- const x = new Float64Array( 10 );
254
- const y = new Float64Array( 10 );
255
-
256
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, '10' ); // $ExpectError
257
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, true ); // $ExpectError
258
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, false ); // $ExpectError
259
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, null ); // $ExpectError
260
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, undefined ); // $ExpectError
261
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, [] ); // $ExpectError
262
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, {} ); // $ExpectError
263
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, ( x: number ): number => x ); // $ExpectError
264
- }
265
-
266
- // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments...
267
- {
268
- const x = new Float64Array( 10 );
269
- const y = new Float64Array( 10 );
270
-
271
- dsort2ins.ndarray(); // $ExpectError
272
- dsort2ins.ndarray( x.length ); // $ExpectError
273
- dsort2ins.ndarray( x.length, 1 ); // $ExpectError
274
- dsort2ins.ndarray( x.length, 1, x ); // $ExpectError
275
- dsort2ins.ndarray( x.length, 1, x, 1 ); // $ExpectError
276
- dsort2ins.ndarray( x.length, 1, x, 1, 0 ); // $ExpectError
277
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y ); // $ExpectError
278
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1 ); // $ExpectError
279
- dsort2ins.ndarray( x.length, 1, x, 1, 0, y, 1, 0, 10 ); // $ExpectError
280
- }