You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/blas/ext/base/gsort2sh/README.md
+20-37Lines changed: 20 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ var gsort2sh = require( '@stdlib/blas/ext/base/gsort2sh' );
32
32
33
33
#### gsort2sh( N, order, x, strideX, y, strideY )
34
34
35
-
Simultaneously sorts two strided arrays based on the sort order of the first array `x`using Shellsort.
35
+
Simultaneously sorts two strided arrays based on the sort order of the first array using Shellsort.
36
36
37
37
```javascript
38
38
var x = [ 1.0, -2.0, 3.0, -4.0 ];
@@ -52,20 +52,17 @@ The function has the following parameters:
52
52
-**N**: number of indexed elements.
53
53
-**order**: sort order. If `order < 0.0`, the input strided array `x` is sorted in **decreasing** order. If `order > 0.0`, the input strided array `x` is sorted in **increasing** order. If `order == 0.0`, the input strided arrays are left unchanged.
54
54
-**x**: first input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
55
-
-**strideX**: `x` index increment.
55
+
-**strideX**: stride length for `x`.
56
56
-**y**: second input [`Array`][mdn-array] or [`typed array`][mdn-typed-array].
57
-
-**strideY**: `y` index increment.
57
+
-**strideY**: stride length for `y`.
58
58
59
-
The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to sort every other element
59
+
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to sort every other element:
60
60
61
61
```javascript
62
-
var floor =require( '@stdlib/math/base/special/floor' );
63
-
64
62
var x = [ 1.0, -2.0, 3.0, -4.0 ];
65
63
var y = [ 0.0, 1.0, 2.0, 3.0 ];
66
-
varN=floor( x.length/2 );
67
64
68
-
gsort2sh( N, -1.0, x, 2, y, 2 );
65
+
gsort2sh( 2, -1.0, x, 2, y, 2 );
69
66
70
67
console.log( x );
71
68
// => [ 3.0, -2.0, 1.0, -4.0 ]
@@ -78,7 +75,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [
var floor =require( '@stdlib/math/base/special/floor' );
82
78
83
79
// Initial arrays...
84
80
var x0 =newFloat64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
@@ -87,10 +83,9 @@ var y0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] );
87
83
// Create offset views...
88
84
var x1 =newFloat64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
89
85
var y1 =newFloat64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
90
-
varN=floor( x0.length/2 );
91
86
92
87
// Sort every other element...
93
-
gsort2sh( N, -1.0, x1, 2, y1, 2 );
88
+
gsort2sh( 2, -1.0, x1, 2, y1, 2 );
94
89
95
90
console.log( x0 );
96
91
// => <Float64Array>[ 1.0, 4.0, 3.0, 2.0 ]
@@ -101,7 +96,7 @@ console.log( y0 );
101
96
102
97
#### gsort2sh.ndarray( N, order, x, strideX, offsetX, y, strideY, offsetY )
103
98
104
-
Simultaneously sorts two strided arrays based on the sort order of the first array `x`using Shellsort and alternative indexing semantics.
99
+
Simultaneously sorts two strided arrays based on the sort order of the first array using Shellsort and alternative indexing semantics.
105
100
106
101
```javascript
107
102
var x = [ 1.0, -2.0, 3.0, -4.0 ];
@@ -118,10 +113,10 @@ console.log( y );
118
113
119
114
The function has the following additional parameters:
120
115
121
-
-**offsetX**: `x`starting index.
122
-
-**offsetY**: `y`starting index.
116
+
-**offsetX**: starting index for `x`.
117
+
-**offsetY**: starting index for `y`.
123
118
124
-
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`
119
+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to access only the last three elements:
125
120
126
121
```javascript
127
122
var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
@@ -145,6 +140,7 @@ console.log( y );
145
140
## Notes
146
141
147
142
- If `N <= 0` or `order == 0.0`, both functions leave `x` and `y` unchanged.
143
+
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor])
148
144
- The algorithm distinguishes between `-0` and `+0`. When sorted in increasing order, `-0` is sorted before `+0`. When sorted in decreasing order, `-0` is sorted after `+0`.
149
145
- The algorithm sorts `NaN` values to the end. When sorted in increasing order, `NaN` values are sorted last. When sorted in decreasing order, `NaN` values are sorted first.
150
146
- The algorithm has space complexity `O(1)` and worst case time complexity `O(N^(4/3))`.
@@ -164,30 +160,15 @@ console.log( y );
164
160
<!-- eslint no-undef: "error" -->
165
161
166
162
```javascript
167
-
var round =require( '@stdlib/math/base/special/round' );
168
-
var randu =require( '@stdlib/random/base/randu' );
0 commit comments