README.md (135682B)
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 # mskunary 22 23 > Apply a unary callback to elements in a strided input array according to elements in a strided mask array and assign results to elements in a strided output array. 24 25 <section class="intro"> 26 27 </section> 28 29 <!-- /.intro --> 30 31 <section class="usage"> 32 33 ## Usage 34 35 ```javascript 36 var mskunary = require( '@stdlib/strided/base/mskunary' ); 37 ``` 38 39 #### mskunary( arrays, shape, strides, fcn ) 40 41 Applies a unary callback to elements in a strided input array according to elements in a strided mask array and assigns results to elements in a strided output array. 42 43 ```javascript 44 var Float64Array = require( '@stdlib/array/float64' ); 45 var Uint8Array = require( '@stdlib/array/uint8' ); 46 var abs = require( '@stdlib/math/base/special/abs' ); 47 48 var x = new Float64Array( [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ] ); 49 var mask = new Uint8Array( [ 0, 0, 0, 1, 0, 0, 0, 1 ] ); 50 51 // Compute the absolute values in-place: 52 mskunary( [ x, mask, x ], [ x.length ], [ 1, 1, 1 ], abs ); 53 // x => <Float64Array>[ 2.0, 1.0, 3.0, -5.0, 4.0, 0.0, 1.0, -3.0 ] 54 ``` 55 56 The function accepts the following arguments: 57 58 - **arrays**: array-like object containing one strided input array, a strided mask array, and one strided output array. 59 - **shape**: array-like object containing a single element, the number of indexed elements. 60 - **strides**: array-like object containing the stride lengths for the strided arrays. 61 - **fcn**: unary function to apply. 62 63 The `shape` and `strides` parameters determine which elements in the strided arrays are accessed at runtime. For example, to index every other value in the strided input array and to index the first `N` elements of the strided output array in reverse order, 64 65 ```javascript 66 var Float64Array = require( '@stdlib/array/float64' ); 67 var Uint8Array = require( '@stdlib/array/uint8' ); 68 var floor = require( '@stdlib/math/base/special/floor' ); 69 var abs = require( '@stdlib/math/base/special/abs' ); 70 71 var x = new Float64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 ] ); 72 var mask = new Uint8Array( [ 0, 1, 0, 0, 0, 0 ] ); 73 var y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); 74 75 var N = floor( x.length / 2 ); 76 77 mskunary( [ x, mask, y ], [ N ], [ 2, 1, -1 ], abs ); 78 // y => <Float64Array>[ 5.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] 79 ``` 80 81 Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. 82 83 ```javascript 84 var Float64Array = require( '@stdlib/array/float64' ); 85 var Uint8Array = require( '@stdlib/array/uint8' ); 86 var floor = require( '@stdlib/math/base/special/floor' ); 87 var abs = require( '@stdlib/math/base/special/abs' ); 88 89 // Initial arrays... 90 var x0 = new Float64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 ] ); 91 var m0 = new Uint8Array( [ 0, 0, 0, 0, 0, 1 ] ); 92 var y0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); 93 94 // Create offset views... 95 var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element 96 var m1 = new Uint8Array( m0.buffer, m0.BYTES_PER_ELEMENT*3 ); // start at 4th element 97 var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element 98 99 var N = floor( x0.length / 2 ); 100 101 mskunary( [ x1, m1, y1 ], [ N ], [ -2, 1, 1 ], abs ); 102 // y0 => <Float64Array>[ 0.0, 0.0, 0.0, 6.0, 4.0, 0.0 ] 103 ``` 104 105 #### mskunary.ndarray( arrays, shape, strides, offsets, fcn ) 106 107 Applies a unary callback to elements in a strided input array according to elements in a strided mask array and assigns results to elements in a strided output array using alternative indexing semantics. 108 109 ```javascript 110 var Float64Array = require( '@stdlib/array/float64' ); 111 var Uint8Array = require( '@stdlib/array/uint8' ); 112 var abs = require( '@stdlib/math/base/special/abs' ); 113 114 var x = new Float64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0 ] ); 115 var mask = new Uint8Array( [ 0, 0, 1, 0, 0 ] ); 116 var y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); 117 118 mskunary.ndarray( [ x, mask, y ], [ x.length ], [ 1, 1, 1 ], [ 0, 0, 0 ], abs ); 119 // y => <Float64Array>[ 1.0, 2.0, 0.0, 4.0, 5.0 ] 120 ``` 121 122 The function accepts the following additional arguments: 123 124 - **offsets**: array-like object containing the starting indices (i.e., index offsets) for the strided arrays. 125 126 While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offsets` parameter supports indexing semantics based on starting indices. For example, to index every other value in the strided input array starting from the second value and to index the last `N` elements in the strided output array, 127 128 <!-- eslint-disable max-len --> 129 130 ```javascript 131 var Float64Array = require( '@stdlib/array/float64' ); 132 var Uint8Array = require( '@stdlib/array/uint8' ); 133 var floor = require( '@stdlib/math/base/special/floor' ); 134 var abs = require( '@stdlib/math/base/special/abs' ); 135 136 var x = new Float64Array( [ -1.0, -2.0, -3.0, -4.0, -5.0, -6.0 ] ); 137 var mask = new Uint8Array( [ 0, 1, 0, 0, 0, 0 ] ); 138 var y = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); 139 140 var N = floor( x.length / 2 ); 141 142 mskunary.ndarray( [ x, mask, y ], [ N ], [ 2, 1, -1 ], [ 1, 0, y.length-1 ], abs ); 143 // y => <Float64Array>[ 0.0, 0.0, 0.0, 6.0, 0.0, 2.0 ] 144 ``` 145 146 </section> 147 148 <!-- /.usage --> 149 150 <section class="notes"> 151 152 </section> 153 154 <!-- /.notes --> 155 156 <section class="examples"> 157 158 ## Examples 159 160 <!-- eslint no-undef: "error" --> 161 162 ```javascript 163 var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; 164 var bernoulli = require( '@stdlib/random/base/bernoulli' ).factory; 165 var filledarray = require( '@stdlib/array/filled' ); 166 var gfillBy = require( '@stdlib/blas/ext/base/gfill-by' ); 167 var mskunary = require( '@stdlib/strided/base/mskunary' ); 168 169 function add10( x ) { 170 return x + 10; 171 } 172 173 var N = 10; 174 175 var x = filledarray( 0.0, N, 'generic' ); 176 gfillBy( x.length, x, 1, discreteUniform( -100, 100 ) ); 177 console.log( x ); 178 179 var m = filledarray( 0, N, 'generic' ); 180 gfillBy( m.length, m, 1, bernoulli( 0.5 ) ); 181 console.log( m ); 182 183 var y = filledarray( 0.0, N, 'generic' ); 184 console.log( y ); 185 186 var shape = [ N ]; 187 var strides = [ 1, 1, -1 ]; 188 var offsets = [ 0, 0, N-1 ]; 189 190 mskunary.ndarray( [ x, m, y ], shape, strides, offsets, add10 ); 191 console.log( y ); 192 ``` 193 194 </section> 195 196 <!-- /.examples --> 197 198 <!-- C interface documentation. --> 199 200 * * * 201 202 <section class="c"> 203 204 ## C APIs 205 206 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 207 208 <section class="intro"> 209 210 Character codes for data types: 211 212 - **d**: `float64` (double-precision floating-point number). 213 - **f**: `float32` (single-precision floating-point number). 214 - **s**: `int8` (signed 8-bit integer). 215 - **b**: `uint8` (unsigned 8-bit integer). 216 - **k**: `int16` (signed 16-bit integer). 217 - **t**: `uint16` (unsigned 16-bit integer). 218 - **i**: `int32` (signed 32-bit integer). 219 - **u**: `uint32` (unsigned 32-bit integer). 220 - **l**: `int64` (signed 64-bit integer). 221 - **v**: `uint64` (unsigned 64-bit integer). 222 223 Function name suffix naming convention: 224 225 ```text 226 stdlib_strided_mask_<input_data_type>_<output_data_type>[_as_<callback_arg_data_type>_<callback_return_data_type>] 227 ``` 228 229 For example, 230 231 ```c 232 void stdlib_strided_mask_d_d(...) {...} 233 ``` 234 235 is a function which accepts one double-precision floating-point strided input array and one double-precision floating-point strided output array. In other words, the suffix encodes the function type signature. 236 237 To support callbacks whose input arguments and/or return values are of a different data type than the strided input and/or output array data types, the naming convention supports appending an `as` suffix. For example, 238 239 ```c 240 void stdlib_strided_mask_f_f_as_d_d(...) {...} 241 ``` 242 243 is a function which accepts one single-precision floating-point strided input array and one single-precision floating-point strided output array. However, the callback accepts and returns double-precision floating-point numbers. Accordingly, the input and output values need to be cast using the following conversion sequence 244 245 ```c 246 // Convert each input array element to double-precision: 247 double dxi = (double)fx[ i ]; 248 249 // Evaluate the callback: 250 double dyi = f( dxi ); 251 252 // Convert the callback return value to single-precision: 253 fy[ i ] = (float)dyi; 254 ``` 255 256 </section> 257 258 <!-- /.intro --> 259 260 <!-- C usage documentation. --> 261 262 <section class="usage"> 263 264 ### Usage 265 266 ```c 267 #include "stdlib/strided/base/mskunary.h" 268 ``` 269 270 #### UnaryFcnFloat32 271 272 Function type for a function accepting and returning single-precision floating-point numbers. 273 274 ```c 275 typedef float UnaryFcnFloat32( const float x ); 276 ``` 277 278 A `UnaryFcnFloat32` function should accept the following arguments: 279 280 - **x**: `[in] float` single-precision floating-point number. 281 282 The function should return a single-precision floating-point number. 283 284 #### UnaryFcnFloat32Int64 285 286 Function type for a function which accepts a single-precision floating-point number and returns a signed 64-bit integer. 287 288 ```c 289 typedef int64_t UnaryFcnFloat32Int64( const float x ); 290 ``` 291 292 A `UnaryFcnFloat32Int64` function should accept the following arguments: 293 294 - **x**: `[in] float` single-precision floating-point number. 295 296 The function should return a signed 64-bit integer. 297 298 #### UnaryFcnFloat32Int32 299 300 Function type for a function which accepts a single-precision floating-point number and returns a signed 32-bit integer. 301 302 ```c 303 typedef int32_t UnaryFcnFloat32Int32( const float x ); 304 ``` 305 306 A `UnaryFcnFloat32Int32` function should accept the following arguments: 307 308 - **x**: `[in] float` single-precision floating-point number. 309 310 The function should return a signed 32-bit integer. 311 312 #### UnaryFcnFloat64 313 314 Function type for a function which accepts and returns double-precision floating-point numbers. 315 316 ```c 317 typedef double UnaryFcnFloat64( const double x ); 318 ``` 319 320 A `UnaryFcnFloat64` function should accept the following arguments: 321 322 - **x**: `[in] double` double-precision floating-point number. 323 324 The function should return a double-precision floating-point number. 325 326 #### UnaryFcnFloat64Int64 327 328 Function type for a function which accepts a double-precision floating-point number and returns a signed 64-bit integer. 329 330 ```c 331 typedef int64_t UnaryFcnFloat64Int64( const double x ); 332 ``` 333 334 A `UnaryFcnFloat64Int64` function should accept the following arguments: 335 336 - **x**: `[in] double` double-precision floating-point number. 337 338 The function should return a signed 64-bit integer. 339 340 #### UnaryFcnFloat64Int32 341 342 Function type for a function which accepts a double-precision floating-point number and returns a signed 32-bit integer. 343 344 ```c 345 typedef int32_t UnaryFcnFloat64Int32( const double x ); 346 ``` 347 348 A `UnaryFcnFloat64Int32` function should accept the following arguments: 349 350 - **x**: `[in] double` double-precision floating-point number. 351 352 The function should return a signed 32-bit integer. 353 354 #### UnaryFcnInt64 355 356 Function type for a function which accepts and returns signed 64-bit integers. 357 358 ```c 359 typedef int64_t UnaryFcnInt64( const int64_t x ); 360 ``` 361 362 A `UnaryFcnInt64` function should accept the following arguments: 363 364 - **x**: `[in] int64_t` signed 64-bit integer. 365 366 The function should return a signed 64-bit integer. 367 368 #### UnaryFcnUint64 369 370 Function type for a function which accepts and returns unsigned 64-bit integers. 371 372 ```c 373 typedef uint64_t UnaryFcnUint64( const uint64_t x ); 374 ``` 375 376 A `UnaryFcnUint64` function should accept the following arguments: 377 378 - **x**: `[in] uint64_t` unsigned 64-bit integer. 379 380 The function should return an unsigned 64-bit integer. 381 382 #### UnaryFcnInt32 383 384 Function type for a function which accepts and returns signed 32-bit integers. 385 386 ```c 387 typedef int32_t UnaryFcnInt32( const int32_t x ); 388 ``` 389 390 A `UnaryFcnInt32` function should accept the following arguments: 391 392 - **x**: `[in] int32_t` signed 32-bit integer. 393 394 The function should return a signed 32-bit integer. 395 396 #### UnaryFcnUint32 397 398 Function type for a function which accepts and returns unsigned 32-bit integers. 399 400 ```c 401 typedef uint32_t UnaryFcnUint32( const uint32_t x ); 402 ``` 403 404 A `UnaryFcnUint32` function should accept the following arguments: 405 406 - **x**: `[in] uint32_t` unsigned 32-bit integer. 407 408 The function should return an unsigned 32-bit integer. 409 410 #### UnaryFcnInt16 411 412 Function type for a function which accepts and returns signed 16-bit integers. 413 414 ```c 415 typedef int16_t UnaryFcnInt16( const int16_t x ); 416 ``` 417 418 A `UnaryFcnInt16` function should accept the following arguments: 419 420 - **x**: `[in] int16_t` signed 16-bit integer. 421 422 The function should return a signed 16-bit integer. 423 424 #### UnaryFcnUint16 425 426 Function type for a function which accepts and returns unsigned 16-bit integers. 427 428 ```c 429 typedef uint16_t UnaryFcnUint16( const uint16_t x ); 430 ``` 431 432 A `UnaryFcnUint16` function should accept the following arguments: 433 434 - **x**: `[in] uint16_t` unsigned 16-bit integer. 435 436 The function should return an unsigned 16-bit integer. 437 438 #### UnaryFcnInt8 439 440 Function type for a function which accepts and returns signed 8-bit integers. 441 442 ```c 443 typedef int8_t UnaryFcnInt8( const int8_t x ); 444 ``` 445 446 A `UnaryFcnInt8` function should accept the following arguments: 447 448 - **x**: `[in] int8_t` signed 8-bit integer. 449 450 The function should return a signed 8-bit integer. 451 452 #### UnaryFcnUint8 453 454 Function type for a function which accepts and returns unsigned 8-bit integers. 455 456 ```c 457 typedef uint8_t UnaryFcnUint8( const uint8_t x ); 458 ``` 459 460 A `UnaryFcnUint8` function should accept the following arguments: 461 462 - **x**: `[in] uint8_t` unsigned 8-bit integer. 463 464 The function should return an unsigned 8-bit integer. 465 466 <!-- NOTE: keep the following in alphabetical order --> 467 468 * * * 469 470 #### stdlib_strided_mask_b_b( \*arrays[], \*shape, \*strides, \*fcn ) 471 472 Applies a unary callback accepting and returning unsigned 8-bit integers to an unsigned 8-bit integer strided input array and assigns results to elements in an unsigned 8-bit integer strided output array. 473 474 ```c 475 #include <stdint.h> 476 477 // Create underlying byte arrays: 478 uint8_t x[] = { 0, 0, 0 }; 479 uint8_t m[] = { 0, 1, 0 }; 480 uint8_t out[] = { 0, 0, 0 }; 481 482 // Define a pointer to an array containing pointers to strided arrays: 483 uint8_t *arrays[] = { x, m, out }; 484 485 // Define the strides: 486 int64_t strides[] = { 1, 1, 1 }; // 1 byte per uint8 487 488 // Define the number of elements over which to iterate: 489 int64_t shape[] = { 3 }; 490 491 // Define a callback: 492 uint8_t scale( const uint8_t x ) { 493 return x + 10; 494 } 495 496 // Apply the callback: 497 stdlib_strided_mask_b_b( arrays, shape, strides, (void *)scale ); 498 ``` 499 500 The function accepts the following arguments: 501 502 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 503 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 504 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 505 - **fcn**: `[in] void*` a `UnaryFcnUint8` function to apply provided as a `void` pointer. 506 507 ```c 508 void stdlib_strided_mask_b_b( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 509 ``` 510 511 #### stdlib_strided_mask_b_d( \*arrays[], \*shape, \*strides, \*fcn ) 512 513 Applies a unary callback accepting and returning unsigned 8-bit integers to an unsigned 8-bit integer strided input array, casts the callback's unsigned 8-bit integer return value to a double-precision floating-point number, and assigns results to elements in a double-precision floating-point strided output array. 514 515 ```c 516 #include <stdint.h> 517 518 // Create underlying byte arrays: 519 uint8_t x[] = { 0, 0, 0 }; 520 uint8_t m[] = { 0, 1, 0 }; 521 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 522 523 // Define a pointer to an array containing pointers to strided arrays: 524 uint8_t *arrays[] = { x, m, out }; 525 526 // Define the strides: 527 int64_t strides[] = { 1, 1, 8 }; // 1 byte per uint8, 8 bytes per double 528 529 // Define the number of elements over which to iterate: 530 int64_t shape[] = { 3 }; 531 532 // Define a callback: 533 uint8_t scale( const uint8_t x ) { 534 return x + 10; 535 } 536 537 // Apply the callback: 538 stdlib_strided_mask_b_d( arrays, shape, strides, (void *)scale ); 539 ``` 540 541 The function accepts the following arguments: 542 543 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 544 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 545 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 546 - **fcn**: `[in] void*` a `UnaryFcnUint8` function to apply provided as a `void` pointer. 547 548 ```c 549 void stdlib_strided_mask_b_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 550 ``` 551 552 #### stdlib_strided_mask_b_d_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 553 554 Applies a unary callback accepting and returning double-precision floating-point numbers to an unsigned 8-bit integer strided input array and assigns results to elements in a double-precision floating-point strided output array. 555 556 ```c 557 #include <stdint.h> 558 559 // Create underlying byte arrays: 560 uint8_t x[] = { 0, 0, 0 }; 561 uint8_t m[] = { 0, 1, 0 }; 562 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 563 564 // Define a pointer to an array containing pointers to strided arrays: 565 uint8_t *arrays[] = { x, m, out }; 566 567 // Define the strides: 568 int64_t strides[] = { 1, 1, 8 }; // 1 byte per uint8, 8 bytes per double 569 570 // Define the number of elements over which to iterate: 571 int64_t shape[] = { 3 }; 572 573 // Define a callback: 574 double scale( const double x ) { 575 return x + 10.0; 576 } 577 578 // Apply the callback: 579 stdlib_strided_mask_b_d_as_d_d( arrays, shape, strides, (void *)scale ); 580 ``` 581 582 The function accepts the following arguments: 583 584 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 585 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 586 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 587 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 588 589 ```c 590 void stdlib_strided_mask_b_d_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 591 ``` 592 593 #### stdlib_strided_mask_b_f( \*arrays[], \*shape, \*strides, \*fcn ) 594 595 Applies a unary callback accepting and returning unsigned 8-bit integers to an unsigned 8-bit integer strided input array, casts the callback's unsigned 8-bit integer return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 596 597 ```c 598 #include <stdint.h> 599 600 // Create underlying byte arrays: 601 uint8_t x[] = { 0, 0, 0 }; 602 uint8_t m[] = { 0, 1, 0 }; 603 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 604 605 // Define a pointer to an array containing pointers to strided arrays: 606 uint8_t *arrays[] = { x, m, out }; 607 608 // Define the strides: 609 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per float 610 611 // Define the number of elements over which to iterate: 612 int64_t shape[] = { 3 }; 613 614 // Define a callback: 615 uint8_t scale( const uint8_t x ) { 616 return x + 10; 617 } 618 619 // Apply the callback: 620 stdlib_strided_mask_b_f( arrays, shape, strides, (void *)scale ); 621 ``` 622 623 The function accepts the following arguments: 624 625 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 626 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 627 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 628 - **fcn**: `[in] void*` a `UnaryFcnUint8` function to apply provided as a `void` pointer. 629 630 ```c 631 void stdlib_strided_mask_b_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 632 ``` 633 634 #### stdlib_strided_mask_b_f_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 635 636 Applies a unary callback accepting and returning double-precision floating-point numbers to an unsigned 8-bit integer strided input array, casts the callback's double-precision floating-point return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 637 638 ```c 639 #include <stdint.h> 640 641 // Create underlying byte arrays: 642 uint8_t x[] = { 0, 0, 0 }; 643 uint8_t m[] = { 0, 1, 0 }; 644 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 645 646 // Define a pointer to an array containing pointers to strided arrays: 647 uint8_t *arrays[] = { x, m, out }; 648 649 // Define the strides: 650 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per float 651 652 // Define the number of elements over which to iterate: 653 int64_t shape[] = { 3 }; 654 655 // Define a callback: 656 double scale( const double x ) { 657 return x + 10.0; 658 } 659 660 // Apply the callback: 661 stdlib_strided_mask_b_f_as_d_d( arrays, shape, strides, (void *)scale ); 662 ``` 663 664 The function accepts the following arguments: 665 666 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 667 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 668 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 669 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 670 671 ```c 672 void stdlib_strided_mask_b_f_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 673 ``` 674 675 #### stdlib_strided_mask_b_f_as_f_f( \*arrays[], \*shape, \*strides, \*fcn ) 676 677 Applies a unary callback accepting and returning single-precision floating-point numbers to an unsigned 8-bit integer strided input array, casts the callback's single-precision floating-point return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 678 679 ```c 680 #include <stdint.h> 681 682 // Create underlying byte arrays: 683 uint8_t x[] = { 0, 0, 0 }; 684 uint8_t m[] = { 0, 1, 0 }; 685 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 686 687 // Define a pointer to an array containing pointers to strided arrays: 688 uint8_t *arrays[] = { x, m, out }; 689 690 // Define the strides: 691 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per float 692 693 // Define the number of elements over which to iterate: 694 int64_t shape[] = { 3 }; 695 696 // Define a callback: 697 float scale( const float x ) { 698 return x + 10.0f; 699 } 700 701 // Apply the callback: 702 stdlib_strided_mask_b_f_as_f_f( arrays, shape, strides, (void *)scale ); 703 ``` 704 705 The function accepts the following arguments: 706 707 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 708 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 709 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 710 - **fcn**: `[in] void*` a `UnaryFcnFloat32` function to apply provided as a `void` pointer. 711 712 ```c 713 void stdlib_strided_mask_b_f_as_f_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 714 ``` 715 716 #### stdlib_strided_mask_b_i( \*arrays[], \*shape, \*strides, \*fcn ) 717 718 Applies a unary callback accepting and returning signed 32-bit integers to an unsigned 8-bit integer strided input array, casts the callback's unsigned 8-bit integer return value to a signed 32-bit integer, and assigns results to elements in a signed 32-bit integer strided output array. 719 720 ```c 721 #include <stdint.h> 722 723 // Create underlying byte arrays: 724 uint8_t x[] = { 0, 0, 0 }; 725 uint8_t m[] = { 0, 1, 0 }; 726 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 727 728 // Define a pointer to an array containing pointers to strided arrays: 729 uint8_t *arrays[] = { x, m, out }; 730 731 // Define the strides: 732 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per int32 733 734 // Define the number of elements over which to iterate: 735 int64_t shape[] = { 3 }; 736 737 // Define a callback: 738 uint8_t scale( const uint8_t x ) { 739 return x + 10; 740 } 741 742 // Apply the callback: 743 stdlib_strided_mask_b_i( arrays, shape, strides, (void *)scale ); 744 ``` 745 746 The function accepts the following arguments: 747 748 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 749 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 750 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 751 - **fcn**: `[in] void*` a `UnaryFcnUint8` function to apply provided as a `void` pointer. 752 753 ```c 754 void stdlib_strided_mask_b_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 755 ``` 756 757 #### stdlib_strided_mask_b_i_as_i_i( \*arrays[], \*shape, \*strides, \*fcn ) 758 759 Applies a unary callback accepting and returning signed 32-bit integers to an unsigned 8-bit integer strided input array and assigns results to elements in a signed 32-bit integer strided output array. 760 761 ```c 762 #include <stdint.h> 763 764 // Create underlying byte arrays: 765 uint8_t x[] = { 0, 0, 0 }; 766 uint8_t m[] = { 0, 1, 0 }; 767 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 768 769 // Define a pointer to an array containing pointers to strided arrays: 770 uint8_t *arrays[] = { x, m, out }; 771 772 // Define the strides: 773 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per int32 774 775 // Define the number of elements over which to iterate: 776 int64_t shape[] = { 3 }; 777 778 // Define a callback: 779 int32_t scale( const int32_t x ) { 780 return x + 10; 781 } 782 783 // Apply the callback: 784 stdlib_strided_mask_b_i_as_i_i( arrays, shape, strides, (void *)scale ); 785 ``` 786 787 The function accepts the following arguments: 788 789 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 790 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 791 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 792 - **fcn**: `[in] void*` a `UnaryFcnInt32` function to apply provided as a `void` pointer. 793 794 ```c 795 void stdlib_strided_mask_b_i_as_i_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 796 ``` 797 798 #### stdlib_strided_mask_b_k( \*arrays[], \*shape, \*strides, \*fcn ) 799 800 Applies a unary callback accepting and returning unsigned 8-bit integers to an unsigned 8-bit integer strided input array, casts the callback's unsigned 8-bit integer return value to a signed 16-bit integer, and assigns results to elements in a signed 16-bit integer strided output array. 801 802 ```c 803 #include <stdint.h> 804 805 // Create underlying byte arrays: 806 uint8_t x[] = { 0, 0, 0 }; 807 uint8_t m[] = { 0, 1, 0 }; 808 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 809 810 // Define a pointer to an array containing pointers to strided arrays: 811 uint8_t *arrays[] = { x, m, out }; 812 813 // Define the strides: 814 int64_t strides[] = { 1, 1, 2 }; // 1 byte per uint8, 2 bytes per int16 815 816 // Define the number of elements over which to iterate: 817 int64_t shape[] = { 3 }; 818 819 // Define a callback: 820 uint8_t scale( const uint8_t x ) { 821 return x + 10; 822 } 823 824 // Apply the callback: 825 stdlib_strided_mask_b_k( arrays, shape, strides, (void *)scale ); 826 ``` 827 828 The function accepts the following arguments: 829 830 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 831 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 832 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 833 - **fcn**: `[in] void*` a `UnaryFcnUint8` function to apply provided as a `void` pointer. 834 835 ```c 836 void stdlib_strided_mask_b_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 837 ``` 838 839 #### stdlib_strided_mask_b_k_as_k_k( \*arrays[], \*shape, \*strides, \*fcn ) 840 841 Applies a unary callback accepting and returning signed 16-bit integers to an unsigned 8-bit integer strided input array and assigns results to elements in a signed 16-bit integer strided output array. 842 843 ```c 844 #include <stdint.h> 845 846 // Create underlying byte arrays: 847 uint8_t x[] = { 0, 0, 0 }; 848 uint8_t m[] = { 0, 1, 0 }; 849 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 850 851 // Define a pointer to an array containing pointers to strided arrays: 852 uint8_t *arrays[] = { x, m, out }; 853 854 // Define the strides: 855 int64_t strides[] = { 1, 1, 2 }; // 1 byte per uint8, 2 bytes per int16 856 857 // Define the number of elements over which to iterate: 858 int64_t shape[] = { 3 }; 859 860 // Define a callback: 861 int16_t scale( const int16_t x ) { 862 return x + 10; 863 } 864 865 // Apply the callback: 866 stdlib_strided_mask_b_k_as_k_k( arrays, shape, strides, (void *)scale ); 867 ``` 868 869 The function accepts the following arguments: 870 871 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 872 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 873 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 874 - **fcn**: `[in] void*` a `UnaryFcnInt16` function to apply provided as a `void` pointer. 875 876 ```c 877 void stdlib_strided_mask_b_k_as_k_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 878 ``` 879 880 #### stdlib_strided_mask_b_t( \*arrays[], \*shape, \*strides, \*fcn ) 881 882 Applies a unary callback accepting and returning unsigned 8-bit integers to an unsigned 8-bit integer strided input array, casts the callback's unsigned 8-bit integer return value to an unsigned 16-bit integer, and assigns results to elements in an unsigned 16-bit integer strided output array. 883 884 ```c 885 #include <stdint.h> 886 887 // Create underlying byte arrays: 888 uint8_t x[] = { 0, 0, 0 }; 889 uint8_t m[] = { 0, 1, 0 }; 890 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 891 892 // Define a pointer to an array containing pointers to strided arrays: 893 uint8_t *arrays[] = { x, m, out }; 894 895 // Define the strides: 896 int64_t strides[] = { 1, 1, 2 }; // 1 byte per uint8, 2 bytes per uint16 897 898 // Define the number of elements over which to iterate: 899 int64_t shape[] = { 3 }; 900 901 // Define a callback: 902 uint8_t scale( const uint8_t x ) { 903 return x + 10; 904 } 905 906 // Apply the callback: 907 stdlib_strided_mask_b_t( arrays, shape, strides, (void *)scale ); 908 ``` 909 910 The function accepts the following arguments: 911 912 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 913 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 914 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 915 - **fcn**: `[in] void*` a `UnaryFcnUint8` function to apply provided as a `void` pointer. 916 917 ```c 918 void stdlib_strided_mask_b_t( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 919 ``` 920 921 #### stdlib_strided_mask_b_t_as_t_t( \*arrays[], \*shape, \*strides, \*fcn ) 922 923 Applies a unary callback accepting and returning unsigned 16-bit integers to an unsigned 8-bit integer strided input array and assigns results to elements in an unsigned 16-bit integer strided output array. 924 925 ```c 926 #include <stdint.h> 927 928 // Create underlying byte arrays: 929 uint8_t x[] = { 0, 0, 0 }; 930 uint8_t m[] = { 0, 1, 0 }; 931 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 932 933 // Define a pointer to an array containing pointers to strided arrays: 934 uint8_t *arrays[] = { x, m, out }; 935 936 // Define the strides: 937 int64_t strides[] = { 1, 1, 2 }; // 1 byte per uint8, 2 bytes per uint16 938 939 // Define the number of elements over which to iterate: 940 int64_t shape[] = { 3 }; 941 942 // Define a callback: 943 uint16_t scale( const uint16_t x ) { 944 return x + 10; 945 } 946 947 // Apply the callback: 948 stdlib_strided_mask_b_t_as_t_t( arrays, shape, strides, (void *)scale ); 949 ``` 950 951 The function accepts the following arguments: 952 953 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 954 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 955 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 956 - **fcn**: `[in] void*` a `UnaryFcnUint16` function to apply provided as a `void` pointer. 957 958 ```c 959 void stdlib_strided_mask_b_t_as_t_t( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 960 ``` 961 962 #### stdlib_strided_mask_b_u( \*arrays[], \*shape, \*strides, \*fcn ) 963 964 Applies a unary callback accepting and returning unsigned 8-bit integers to an unsigned 8-bit integer strided input array, casts the callback's unsigned 8-bit integer return value to an unsigned 32-bit integer, and assigns results to elements in an unsigned 32-bit integer strided output array. 965 966 ```c 967 #include <stdint.h> 968 969 // Create underlying byte arrays: 970 uint8_t x[] = { 0, 0, 0 }; 971 uint8_t m[] = { 0, 1, 0 }; 972 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 973 974 // Define a pointer to an array containing pointers to strided arrays: 975 uint8_t *arrays[] = { x, m, out }; 976 977 // Define the strides: 978 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per uint32 979 980 // Define the number of elements over which to iterate: 981 int64_t shape[] = { 3 }; 982 983 // Define a callback: 984 uint8_t scale( const uint8_t x ) { 985 return x + 10; 986 } 987 988 // Apply the callback: 989 stdlib_strided_mask_b_u( arrays, shape, strides, (void *)scale ); 990 ``` 991 992 The function accepts the following arguments: 993 994 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 995 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 996 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 997 - **fcn**: `[in] void*` a `UnaryFcnUint8` function to apply provided as a `void` pointer. 998 999 ```c 1000 void stdlib_strided_mask_b_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1001 ``` 1002 1003 #### stdlib_strided_mask_b_u_as_u_u( \*arrays[], \*shape, \*strides, \*fcn ) 1004 1005 Applies a unary callback accepting and returning unsigned 32-bit integers to an unsigned 8-bit integer strided input array and assigns results to elements in an unsigned 32-bit integer strided output array. 1006 1007 ```c 1008 #include <stdint.h> 1009 1010 // Create underlying byte arrays: 1011 uint8_t x[] = { 0, 0, 0 }; 1012 uint8_t m[] = { 0, 1, 0 }; 1013 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1014 1015 // Define a pointer to an array containing pointers to strided arrays: 1016 uint8_t *arrays[] = { x, m, out }; 1017 1018 // Define the strides: 1019 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per uint32 1020 1021 // Define the number of elements over which to iterate: 1022 int64_t shape[] = { 3 }; 1023 1024 // Define a callback: 1025 uint32_t scale( const uint32_t x ) { 1026 return x + 10; 1027 } 1028 1029 // Apply the callback: 1030 stdlib_strided_mask_b_u_as_u_u( arrays, shape, strides, (void *)scale ); 1031 ``` 1032 1033 The function accepts the following arguments: 1034 1035 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1036 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1037 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1038 - **fcn**: `[in] void*` a `UnaryFcnUint32` function to apply provided as a `void` pointer. 1039 1040 ```c 1041 void stdlib_strided_mask_b_u_as_u_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1042 ``` 1043 1044 #### stdlib_strided_mask_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 1045 1046 Applies a unary callback accepting and returning double-precision floating-point numbers to a double-precision floating-point strided input array and assigns results to elements in a double-precision floating-point strided output array. 1047 1048 ```c 1049 #include <stdint.h> 1050 1051 // Create underlying byte arrays: 1052 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1053 uint8_t m[] = { 0, 1, 0 }; 1054 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1055 1056 // Define a pointer to an array containing pointers to strided arrays: 1057 uint8_t *arrays[] = { x, m, out }; 1058 1059 // Define the strides: 1060 int64_t strides[] = { 8, 1, 8 }; // 8 bytes per double, 1 byte per uint8 1061 1062 // Define the number of elements over which to iterate: 1063 int64_t shape[] = { 3 }; 1064 1065 // Define a callback: 1066 double scale( const double x ) { 1067 return x + 10.0; 1068 } 1069 1070 // Apply the callback: 1071 stdlib_strided_mask_d_d( arrays, shape, strides, (void *)scale ); 1072 ``` 1073 1074 The function accepts the following arguments: 1075 1076 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1077 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1078 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1079 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 1080 1081 ```c 1082 void stdlib_strided_mask_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1083 ``` 1084 1085 #### stdlib_strided_mask_d_i( \*arrays[], \*shape, \*strides, \*fcn ) 1086 1087 Applies a unary callback accepting a double-precision floating-point number and returning a signed 32-bit integer to a double-precision floating-point strided input array and assigns results to elements in a signed 32-bit integer strided output array. 1088 1089 ```c 1090 #include <stdint.h> 1091 #include <math.h> 1092 1093 // Create underlying byte arrays: 1094 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1095 uint8_t m[] = { 0, 1, 0 }; 1096 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1097 1098 // Define a pointer to an array containing pointers to strided arrays: 1099 uint8_t *arrays[] = { x, m, out }; 1100 1101 // Define the strides: 1102 int64_t strides[] = { 8, 1, 4 }; // 8 bytes per double, 1 byte per uint8, 4 bytes per int32 1103 1104 // Define the number of elements over which to iterate: 1105 int64_t shape[] = { 3 }; 1106 1107 // Apply the callback: 1108 stdlib_strided_mask_d_i( arrays, shape, strides, (void *)lrint ); 1109 ``` 1110 1111 The function accepts the following arguments: 1112 1113 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1114 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1115 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1116 - **fcn**: `[in] void*` a `UnaryFcnFloat64Int32` function to apply provided as a `void` pointer. 1117 1118 ```c 1119 void stdlib_strided_mask_d_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1120 ``` 1121 1122 #### stdlib_strided_mask_d_l( \*arrays[], \*shape, \*strides, \*fcn ) 1123 1124 Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a double-precision floating-point strided input array and assigns results to elements in a signed 64-bit integer strided output array. 1125 1126 ```c 1127 #include <stdint.h> 1128 #include <math.h> 1129 1130 // Create underlying byte arrays: 1131 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1132 uint8_t m[] = { 0, 1, 0 }; 1133 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1134 1135 // Define a pointer to an array containing pointers to strided arrays: 1136 uint8_t *arrays[] = { x, m, out }; 1137 1138 // Define the strides: 1139 int64_t strides[] = { 8, 1, 8 }; // 8 bytes per double, 1 byte per uint8, 8 bytes per int64 1140 1141 // Define the number of elements over which to iterate: 1142 int64_t shape[] = { 3 }; 1143 1144 // Apply the callback: 1145 stdlib_strided_mask_d_l( arrays, shape, strides, (void *)llrint ); 1146 ``` 1147 1148 The function accepts the following arguments: 1149 1150 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1151 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1152 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1153 - **fcn**: `[in] void*` a `UnaryFcnFloat64Int64` function to apply provided as a `void` pointer. 1154 1155 ```c 1156 void stdlib_strided_mask_d_l( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1157 ``` 1158 1159 #### stdlib_strided_mask_f_d( \*arrays[], \*shape, \*strides, \*fcn ) 1160 1161 Applies a unary callback accepting and returning single-precision floating-point numbers to a single-precision floating-point strided input array, casts the callback's single-precision floating-point return value to a double-precision floating-point number, and assigns results to elements in a double-precision floating-point strided output array. 1162 1163 ```c 1164 #include <stdint.h> 1165 1166 // Create underlying byte arrays: 1167 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1168 uint8_t m[] = { 0, 1, 0 }; 1169 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1170 1171 // Define a pointer to an array containing pointers to strided arrays: 1172 uint8_t *arrays[] = { x, m, out }; 1173 1174 // Define the strides: 1175 int64_t strides[] = { 4, 1, 8 }; // 4 bytes per float, 1 byte per uint8, 8 bytes per double 1176 1177 // Define the number of elements over which to iterate: 1178 int64_t shape[] = { 3 }; 1179 1180 // Define a callback: 1181 float scale( const float x ) { 1182 return x + 10.0f; 1183 } 1184 1185 // Apply the callback: 1186 stdlib_strided_mask_f_d( arrays, shape, strides, (void *)scale ); 1187 ``` 1188 1189 The function accepts the following arguments: 1190 1191 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1192 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1193 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1194 - **fcn**: `[in] void*` a `UnaryFcnFloat32` function to apply provided as a `void` pointer. 1195 1196 ```c 1197 void stdlib_strided_mask_f_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1198 ``` 1199 1200 #### stdlib_strided_mask_f_d_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 1201 1202 Applies a unary callback accepting and returning double-precision floating-point numbers to a single-precision floating-point strided input array and assigns results to elements in a double-precision floating-point strided output array. 1203 1204 ```c 1205 #include <stdint.h> 1206 1207 // Create underlying byte arrays: 1208 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1209 uint8_t m[] = { 0, 1, 0 }; 1210 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1211 1212 // Define a pointer to an array containing pointers to strided arrays: 1213 uint8_t *arrays[] = { x, m, out }; 1214 1215 // Define the strides: 1216 int64_t strides[] = { 4, 1, 8 }; // 4 bytes per float, 1 byte per uint8, 8 bytes per double 1217 1218 // Define the number of elements over which to iterate: 1219 int64_t shape[] = { 3 }; 1220 1221 // Define a callback: 1222 double scale( const double x ) { 1223 return x + 10.0; 1224 } 1225 1226 // Apply the callback: 1227 stdlib_strided_mask_f_d_as_d_d( arrays, shape, strides, (void *)scale ); 1228 ``` 1229 1230 The function accepts the following arguments: 1231 1232 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1233 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1234 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1235 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 1236 1237 ```c 1238 void stdlib_strided_mask_f_d_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1239 ``` 1240 1241 #### stdlib_strided_mask_f_f( \*arrays[], \*shape, \*strides, \*fcn ) 1242 1243 Applies a unary callback accepting and returning single-precision floating-point numbers to a single-precision floating-point strided input array and assigns results to elements in a single-precision floating-point strided output array. 1244 1245 ```c 1246 #include <stdint.h> 1247 1248 // Create underlying byte arrays: 1249 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1250 uint8_t m[] = { 0, 1, 0 }; 1251 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1252 1253 // Define a pointer to an array containing pointers to strided arrays: 1254 uint8_t *arrays[] = { x, m, out }; 1255 1256 // Define the strides: 1257 int64_t strides[] = { 4, 1, 4 }; // 4 bytes per float, 1 byte per uint8 1258 1259 // Define the number of elements over which to iterate: 1260 int64_t shape[] = { 3 }; 1261 1262 // Define a callback: 1263 float scale( const float x ) { 1264 return x + 10.0f; 1265 } 1266 1267 // Apply the callback: 1268 stdlib_strided_mask_f_f( arrays, shape, strides, (void *)scale ); 1269 ``` 1270 1271 The function accepts the following arguments: 1272 1273 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1274 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1275 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1276 - **fcn**: `[in] void*` a `UnaryFcnFloat32` function to apply provided as a `void` pointer. 1277 1278 ```c 1279 void stdlib_strided_mask_f_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1280 ``` 1281 1282 #### stdlib_strided_mask_f_f_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 1283 1284 Applies a unary callback accepting and returning double-precision floating-point numbers, casts the callback's double-precision floating-point return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 1285 1286 ```c 1287 #include <stdint.h> 1288 1289 // Create underlying byte arrays: 1290 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1291 uint8_t m[] = { 0, 1, 0 }; 1292 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1293 1294 // Define a pointer to an array containing pointers to strided arrays: 1295 uint8_t *arrays[] = { x, m, out }; 1296 1297 // Define the strides: 1298 int64_t strides[] = { 4, 1, 4 }; // 4 bytes per float, 1 byte per uint8 1299 1300 // Define the number of elements over which to iterate: 1301 int64_t shape[] = { 3 }; 1302 1303 // Define a callback: 1304 double scale( const double x ) { 1305 return x + 10.0; 1306 } 1307 1308 // Apply the callback: 1309 stdlib_strided_mask_f_f_as_d_d( arrays, shape, strides, (void *)scale ); 1310 ``` 1311 1312 The function accepts the following arguments: 1313 1314 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1315 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1316 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1317 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 1318 1319 ```c 1320 void stdlib_strided_mask_f_f_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1321 ``` 1322 1323 #### stdlib_strided_mask_f_i( \*arrays[], \*shape, \*strides, \*fcn ) 1324 1325 Applies a unary callback accepting a single-precision floating-point number and returning a signed 32-bit integer to a single-precision floating-point strided input array and assigns results to elements in a signed 32-bit integer strided output array. 1326 1327 ```c 1328 #include <stdint.h> 1329 #include <math.h> 1330 1331 // Create underlying byte arrays: 1332 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1333 uint8_t m[] = { 0, 1, 0 }; 1334 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1335 1336 // Define a pointer to an array containing pointers to strided arrays: 1337 uint8_t *arrays[] = { x, m, out }; 1338 1339 // Define the strides: 1340 int64_t strides[] = { 4, 1, 4 }; // 4 bytes per float, 1 byte per uint8, 4 bytes per int32 1341 1342 // Define the number of elements over which to iterate: 1343 int64_t shape[] = { 3 }; 1344 1345 // Apply the callback: 1346 stdlib_strided_mask_f_i( arrays, shape, strides, (void *)lrintf ); 1347 ``` 1348 1349 The function accepts the following arguments: 1350 1351 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1352 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1353 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1354 - **fcn**: `[in] void*` a `UnaryFcnFloat32Int32` function to apply provided as a `void` pointer. 1355 1356 ```c 1357 void stdlib_strided_mask_f_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1358 ``` 1359 1360 #### stdlib_strided_mask_f_l( \*arrays[], \*shape, \*strides, \*fcn ) 1361 1362 Applies a unary callback accepting a single-precision floating-point number and returning a signed 64-bit integer to a single-precision floating-point strided input array and assigns results to elements in a signed 64-bit integer strided output array. 1363 1364 ```c 1365 #include <stdint.h> 1366 #include <math.h> 1367 1368 // Create underlying byte arrays: 1369 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1370 uint8_t m[] = { 0, 1, 0 }; 1371 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1372 1373 // Define a pointer to an array containing pointers to strided arrays: 1374 uint8_t *arrays[] = { x, m, out }; 1375 1376 // Define the strides: 1377 int64_t strides[] = { 4, 1, 8 }; // 4 bytes per float, 1 byte per uint8, 8 bytes per int64 1378 1379 // Define the number of elements over which to iterate: 1380 int64_t shape[] = { 3 }; 1381 1382 // Apply the callback: 1383 stdlib_strided_mask_f_l( arrays, shape, strides, (void *)lrintf ); 1384 ``` 1385 1386 The function accepts the following arguments: 1387 1388 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1389 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1390 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1391 - **fcn**: `[in] void*` a `UnaryFcnFloat32Int64` function to apply provided as a `void` pointer. 1392 1393 ```c 1394 void stdlib_strided_mask_f_l( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1395 ``` 1396 1397 #### stdlib_strided_mask_i_d( \*arrays[], \*shape, \*strides, \*fcn ) 1398 1399 Applies a unary callback accepting and returning signed 32-bit integers to a signed 32-bit integer strided input array, casts the callback's signed 32-bit integer return value to a double-precision floating-point number, and assigns results to elements in a double-precision floating-point strided output array. 1400 1401 ```c 1402 #include <stdint.h> 1403 1404 // Create underlying byte arrays: 1405 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1406 uint8_t m[] = { 0, 1, 0 }; 1407 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1408 1409 // Define a pointer to an array containing pointers to strided arrays: 1410 uint8_t *arrays[] = { x, m, out }; 1411 1412 // Define the strides: 1413 int64_t strides[] = { 4, 1, 8 }; // 4 bytes per int32, 1 byte per uint8, 8 bytes per double 1414 1415 // Define the number of elements over which to iterate: 1416 int64_t shape[] = { 3 }; 1417 1418 // Define a callback: 1419 int32_t scale( const int32_t x ) { 1420 return x + 10; 1421 } 1422 1423 // Apply the callback: 1424 stdlib_strided_mask_i_d( arrays, shape, strides, (void *)scale ); 1425 ``` 1426 1427 The function accepts the following arguments: 1428 1429 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1430 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1431 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1432 - **fcn**: `[in] void*` a `UnaryFcnInt32` function to apply provided as a `void` pointer. 1433 1434 ```c 1435 void stdlib_strided_mask_i_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1436 ``` 1437 1438 #### stdlib_strided_mask_i_d_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 1439 1440 Applies a unary callback accepting and returning double-precision floating-point numbers to a signed 32-bit integer strided input array and assigns results to elements in a double-precision floating-point strided output array. 1441 1442 ```c 1443 #include <stdint.h> 1444 1445 // Create underlying byte arrays: 1446 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1447 uint8_t m[] = { 0, 1, 0 }; 1448 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1449 1450 // Define a pointer to an array containing pointers to strided arrays: 1451 uint8_t *arrays[] = { x, m, out }; 1452 1453 // Define the strides: 1454 int64_t strides[] = { 4, 1, 8 }; // 4 bytes per int32, 1 byte per uint8, 8 bytes per double 1455 1456 // Define the number of elements over which to iterate: 1457 int64_t shape[] = { 3 }; 1458 1459 // Define a callback: 1460 double scale( const double x ) { 1461 return x + 10.0; 1462 } 1463 1464 // Apply the callback: 1465 stdlib_strided_mask_i_d_as_d_d( arrays, shape, strides, (void *)scale ); 1466 ``` 1467 1468 The function accepts the following arguments: 1469 1470 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1471 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1472 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1473 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 1474 1475 ```c 1476 void stdlib_strided_mask_i_d_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1477 ``` 1478 1479 #### stdlib_strided_mask_i_i( \*arrays[], \*shape, \*strides, \*fcn ) 1480 1481 Applies a unary callback accepting and returning signed 32-bit integers to a signed 32-bit integer strided input array and assigns results to elements in a signed 32-bit integer strided output array. 1482 1483 ```c 1484 #include <stdint.h> 1485 1486 // Create underlying byte arrays: 1487 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1488 uint8_t m[] = { 0, 1, 0 }; 1489 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1490 1491 // Define a pointer to an array containing pointers to strided arrays: 1492 uint8_t *arrays[] = { x, m, out }; 1493 1494 // Define the strides: 1495 int64_t strides[] = { 4, 1, 4 }; // 4 bytes per int32, 1 byte per uint8 1496 1497 // Define the number of elements over which to iterate: 1498 int64_t shape[] = { 3 }; 1499 1500 // Define a callback: 1501 int32_t scale( const int32_t x ) { 1502 return x + 10; 1503 } 1504 1505 // Apply the callback: 1506 stdlib_strided_mask_i_i( arrays, shape, strides, (void *)scale ); 1507 ``` 1508 1509 The function accepts the following arguments: 1510 1511 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1512 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1513 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1514 - **fcn**: `[in] void*` a `UnaryFcnInt32` function to apply provided as a `void` pointer. 1515 1516 ```c 1517 void stdlib_strided_mask_i_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1518 ``` 1519 1520 #### stdlib_strided_mask_i_u( \*arrays[], \*shape, \*strides, \*fcn ) 1521 1522 Applies a unary callback accepting and returning signed 32-bit integers to a signed 32-bit integer strided input array, casts the callback's signed 32-bit integer return value to an unsigned 32-bit integer, and assigns results to elements in an unsigned 32-bit integer strided output array. 1523 1524 ```c 1525 #include <stdint.h> 1526 1527 // Create underlying byte arrays: 1528 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1529 uint8_t m[] = { 0, 1, 0 }; 1530 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1531 1532 // Define a pointer to an array containing pointers to strided arrays: 1533 uint8_t *arrays[] = { x, m, out }; 1534 1535 // Define the strides: 1536 int64_t strides[] = { 4, 1, 4 }; // 4 bytes per int32, 1 byte per uint8, 4 bytes per uint32 1537 1538 // Define the number of elements over which to iterate: 1539 int64_t shape[] = { 3 }; 1540 1541 // Define a callback: 1542 int32_t abs( const int32_t x ) { 1543 if ( x < 0 ) { 1544 return -x; 1545 } 1546 return x; 1547 } 1548 1549 // Apply the callback: 1550 stdlib_strided_mask_i_u( arrays, shape, strides, (void *)abs ); 1551 ``` 1552 1553 The function accepts the following arguments: 1554 1555 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1556 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1557 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1558 - **fcn**: `[in] void*` a `UnaryFcnInt32` function to apply provided as a `void` pointer. 1559 1560 ```c 1561 void stdlib_strided_mask_i_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1562 ``` 1563 1564 #### stdlib_strided_mask_k_d( \*arrays[], \*shape, \*strides, \*fcn ) 1565 1566 Applies a unary callback accepting and returning signed 16-bit integers to a signed 16-bit integer strided input array, casts the callback's signed 16-bit integer return value to a double-precision floating-point number, and assigns results to elements in a double-precision floating-point strided output array. 1567 1568 ```c 1569 #include <stdint.h> 1570 1571 // Create underlying byte arrays: 1572 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1573 uint8_t m[] = { 0, 1, 0 }; 1574 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1575 1576 // Define a pointer to an array containing pointers to strided arrays: 1577 uint8_t *arrays[] = { x, m, out }; 1578 1579 // Define the strides: 1580 int64_t strides[] = { 2, 1, 8 }; // 2 bytes per int16, 1 byte per uint8, 8 bytes per double 1581 1582 // Define the number of elements over which to iterate: 1583 int64_t shape[] = { 3 }; 1584 1585 // Define a callback: 1586 int16_t scale( const int16_t x ) { 1587 return x + 10; 1588 } 1589 1590 // Apply the callback: 1591 stdlib_strided_mask_k_d( arrays, shape, strides, (void *)scale ); 1592 ``` 1593 1594 The function accepts the following arguments: 1595 1596 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1597 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1598 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1599 - **fcn**: `[in] void*` a `UnaryFcnInt16` function to apply provided as a `void` pointer. 1600 1601 ```c 1602 void stdlib_strided_mask_k_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1603 ``` 1604 1605 #### stdlib_strided_mask_k_d_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 1606 1607 Applies a unary callback accepting and returning double-precision floating-point numbers to a signed 16-bit integer strided input array and assigns results to elements in a double-precision floating-point strided output array. 1608 1609 ```c 1610 #include <stdint.h> 1611 1612 // Create underlying byte arrays: 1613 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1614 uint8_t m[] = { 0, 1, 0 }; 1615 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1616 1617 // Define a pointer to an array containing pointers to strided arrays: 1618 uint8_t *arrays[] = { x, m, out }; 1619 1620 // Define the strides: 1621 int64_t strides[] = { 2, 1, 8 }; // 2 bytes per int16, 1 byte per uint8, 8 bytes per double 1622 1623 // Define the number of elements over which to iterate: 1624 int64_t shape[] = { 3 }; 1625 1626 // Define a callback: 1627 double scale( const double x ) { 1628 return x + 10.0; 1629 } 1630 1631 // Apply the callback: 1632 stdlib_strided_mask_k_d_as_d_d( arrays, shape, strides, (void *)scale ); 1633 ``` 1634 1635 The function accepts the following arguments: 1636 1637 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1638 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1639 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1640 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 1641 1642 ```c 1643 void stdlib_strided_mask_k_d_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1644 ``` 1645 1646 #### stdlib_strided_mask_k_f( \*arrays[], \*shape, \*strides, \*fcn ) 1647 1648 Applies a unary callback accepting and returning signed 16-bit integers to a signed 16-bit integer strided input array, casts the callback's signed 16-bit integer return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 1649 1650 ```c 1651 #include <stdint.h> 1652 1653 // Create underlying byte arrays: 1654 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1655 uint8_t m[] = { 0, 1, 0 }; 1656 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1657 1658 // Define a pointer to an array containing pointers to strided arrays: 1659 uint8_t *arrays[] = { x, m, out }; 1660 1661 // Define the strides: 1662 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per int16, 1 byte per uint8, 4 bytes per float 1663 1664 // Define the number of elements over which to iterate: 1665 int64_t shape[] = { 3 }; 1666 1667 // Define a callback: 1668 int16_t scale( const int16_t x ) { 1669 return x + 10; 1670 } 1671 1672 // Apply the callback: 1673 stdlib_strided_mask_k_f( arrays, shape, strides, (void *)scale ); 1674 ``` 1675 1676 The function accepts the following arguments: 1677 1678 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1679 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1680 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1681 - **fcn**: `[in] void*` a `UnaryFcnInt16` function to apply provided as a `void` pointer. 1682 1683 ```c 1684 void stdlib_strided_mask_k_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1685 ``` 1686 1687 #### stdlib_strided_mask_k_f_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 1688 1689 Applies a unary callback accepting and returning double-precision floating-point numbers to a signed 16-bit integer strided input array, casts the callback's double-precision floating-point return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 1690 1691 ```c 1692 #include <stdint.h> 1693 1694 // Create underlying byte arrays: 1695 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1696 uint8_t m[] = { 0, 1, 0 }; 1697 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1698 1699 // Define a pointer to an array containing pointers to strided arrays: 1700 uint8_t *arrays[] = { x, m, out }; 1701 1702 // Define the strides: 1703 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per int16, 1 byte per uint8, 4 bytes per float 1704 1705 // Define the number of elements over which to iterate: 1706 int64_t shape[] = { 3 }; 1707 1708 // Define a callback: 1709 double scale( const double x ) { 1710 return x + 10.0; 1711 } 1712 1713 // Apply the callback: 1714 stdlib_strided_mask_k_f_as_d_d( arrays, shape, strides, (void *)scale ); 1715 ``` 1716 1717 The function accepts the following arguments: 1718 1719 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1720 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1721 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1722 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 1723 1724 ```c 1725 void stdlib_strided_mask_k_f_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1726 ``` 1727 1728 #### stdlib_strided_mask_k_f_as_f_f( \*arrays[], \*shape, \*strides, \*fcn ) 1729 1730 Applies a unary callback accepting and returning single-precision floating-point numbers to a signed 16-bit integer strided input array and assigns results to elements in a single-precision floating-point strided output array. 1731 1732 ```c 1733 #include <stdint.h> 1734 1735 // Create underlying byte arrays: 1736 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1737 uint8_t m[] = { 0, 1, 0 }; 1738 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1739 1740 // Define a pointer to an array containing pointers to strided arrays: 1741 uint8_t *arrays[] = { x, m, out }; 1742 1743 // Define the strides: 1744 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per int16, 1 byte per uint8, 4 bytes per float 1745 1746 // Define the number of elements over which to iterate: 1747 int64_t shape[] = { 3 }; 1748 1749 // Define a callback: 1750 float scale( const float x ) { 1751 return x + 10.0f; 1752 } 1753 1754 // Apply the callback: 1755 stdlib_strided_mask_k_f_as_f_f( arrays, shape, strides, (void *)scale ); 1756 ``` 1757 1758 The function accepts the following arguments: 1759 1760 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1761 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1762 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1763 - **fcn**: `[in] void*` a `UnaryFcnFloat32` function to apply provided as a `void` pointer. 1764 1765 ```c 1766 void stdlib_strided_mask_k_f_as_f_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1767 ``` 1768 1769 #### stdlib_strided_mask_k_i( \*arrays[], \*shape, \*strides, \*fcn ) 1770 1771 Applies a unary callback accepting and returning signed 16-bit integers to a signed 16-bit integer strided input array, casts the callback's signed 16-bit integer return value to a signed 32-bit integer, and assigns results to elements in a signed 32-bit integer strided output array. 1772 1773 ```c 1774 #include <stdint.h> 1775 1776 // Create underlying byte arrays: 1777 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1778 uint8_t m[] = { 0, 1, 0 }; 1779 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1780 1781 // Define a pointer to an array containing pointers to strided arrays: 1782 uint8_t *arrays[] = { x, m, out }; 1783 1784 // Define the strides: 1785 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per int16, 1 byte per uint8, 4 bytes per int32 1786 1787 // Define the number of elements over which to iterate: 1788 int64_t shape[] = { 3 }; 1789 1790 // Define a callback: 1791 int16_t scale( const int16_t x ) { 1792 return x + 10; 1793 } 1794 1795 // Apply the callback: 1796 stdlib_strided_mask_k_i( arrays, shape, strides, (void *)scale ); 1797 ``` 1798 1799 The function accepts the following arguments: 1800 1801 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1802 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1803 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1804 - **fcn**: `[in] void*` a `UnaryFcnInt16` function to apply provided as a `void` pointer. 1805 1806 ```c 1807 void stdlib_strided_mask_k_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1808 ``` 1809 1810 #### stdlib_strided_mask_k_i_as_i_i( \*arrays[], \*shape, \*strides, \*fcn ) 1811 1812 Applies a unary callback accepting and returning signed 32-bit integers to a signed 16-bit integer strided input array and assigns results to elements in a signed 32-bit integer strided output array. 1813 1814 ```c 1815 #include <stdint.h> 1816 1817 // Create underlying byte arrays: 1818 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1819 uint8_t m[] = { 0, 1, 0 }; 1820 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1821 1822 // Define a pointer to an array containing pointers to strided arrays: 1823 uint8_t *arrays[] = { x, m, out }; 1824 1825 // Define the strides: 1826 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per int16, 1 byte per uint8, 4 bytes per int32 1827 1828 // Define the number of elements over which to iterate: 1829 int64_t shape[] = { 3 }; 1830 1831 // Define a callback: 1832 int32_t scale( const int32_t x ) { 1833 return x + 10; 1834 } 1835 1836 // Apply the callback: 1837 stdlib_strided_mask_k_i_as_i_i( arrays, shape, strides, (void *)scale ); 1838 ``` 1839 1840 The function accepts the following arguments: 1841 1842 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1843 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1844 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1845 - **fcn**: `[in] void*` a `UnaryFcnInt32` function to apply provided as a `void` pointer. 1846 1847 ```c 1848 void stdlib_strided_mask_k_i_as_i_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1849 ``` 1850 1851 #### stdlib_strided_mask_k_k( \*arrays[], \*shape, \*strides, \*fcn ) 1852 1853 Applies a unary callback accepting and returning signed 16-bit integers to a signed 16-bit integer strided input array and assigns results to elements in a signed 16-bit integer strided output array. 1854 1855 ```c 1856 #include <stdint.h> 1857 1858 // Create underlying byte arrays: 1859 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1860 uint8_t m[] = { 0, 1, 0 }; 1861 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 1862 1863 // Define a pointer to an array containing pointers to strided arrays: 1864 uint8_t *arrays[] = { x, m, out }; 1865 1866 // Define the strides: 1867 int64_t strides[] = { 2, 1, 2 }; // 2 bytes per int16, 1 byte per uint8 1868 1869 // Define the number of elements over which to iterate: 1870 int64_t shape[] = { 3 }; 1871 1872 // Define a callback: 1873 int16_t scale( const int16_t x ) { 1874 return x + 10; 1875 } 1876 1877 // Apply the callback: 1878 stdlib_strided_mask_k_k( arrays, shape, strides, (void *)scale ); 1879 ``` 1880 1881 The function accepts the following arguments: 1882 1883 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1884 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1885 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1886 - **fcn**: `[in] void*` a `UnaryFcnInt16` function to apply provided as a `void` pointer. 1887 1888 ```c 1889 void stdlib_strided_mask_k_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1890 ``` 1891 1892 #### stdlib_strided_mask_k_t( \*arrays[], \*shape, \*strides, \*fcn ) 1893 1894 Applies a unary callback accepting and returned signed 16-bit integers to a signed 16-bit integer strided input array, casts the callback's signed 16-bit integer return value to an unsigned 16-bit integer, and assigns results to elements in an unsigned 16-bit integer strided output array. 1895 1896 ```c 1897 #include <stdint.h> 1898 1899 // Create underlying byte arrays: 1900 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1901 uint8_t m[] = { 0, 1, 0 }; 1902 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 1903 1904 // Define a pointer to an array containing pointers to strided arrays: 1905 uint8_t *arrays[] = { x, m, out }; 1906 1907 // Define the strides: 1908 int64_t strides[] = { 2, 1, 2 }; // 2 bytes per int16, 1 byte per uint8, 2 bytes per uint16 1909 1910 // Define the number of elements over which to iterate: 1911 int64_t shape[] = { 3 }; 1912 1913 // Define a callback: 1914 int16_t abs( const int16_t x ) { 1915 if ( x < 0 ) { 1916 return -x; 1917 } 1918 return x; 1919 } 1920 1921 // Apply the callback: 1922 stdlib_strided_mask_k_t( arrays, shape, strides, (void *)abs ); 1923 ``` 1924 1925 The function accepts the following arguments: 1926 1927 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1928 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1929 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1930 - **fcn**: `[in] void*` a `UnaryFcnInt16` function to apply provided as a `void` pointer. 1931 1932 ```c 1933 void stdlib_strided_mask_k_t( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1934 ``` 1935 1936 #### stdlib_strided_mask_k_u( \*arrays[], \*shape, \*strides, \*fcn ) 1937 1938 Applies a unary callback accepting and returning signed 16-bit integers to a signed 16-bit integer strided input array, casts the callback's signed 16-bit integer return value to an unsigned 32-bit integer, and assigns results to elements in an unsigned 32-bit integer strided output array. 1939 1940 ```c 1941 #include <stdint.h> 1942 1943 // Create underlying byte arrays: 1944 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1945 uint8_t m[] = { 0, 1, 0 }; 1946 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1947 1948 // Define a pointer to an array containing pointers to strided arrays: 1949 uint8_t *arrays[] = { x, m, out }; 1950 1951 // Define the strides: 1952 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per int16, 1 byte per uint8, 4 bytes per uint32 1953 1954 // Define the number of elements over which to iterate: 1955 int64_t shape[] = { 3 }; 1956 1957 // Define a callback: 1958 int16_t abs( const int16_t x ) { 1959 if ( x < 0 ) { 1960 return -x; 1961 } 1962 return x; 1963 } 1964 1965 // Apply the callback: 1966 stdlib_strided_mask_k_u( arrays, shape, strides, (void *)abs ); 1967 ``` 1968 1969 The function accepts the following arguments: 1970 1971 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 1972 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1973 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1974 - **fcn**: `[in] void*` a `UnaryFcnInt16` function to apply provided as a `void` pointer. 1975 1976 ```c 1977 void stdlib_strided_mask_k_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1978 ``` 1979 1980 #### stdlib_strided_mask_l_l( \*arrays[], \*shape, \*strides, \*fcn ) 1981 1982 Applies a unary callback accepting and returning signed 64-bit integers to a signed 64-bit integer strided input array and assigns results to elements in a signed 64-bit integer strided output array. 1983 1984 ```c 1985 #include <stdint.h> 1986 1987 // Create underlying byte arrays: 1988 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1989 uint8_t m[] = { 0, 1, 0 }; 0, 0 }; 1990 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1991 1992 // Define a pointer to an array containing pointers to strided arrays: 1993 uint8_t *arrays[] = { x, m, out }; 1994 1995 // Define the strides: 1996 int64_t strides[] = { 8, 1, 8 }; // 8 bytes per int64, 1 byte per uint8 1997 1998 // Define the number of elements over which to iterate: 1999 int64_t shape[] = { 3 }; 2000 2001 // Define a callback: 2002 int64_t scale( const int64_t x ) { 2003 return x + 10; 2004 } 2005 2006 // Apply the callback: 2007 stdlib_strided_mask_l_l( arrays, shape, strides, (void *)scale ); 2008 ``` 2009 2010 The function accepts the following arguments: 2011 2012 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2013 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2014 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2015 - **fcn**: `[in] void*` a `UnaryFcnInt64` function to apply provided as a `void` pointer. 2016 2017 ```c 2018 void stdlib_strided_mask_l_l( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2019 ``` 2020 2021 #### stdlib_strided_mask_l_v( \*arrays[], \*shape, \*strides, \*fcn ) 2022 2023 Applies a unary callback accepting and returning signed 64-bit integers to a signed 64-bit integer strided input array, casts the callback's signed 64-bit integer return value to an unsigned 64-bit integer, and assigns results to elements in an unsigned 64-bit integer strided output array. 2024 2025 ```c 2026 #include <stdint.h> 2027 2028 // Create underlying byte arrays: 2029 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2030 uint8_t m[] = { 0, 1, 0 }; 0, 0 }; 2031 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2032 2033 // Define a pointer to an array containing pointers to strided arrays: 2034 uint8_t *arrays[] = { x, m, out }; 2035 2036 // Define the strides: 2037 int64_t strides[] = { 8, 1, 8 }; // 8 bytes per int64, 1 byte per uint8, 8 bytes per uint64 2038 2039 // Define the number of elements over which to iterate: 2040 int64_t shape[] = { 3 }; 2041 2042 // Define a callback: 2043 int64_t abs( const int64_t x ) { 2044 if ( x < 0 ) { 2045 return -x; 2046 } 2047 return x; 2048 } 2049 2050 // Apply the callback: 2051 stdlib_strided_mask_l_v( arrays, shape, strides, (void *)abs ); 2052 ``` 2053 2054 The function accepts the following arguments: 2055 2056 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2057 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2058 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2059 - **fcn**: `[in] void*` a `UnaryFcnInt64` function to apply provided as a `void` pointer. 2060 2061 ```c 2062 void stdlib_strided_mask_l_v( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2063 ``` 2064 2065 #### stdlib_strided_mask_s_b( \*arrays[], \*shape, \*strides, \*fcn ) 2066 2067 Applies a unary callback accepting and returning signed 8-bit integers to a signed 8-bit integer strided input array, casts the callback's signed 8-bit integer return value to an unsigned 8-bit integer, and assigns results to elements in an unsigned 8-bit integer strided output array. 2068 2069 ```c 2070 #include <stdint.h> 2071 2072 // Create underlying byte arrays: 2073 uint8_t x[] = { 0, 0, 0 }; 2074 uint8_t m[] = { 0, 1, 0 }; 2075 uint8_t out[] = { 0, 0, 0 }; 2076 2077 // Define a pointer to an array containing pointers to strided arrays: 2078 uint8_t *arrays[] = { x, m, out }; 2079 2080 // Define the strides: 2081 int64_t strides[] = { 1, 1, 1 }; // 1 byte per int8, 1 byte per uint8, 1 byte per uint8 2082 2083 // Define the number of elements over which to iterate: 2084 int64_t shape[] = { 3 }; 2085 2086 // Define a callback: 2087 int8_t abs( const int8_t x ) { 2088 if ( x < 0 ) { 2089 return -x; 2090 } 2091 return x; 2092 } 2093 2094 // Apply the callback: 2095 stdlib_strided_mask_s_b( arrays, shape, strides, (void *)abs ); 2096 ``` 2097 2098 The function accepts the following arguments: 2099 2100 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2101 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2102 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2103 - **fcn**: `[in] void*` a `UnaryFcnInt8` function to apply provided as a `void` pointer. 2104 2105 ```c 2106 void stdlib_strided_mask_s_b( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2107 ``` 2108 2109 #### stdlib_strided_mask_s_d( \*arrays[], \*shape, \*strides, \*fcn ) 2110 2111 Applies a unary callback accepting and returning signed 8-bit integers to a signed 8-bit integer strided input array, casts the callback's signed 8-bit integer return value to a double-precision floating-point number, and assigns results to elements in a double-precision floating-point strided output array. 2112 2113 ```c 2114 #include <stdint.h> 2115 2116 // Create underlying byte arrays: 2117 uint8_t x[] = { 0, 0, 0 }; 2118 uint8_t m[] = { 0, 1, 0 }; 2119 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2120 2121 // Define a pointer to an array containing pointers to strided arrays: 2122 uint8_t *arrays[] = { x, m, out }; 2123 2124 // Define the strides: 2125 int64_t strides[] = { 1, 1, 8 }; // 1 byte per int8, 1 byte per uint8, 8 bytes per double 2126 2127 // Define the number of elements over which to iterate: 2128 int64_t shape[] = { 3 }; 2129 2130 // Define a callback: 2131 int8_t scale( const int8_t x ) { 2132 return x + 10; 2133 } 2134 2135 // Apply the callback: 2136 stdlib_strided_mask_s_d( arrays, shape, strides, (void *)scale ); 2137 ``` 2138 2139 The function accepts the following arguments: 2140 2141 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2142 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2143 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2144 - **fcn**: `[in] void*` a `UnaryFcnInt8` function to apply provided as a `void` pointer. 2145 2146 ```c 2147 void stdlib_strided_mask_s_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2148 ``` 2149 2150 #### stdlib_strided_mask_s_d_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 2151 2152 Applies a unary callback accepting and returning double-precision floating-point numbers to a signed 8-bit integer strided input array and assigns results to elements in a double-precision floating-point strided output array. 2153 2154 ```c 2155 #include <stdint.h> 2156 2157 // Create underlying byte arrays: 2158 uint8_t x[] = { 0, 0, 0 }; 2159 uint8_t m[] = { 0, 1, 0 }; 2160 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2161 2162 // Define a pointer to an array containing pointers to strided arrays: 2163 uint8_t *arrays[] = { x, m, out }; 2164 2165 // Define the strides: 2166 int64_t strides[] = { 1, 1, 8 }; // 1 byte per int8, 1 byte per uint8, 8 bytes per double 2167 2168 // Define the number of elements over which to iterate: 2169 int64_t shape[] = { 3 }; 2170 2171 // Define a callback: 2172 double scale( const double x ) { 2173 return x + 10.0; 2174 } 2175 2176 // Apply the callback: 2177 stdlib_strided_mask_s_d_as_d_d( arrays, shape, strides, (void *)scale ); 2178 ``` 2179 2180 The function accepts the following arguments: 2181 2182 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2183 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2184 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2185 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 2186 2187 ```c 2188 void stdlib_strided_mask_s_d_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2189 ``` 2190 2191 #### stdlib_strided_mask_s_f( \*arrays[], \*shape, \*strides, \*fcn ) 2192 2193 Applies a unary callback accepting and returning signed 8-bit integers to a signed 8-bit integer strided input array, casts the callback's signed 8-bit integer return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 2194 2195 ```c 2196 #include <stdint.h> 2197 2198 // Create underlying byte arrays: 2199 uint8_t x[] = { 0, 0, 0 }; 2200 uint8_t m[] = { 0, 1, 0 }; 2201 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2202 2203 // Define a pointer to an array containing pointers to strided arrays: 2204 uint8_t *arrays[] = { x, m, out }; 2205 2206 // Define the strides: 2207 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 1 byte per uint8, 4 bytes per float 2208 2209 // Define the number of elements over which to iterate: 2210 int64_t shape[] = { 3 }; 2211 2212 // Define a callback: 2213 int8_t scale( const int8_t x ) { 2214 return x + 10; 2215 } 2216 2217 // Apply the callback: 2218 stdlib_strided_mask_s_f( arrays, shape, strides, (void *)scale ); 2219 ``` 2220 2221 The function accepts the following arguments: 2222 2223 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2224 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2225 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2226 - **fcn**: `[in] void*` a `UnaryFcnInt8` function to apply provided as a `void` pointer. 2227 2228 ```c 2229 void stdlib_strided_mask_s_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2230 ``` 2231 2232 #### stdlib_strided_mask_s_f_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 2233 2234 Applies a unary callback accepting and returning double-precision floating-point numbers to a signed 8-bit integer strided input array, casts the callback's double-precision floating-point return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 2235 2236 ```c 2237 #include <stdint.h> 2238 2239 // Create underlying byte arrays: 2240 uint8_t x[] = { 0, 0, 0 }; 2241 uint8_t m[] = { 0, 1, 0 }; 2242 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2243 2244 // Define a pointer to an array containing pointers to strided arrays: 2245 uint8_t *arrays[] = { x, m, out }; 2246 2247 // Define the strides: 2248 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 1 byte per uint8, 4 bytes per float 2249 2250 // Define the number of elements over which to iterate: 2251 int64_t shape[] = { 3 }; 2252 2253 // Define a callback: 2254 double scale( const double x ) { 2255 return x + 10.0; 2256 } 2257 2258 // Apply the callback: 2259 stdlib_strided_mask_s_f_as_d_d( arrays, shape, strides, (void *)scale ); 2260 ``` 2261 2262 The function accepts the following arguments: 2263 2264 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2265 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2266 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2267 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 2268 2269 ```c 2270 void stdlib_strided_mask_s_f_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2271 ``` 2272 2273 #### stdlib_strided_mask_s_f_as_f_f( \*arrays[], \*shape, \*strides, \*fcn ) 2274 2275 Applies a unary callback accepting and returning single-precision floating-point numbers to a signed 8-bit integer strided input array and assigns results to elements in a single-precision floating-point strided output array. 2276 2277 ```c 2278 #include <stdint.h> 2279 2280 // Create underlying byte arrays: 2281 uint8_t x[] = { 0, 0, 0 }; 2282 uint8_t m[] = { 0, 1, 0 }; 2283 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2284 2285 // Define a pointer to an array containing pointers to strided arrays: 2286 uint8_t *arrays[] = { x, m, out }; 2287 2288 // Define the strides: 2289 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 1 byte per uint8, 4 bytes per float 2290 2291 // Define the number of elements over which to iterate: 2292 int64_t shape[] = { 3 }; 2293 2294 // Define a callback: 2295 float scale( const float x ) { 2296 return x + 10.0f; 2297 } 2298 2299 // Apply the callback: 2300 stdlib_strided_mask_s_f_as_f_f( arrays, shape, strides, (void *)scale ); 2301 ``` 2302 2303 The function accepts the following arguments: 2304 2305 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2306 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2307 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2308 - **fcn**: `[in] void*` a `UnaryFcnFloat32` function to apply provided as a `void` pointer. 2309 2310 ```c 2311 void stdlib_strided_mask_s_f_as_f_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2312 ``` 2313 2314 #### stdlib_strided_mask_s_i( \*arrays[], \*shape, \*strides, \*fcn ) 2315 2316 Applies a unary callback accepting and returning signed 8-bit integers to a signed 8-bit integer strided input array, casts the callback's signed 8-bit integer return value to a signed 32-bit integer, and assigns results to elements in a signed 32-bit integer strided output array. 2317 2318 ```c 2319 #include <stdint.h> 2320 2321 // Create underlying byte arrays: 2322 uint8_t x[] = { 0, 0, 0 }; 2323 uint8_t m[] = { 0, 1, 0 }; 2324 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2325 2326 // Define a pointer to an array containing pointers to strided arrays: 2327 uint8_t *arrays[] = { x, m, out }; 2328 2329 // Define the strides: 2330 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 1 byte per uint8, 4 bytes per int32 2331 2332 // Define the number of elements over which to iterate: 2333 int64_t shape[] = { 3 }; 2334 2335 // Define a callback: 2336 int8_t scale( const int8_t x ) { 2337 return x + 10; 2338 } 2339 2340 // Apply the callback: 2341 stdlib_strided_mask_s_i( arrays, shape, strides, (void *)scale ); 2342 ``` 2343 2344 The function accepts the following arguments: 2345 2346 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2347 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2348 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2349 - **fcn**: `[in] void*` a `UnaryFcnInt8` function to apply provided as a `void` pointer. 2350 2351 ```c 2352 void stdlib_strided_mask_s_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2353 ``` 2354 2355 #### stdlib_strided_mask_s_i_as_i_i( \*arrays[], \*shape, \*strides, \*fcn ) 2356 2357 Applies a unary callback accepting and returning signed 32-bit integers to a signed 8-bit integer strided input array and assigns results to elements in a signed 32-bit integer strided output array. 2358 2359 ```c 2360 #include <stdint.h> 2361 2362 // Create underlying byte arrays: 2363 uint8_t x[] = { 0, 0, 0 }; 2364 uint8_t m[] = { 0, 1, 0 }; 2365 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2366 2367 // Define a pointer to an array containing pointers to strided arrays: 2368 uint8_t *arrays[] = { x, m, out }; 2369 2370 // Define the strides: 2371 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 1 byte per uint8, 4 bytes per int32 2372 2373 // Define the number of elements over which to iterate: 2374 int64_t shape[] = { 3 }; 2375 2376 // Define a callback: 2377 int32_t scale( const int32_t x ) { 2378 return x + 10; 2379 } 2380 2381 // Apply the callback: 2382 stdlib_strided_mask_s_i_as_i_i( arrays, shape, strides, (void *)scale ); 2383 ``` 2384 2385 The function accepts the following arguments: 2386 2387 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2388 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2389 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2390 - **fcn**: `[in] void*` a `UnaryFcnInt32` function to apply provided as a `void` pointer. 2391 2392 ```c 2393 void stdlib_strided_mask_s_i_as_i_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2394 ``` 2395 2396 #### stdlib_strided_mask_s_k( \*arrays[], \*shape, \*strides, \*fcn ) 2397 2398 Applies a unary callback accepting and returning signed 8-bit integers to a signed 8-bit integer strided input array, casts the callback's signed 8-bit integer return value to a signed 16-bit integer, and assigns results to elements in a signed 16-bit integer strided output array. 2399 2400 ```c 2401 #include <stdint.h> 2402 2403 // Create underlying byte arrays: 2404 uint8_t x[] = { 0, 0, 0 }; 2405 uint8_t m[] = { 0, 1, 0 }; 2406 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 2407 2408 // Define a pointer to an array containing pointers to strided arrays: 2409 uint8_t *arrays[] = { x, m, out }; 2410 2411 // Define the strides: 2412 int64_t strides[] = { 1, 1, 2 }; // 1 byte per int8, 1 byte per uint8, 2 bytes per int16 2413 2414 // Define the number of elements over which to iterate: 2415 int64_t shape[] = { 3 }; 2416 2417 // Define a callback: 2418 int8_t scale( const int8_t x ) { 2419 return x + 10; 2420 } 2421 2422 // Apply the callback: 2423 stdlib_strided_mask_s_k( arrays, shape, strides, (void *)scale ); 2424 ``` 2425 2426 The function accepts the following arguments: 2427 2428 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2429 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2430 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2431 - **fcn**: `[in] void*` a `UnaryFcnInt8` function to apply provided as a `void` pointer. 2432 2433 ```c 2434 void stdlib_strided_mask_s_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2435 ``` 2436 2437 #### stdlib_strided_mask_s_k_as_k_k( \*arrays[], \*shape, \*strides, \*fcn ) 2438 2439 Applies a unary callback accepting and returning signed 16-bit integers to a signed 8-bit integer strided input array and assigns results to elements in a signed 16-bit integer strided output array. 2440 2441 ```c 2442 #include <stdint.h> 2443 2444 // Create underlying byte arrays: 2445 uint8_t x[] = { 0, 0, 0 }; 2446 uint8_t m[] = { 0, 1, 0 }; 2447 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 2448 2449 // Define a pointer to an array containing pointers to strided arrays: 2450 uint8_t *arrays[] = { x, m, out }; 2451 2452 // Define the strides: 2453 int64_t strides[] = { 1, 1, 2 }; // 1 byte per int8, 1 byte per uint8, 2 bytes per int16 2454 2455 // Define the number of elements over which to iterate: 2456 int64_t shape[] = { 3 }; 2457 2458 // Define a callback: 2459 int16_t scale( const int16_t x ) { 2460 return x + 10; 2461 } 2462 2463 // Apply the callback: 2464 stdlib_strided_mask_s_k_as_k_k( arrays, shape, strides, (void *)scale ); 2465 ``` 2466 2467 The function accepts the following arguments: 2468 2469 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2470 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2471 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2472 - **fcn**: `[in] void*` a `UnaryFcnInt16` function to apply provided as a `void` pointer. 2473 2474 ```c 2475 void stdlib_strided_mask_s_k_as_k_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2476 ``` 2477 2478 #### stdlib_strided_mask_s_s( \*arrays[], \*shape, \*strides, \*fcn ) 2479 2480 Applies a unary callback accepting and returning signed 8-bit integers to a signed 8-bit integer strided input array and assigns results to elements in a signed 8-bit integer strided output array. 2481 2482 ```c 2483 #include <stdint.h> 2484 2485 // Create underlying byte arrays: 2486 uint8_t x[] = { 0, 0, 0 }; 2487 uint8_t m[] = { 0, 1, 0 }; 2488 uint8_t out[] = { 0, 0, 0 }; 2489 2490 // Define a pointer to an array containing pointers to strided arrays: 2491 uint8_t *arrays[] = { x, m, out }; 2492 2493 // Define the strides: 2494 int64_t strides[] = { 1, 1, 1 }; // 1 byte per int8, 1 byte per uint8 2495 2496 // Define the number of elements over which to iterate: 2497 int64_t shape[] = { 3 }; 2498 2499 // Define a callback: 2500 int8_t scale( const int8_t x ) { 2501 return x + 10; 2502 } 2503 2504 // Apply the callback: 2505 stdlib_strided_mask_s_s( arrays, shape, strides, (void *)scale ); 2506 ``` 2507 2508 The function accepts the following arguments: 2509 2510 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2511 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2512 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2513 - **fcn**: `[in] void*` a `UnaryFcnInt8` function to apply provided as a `void` pointer. 2514 2515 ```c 2516 void stdlib_strided_mask_s_s( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2517 ``` 2518 2519 #### stdlib_strided_mask_s_t( \*arrays[], \*shape, \*strides, \*fcn ) 2520 2521 Applies a unary callback accepting and returning signed 8-bit integers to a signed 8-bit integer strided input array, casts the callback's signed 8-bit integer return value to an unsigned 16-bit integer, and assigns results to elements in an unsigned 16-bit integer strided output array. 2522 2523 ```c 2524 #include <stdint.h> 2525 2526 // Create underlying byte arrays: 2527 uint8_t x[] = { 0, 0, 0 }; 2528 uint8_t m[] = { 0, 1, 0 }; 2529 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 2530 2531 // Define a pointer to an array containing pointers to strided arrays: 2532 uint8_t *arrays[] = { x, m, out }; 2533 2534 // Define the strides: 2535 int64_t strides[] = { 1, 1, 2 }; // 1 byte per int8, 1 byte per uint8, 2 bytes per uint16 2536 2537 // Define the number of elements over which to iterate: 2538 int64_t shape[] = { 3 }; 2539 2540 // Define a callback: 2541 int8_t abs( const int8_t x ) { 2542 if ( x < 0 ) { 2543 return -x; 2544 } 2545 return x; 2546 } 2547 2548 // Apply the callback: 2549 stdlib_strided_mask_s_t( arrays, shape, strides, (void *)abs ); 2550 ``` 2551 2552 The function accepts the following arguments: 2553 2554 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2555 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2556 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2557 - **fcn**: `[in] void*` a `UnaryFcnInt8` function to apply provided as a `void` pointer. 2558 2559 ```c 2560 void stdlib_strided_mask_s_t( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2561 ``` 2562 2563 #### stdlib_strided_mask_s_u( \*arrays[], \*shape, \*strides, \*fcn ) 2564 2565 Applies a unary callback accepting and returning signed 8-bit integers to a signed 8-bit integer strided input array, casts the callback's signed 8-bit integer return value to an unsigned 32-bit integer, and assigns results to elements in an unsigned 32-bit integer strided output array. 2566 2567 ```c 2568 #include <stdint.h> 2569 2570 // Create underlying byte arrays: 2571 uint8_t x[] = { 0, 0, 0 }; 2572 uint8_t m[] = { 0, 1, 0 }; 2573 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2574 2575 // Define a pointer to an array containing pointers to strided arrays: 2576 uint8_t *arrays[] = { x, m, out }; 2577 2578 // Define the strides: 2579 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 1 byte per uint8, 4 bytes per uint32 2580 2581 // Define the number of elements over which to iterate: 2582 int64_t shape[] = { 3 }; 2583 2584 // Define a callback: 2585 int8_t abs( const int8_t x ) { 2586 if ( x < 0 ) { 2587 return -x; 2588 } 2589 return x; 2590 } 2591 2592 // Apply the callback: 2593 stdlib_strided_mask_s_u( arrays, shape, strides, (void *)abs ); 2594 ``` 2595 2596 The function accepts the following arguments: 2597 2598 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2599 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2600 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2601 - **fcn**: `[in] void*` a `UnaryFcnInt8` function to apply provided as a `void` pointer. 2602 2603 ```c 2604 void stdlib_strided_mask_s_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2605 ``` 2606 2607 #### stdlib_strided_mask_t_d( \*arrays[], \*shape, \*strides, \*fcn ) 2608 2609 Applies a unary callback accepting and returning unsigned 16-bit integers to an unsigned 16-bit integer strided input array, casts the callback's unsigned 16-bit integer return value to a double-precision floating-point number, and assigns results to elements in a double-precision floating-point strided output array. 2610 2611 ```c 2612 #include <stdint.h> 2613 2614 // Create underlying byte arrays: 2615 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2616 uint8_t m[] = { 0, 1, 0 }; 2617 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2618 2619 // Define a pointer to an array containing pointers to strided arrays: 2620 uint8_t *arrays[] = { x, m, out }; 2621 2622 // Define the strides: 2623 int64_t strides[] = { 2, 1, 8 }; // 2 bytes per uint16, 1 byte per uint8, 8 bytes per double 2624 2625 // Define the number of elements over which to iterate: 2626 int64_t shape[] = { 3 }; 2627 2628 // Define a callback: 2629 uint16_t scale( const uint16_t x ) { 2630 return x + 10; 2631 } 2632 2633 // Apply the callback: 2634 stdlib_strided_mask_t_d( arrays, shape, strides, (void *)scale ); 2635 ``` 2636 2637 The function accepts the following arguments: 2638 2639 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2640 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2641 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2642 - **fcn**: `[in] void*` a `UnaryFcnUint16` function to apply provided as a `void` pointer. 2643 2644 ```c 2645 void stdlib_strided_mask_t_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2646 ``` 2647 2648 #### stdlib_strided_mask_t_d_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 2649 2650 Applies a unary callback accepting and returning double-precision floating-point numbers to an unsigned 16-bit integer strided input array and assigns results to elements in a double-precision floating-point strided output array. 2651 2652 ```c 2653 #include <stdint.h> 2654 2655 // Create underlying byte arrays: 2656 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2657 uint8_t m[] = { 0, 1, 0 }; 2658 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2659 2660 // Define a pointer to an array containing pointers to strided arrays: 2661 uint8_t *arrays[] = { x, m, out }; 2662 2663 // Define the strides: 2664 int64_t strides[] = { 2, 1, 8 }; // 2 bytes per uint16, 1 byte per uint8, 8 bytes per double 2665 2666 // Define the number of elements over which to iterate: 2667 int64_t shape[] = { 3 }; 2668 2669 // Define a callback: 2670 double scale( const double x ) { 2671 return x + 10.0; 2672 } 2673 2674 // Apply the callback: 2675 stdlib_strided_mask_t_d_as_d_d( arrays, shape, strides, (void *)scale ); 2676 ``` 2677 2678 The function accepts the following arguments: 2679 2680 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2681 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2682 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2683 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 2684 2685 ```c 2686 void stdlib_strided_mask_t_d_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2687 ``` 2688 2689 #### stdlib_strided_mask_t_f( \*arrays[], \*shape, \*strides, \*fcn ) 2690 2691 Applies a unary callback accepting and returning unsigned 16-bit integers to an unsigned 16-bit integer strided input array, casts the callback's unsigned 16-bit integer return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 2692 2693 ```c 2694 #include <stdint.h> 2695 2696 // Create underlying byte arrays: 2697 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2698 uint8_t m[] = { 0, 1, 0 }; 2699 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2700 2701 // Define a pointer to an array containing pointers to strided arrays: 2702 uint8_t *arrays[] = { x, m, out }; 2703 2704 // Define the strides: 2705 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per uint16, 1 byte per uint8, 4 bytes per float 2706 2707 // Define the number of elements over which to iterate: 2708 int64_t shape[] = { 3 }; 2709 2710 // Define a callback: 2711 uint16_t scale( const uint16_t x ) { 2712 return x + 10; 2713 } 2714 2715 // Apply the callback: 2716 stdlib_strided_mask_t_f( arrays, shape, strides, (void *)scale ); 2717 ``` 2718 2719 The function accepts the following arguments: 2720 2721 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2722 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2723 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2724 - **fcn**: `[in] void*` a `UnaryFcnUint16` function to apply provided as a `void` pointer. 2725 2726 ```c 2727 void stdlib_strided_mask_t_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2728 ``` 2729 2730 #### stdlib_strided_mask_t_f_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 2731 2732 Applies a unary callback accepting and returning double-precision floating-point numbers to an unsigned 16-bit integer strided input array, casts the callback's double-precision floating-point return value to a single-precision floating-point number, and assigns results to elements in a single-precision floating-point strided output array. 2733 2734 ```c 2735 #include <stdint.h> 2736 2737 // Create underlying byte arrays: 2738 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2739 uint8_t m[] = { 0, 1, 0 }; 2740 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2741 2742 // Define a pointer to an array containing pointers to strided arrays: 2743 uint8_t *arrays[] = { x, m, out }; 2744 2745 // Define the strides: 2746 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per uint16, 1 byte per uint8, 4 bytes per float 2747 2748 // Define the number of elements over which to iterate: 2749 int64_t shape[] = { 3 }; 2750 2751 // Define a callback: 2752 double scale( const double x ) { 2753 return x + 10.0; 2754 } 2755 2756 // Apply the callback: 2757 stdlib_strided_mask_t_f_as_d_d( arrays, shape, strides, (void *)scale ); 2758 ``` 2759 2760 The function accepts the following arguments: 2761 2762 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2763 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2764 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2765 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 2766 2767 ```c 2768 void stdlib_strided_mask_t_f_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2769 ``` 2770 2771 #### stdlib_strided_mask_t_f_as_f_f( \*arrays[], \*shape, \*strides, \*fcn ) 2772 2773 Applies a unary callback accepting and returning single-precision floating-point numbers to an unsigned 16-bit integer strided input array and assigns results to elements in a single-precision floating-point strided output array. 2774 2775 ```c 2776 #include <stdint.h> 2777 2778 // Create underlying byte arrays: 2779 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2780 uint8_t m[] = { 0, 1, 0 }; 2781 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2782 2783 // Define a pointer to an array containing pointers to strided arrays: 2784 uint8_t *arrays[] = { x, m, out }; 2785 2786 // Define the strides: 2787 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per uint16, 1 byte per uint8, 4 bytes per float 2788 2789 // Define the number of elements over which to iterate: 2790 int64_t shape[] = { 3 }; 2791 2792 // Define a callback: 2793 float scale( const float x ) { 2794 return x + 10.0f; 2795 } 2796 2797 // Apply the callback: 2798 stdlib_strided_mask_t_f_as_f_f( arrays, shape, strides, (void *)scale ); 2799 ``` 2800 2801 The function accepts the following arguments: 2802 2803 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2804 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2805 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2806 - **fcn**: `[in] void*` a `UnaryFcnFloat32` function to apply provided as a `void` pointer. 2807 2808 ```c 2809 void stdlib_strided_mask_t_f_as_f_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2810 ``` 2811 2812 #### stdlib_strided_mask_t_i( \*arrays[], \*shape, \*strides, \*fcn ) 2813 2814 Applies a unary callback accepting and returning unsigned 16-bit integers to an unsigned 16-bit integer strided input array, casts the callback's unsigned 16-bit integer return value to a signed 32-bit integer, and assigns results to elements in a signed 32-bit integer strided output array. 2815 2816 ```c 2817 #include <stdint.h> 2818 2819 // Create underlying byte arrays: 2820 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2821 uint8_t m[] = { 0, 1, 0 }; 2822 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2823 2824 // Define a pointer to an array containing pointers to strided arrays: 2825 uint8_t *arrays[] = { x, m, out }; 2826 2827 // Define the strides: 2828 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per uint16, 1 byte per uint8, 4 bytes per int32 2829 2830 // Define the number of elements over which to iterate: 2831 int64_t shape[] = { 3 }; 2832 2833 // Define a callback: 2834 uint16_t scale( const uint16_t x ) { 2835 return x + 10; 2836 } 2837 2838 // Apply the callback: 2839 stdlib_strided_mask_t_i( arrays, shape, strides, (void *)scale ); 2840 ``` 2841 2842 The function accepts the following arguments: 2843 2844 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2845 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2846 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2847 - **fcn**: `[in] void*` a `UnaryFcnUint16` function to apply provided as a `void` pointer. 2848 2849 ```c 2850 void stdlib_strided_mask_t_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2851 ``` 2852 2853 #### stdlib_strided_mask_t_i_as_i_i( \*arrays[], \*shape, \*strides, \*fcn ) 2854 2855 Applies a unary callback accepting and returning signed 32-bit integers to an unsigned 16-bit integer strided input array and assigns results to elements in a signed 32-bit integer strided output array. 2856 2857 ```c 2858 #include <stdint.h> 2859 2860 // Create underlying byte arrays: 2861 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2862 uint8_t m[] = { 0, 1, 0 }; 2863 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2864 2865 // Define a pointer to an array containing pointers to strided arrays: 2866 uint8_t *arrays[] = { x, m, out }; 2867 2868 // Define the strides: 2869 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per uint16, 1 byte per uint8, 4 bytes per int32 2870 2871 // Define the number of elements over which to iterate: 2872 int64_t shape[] = { 3 }; 2873 2874 // Define a callback: 2875 int32_t scale( const int32_t x ) { 2876 return x + 10; 2877 } 2878 2879 // Apply the callback: 2880 stdlib_strided_mask_t_i_as_i_i( arrays, shape, strides, (void *)scale ); 2881 ``` 2882 2883 The function accepts the following arguments: 2884 2885 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2886 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2887 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2888 - **fcn**: `[in] void*` a `UnaryFcnInt32` function to apply provided as a `void` pointer. 2889 2890 ```c 2891 void stdlib_strided_mask_t_i_as_i_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2892 ``` 2893 2894 #### stdlib_strided_mask_t_t( \*arrays[], \*shape, \*strides, \*fcn ) 2895 2896 Applies a unary callback accepting and returning unsigned 16-bit integers to an unsigned 16-bit integer strided input array and assigns results to elements in an unsigned 16-bit integer strided output array. 2897 2898 ```c 2899 #include <stdint.h> 2900 2901 // Create underlying byte arrays: 2902 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2903 uint8_t m[] = { 0, 1, 0 }; 2904 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 2905 2906 // Define a pointer to an array containing pointers to strided arrays: 2907 uint8_t *arrays[] = { x, m, out }; 2908 2909 // Define the strides: 2910 int64_t strides[] = { 2, 1, 2 }; // 2 bytes per uint16, 1 byte per uint8 2911 2912 // Define the number of elements over which to iterate: 2913 int64_t shape[] = { 3 }; 2914 2915 // Define a callback: 2916 uint16_t scale( const uint16_t x ) { 2917 return x + 10; 2918 } 2919 2920 // Apply the callback: 2921 stdlib_strided_mask_t_t( arrays, shape, strides, (void *)scale ); 2922 ``` 2923 2924 The function accepts the following arguments: 2925 2926 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2927 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2928 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2929 - **fcn**: `[in] void*` a `UnaryFcnUint16` function to apply provided as a `void` pointer. 2930 2931 ```c 2932 void stdlib_strided_mask_t_t( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2933 ``` 2934 2935 #### stdlib_strided_mask_t_u( \*arrays[], \*shape, \*strides, \*fcn ) 2936 2937 Applies a unary callback accepting and returning unsigned 16-bit integers to each element in an unsigned 16-bit integer strided input array, casts the callback's unsigned 16-bit integer return value to an unsigned 32-bit integer, and assigns results to elements in an unsigned 32-bit integer strided output array. 2938 2939 ```c 2940 #include <stdint.h> 2941 2942 // Create underlying byte arrays: 2943 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2944 uint8_t m[] = { 0, 1, 0 }; 2945 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2946 2947 // Define a pointer to an array containing pointers to strided arrays: 2948 uint8_t *arrays[] = { x, m, out }; 2949 2950 // Define the strides: 2951 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per uint16, 1 byte per uint8, 4 bytes per uint32 2952 2953 // Define the number of elements over which to iterate: 2954 int64_t shape[] = { 3 }; 2955 2956 // Define a callback: 2957 uint16_t scale( const uint16_t x ) { 2958 return x + 10; 2959 } 2960 2961 // Apply the callback: 2962 stdlib_strided_mask_t_u( arrays, shape, strides, (void *)scale ); 2963 ``` 2964 2965 The function accepts the following arguments: 2966 2967 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 2968 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2969 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2970 - **fcn**: `[in] void*` a `UnaryFcnUint16` function to apply provided as a `void` pointer. 2971 2972 ```c 2973 void stdlib_strided_mask_t_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2974 ``` 2975 2976 #### stdlib_strided_mask_t_u_as_u_u( \*arrays[], \*shape, \*strides, \*fcn ) 2977 2978 Applies a unary callback accepting and returning unsigned 32-bit integers to an unsigned 16-bit integer strided input array and assigns results to elements in an unsigned 32-bit integer strided output array. 2979 2980 ```c 2981 #include <stdint.h> 2982 2983 // Create underlying byte arrays: 2984 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2985 uint8_t m[] = { 0, 1, 0 }; 2986 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2987 2988 // Define a pointer to an array containing pointers to strided arrays: 2989 uint8_t *arrays[] = { x, m, out }; 2990 2991 // Define the strides: 2992 int64_t strides[] = { 2, 1, 4 }; // 2 bytes per uint16, 1 byte per uint8, 4 bytes per uint32 2993 2994 // Define the number of elements over which to iterate: 2995 int64_t shape[] = { 3 }; 2996 2997 // Define a callback: 2998 uint32_t scale( const uint32_t x ) { 2999 return x + 10; 3000 } 3001 3002 // Apply the callback: 3003 stdlib_strided_mask_t_u_as_u_u( arrays, shape, strides, (void *)scale ); 3004 ``` 3005 3006 The function accepts the following arguments: 3007 3008 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 3009 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 3010 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 3011 - **fcn**: `[in] void*` a `UnaryFcnUint32` function to apply provided as a `void` pointer. 3012 3013 ```c 3014 void stdlib_strided_mask_t_u_as_u_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 3015 ``` 3016 3017 #### stdlib_strided_mask_u_d( \*arrays[], \*shape, \*strides, \*fcn ) 3018 3019 Applies a unary callback accepting and returning unsigned 32-bit integers to an unsigned 32-bit integer strided input array, casts the callback's unsigned 32-bit integer return value to a double-precision floating-point number, and assigns results to elements in a double-precision floating-point strided output array. 3020 3021 ```c 3022 #include <stdint.h> 3023 3024 // Create underlying byte arrays: 3025 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 3026 uint8_t m[] = { 0, 1, 0 }; 3027 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 3028 3029 // Define a pointer to an array containing pointers to strided arrays: 3030 uint8_t *arrays[] = { x, m, out }; 3031 3032 // Define the strides: 3033 int64_t strides[] = { 4, 1, 8 }; // 4 bytes per uint32, 1 byte per uint8, 8 bytes per double 3034 3035 // Define the number of elements over which to iterate: 3036 int64_t shape[] = { 3 }; 3037 3038 // Define a callback: 3039 uint32_t scale( const uint32_t x ) { 3040 return x + 10; 3041 } 3042 3043 // Apply the callback: 3044 stdlib_strided_mask_u_d( arrays, shape, strides, (void *)scale ); 3045 ``` 3046 3047 The function accepts the following arguments: 3048 3049 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 3050 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 3051 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 3052 - **fcn**: `[in] void*` a `UnaryFcnUint32` function to apply provided as a `void` pointer. 3053 3054 ```c 3055 void stdlib_strided_mask_u_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 3056 ``` 3057 3058 #### stdlib_strided_mask_u_d_as_d_d( \*arrays[], \*shape, \*strides, \*fcn ) 3059 3060 Applies a unary callback accepting and returning double-precision floating-point numbers to an unsigned 32-bit integer strided input array and assigns results to elements in a double-precision floating-point strided output array. 3061 3062 ```c 3063 #include <stdint.h> 3064 3065 // Create underlying byte arrays: 3066 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 3067 uint8_t m[] = { 0, 1, 0 }; 3068 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 3069 3070 // Define a pointer to an array containing pointers to strided arrays: 3071 uint8_t *arrays[] = { x, m, out }; 3072 3073 // Define the strides: 3074 int64_t strides[] = { 4, 1, 8 }; // 4 bytes per uint32, 1 byte per uint8, 8 bytes per double 3075 3076 // Define the number of elements over which to iterate: 3077 int64_t shape[] = { 3 }; 3078 3079 // Define a callback: 3080 double scale( const double x ) { 3081 return x + 10.0; 3082 } 3083 3084 // Apply the callback: 3085 stdlib_strided_mask_u_d_as_d_d( arrays, shape, strides, (void *)scale ); 3086 ``` 3087 3088 The function accepts the following arguments: 3089 3090 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 3091 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 3092 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 3093 - **fcn**: `[in] void*` a `UnaryFcnFloat64` function to apply provided as a `void` pointer. 3094 3095 ```c 3096 void stdlib_strided_mask_u_d_as_d_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 3097 ``` 3098 3099 #### stdlib_strided_mask_u_u( \*arrays[], \*shape, \*strides, \*fcn ) 3100 3101 Applies a unary callback accepting and returning unsigned 32-bit integers to an unsigned 32-bit integer strided input array and assigns results to elements in an unsigned 32-bit integer strided output array. 3102 3103 ```c 3104 #include <stdint.h> 3105 3106 // Create underlying byte arrays: 3107 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 3108 uint8_t m[] = { 0, 1, 0 }; 3109 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 3110 3111 // Define a pointer to an array containing pointers to strided arrays: 3112 uint8_t *arrays[] = { x, m, out }; 3113 3114 // Define the strides: 3115 int64_t strides[] = { 4, 1, 4 }; // 4 bytes per uint32, 1 byte per uint8 3116 3117 // Define the number of elements over which to iterate: 3118 int64_t shape[] = { 3 }; 3119 3120 // Define a callback: 3121 uint32_t scale( const uint32_t x ) { 3122 return x + 10; 3123 } 3124 3125 // Apply the callback: 3126 stdlib_strided_mask_u_u( arrays, shape, strides, (void *)scale ); 3127 ``` 3128 3129 The function accepts the following arguments: 3130 3131 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 3132 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 3133 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 3134 - **fcn**: `[in] void*` a `UnaryFcnUint32` function to apply provided as a `void` pointer. 3135 3136 ```c 3137 void stdlib_strided_mask_u_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 3138 ``` 3139 3140 #### stdlib_strided_mask_v_v( \*arrays[], \*shape, \*strides, \*fcn ) 3141 3142 Applies a unary callback accepting and returning unsigned 64-bit integers to an unsigned 64-bit integer strided input array and assigns results to elements in an unsigned 64-bit integer strided output array. 3143 3144 ```c 3145 #include <stdint.h> 3146 3147 // Create underlying byte arrays: 3148 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 3149 uint8_t m[] = { 0, 1, 0 }; 3150 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 3151 3152 // Define a pointer to an array containing pointers to strided arrays: 3153 uint8_t *arrays[] = { x, m, out }; 3154 3155 // Define the strides: 3156 int64_t strides[] = { 8, 1, 8 }; // 8 bytes per uint64, 1 byte per uint8 3157 3158 // Define the number of elements over which to iterate: 3159 int64_t shape[] = { 3 }; 3160 3161 // Define a callback: 3162 uint64_t scale( const uint64_t x ) { 3163 return x + 10; 3164 } 3165 3166 // Apply the callback: 3167 stdlib_strided_mask_v_v( arrays, shape, strides, (void *)scale ); 3168 ``` 3169 3170 The function accepts the following arguments: 3171 3172 - **arrays**: `[inout] uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 3173 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 3174 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 3175 - **fcn**: `[in] void*` a `UnaryFcnUint64` function to apply provided as a `void` pointer. 3176 3177 ```c 3178 void stdlib_strided_mask_v_v( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 3179 ``` 3180 3181 <!-- macros --> 3182 3183 * * * 3184 3185 #### STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE 3186 3187 Macro containing the preamble for a loop which operates on strided array elements according to a strided mask array. 3188 3189 ```c 3190 STDLIB_STRIDED_MSKUNARY_LOOP_PREMABLE { 3191 // Loop body... 3192 } 3193 ``` 3194 3195 The macro expects the following variables to be defined: 3196 3197 - **arrays**: `uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last element is a pointer to a strided output array. 3198 - **shape**: `int64_t*` array whose only element is the number of elements over which to iterate. 3199 - **strides**: `int64_t*` array containing strides (in bytes) for each strided array. 3200 3201 The macro defines the following variables: 3202 3203 - **ip1**: `uint8_t*` pointer to the first indexed element of the input strided array. 3204 - **mp1**: `uint8_t*` pointer to the first indexed element of the mask strided array. 3205 - **op1**: `uint8_t*` pointer to the first indexed element of the output strided array. 3206 - **is1**: `int64_t` index increment for the input strided array. 3207 - **ms1**: `int64_t` index increment for the mask strided array. 3208 - **os1**: `int64_t` index increment for the output strided array. 3209 - **n**: `int64_t` number of indexed elements. 3210 - **i**: `int64_t` loop counter. 3211 3212 ```c 3213 #define STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE \ 3214 uint8_t *ip1 = arrays[ 0 ]; \ 3215 uint8_t *mp1 = arrays[ 1 ]; \ 3216 uint8_t *op1 = arrays[ 2 ]; \ 3217 int64_t is1 = strides[ 0 ]; \ 3218 int64_t ms1 = strides[ 1 ]; \ 3219 int64_t os1 = strides[ 2 ]; \ 3220 int64_t n = shape[ 0 ]; \ 3221 int64_t i; \ 3222 if ( n <= 0 ) { \ 3223 return; \ 3224 } \ 3225 if ( is1 < 0 ) { \ 3226 ip1 += (1-n) * is1; \ 3227 } \ 3228 if ( ms1 < 0 ) { \ 3229 mp1 += (1-n) * ms1; \ 3230 } \ 3231 if ( os1 < 0 ) { \ 3232 op1 += (1-n) * os1; \ 3233 } \ 3234 for ( i = 0; i < n; i++, ip1 += is1, mp1 += ms1, op1 += os1 ) 3235 ``` 3236 3237 #### STDLIB_STRIDED_MSKUNARY_LOOP_TWO_OUT_PREAMBLE 3238 3239 Macro containing the preamble for a loop which operates on strided array elements according to a strided mask array and updates two strided output arrays. 3240 3241 ```c 3242 STDLIB_STRIDED_MSKUNARY_LOOP_TWO_OUT_PREAMBLE { 3243 // Loop body... 3244 } 3245 ``` 3246 3247 The macro expects the following variables to be defined: 3248 3249 - **arrays**: `uint8_t**` array whose first element is a pointer to a strided input array, whose second element is a pointer to a strided mask array, and whose last two elements are pointers to strided output arrays. 3250 - **shape**: `int64_t*` array whose only element is the number of elements over which to iterate. 3251 - **strides**: `int64_t*` array containing strides (in bytes) for each strided array. 3252 3253 The macro defines the following variables: 3254 3255 - **ip1**: `uint8_t*` pointer to the first indexed element of the input strided array. 3256 - **mp1**: `uint8_t*` pointer to the first indexed element o the mask strided array. 3257 - **op1**: `uint8_t*` pointer to the first indexed element of the first output strided array. 3258 - **op2**: `uint8_t*` pointer to the first indexed element of the second output strided array. 3259 - **is1**: `int64_t` index increment for the input strided array. 3260 - **ms1**: `int64_t` index increment for the mask strided array. 3261 - **os1**: `int64_t` index increment for the first output strided array. 3262 - **os2**: `int64_t` index increment for the second output strided array. 3263 - **n**: `int64_t` number of indexed elements. 3264 - **i**: `int64_t` loop counter. 3265 3266 ```c 3267 #define STDLIB_STRIDED_MSKUNARY_LOOP_TWO_OUT_PREAMBLE \ 3268 uint8_t *ip1 = arrays[ 0 ]; \ 3269 uint8_t *mp1 = arrays[ 1 ]; \ 3270 uint8_t *op1 = arrays[ 2 ]; \ 3271 uint8_t *op2 = arrays[ 3 ]; \ 3272 int64_t is1 = strides[ 0 ]; \ 3273 int64_t ms1 = strides[ 1 ]; \ 3274 int64_t os1 = strides[ 2 ]; \ 3275 int64_t os2 = strides[ 3 ]; \ 3276 int64_t n = shape[ 0 ]; \ 3277 int64_t i; \ 3278 if ( n <= 0 ) { \ 3279 return; \ 3280 } \ 3281 if ( is1 < 0 ) { \ 3282 ip1 += (1-n) * is1; \ 3283 } \ 3284 if ( ms1 < 0 ) { \ 3285 mp1 += (1-n) * ms1; \ 3286 } \ 3287 if ( os1 < 0 ) { \ 3288 op1 += (1-n) * os1; \ 3289 } \ 3290 if ( os2 < 0 ) { \ 3291 op2 += (1-n) * os2; \ 3292 } \ 3293 for ( i = 0; i < n; i++, ip1 += os1, mp1 += ms1, op1 += os1, op2 += os2 ) 3294 ``` 3295 3296 #### STDLIB_STRIDED_MSKUNARY_LOOP_INLINE( tin, tout, expr ) 3297 3298 Macro for a unary loop which inlines an expression. 3299 3300 ```c 3301 STDLIB_STRIDED_MSKUNARY_LOOP_INLINE( double, double, *out = in1 * in1 ) 3302 ``` 3303 3304 The macro expects the following arguments: 3305 3306 - **tin**: input strided array element type. 3307 - **tout**: output strided array element type. 3308 - **expr**: expression to inline. 3309 3310 In addition to the variables defined by the `STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE` macro, the macro defines the following variables: 3311 3312 - **in1**: `<tin>` input strided array element. 3313 - **out**: `<tout>*` pointer to an output strided array element. 3314 3315 The macro expects a provided expression to operate on `in1` and to store the result via `*out`. 3316 3317 ```c 3318 #define STDLIB_STRIDED_MSKUNARY_LOOP_INLINE( tin, tout, expr ) \ 3319 STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE { \ 3320 if ( *(uint8_t *)mp1 ) { \ 3321 continue; \ 3322 } \ 3323 const tin in1 = *(tin *)ip1; \ 3324 tout *out = (tout *)op1; \ 3325 expr; \ 3326 } 3327 ``` 3328 3329 #### STDLIB_STRIDED_MSKUNARY_LOOP_CLBK( tin, tout ) 3330 3331 Macro for a unary loop which invokes a callback. 3332 3333 ```c 3334 STDLIB_STRIDED_MSKUNARY_LOOP_CLBK( double, double ) 3335 ``` 3336 3337 The macro expects the following arguments: 3338 3339 - **tin**: input strided array element data type. 3340 - **tout**: output strided array element data type. 3341 3342 In addition to the variables expected by `STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE`, the macro expects the following variables to be defined: 3343 3344 - **f**: unary callback. 3345 3346 In addition to the variables defined by the `STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE`, the macro defines the following variables: 3347 3348 - **x**: `<tin>` input strided array element. 3349 3350 ```c 3351 #define STDLIB_STRIDED_MSKUNARY_LOOP_CLBK( tin, tout ) \ 3352 STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE { \ 3353 if ( *(uint8_t *)mp1 ) { \ 3354 continue; \ 3355 } \ 3356 const tin x = *(tin *)ip1; \ 3357 *(tout *)op1 = (tout)f( x ); \ 3358 } 3359 ``` 3360 3361 #### STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_ARG_CAST( tin, tout, fin ) 3362 3363 Macro for a unary loop which invokes a callback requiring arguments be explicitly cast to a different type. 3364 3365 ```c 3366 STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_ARG_CAST( float, float, double ) 3367 ``` 3368 3369 The macro expects the following arguments: 3370 3371 - **tin**: input strided array element data type. 3372 - **tout**: output strided array element data type. 3373 - **fin**: callback argument data type. 3374 3375 In addition to the variables expected by `STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE`, the macro expects the following variables to be defined: 3376 3377 - **f**: unary callback. 3378 3379 In addition to the variables defined by the `STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE`, the macro defines the following variables: 3380 3381 - **x**: `<tin>` input strided array element. 3382 3383 ```c 3384 #define STDLIB_STRIDED_MSKUNARY_LOOP_CLBK_ARG_CAST( tin, tout, fin ) \ 3385 STDLIB_STRIDED_MSKUNARY_LOOP_PREAMBLE { \ 3386 if ( *(uint8_t *)mp1 ) { \ 3387 continue; \ 3388 } \ 3389 const tin x = *(tin *)ip1; \ 3390 *(tout *)op1 = (tout)f( (fin)x ); \ 3391 } 3392 ``` 3393 3394 </section> 3395 3396 <!-- /.usage --> 3397 3398 <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 3399 3400 <section class="notes"> 3401 3402 </section> 3403 3404 <!-- /.notes --> 3405 3406 <!-- C API usage examples. --> 3407 3408 * * * 3409 3410 <section class="examples"> 3411 3412 ### Examples 3413 3414 ```c 3415 #include "stdlib/strided/base/mskunary.h" 3416 #include <stdint.h> 3417 #include <stdio.h> 3418 #include <inttypes.h> 3419 3420 // Define a callback: 3421 static double scale( const double x ) { 3422 return x * 10.0; 3423 } 3424 3425 int main() { 3426 // Create underlying byte arrays: 3427 uint8_t x[] = { 1, 4, 7 }; 3428 uint8_t m[] = { 0, 1, 0 }; 3429 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 3430 3431 // Define a pointer to an array containing pointers to strided arrays: 3432 uint8_t *arrays[] = { x, m, out }; 3433 3434 // Define the strides: 3435 int64_t strides[] = { 1, 1, 8 }; // 1 byte per uint8, 8 bytes per double 3436 3437 // Define the number of elements over which to iterate: 3438 int64_t shape[] = { 3 }; 3439 3440 // Apply the callback: 3441 stdlib_strided_mask_b_d_as_d_d( arrays, shape, strides, (void *)scale ); 3442 3443 // Print the contents of the output array: 3444 uint8_t *op1 = out; 3445 for ( int64_t i = 0; i < shape[0]; i++, op1 += strides[2] ) { 3446 const double v = *(double *)op1; 3447 printf( "out[ %"PRId64" ] = %lf\n", i, v ); 3448 } 3449 } 3450 ``` 3451 3452 </section> 3453 3454 <!-- /.examples --> 3455 3456 </section> 3457 3458 <!-- /.c --> 3459 3460 <section class="links"> 3461 3462 [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray 3463 3464 </section> 3465 3466 <!-- /.links -->