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