@@ -38,36 +38,33 @@ The [**range**][range] is defined as the difference between the maximum and mini
3838var dnanrange = require ( ' @stdlib/stats/base/dnanrange' );
3939```
4040
41- #### dnanrange( N, x, stride )
41+ #### dnanrange( N, x, strideX )
4242
4343Computes the [ range] [ range ] of a double-precision floating-point strided array ` x ` , ignoring ` NaN ` values.
4444
4545``` javascript
4646var Float64Array = require ( ' @stdlib/array/float64' );
4747
4848var x = new Float64Array ( [ 1.0 , - 2.0 , NaN , 2.0 ] );
49- var N = x .length ;
5049
51- var v = dnanrange ( N , x, 1 );
50+ var v = dnanrange ( x . length , x, 1 );
5251// returns 4.0
5352```
5453
5554The function has the following parameters:
5655
5756- ** N** : number of indexed elements.
5857- ** x** : input [ ` Float64Array ` ] [ @stdlib/array/float64 ] .
59- - ** stride ** : index increment for ` x ` .
58+ - ** strideX ** : index increment for ` x ` .
6059
6160The ` N ` and ` stride ` parameters determine which elements in ` x ` are accessed at runtime. For example, to compute the [ range] [ range ] of every other element in ` x ` ,
6261
6362``` javascript
6463var Float64Array = require ( ' @stdlib/array/float64' );
65- var floor = require ( ' @stdlib/math/base/special/floor' );
6664
6765var x = new Float64Array ( [ 1.0 , 2.0 , - 7.0 , - 2.0 , 4.0 , 3.0 , NaN , NaN ] );
68- var N = floor ( x .length / 2 );
6966
70- var v = dnanrange ( N , x, 2 );
67+ var v = dnanrange ( 5 , x, 2 );
7168// returns 11.0
7269```
7370
@@ -77,45 +74,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
7774
7875``` javascript
7976var Float64Array = require ( ' @stdlib/array/float64' );
80- var floor = require ( ' @stdlib/math/base/special/floor' );
8177
8278var x0 = new Float64Array ( [ 2.0 , 1.0 , - 2.0 , - 2.0 , 3.0 , 4.0 , NaN , NaN ] );
8379var x1 = new Float64Array ( x0 .buffer , x0 .BYTES_PER_ELEMENT * 1 ); // start at 2nd element
8480
85- var N = floor ( x0 .length / 2 );
86-
87- var v = dnanrange ( N , x1, 2 );
81+ var v = dnanrange ( 5 , x1, 2 );
8882// returns 6.0
8983```
9084
91- #### dnanrange.ndarray( N, x, stride, offset )
85+ #### dnanrange.ndarray( N, x, strideX, offsetX )
9286
9387Computes the [ range] [ range ] of a double-precision floating-point strided array, ignoring ` NaN ` values and using alternative indexing semantics.
9488
9589``` javascript
9690var Float64Array = require ( ' @stdlib/array/float64' );
9791
9892var x = new Float64Array ( [ 1.0 , - 2.0 , NaN , 2.0 ] );
99- var N = x .length ;
10093
101- var v = dnanrange .ndarray ( N , x, 1 , 0 );
94+ var v = dnanrange .ndarray ( 5 , x, 1 , 0 );
10295// returns 4.0
10396```
10497
10598The function has the following additional parameters:
10699
107100- ** offset** : starting index for ` x ` .
108101
109- 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 [ range] [ range ] for every other value in ` x ` starting from the second value
102+ 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 [ range] [ range ] for every other element in ` x ` starting from the second element
110103
111104``` javascript
112105var Float64Array = require ( ' @stdlib/array/float64' );
113- var floor = require ( ' @stdlib/math/base/special/floor' );
114106
115107var x = new Float64Array ( [ 2.0 , 1.0 , - 2.0 , - 2.0 , 3.0 , 4.0 , NaN , NaN ] );
116- var N = floor ( x .length / 2 );
117108
118- var v = dnanrange .ndarray ( N , x, 2 , 1 );
109+ var v = dnanrange .ndarray ( 5 , x, 2 , 1 );
119110// returns 6.0
120111```
121112
@@ -166,6 +157,107 @@ console.log( v );
166157
167158<!-- /.examples -->
168159
160+ <!-- C usage documentation. -->
161+
162+ <section class =" usage " >
163+
164+ ### Usage
165+
166+ ``` c
167+ #include " stdlib/stats/base/dnanrange.h"
168+ ```
169+
170+ #### stdlib_strided_dnanrange( N, \* X, strideX )
171+
172+ Calculate the range value of a double-precision floating-point strided array ` x ` , ignoring ` NaN ` values.
173+
174+ ``` c
175+ 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 };
176+
177+ double v = stdlib_strided_dnanrange( 5, x, 2 );
178+ // returns 6.0
179+ ```
180+
181+ The function accepts the following arguments:
182+
183+ - **N**: `[in] CBLAS_INT` number of indexed elements.
184+ - **X**: `[in] double*` input array.
185+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
186+
187+ ```c
188+ double stdlib_strided_dnanrange( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
189+ ```
190+
191+ #### stdlib_strided_dnanrange_ndarray( N, \* X, strideX, offsetX )
192+
193+ Computes the range value of a double-precision floating-point strided array, ignoring ` NaN ` values and using alternative indexing semantics.
194+
195+ ``` c
196+ 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 };
197+
198+ double v = stdlib_strided_dnanrange_ndarray( 5, x, 2, 0 );
199+ // returns 6.0
200+ ```
201+
202+ The function accepts the following arguments:
203+
204+ - **N**: `[in] CBLAS_INT` number of indexed elements.
205+ - **X**: `[in] double*` input array.
206+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
207+ - **offsetX**: `[in] CBLAS_INT` starting index for `X`.
208+
209+ ```c
210+ double stdlib_strided_dnanrange_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
211+ ```
212+
213+ </section >
214+
215+ <!-- /.usage -->
216+
217+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
218+
219+ <section class =" notes " >
220+
221+ </section >
222+
223+ <!-- /.notes -->
224+
225+ <!-- C API usage examples. -->
226+
227+ <section class =" examples " >
228+
229+ ### Examples
230+
231+ ``` c
232+ #include " stdlib/stats/base/dnanrange.h"
233+ #include < stdio.h>
234+
235+ int main ( void ) {
236+ // Create a strided array:
237+ 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 };
238+
239+ // Specify the number of elements:
240+ const int N = 5;
241+
242+ // Specify the stride length:
243+ const int strideX = 2;
244+
245+ // Compute the range:
246+ double v = stdlib_strided_dnanrange( N, x, strideX );
247+
248+ // Print the result:
249+ printf( "range: %lf\n", v );
250+ }
251+ ```
252+
253+ </section>
254+
255+ <!-- /.examples -->
256+
257+ </section>
258+
259+ <!-- /.c -->
260+
169261<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
170262
171263<section class="related">
0 commit comments