@@ -36,42 +36,38 @@ limitations under the License.
36
36
var dminsorted = require ( ' @stdlib/stats/base/dminsorted' );
37
37
```
38
38
39
- #### dminsorted( N, x, stride )
39
+ #### dminsorted( N, x, strideX )
40
40
41
41
Computes the minimum value of a sorted double-precision floating-point strided array ` x ` .
42
42
43
43
``` javascript
44
44
var Float64Array = require ( ' @stdlib/array/float64' );
45
45
46
46
var x = new Float64Array ( [ 1.0 , 2.0 , 3.0 ] );
47
- var N = x .length ;
48
47
49
- var v = dminsorted ( N , x, 1 );
48
+ var v = dminsorted ( x . length , x, 1 );
50
49
// returns 1.0
51
50
52
51
x = new Float64Array ( [ 3.0 , 2.0 , 1.0 ] );
53
- N = x .length ;
54
52
55
- v = dminsorted ( N , x, 1 );
53
+ v = dminsorted ( x . length , x, 1 );
56
54
// returns 1.0
57
55
```
58
56
59
57
The function has the following parameters:
60
58
61
59
- ** N** : number of indexed elements.
62
60
- ** x** : sorted input [ ` Float64Array ` ] [ @stdlib/array/float64 ] .
63
- - ** stride ** : index increment for ` x ` .
61
+ - ** strideX ** : stride length for ` x ` .
64
62
65
- The ` N ` and ` stride ` parameters determine which elements in ` x ` are accessed at runtime. For example, to compute the minimum value of every other element in ` x ` ,
63
+ The ` N ` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the minimum value of every other element in ` x ` ,
66
64
67
65
``` javascript
68
66
var Float64Array = require ( ' @stdlib/array/float64' );
69
- var floor = require ( ' @stdlib/math/base/special/floor' );
70
67
71
68
var x = new Float64Array ( [ 1.0 , 2.0 , 2.0 , - 7.0 , 3.0 , 3.0 , 4.0 , 2.0 ] );
72
- var N = floor ( x .length / 2 );
73
69
74
- var v = dminsorted ( N , x, 2 );
70
+ var v = dminsorted ( 4 , x, 2 );
75
71
// returns 1.0
76
72
```
77
73
@@ -81,45 +77,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
81
77
82
78
``` javascript
83
79
var Float64Array = require ( ' @stdlib/array/float64' );
84
- var floor = require ( ' @stdlib/math/base/special/floor' );
85
80
86
81
var x0 = new Float64Array ( [ 2.0 , 1.0 , 2.0 , 2.0 , - 2.0 , 2.0 , 3.0 , 4.0 ] );
87
82
var x1 = new Float64Array ( x0 .buffer , x0 .BYTES_PER_ELEMENT * 1 ); // start at 2nd element
88
83
89
- var N = floor ( x0 .length / 2 );
90
-
91
- var v = dminsorted ( N , x1, 2 );
84
+ var v = dminsorted ( 4 , x1, 2 );
92
85
// returns 1.0
93
86
```
94
87
95
- #### dminsorted.ndarray( N, x, stride, offset )
88
+ #### dminsorted.ndarray( N, x, strideX, offsetX )
96
89
97
90
Computes the minimum value of a sorted double-precision floating-point strided array using alternative indexing semantics.
98
91
99
92
``` javascript
100
93
var Float64Array = require ( ' @stdlib/array/float64' );
101
94
102
95
var x = new Float64Array ( [ 1.0 , 2.0 , 3.0 ] );
103
- var N = x .length ;
104
96
105
- var v = dminsorted .ndarray ( N , x, 1 , 0 );
97
+ var v = dminsorted .ndarray ( x . length , x, 1 , 0 );
106
98
// returns 1.0
107
99
```
108
100
109
101
The function has the following additional parameters:
110
102
111
- - ** offset ** : starting index for ` x ` .
103
+ - ** offsetX ** : starting index for ` x ` .
112
104
113
- 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 calculate the minimum value for every other value in ` x ` starting from the second value
105
+ 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 calculate the minimum value for every other element in ` x ` starting from the second element
114
106
115
107
``` javascript
116
108
var Float64Array = require ( ' @stdlib/array/float64' );
117
- var floor = require ( ' @stdlib/math/base/special/floor' );
118
109
119
110
var x = new Float64Array ( [ 2.0 , 1.0 , 2.0 , 2.0 , - 2.0 , 2.0 , 3.0 , 4.0 ] );
120
- var N = floor ( x .length / 2 );
121
111
122
- var v = dminsorted .ndarray ( N , x, 2 , 1 );
112
+ var v = dminsorted .ndarray ( 4 , x, 2 , 1 );
123
113
// returns 1.0
124
114
```
125
115
@@ -145,16 +135,13 @@ var v = dminsorted.ndarray( N, x, 2, 1 );
145
135
<!-- eslint no-undef: "error" -->
146
136
147
137
``` javascript
148
- var Float64Array = require ( ' @stdlib/array/float64 ' );
138
+ var linspace = require ( ' @stdlib/array/linspace ' );
149
139
var dminsorted = require ( ' @stdlib/stats/base/dminsorted' );
150
140
151
- var x;
152
- var i;
153
-
154
- x = new Float64Array ( 10 );
155
- for ( i = 0 ; i < x .length ; i++ ) {
156
- x[ i ] = i - 5.0 ;
157
- }
141
+ var options = {
142
+ ' dtype' : ' float64'
143
+ };
144
+ var x = linspace ( - 5.0 , 5.0 , 10 , options );
158
145
console .log ( x );
159
146
160
147
var v = dminsorted ( x .length , x, 1 );
@@ -165,6 +152,107 @@ console.log( v );
165
152
166
153
<!-- /.examples -->
167
154
155
+ <!-- C usage documentation. -->
156
+
157
+ <section class =" usage " >
158
+
159
+ ### Usage
160
+
161
+ ``` c
162
+ #include " stdlib/stats/base/dminsorted.h"
163
+ ```
164
+
165
+ #### stdlib_strided_dminsorted( N, \* X, strideX )
166
+
167
+ Computes the minimum value of a sorted double-precision floating-point strided array.
168
+
169
+ ``` c
170
+ const double x[] = { 1.0, 2.0, 3.0 };
171
+
172
+ double v = stdlib_strided_dmax( 3, x, 1 );
173
+ // returns 1.0
174
+ ```
175
+
176
+ The function accepts the following arguments:
177
+
178
+ - **N**: `[in] CBLAS_INT` number of indexed elements.
179
+ - **X**: `[in] double*` input array.
180
+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
181
+
182
+ ```c
183
+ double stdlib_strided_dminsorted( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
184
+ ```
185
+
186
+ #### stdlib_strided_dminsorted_ndarray( N, \* X, strideX, offsetX )
187
+
188
+ Computes the minimum value of a sorted double-precision floating-point strided array using alternative indexing semantics.
189
+
190
+ ``` c
191
+ const double x[] = { 1.0, 2.0, 3.0 };
192
+
193
+ double v = stdlib_strided_dminsorted_ndarray( 3, x, 1, 0 );
194
+ // returns 1.0
195
+ ```
196
+
197
+ The function accepts the following arguments:
198
+
199
+ - **N**: `[in] CBLAS_INT` number of indexed elements.
200
+ - **X**: `[in] double*` input array.
201
+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
202
+ - **offsetX**: `[in] CBLAS_INT` starting index for `X`.
203
+
204
+ ```c
205
+ double stdlib_strided_dminsorted_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
206
+ ```
207
+
208
+ </section >
209
+
210
+ <!-- /.usage -->
211
+
212
+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
213
+
214
+ <section class =" notes " >
215
+
216
+ </section >
217
+
218
+ <!-- /.notes -->
219
+
220
+ <!-- C API usage examples. -->
221
+
222
+ <section class =" examples " >
223
+
224
+ ### Examples
225
+
226
+ ``` c
227
+ #include " stdlib/stats/base/dminsorted.h"
228
+ #include < stdio.h>
229
+
230
+ int main ( void ) {
231
+ // Create a strided array:
232
+ const double x[ ] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
233
+
234
+ // Specify the number of elements:
235
+ const int N = 4;
236
+
237
+ // Specify the stride length:
238
+ const int strideX = 2;
239
+
240
+ // Compute the minimum value:
241
+ double v = stdlib_strided_dminsorted( N, x, strideX );
242
+
243
+ // Print the result:
244
+ printf( "min: %lf\n", v );
245
+ }
246
+ ```
247
+
248
+ </section>
249
+
250
+ <!-- /.examples -->
251
+
252
+ </section>
253
+
254
+ <!-- /.c -->
255
+
168
256
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
169
257
170
258
<section class="related">
0 commit comments