@@ -36,36 +36,33 @@ limitations under the License.
3636var dminabs = require ( ' @stdlib/stats/base/dminabs' );
3737```
3838
39- #### dminabs( N, x, stride )
39+ #### dminabs( N, x, strideX )
4040
4141Computes the minimum absolute value of a double-precision floating-point strided array ` x ` .
4242
4343``` javascript
4444var Float64Array = require ( ' @stdlib/array/float64' );
4545
4646var x = new Float64Array ( [ 1.0 , - 2.0 , 2.0 ] );
47- var N = x .length ;
4847
49- var v = dminabs ( N , x, 1 );
48+ var v = dminabs ( x . length , x, 1 );
5049// returns 1.0
5150```
5251
5352The function has the following parameters:
5453
5554- ** N** : number of indexed elements.
5655- ** x** : input [ ` Float64Array ` ] [ @stdlib/array/float64 ] .
57- - ** stride** : index increment for ` x ` .
56+ - ** stride** : stride length for ` x ` .
5857
59- The ` N ` and ` stride ` parameters determine which elements in ` x ` are accessed at runtime. For example, to compute the minimum absolute 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 minimum absolute value of every other element in ` x ` ,
6059
6160``` javascript
6261var Float64Array = require ( ' @stdlib/array/float64' );
63- var floor = require ( ' @stdlib/math/base/special/floor' );
6462
6563var x = new Float64Array ( [ 1.0 , 2.0 , 2.0 , - 7.0 , - 2.0 , 3.0 , 4.0 , 2.0 ] );
66- var N = floor ( x .length / 2 );
6764
68- var v = dminabs ( N , x, 2 );
65+ var v = dminabs ( 4 , x, 2 );
6966// returns 1.0
7067```
7168
@@ -75,45 +72,39 @@ Note that indexing is relative to the first index. To introduce an offset, use [
7572
7673``` javascript
7774var Float64Array = require ( ' @stdlib/array/float64' );
78- var floor = require ( ' @stdlib/math/base/special/floor' );
7975
8076var x0 = new Float64Array ( [ 2.0 , 1.0 , 2.0 , - 2.0 , - 2.0 , 2.0 , 3.0 , 4.0 ] );
8177var x1 = new Float64Array ( x0 .buffer , x0 .BYTES_PER_ELEMENT * 1 ); // start at 2nd element
8278
83- var N = floor ( x0 .length / 2 );
84-
85- var v = dminabs ( N , x1, 2 );
79+ var v = dminabs ( 4 , x1, 2 );
8680// returns 1.0
8781```
8882
89- #### dminabs.ndarray( N, x, stride, offset )
83+ #### dminabs.ndarray( N, x, strideX, offsetX )
9084
9185Computes the minimum absolute value of a double-precision floating-point strided array using alternative indexing semantics.
9286
9387``` javascript
9488var Float64Array = require ( ' @stdlib/array/float64' );
9589
9690var x = new Float64Array ( [ 1.0 , - 2.0 , 2.0 ] );
97- var N = x .length ;
9891
99- var v = dminabs .ndarray ( N , x, 1 , 0 );
92+ var v = dminabs .ndarray ( x . length , x, 1 , 0 );
10093// returns 1.0
10194```
10295
10396The function has the following additional parameters:
10497
105- - ** offset ** : starting index for ` x ` .
98+ - ** offsetX ** : starting index for ` x ` .
10699
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 minimum absolute 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 minimum absolute value for every other element in ` x ` starting from the second element
108101
109102``` javascript
110103var Float64Array = require ( ' @stdlib/array/float64' );
111- var floor = require ( ' @stdlib/math/base/special/floor' );
112104
113105var x = new Float64Array ( [ 2.0 , 1.0 , 2.0 , - 2.0 , - 2.0 , 2.0 , 3.0 , 4.0 ] );
114- var N = floor ( x .length / 2 );
115106
116- var v = dminabs .ndarray ( N , x, 2 , 1 );
107+ var v = dminabs .ndarray ( 4 , x, 2 , 1 );
117108// returns 1.0
118109```
119110
@@ -138,18 +129,12 @@ var v = dminabs.ndarray( N, x, 2, 1 );
138129<!-- eslint no-undef: "error" -->
139130
140131``` javascript
141- var randu = require ( ' @stdlib/random/base/randu' );
142- var round = require ( ' @stdlib/math/base/special/round' );
143- var Float64Array = require ( ' @stdlib/array/float64' );
132+ var discreteUniform = require ( ' @stdlib/random/array/discrete-uniform' );
144133var dminabs = require ( ' @stdlib/stats/base/dminabs' );
145134
146- var x;
147- var i;
148-
149- x = new Float64Array ( 10 );
150- for ( i = 0 ; i < x .length ; i++ ) {
151- x[ i ] = round ( (randu ()* 100.0 ) - 50.0 );
152- }
135+ var x = discreteUniform ( 10 , - 50 , 50 , {
136+ ' dtype' : ' float64'
137+ });
153138console .log ( x );
154139
155140var v = dminabs ( x .length , x, 1 );
@@ -160,6 +145,107 @@ console.log( v );
160145
161146<!-- /.examples -->
162147
148+ <!-- C usage documentation. -->
149+
150+ <section class =" usage " >
151+
152+ ### Usage
153+
154+ ``` c
155+ #include " stdlib/stats/base/dminabs.h"
156+ ```
157+
158+ #### stdlib_strided_dminabs( N, \* X, strideX )
159+
160+ Computes the minimum absolute value of a double-precision floating-point strided array.
161+
162+ ``` c
163+ const double x[] = { 1.0, -2.0, 2.0 };
164+
165+ double v = stdlib_strided_dminabs( 3, x, 1 );
166+ // returns 1.0
167+ ```
168+
169+ The function accepts the following arguments:
170+
171+ - **N**: `[in] CBLAS_INT` number of indexed elements.
172+ - **X**: `[in] double*` input array.
173+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
174+
175+ ```c
176+ double stdlib_strided_dminabs( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
177+ ```
178+
179+ #### stdlib_strided_dminabs_ndarray( N, \* X, strideX, offsetX )
180+
181+ Computes the minimum absolute value of a double-precision floating-point strided array using alternative indexing semantics.
182+
183+ ``` c
184+ const double x[] = { 1.0, -2.0, 2.0 };
185+
186+ double v = stdlib_strided_dminabs_ndarray( 3, x, 1, 0 );
187+ // returns 1.0
188+ ```
189+
190+ The function accepts the following arguments:
191+
192+ - **N**: `[in] CBLAS_INT` number of indexed elements.
193+ - **X**: `[in] double*` input array.
194+ - **strideX**: `[in] CBLAS_INT` stride length for `X`.
195+ - **offsetX**: `[in] CBLAS_INT` starting index for `X`.
196+
197+ ```c
198+ double stdlib_strided_dminabs_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
199+ ```
200+
201+ </section >
202+
203+ <!-- /.usage -->
204+
205+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
206+
207+ <section class =" notes " >
208+
209+ </section >
210+
211+ <!-- /.notes -->
212+
213+ <!-- C API usage examples. -->
214+
215+ <section class =" examples " >
216+
217+ ### Examples
218+
219+ ``` c
220+ #include " stdlib/stats/base/dminabs.h"
221+ #include < stdio.h>
222+
223+ int main ( void ) {
224+ // Create a strided array:
225+ const double x[ ] = { 1.0, 2.0, -3.0, -4.0, 5.0, -6.0, -7.0, 8.0 };
226+
227+ // Specify the number of elements:
228+ const int N = 4;
229+
230+ // Specify the stride length:
231+ const int strideX = 2;
232+
233+ // Compute the minimum absolute value:
234+ double v = stdlib_strided_dminabs( N, x, strideX );
235+
236+ // Print the result:
237+ printf( "minabs: %lf\n", v );
238+ }
239+ ```
240+
241+ </section>
242+
243+ <!-- /.examples -->
244+
245+ </section>
246+
247+ <!-- /.c -->
248+
163249<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
164250
165251<section class="related">
0 commit comments