@@ -36,36 +36,33 @@ limitations under the License.
3636var dmin = require ( ' @stdlib/stats/base/dmin' );
3737```
3838
39- #### dmin( N, x, stride )
39+ #### dmin( N, x, strideX )
4040
4141Computes the minimum 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 = dmin ( N , x, 1 );
48+ var v = dmin ( x . length , x, 1 );
5049// returns -2.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+ - ** strideX ** : 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 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 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 = dmin ( N , x, 2 );
65+ var v = dmin ( 4 , x, 2 );
6966// returns -2.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 = dmin ( N , x1, 2 );
79+ var v = dmin ( 4 , x1, 2 );
8680// returns -2.0
8781```
8882
89- #### dmin.ndarray( N, x, stride, offset )
83+ #### dmin.ndarray( N, x, strideX, offsetX )
9084
9185Computes the minimum 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 = dmin .ndarray ( N , x, 1 , 0 );
92+ var v = dmin .ndarray ( x . length , x, 1 , 0 );
10093// returns -2.0
10194```
10295
10396The function has the following additional parameters:
10497
10598- ** offset** : 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 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 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 = dmin .ndarray ( N , x, 2 , 1 );
107+ var v = dmin .ndarray ( 4 , x, 2 , 1 );
117108// returns -2.0
118109```
119110
@@ -138,18 +129,12 @@ var v = dmin.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 dmin = require ( ' @stdlib/stats/base/dmin' );
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 = dmin ( x .length , x, 1 );
@@ -160,6 +145,108 @@ 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/dmin.h"
156+ ```
157+
158+ #### stdlib_strided_dmin( N, \* X, strideX )
159+
160+ Computes the minimum value of a double-precision floating-point strided array.
161+
162+ ``` c
163+ const double x[] = { 1.0, -2.0, 2 };
164+
165+ double v = stdlib_strided_dmin( 3, x, 2 );
166+ // returns -2.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_dmin( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
177+ ```
178+
179+ #### stdlib_strided_dmin_ndarray( N, \* X, strideX, offsetX )
180+
181+ Computes the minimum 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 };
185+
186+ double v = stdlib_strided_dmin_ndarray( 3, x, 2, 0 );
187+ // returns -2.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_dmin_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/dmin.h"
221+ #include < stdint.h>
222+ #include < stdio.h>
223+
224+ int main ( void ) {
225+ // Create a strided array:
226+ const double x[ ] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
227+
228+ // Specify the number of elements:
229+ const int N = 4;
230+
231+ // Specify the stride length:
232+ const int stride = 2;
233+
234+ // Compute the minimum value:
235+ double v = stdlib_strided_dmin( N, x, stride );
236+
237+ // Print the result:
238+ printf( "min: %lf\n", v );
239+ }
240+ ```
241+
242+ </section>
243+
244+ <!-- /.examples -->
245+
246+ </section>
247+
248+ <!-- /.c -->
249+
163250<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
164251
165252<section class="related">
0 commit comments