|  | 
|  | 1 | +<!-- | 
|  | 2 | +
 | 
|  | 3 | +@license Apache-2.0 | 
|  | 4 | +
 | 
|  | 5 | +Copyright (c) 2020 The Stdlib Authors. | 
|  | 6 | +
 | 
|  | 7 | +Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 8 | +you may not use this file except in compliance with the License. | 
|  | 9 | +You may obtain a copy of the License at | 
|  | 10 | +
 | 
|  | 11 | +   http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 12 | +
 | 
|  | 13 | +Unless required by applicable law or agreed to in writing, software | 
|  | 14 | +distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 15 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 16 | +See the License for the specific language governing permissions and | 
|  | 17 | +limitations under the License. | 
|  | 18 | +
 | 
|  | 19 | +--> | 
|  | 20 | + | 
|  | 21 | +# snanminabs | 
|  | 22 | + | 
|  | 23 | +> Calculate the minimum absolute value of a single-precision floating-point strided array, ignoring `NaN` values. | 
|  | 24 | +
 | 
|  | 25 | +<section class="intro"> | 
|  | 26 | + | 
|  | 27 | +</section> | 
|  | 28 | + | 
|  | 29 | +<!-- /.intro --> | 
|  | 30 | + | 
|  | 31 | +<section class="usage"> | 
|  | 32 | + | 
|  | 33 | +## Usage | 
|  | 34 | + | 
|  | 35 | +```javascript | 
|  | 36 | +var snanminabs = require( '@stdlib/stats/strided/snanminabs' ); | 
|  | 37 | +``` | 
|  | 38 | + | 
|  | 39 | +#### snanminabs( N, x, strideX ) | 
|  | 40 | + | 
|  | 41 | +Computes the minimum absolute value of a single-precision floating-point strided array `x`, ignoring `NaN` values. | 
|  | 42 | + | 
|  | 43 | +```javascript | 
|  | 44 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 45 | + | 
|  | 46 | +var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); | 
|  | 47 | + | 
|  | 48 | +var v = snanminabs( x.length, x, 1 ); | 
|  | 49 | +// returns 1.0 | 
|  | 50 | +``` | 
|  | 51 | + | 
|  | 52 | +The function has the following parameters: | 
|  | 53 | + | 
|  | 54 | +-   **N**: number of indexed elements. | 
|  | 55 | +-   **x**: input [`Float32Array`][@stdlib/array/float32]. | 
|  | 56 | +-   **strideX**: stride length for `x`. | 
|  | 57 | + | 
|  | 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`, | 
|  | 59 | + | 
|  | 60 | +```javascript | 
|  | 61 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 62 | + | 
|  | 63 | +var x = new Float32Array( [ 1.0, 2.0, -7.0, -2.0, 4.0, 3.0, NaN, NaN ] ); | 
|  | 64 | + | 
|  | 65 | +var v = snanminabs( 4, x, 2 ); | 
|  | 66 | +// returns 1.0 | 
|  | 67 | +``` | 
|  | 68 | + | 
|  | 69 | +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. | 
|  | 70 | + | 
|  | 71 | +<!-- eslint-disable stdlib/capitalized-comments --> | 
|  | 72 | + | 
|  | 73 | +```javascript | 
|  | 74 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 75 | + | 
|  | 76 | +var x0 = new Float32Array( [ 2.0, 1.0, -2.0, -2.0, 3.0, 4.0, NaN, NaN ] ); | 
|  | 77 | +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element | 
|  | 78 | + | 
|  | 79 | +var v = snanminabs( 4, x1, 2 ); | 
|  | 80 | +// returns 1.0 | 
|  | 81 | +``` | 
|  | 82 | + | 
|  | 83 | +#### snanminabs.ndarray( N, x, strideX, offsetX ) | 
|  | 84 | + | 
|  | 85 | +Computes the minimum absolute value of a single-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics. | 
|  | 86 | + | 
|  | 87 | +```javascript | 
|  | 88 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 89 | + | 
|  | 90 | +var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); | 
|  | 91 | + | 
|  | 92 | +var v = snanminabs.ndarray( x.length, x, 1, 0 ); | 
|  | 93 | +// returns 1.0 | 
|  | 94 | +``` | 
|  | 95 | + | 
|  | 96 | +The function has the following additional parameters: | 
|  | 97 | + | 
|  | 98 | +-   **offsetX**: starting index for `x`. | 
|  | 99 | + | 
|  | 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 | 
|  | 101 | + | 
|  | 102 | +```javascript | 
|  | 103 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 104 | + | 
|  | 105 | +var x = new Float32Array( [ 2.0, 1.0, -2.0, -2.0, 3.0, 4.0, NaN, NaN ] ); | 
|  | 106 | + | 
|  | 107 | +var v = snanminabs.ndarray( 4, x, 2, 1 ); | 
|  | 108 | +// returns 1.0 | 
|  | 109 | +``` | 
|  | 110 | + | 
|  | 111 | +</section> | 
|  | 112 | + | 
|  | 113 | +<!-- /.usage --> | 
|  | 114 | + | 
|  | 115 | +<section class="notes"> | 
|  | 116 | + | 
|  | 117 | +## Notes | 
|  | 118 | + | 
|  | 119 | +-   If `N <= 0`, both functions return `NaN`. | 
|  | 120 | + | 
|  | 121 | +</section> | 
|  | 122 | + | 
|  | 123 | +<!-- /.notes --> | 
|  | 124 | + | 
|  | 125 | +<section class="examples"> | 
|  | 126 | + | 
|  | 127 | +## Examples | 
|  | 128 | + | 
|  | 129 | +<!-- eslint no-undef: "error" --> | 
|  | 130 | + | 
|  | 131 | +```javascript | 
|  | 132 | +var randu = require( '@stdlib/random/base/randu' ); | 
|  | 133 | +var round = require( '@stdlib/math/base/special/round' ); | 
|  | 134 | +var Float32Array = require( '@stdlib/array/float32' ); | 
|  | 135 | +var snanminabs = require( '@stdlib/stats/strided/snanminabs' ); | 
|  | 136 | + | 
|  | 137 | +var x; | 
|  | 138 | +var i; | 
|  | 139 | + | 
|  | 140 | +x = new Float32Array( 10 ); | 
|  | 141 | +for ( i = 0; i < x.length; i++ ) { | 
|  | 142 | +    if ( randu() < 0.2 ) { | 
|  | 143 | +        x[ i ] = NaN; | 
|  | 144 | +    } else { | 
|  | 145 | +        x[ i ] = round( (randu()*100.0) - 50.0 ); | 
|  | 146 | +    } | 
|  | 147 | +} | 
|  | 148 | +console.log( x ); | 
|  | 149 | + | 
|  | 150 | +var v = snanminabs( x.length, x, 1 ); | 
|  | 151 | +console.log( v ); | 
|  | 152 | +``` | 
|  | 153 | + | 
|  | 154 | +</section> | 
|  | 155 | + | 
|  | 156 | +<!-- /.examples --> | 
|  | 157 | + | 
|  | 158 | +<!-- C interface documentation. --> | 
|  | 159 | + | 
|  | 160 | +* * * | 
|  | 161 | + | 
|  | 162 | +<section class="c"> | 
|  | 163 | + | 
|  | 164 | +## C APIs | 
|  | 165 | + | 
|  | 166 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> | 
|  | 167 | + | 
|  | 168 | +<section class="intro"> | 
|  | 169 | + | 
|  | 170 | +</section> | 
|  | 171 | + | 
|  | 172 | +<!-- /.intro --> | 
|  | 173 | + | 
|  | 174 | +<!-- C usage documentation. --> | 
|  | 175 | + | 
|  | 176 | +<section class="usage"> | 
|  | 177 | + | 
|  | 178 | +### Usage | 
|  | 179 | + | 
|  | 180 | +```c | 
|  | 181 | +#include "stdlib/stats/strided/snanminabs.h" | 
|  | 182 | +``` | 
|  | 183 | + | 
|  | 184 | +#### stdlib_strided_snanminabs( N, \*X, strideX ) | 
|  | 185 | + | 
|  | 186 | +Computes the minimum absolute value of a single-precision floating-point strided array `x`, ignoring `NaN` values. | 
|  | 187 | + | 
|  | 188 | +```c | 
|  | 189 | +const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, -4.0f }; | 
|  | 190 | + | 
|  | 191 | +float v = stdlib_strided_snanminabs( 4, x, 1 ); | 
|  | 192 | +// returns 1.0f | 
|  | 193 | +``` | 
|  | 194 | +
 | 
|  | 195 | +The function accepts the following arguments: | 
|  | 196 | +
 | 
|  | 197 | +-   **N**: `[in] CBLAS_INT` number of indexed elements. | 
|  | 198 | +-   **X**: `[in] float*` input array. | 
|  | 199 | +-   **strideX**: `[in] CBLAS_INT` stride length for `X`. | 
|  | 200 | +
 | 
|  | 201 | +```c | 
|  | 202 | +float stdlib_strided_snanminabs( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); | 
|  | 203 | +``` | 
|  | 204 | + | 
|  | 205 | +#### stdlib_strided_snanminabs_ndarray( N, \*X, strideX, offsetX ) | 
|  | 206 | + | 
|  | 207 | +Computes the minimum absolute value of a single-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics. | 
|  | 208 | + | 
|  | 209 | +```c | 
|  | 210 | +const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, -4.0f }; | 
|  | 211 | + | 
|  | 212 | +float v = stdlib_strided_snanminabs_ndarray( 4, x, 1, 0 ); | 
|  | 213 | +// returns 1.0f | 
|  | 214 | +``` | 
|  | 215 | +
 | 
|  | 216 | +The function accepts the following arguments: | 
|  | 217 | +
 | 
|  | 218 | +-   **N**: `[in] CBLAS_INT` number of indexed elements. | 
|  | 219 | +-   **X**: `[in] float*` input array. | 
|  | 220 | +-   **strideX**: `[in] CBLAS_INT` stride length for `X`. | 
|  | 221 | +-   **offsetX**: `[in] CBLAS_INT` starting index for `X`. | 
|  | 222 | +
 | 
|  | 223 | +```c | 
|  | 224 | +float stdlib_strided_snanminabs_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); | 
|  | 225 | +``` | 
|  | 226 | + | 
|  | 227 | +</section> | 
|  | 228 | + | 
|  | 229 | +<!-- /.usage --> | 
|  | 230 | + | 
|  | 231 | +<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | 
|  | 232 | + | 
|  | 233 | +<section class="notes"> | 
|  | 234 | + | 
|  | 235 | +</section> | 
|  | 236 | + | 
|  | 237 | +<!-- /.notes --> | 
|  | 238 | + | 
|  | 239 | +<!-- C API usage examples. --> | 
|  | 240 | + | 
|  | 241 | +<section class="examples"> | 
|  | 242 | + | 
|  | 243 | +### Examples | 
|  | 244 | + | 
|  | 245 | +```c | 
|  | 246 | +#include "stdlib/stats/strided/snanminabs.h" | 
|  | 247 | +#include <stdio.h> | 
|  | 248 | + | 
|  | 249 | +int main( void ) { | 
|  | 250 | +    // Create a strided array: | 
|  | 251 | +    const float x[] = { 1.0f, -2.0f, -3.0f, 4.0f, -5.0f, -6.0f, 7.0f, -8.0f, 0.0f/0.0f, 0.0f/0.0f }; | 
|  | 252 | + | 
|  | 253 | +    // Specify the number of elements: | 
|  | 254 | +    const int N = 5; | 
|  | 255 | + | 
|  | 256 | +    // Specify the stride length: | 
|  | 257 | +    const int strideX = 2; | 
|  | 258 | + | 
|  | 259 | +    // Compute the minimum absolute value: | 
|  | 260 | +    float v = stdlib_strided_snanminabs( N, x, strideX ); | 
|  | 261 | + | 
|  | 262 | +    // Print the result: | 
|  | 263 | +    printf( "minabs: %f\n", v ); | 
|  | 264 | +} | 
|  | 265 | +``` | 
|  | 266 | +
 | 
|  | 267 | +</section> | 
|  | 268 | +
 | 
|  | 269 | +<!-- /.examples --> | 
|  | 270 | +
 | 
|  | 271 | +</section> | 
|  | 272 | +
 | 
|  | 273 | +<!-- /.c --> | 
|  | 274 | +
 | 
|  | 275 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | 
|  | 276 | +
 | 
|  | 277 | +<section class="related"> | 
|  | 278 | +
 | 
|  | 279 | +* * * | 
|  | 280 | +
 | 
|  | 281 | +## See Also | 
|  | 282 | +
 | 
|  | 283 | +-   <span class="package-name">[`@stdlib/stats/strided/dnanminabs`][@stdlib/stats/strided/dnanminabs]</span><span class="delimiter">: </span><span class="description">calculate the minimum absolute value of a double-precision floating-point strided array, ignoring NaN values.</span> | 
|  | 284 | +-   <span class="package-name">[`@stdlib/stats/base/nanminabs`][@stdlib/stats/base/nanminabs]</span><span class="delimiter">: </span><span class="description">calculate the minimum absolute value of a strided array, ignoring NaN values.</span> | 
|  | 285 | +-   <span class="package-name">[`@stdlib/stats/strided/sminabs`][@stdlib/stats/strided/sminabs]</span><span class="delimiter">: </span><span class="description">calculate the minimum absolute value of a single-precision floating-point strided array.</span> | 
|  | 286 | +-   <span class="package-name">[`@stdlib/stats/strided/snanmaxabs`][@stdlib/stats/strided/snanmaxabs]</span><span class="delimiter">: </span><span class="description">calculate the maximum absolute value of a single-precision floating-point strided array, ignoring NaN values.</span> | 
|  | 287 | +-   <span class="package-name">[`@stdlib/stats/strided/snanmin`][@stdlib/stats/strided/snanmin]</span><span class="delimiter">: </span><span class="description">calculate the minimum value of a single-precision floating-point strided array, ignoring NaN values.</span> | 
|  | 288 | +
 | 
|  | 289 | +</section> | 
|  | 290 | +
 | 
|  | 291 | +<!-- /.related --> | 
|  | 292 | +
 | 
|  | 293 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | 
|  | 294 | +
 | 
|  | 295 | +<section class="links"> | 
|  | 296 | +
 | 
|  | 297 | +[@stdlib/array/float32]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float32 | 
|  | 298 | +
 | 
|  | 299 | +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | 
|  | 300 | +
 | 
|  | 301 | +<!-- <related-links> --> | 
|  | 302 | +
 | 
|  | 303 | +[@stdlib/stats/strided/dnanminabs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dnanminabs | 
|  | 304 | +
 | 
|  | 305 | +[@stdlib/stats/base/nanminabs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/nanminabs | 
|  | 306 | +
 | 
|  | 307 | +[@stdlib/stats/strided/sminabs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/sminabs | 
|  | 308 | +
 | 
|  | 309 | +[@stdlib/stats/strided/snanmaxabs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/snanmaxabs | 
|  | 310 | +
 | 
|  | 311 | +[@stdlib/stats/strided/snanmin]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/snanmin | 
|  | 312 | +
 | 
|  | 313 | +<!-- </related-links> --> | 
|  | 314 | +
 | 
|  | 315 | +</section> | 
|  | 316 | +
 | 
|  | 317 | +<!-- /.links --> | 
0 commit comments