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
@@ -54,11 +54,11 @@ The function has the following parameters:
54
54
-**N**: number of indexed elements.
55
55
-**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.
56
56
-**x**: first input [`Float64Array`][@stdlib/array/float64].
57
-
-**strideX**: `x`index increment.
57
+
-**strideX**: `x`stride length.
58
58
-**y**: second input [`Float64Array`][@stdlib/array/float64].
59
-
-**strideY**: `y`index increment.
59
+
-**strideY**: `y`stride length.
60
60
61
-
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to sort every other element
61
+
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to sort every other element:
@@ -122,7 +122,7 @@ The function has the following additional parameters:
122
122
-**offsetX**: `x` starting index.
123
123
-**offsetY**: `y` starting index.
124
124
125
-
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`
125
+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to access only the last three elements of `x`:
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
172
170
var dsort2ins =require( '@stdlib/blas/ext/base/dsort2ins' );
173
171
174
-
var rand;
175
-
var sign;
176
-
var i;
177
-
178
-
var x =newFloat64Array( 10 );
179
-
var y =newFloat64Array( 10 ); // index array
180
-
for ( i =0; i <x.length; i++ ) {
181
-
rand =round( randu()*100.0 );
182
-
sign =randu();
183
-
if ( sign <0.5 ) {
184
-
sign =-1.0;
185
-
} else {
186
-
sign =1.0;
187
-
}
188
-
x[ i ] = sign * rand;
189
-
y[ i ] = i;
190
-
}
172
+
var x =discreteUniform( 10, -100, 100, {
173
+
'dtype':'float64'
174
+
});
175
+
var y =discreteUniform( 10, -100, 100, {
176
+
'dtype':'float64'
177
+
});
191
178
console.log( x );
192
179
console.log( y );
193
180
@@ -200,6 +187,139 @@ console.log( y );
200
187
201
188
<!-- /.examples -->
202
189
190
+
<!-- C interface documentation. -->
191
+
192
+
* * *
193
+
194
+
<sectionclass="c">
195
+
196
+
## C APIs
197
+
198
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
199
+
200
+
<sectionclass="intro">
201
+
202
+
</section>
203
+
204
+
<!-- /.intro -->
205
+
206
+
<!-- C usage documentation. -->
207
+
208
+
<sectionclass="usage">
209
+
210
+
### Usage
211
+
212
+
```c
213
+
#include"stdlib/blas/ext/base/dsort2ins.h"
214
+
```
215
+
216
+
#### stdlib_strided_dsort2ins( N, order, \*X, strideX, \*Y, strideY )
217
+
218
+
Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort.
219
+
220
+
```c
221
+
double x[] = { 1.0, -2.0, 3.0, -4.0 };
222
+
double y[] = { 0.0, 1.0, 2.0, 3.0 };
223
+
224
+
stdlib_strided_dsort2ins( 4, 1, x, 1, y, 1 );
225
+
```
226
+
227
+
The function accepts the following arguments:
228
+
229
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
230
+
- **order**: `[in] CBLAS_INT` sort order. If `order < 0.0`, the input strided array `x` is sorted in **decreasing** order. If `order > 0.0`, the input strided array `x` is sorted in **increasing** order. If `order == 0.0`, the input strided arrays are left unchanged.
231
+
- **X**: `[inout] double*` input array.
232
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
233
+
- **Y**: `[inout] double*` input array.
234
+
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
Simultaneously sorts two double-precision floating-point strided arrays based on the sort order of the first array using insertion sort and alternative indexing semantics.
247
+
248
+
```c
249
+
double x[] = { 1.0, -2.0, 3.0, -4.0 };
250
+
double y[] = { 0.0, 1.0, 2.0, 3.0 };
251
+
252
+
stdlib_strided_dsort2ins_ndarray( 4, 1, x, 1, 0, y, 1, 0 );
253
+
```
254
+
255
+
The function accepts the following arguments:
256
+
257
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
258
+
- **order**: `[in] CBLAS_INT` sort order.
259
+
- **X**: `[inout] double*` input array. If `order < 0.0`, the input strided array `x` is sorted in **decreasing** order. If `order > 0.0`, the input strided array `x` is sorted in **increasing** order. If `order == 0.0`, the input strided arrays are left unchanged.
260
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
261
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
262
+
- **Y**: `[inout] double*` input array.
263
+
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
264
+
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
0 commit comments