You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**mask**: mask [`Uint8Array`][@stdlib/array/uint8]. If a `mask` array element is `0`, the corresponding element in `x` is considered valid and **included** in computation. If a `mask` array element is `1`, the corresponding element in `x` is considered invalid/missing and **excluded** from computation.
60
-
-**strideMask**: index increment for `mask`.
62
+
-**strideMask**: stride length for `mask`.
61
63
62
-
The `N` and `stride` parameters determine which elements are accessed at runtime. For example, to compute the minimum value of every other element in `x`,
64
+
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the minimum value of every other element in `x`,
var mask1 =newUint8Array( mask0.buffer, mask0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
91
90
92
-
varN=floor( x0.length/2 );
93
-
94
-
var v =snanmskmin( N, x1, 2, mask1, 2 );
91
+
var v =snanmskmin( 4, x1, 2, mask1, 2 );
95
92
// returns -2.0
96
93
```
97
94
@@ -115,18 +112,16 @@ The function has the following additional parameters:
115
112
-**offsetX**: starting index for `x`.
116
113
-**offsetMask**: starting index for `mask`.
117
114
118
-
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
115
+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, to calculate the minimum value for every other element in `x` starting from the second element
var uniform =require( '@stdlib/random/base/uniform' );
150
+
var bernoulli =require( '@stdlib/random/base/bernoulli' );
151
+
var filledarrayBy =require( '@stdlib/array/filled-by' );
158
152
var snanmskmin =require( '@stdlib/stats/base/snanmskmin' );
159
153
160
-
var mask;
161
-
var x;
162
-
var i;
163
-
164
-
x =newFloat32Array( 10 );
165
-
mask =newUint8Array( x.length );
166
-
for ( i =0; i <x.length; i++ ) {
167
-
if ( randu() <0.2 ) {
168
-
mask[ i ] =1;
169
-
} else {
170
-
mask[ i ] =0;
171
-
}
172
-
if ( randu() <0.1 ) {
173
-
x[ i ] =NaN;
174
-
} else {
175
-
x[ i ] =round( (randu()*100.0) -50.0 );
154
+
functionrand() {
155
+
if ( bernoulli( 0.8 ) <1 ) {
156
+
returnNaN;
176
157
}
158
+
returnuniform( -50.0, 50.0 );
177
159
}
160
+
161
+
var x =filledarrayBy( 10, 'float32', rand );
178
162
console.log( x );
163
+
164
+
var mask =filledarrayBy( x.length, 'uint8', bernoulli.factory( 0.2 ) );
179
165
console.log( mask );
180
166
181
167
var v =snanmskmin( x.length, x, 1, mask, 1 );
@@ -186,6 +172,145 @@ console.log( v );
186
172
187
173
<!-- /.examples -->
188
174
175
+
<!-- C interface documentation. -->
176
+
177
+
* * *
178
+
179
+
<sectionclass="c">
180
+
181
+
## C APIs
182
+
183
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
184
+
185
+
<sectionclass="intro">
186
+
187
+
</section>
188
+
189
+
<!-- /.intro -->
190
+
191
+
<!-- C usage documentation. -->
192
+
193
+
<sectionclass="usage">
194
+
195
+
### Usage
196
+
197
+
```c
198
+
#include"stdlib/stats/base/snanmskmin.h"
199
+
```
200
+
201
+
#### stdlib_strided_snanmskmin( N, \*X, strideX, \*Mask, strideMask )
202
+
203
+
Computes the minimum value of a single-precision floating-point strided array according to a `mask`, ignoring `NaN` values.
float v = stdlib_strided_snanmskmin( 5, x, 1, mask, 1 );
212
+
// returns -2.0f
213
+
```
214
+
215
+
The function accepts the following arguments:
216
+
217
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
218
+
- **X**: `[in] float*` input array.
219
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
220
+
- **Mask**: `[in] uint8_t*` mask array. If a `Mask` array element is `0`, the corresponding element in `X` is considered valid and included in computation. If a `Mask` array element is `1`, the corresponding element in `X` is considered invalid/missing and excluded from computation.
221
+
- **strideMask**: `[in] CBLAS_INT` stride length for `Mask`.
#### stdlib_strided_snanmskmin_ndarray( N, \*X, strideX, offsetX, \*Mask, strideMask, offsetMask )
228
+
229
+
Computes the minimum value of a single-precision floating-point strided array according to a `mask`, ignoring `NaN` values and using alternative indexing semantics.
- **N**: `[in] CBLAS_INT` number of indexed elements.
244
+
- **X**: `[in] float*` input array.
245
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
246
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
247
+
- **Mask**: `[in] uint8_t*` mask array. If a `Mask` array element is `0`, the corresponding element in `X` is considered valid and included in computation. If a `Mask` array element is `1`, the corresponding element in `X` is considered invalid/missing and excluded from computation.
248
+
- **strideMask**: `[in] CBLAS_INT` stride length for `Mask`.
249
+
- **offsetMask**: `[in] CBLAS_INT` starting index for `Mask`.
0 commit comments