README.md (107162B)
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 # Binary 22 23 > Apply a binary callback to strided input array elements 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 binary = require( '@stdlib/strided/base/binary' ); 37 ``` 38 39 #### binary( arrays, shape, strides, fcn ) 40 41 Applies a binary callback to strided input array elements and assigns results to elements in a strided output array. 42 43 ```javascript 44 var Float64Array = require( '@stdlib/array/float64' ); 45 46 function add( x, y ) { 47 return x + y; 48 } 49 50 var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); 51 var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); 52 var z = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); 53 54 binary( [ x, y, z ], [ x.length ], [ 1, 1, 1 ], add ); 55 // z => <Float64Array>[ 2.0, 4.0, 6.0, 8.0, 10.0 ] 56 ``` 57 58 The function accepts the following arguments: 59 60 - **arrays**: array-like object containing two strided input arrays and one strided output array. 61 - **shape**: array-like object containing a single element, the number of indexed elements. 62 - **strides**: array-like object containing the stride lengths for the strided input and output arrays. 63 - **fcn**: binary function to apply. 64 65 The `shape` and `strides` parameters determine which elements in the strided input and output arrays are accessed at runtime. For example, to index every other value in the strided input arrays and to index the first `N` elements of the strided output array in reverse order, 66 67 ```javascript 68 var Float64Array = require( '@stdlib/array/float64' ); 69 70 function add( x, y ) { 71 return x + y; 72 } 73 74 var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); 75 var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); 76 var z = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); 77 78 var N = 3; 79 80 binary( [ x, y, z ], [ N ], [ 2, 2, -1 ], add ); 81 // z => <Float64Array>[ 10.0, 6.0, 2.0, 0.0, 0.0, 0.0 ] 82 ``` 83 84 Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. 85 86 ```javascript 87 var Float64Array = require( '@stdlib/array/float64' ); 88 89 function add( x, y ) { 90 return x + y; 91 } 92 93 // Initial arrays... 94 var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); 95 var y0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); 96 var z0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); 97 98 // Create offset views... 99 var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element 100 var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element 101 var z1 = new Float64Array( z0.buffer, z0.BYTES_PER_ELEMENT*3 ); // start at 4th element 102 103 var N = 3; 104 105 binary( [ x1, y1, z1 ], [ N ], [ -2, -2, 1 ], add ); 106 // z0 => <Float64Array>[ 0.0, 0.0, 0.0, 12.0, 8.0, 4.0 ] 107 ``` 108 109 #### binary.ndarray( arrays, shape, strides, offsets, fcn ) 110 111 Applies a binary callback to strided input array elements and assigns results to elements in a strided output array using alternative indexing semantics. 112 113 ```javascript 114 var Float64Array = require( '@stdlib/array/float64' ); 115 116 function add( x, y ) { 117 return x + y; 118 } 119 120 var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); 121 var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); 122 var z = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); 123 124 binary.ndarray( [ x, y, z ], [ x.length ], [ 1, 1, 1 ], [ 0, 0, 0 ], add ); 125 // z => <Float64Array>[ 2.0, 4.0, 6.0, 8.0, 10.0 ] 126 ``` 127 128 The function accepts the following additional arguments: 129 130 - **offsets**: array-like object containing the starting indices (i.e., index offsets) for the strided input and output arrays. 131 132 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 arrays starting from the second value and to index the last `N` elements in the strided output array, 133 134 ```javascript 135 var Float64Array = require( '@stdlib/array/float64' ); 136 137 function add( x, y ) { 138 return x + y; 139 } 140 141 var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); 142 var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); 143 var z = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); 144 145 var N = 3; 146 147 binary.ndarray( [ x, y, z ], [ N ], [ 2, 2, -1 ], [ 1, 1, z.length-1 ], add ); 148 // z => <Float64Array>[ 0.0, 0.0, 0.0, 12.0, 8.0, 4.0 ] 149 ``` 150 151 </section> 152 153 <!-- /.usage --> 154 155 <section class="notes"> 156 157 </section> 158 159 <!-- /.notes --> 160 161 <section class="examples"> 162 163 ## Examples 164 165 <!-- eslint no-undef: "error" --> 166 167 ```javascript 168 var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; 169 var filledarray = require( '@stdlib/array/filled' ); 170 var gfillBy = require( '@stdlib/blas/ext/base/gfill-by' ); 171 var binary = require( '@stdlib/strided/base/binary' ); 172 173 function add( x, y ) { 174 return x + y; 175 } 176 177 var N = 10; 178 179 var x = filledarray( 0.0, N, 'generic' ); 180 gfillBy( x.length, x, 1, discreteUniform( -100, 100 ) ); 181 console.log( x ); 182 183 var y = filledarray( 0.0, N, 'generic' ); 184 gfillBy( y.length, y, 1, discreteUniform( -100, 100 ) ); 185 console.log( y ); 186 187 var z = filledarray( 0.0, N, 'generic' ); 188 console.log( z ); 189 190 var shape = [ N ]; 191 var strides = [ 1, 1, -1 ]; 192 var offsets = [ 0, 0, N-1 ]; 193 194 binary.ndarray( [ x, y, z ], shape, strides, offsets, add ); 195 console.log( z ); 196 ``` 197 198 </section> 199 200 <!-- /.examples --> 201 202 <!-- C interface documentation. --> 203 204 * * * 205 206 <section class="c"> 207 208 ## C APIs 209 210 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 211 212 <section class="intro"> 213 214 Character codes for data types: 215 216 - **d**: `float64` (double-precision floating-point number). 217 - **f**: `float32` (single-precision floating-point number). 218 - **s**: `int8` (signed 8-bit integer). 219 - **b**: `uint8` (unsigned 8-bit integer). 220 - **k**: `int16` (signed 16-bit integer). 221 - **t**: `uint16` (unsigned 16-bit integer). 222 - **i**: `int32` (signed 32-bit integer). 223 - **u**: `uint32` (unsigned 32-bit integer). 224 - **l**: `int64` (signed 64-bit integer). 225 - **v**: `uint64` (unsigned 64-bit integer). 226 227 Function name suffix naming convention: 228 229 ```text 230 stdlib_strided_<input_data_types>_<output_data_type>[_as_<callback_arg_data_types>_<callback_return_data_type>] 231 ``` 232 233 For example, 234 235 ```c 236 void stdlib_strided_dd_d(...) {...} 237 ``` 238 239 is a function which accepts two double-precision floating-point strided input arrays and one double-precision floating-point strided output array. In other words, the suffix encodes the function type signature. 240 241 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, 242 243 ```c 244 void stdlib_strided_ff_f_as_dd_d(...) {...} 245 ``` 246 247 is a function which accepts two single-precision floating-point strided input arrays 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 248 249 ```c 250 // Convert each input array element to double-precision: 251 double dx1i = (double)fx1[ i ]; 252 double dx2i = (double)fx2[ i ]; 253 254 // Evaluate the callback: 255 double dyi = f( dx1i, dx2i ); 256 257 // Convert the callback return value to single-precision: 258 fy[ i ] = (float)dyi; 259 ``` 260 261 </section> 262 263 <!-- /.intro --> 264 265 <!-- C usage documentation. --> 266 267 <section class="usage"> 268 269 ### Usage 270 271 ```c 272 #include "stdlib/strided/base/binary.h" 273 ``` 274 275 #### BinaryFcnFloat32 276 277 Function type for a function accepting and returning single-precision floating-point numbers. 278 279 ```c 280 typedef float BinaryFcnFloat32( const float x, const float y ); 281 ``` 282 283 A `BinaryFcnFloat32` function should accept the following arguments: 284 285 - **x**: `[in] float` single-precision floating-point number. 286 - **y**: `[in] float` single-precision floating-point number. 287 288 The function should return a single-precision floating-point number. 289 290 #### BinaryFcnFloat64 291 292 Function type for a function which accepts and returns double-precision floating-point numbers. 293 294 ```c 295 typedef double BinaryFcnFloat64( const double x, const double y ); 296 ``` 297 298 A `BinaryFcnFloat64` function should accept the following arguments: 299 300 - **x**: `[in] double` double-precision floating-point number. 301 - **y**: `[in] double` double-precision floating-point number. 302 303 The function should return a double-precision floating-point number. 304 305 #### BinaryFcnInt64 306 307 Function type for a function which accepts and returns signed 64-bit integers. 308 309 ```c 310 typedef int64_t BinaryFcnInt64( const int64_t x, const int64_t y ); 311 ``` 312 313 A `BinaryFcnInt64` function should accept the following arguments: 314 315 - **x**: `[in] int64_t` signed 64-bit integer. 316 - **y**: `[in] int64_t` signed 64-bit integer. 317 318 The function should return a signed 64-bit integer. 319 320 #### BinaryFcnUint64 321 322 Function type for a function which accepts and returns unsigned 64-bit integers. 323 324 ```c 325 typedef uint64_t BinaryFcnUint64( const uint64_t x, const uint64_t y ); 326 ``` 327 328 A `BinaryFcnUint64` function should accept the following arguments: 329 330 - **x**: `[in] uint64_t` unsigned 64-bit integer. 331 - **y**: `[in] uint64_t` unsigned 64-bit integer. 332 333 The function should return an unsigned 64-bit integer. 334 335 #### BinaryFcnInt32 336 337 Function type for a function which accepts and returns signed 32-bit integers. 338 339 ```c 340 typedef int32_t BinaryFcnInt32( const int32_t x, const int32_t y ); 341 ``` 342 343 A `BinaryFcnInt32` function should accept the following arguments: 344 345 - **x**: `[in] int32_t` signed 32-bit integer. 346 - **y**: `[in] int32_t` signed 32-bit integer. 347 348 The function should return a signed 32-bit integer. 349 350 #### BinaryFcnUint32 351 352 Function type for a function which accepts and returns unsigned 32-bit integers. 353 354 ```c 355 typedef uint32_t BinaryFcnUint32( const uint32_t x, const uint32_t y ); 356 ``` 357 358 A `BinaryFcnUint32` function should accept the following arguments: 359 360 - **x**: `[in] uint32_t` unsigned 32-bit integer. 361 - **y**: `[in] uint32_t` unsigned 32-bit integer. 362 363 The function should return an unsigned 32-bit integer. 364 365 #### BinaryFcnInt16 366 367 Function type for a function which accepts and returns signed 16-bit integers. 368 369 ```c 370 typedef int16_t BinaryFcnInt16( const int16_t x, const int16_t y ); 371 ``` 372 373 A `BinaryFcnInt16` function should accept the following arguments: 374 375 - **x**: `[in] int16_t` signed 16-bit integer. 376 - **y**: `[in] int16_t` signed 16-bit integer. 377 378 The function should return a signed 16-bit integer. 379 380 #### BinaryFcnUint16 381 382 Function type for a function which accepts and returns unsigned 16-bit integers. 383 384 ```c 385 typedef uint16_t BinaryFcnUint16( const uint16_t x, const uint16_t y ); 386 ``` 387 388 A `BinaryFcnUint16` function should accept the following arguments: 389 390 - **x**: `[in] uint16_t` unsigned 16-bit integer. 391 - **y**: `[in] uint16_t` unsigned 16-bit integer. 392 393 The function should return an unsigned 16-bit integer. 394 395 #### BinaryFcnInt8 396 397 Function type for a function which accepts and returns signed 8-bit integers. 398 399 ```c 400 typedef int8_t BinaryFcnInt8( const int8_t x, const int8_t y ); 401 ``` 402 403 A `BinaryFcnInt8` function should accept the following arguments: 404 405 - **x**: `[in] int8_t` signed 8-bit integer. 406 - **y**: `[in] int8_t` signed 8-bit integer. 407 408 The function should return a signed 8-bit integer. 409 410 #### BinaryFcnUint8 411 412 Function type for a function which accepts and returns unsigned 8-bit integers. 413 414 ```c 415 typedef uint8_t BinaryFcnUint8( const uint8_t x, const uint8_t y ); 416 ``` 417 418 A `BinaryFcnUint8` function should accept the following arguments: 419 420 - **x**: `[in] uint8_t` unsigned 8-bit integer. 421 - **y**: `[in] uint8_t` unsigned 8-bit integer. 422 423 The function should return an unsigned 8-bit integer. 424 425 <!-- NOTE: keep the following in alphabetical order --> 426 427 * * * 428 429 #### stdlib_strided_bb_b( \*arrays[], \*shape, \*strides, \*fcn ) 430 431 Applies a binary callback accepting and returning unsigned 8-bit integers to unsigned 8-bit integer strided input arrays and assigns results to elements in an unsigned 8-bit integer strided output array. 432 433 ```c 434 #include <stdint.h> 435 436 // Create underlying byte arrays: 437 uint8_t x[] = { 0, 0, 0 }; 438 uint8_t y[] = { 0, 0, 0 }; 439 uint8_t out[] = { 0, 0, 0 }; 440 441 // Define a pointer to an array containing pointers to strided arrays: 442 uint8_t *arrays[] = { x, y, out }; 443 444 // Define the strides: 445 int64_t strides[] = { 1, 1, 1 }; // 1 byte per uint8 446 447 // Define the number of elements over which to iterate: 448 int64_t shape[] = { 3 }; 449 450 // Define a callback: 451 uint8_t add( uint8_t x, uint8_t y ) { 452 return x + y; 453 } 454 455 // Apply the callback: 456 stdlib_strided_bb_b( arrays, shape, strides, (void *)add ); 457 ``` 458 459 The function accepts the following arguments: 460 461 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 462 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 463 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 464 - **fcn**: `[in] void*` a `BinaryFcnUint8` function to apply provided as a `void` pointer. 465 466 ```c 467 void stdlib_strided_bb_b( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 468 ``` 469 470 #### stdlib_strided_bb_d( \*arrays[], \*shape, \*strides, \*fcn ) 471 472 Applies a binary callback accepting and returning unsigned 8-bit integers to unsigned 8-bit integer strided input arrays, 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. 473 474 ```c 475 #include <stdint.h> 476 477 // Create underlying byte arrays: 478 uint8_t x[] = { 0, 0, 0 }; 479 uint8_t y[] = { 0, 0, 0 }; 480 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 }; 481 482 // Define a pointer to an array containing pointers to strided arrays: 483 uint8_t *arrays[] = { x, y, out }; 484 485 // Define the strides: 486 int64_t strides[] = { 1, 1, 8 }; // 1 byte per uint8, 8 bytes per double 487 488 // Define the number of elements over which to iterate: 489 int64_t shape[] = { 3 }; 490 491 // Define a callback: 492 uint8_t add( uint8_t x, uint8_t y ) { 493 return x + y; 494 } 495 496 // Apply the callback: 497 stdlib_strided_bb_d( arrays, shape, strides, (void *)add ); 498 ``` 499 500 The function accepts the following arguments: 501 502 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnUint8` function to apply provided as a `void` pointer. 506 507 ```c 508 void stdlib_strided_bb_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 509 ``` 510 511 #### stdlib_strided_bb_d_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 512 513 Applies a binary callback accepting and returning double-precision floating-point numbers to unsigned 8-bit integer strided input arrays 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 y[] = { 0, 0, 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, y, 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 double add( double x, double y ) { 534 return x + y; 535 } 536 537 // Apply the callback: 538 stdlib_strided_bb_d_as_dd_d( arrays, shape, strides, (void *)add ); 539 ``` 540 541 The function accepts the following arguments: 542 543 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnFloat64` function to apply provided as a `void` pointer. 547 548 ```c 549 void stdlib_strided_bb_d_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 550 ``` 551 552 #### stdlib_strided_bb_f( \*arrays[], \*shape, \*strides, \*fcn ) 553 554 Applies a binary callback accepting and returning unsigned 8-bit integers to unsigned 8-bit integer strided input arrays, 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. 555 556 ```c 557 #include <stdint.h> 558 559 // Create underlying byte arrays: 560 uint8_t x[] = { 0, 0, 0 }; 561 uint8_t y[] = { 0, 0, 0 }; 562 uint8_t out[] = { 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, y, out }; 566 567 // Define the strides: 568 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per float 569 570 // Define the number of elements over which to iterate: 571 int64_t shape[] = { 3 }; 572 573 // Define a callback: 574 uint8_t add( uint8_t x, uint8_t y ) { 575 return x + y; 576 } 577 578 // Apply the callback: 579 stdlib_strided_bb_f( arrays, shape, strides, (void *)add ); 580 ``` 581 582 The function accepts the following arguments: 583 584 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnUint8` function to apply provided as a `void` pointer. 588 589 ```c 590 void stdlib_strided_bb_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 591 ``` 592 593 #### stdlib_strided_bb_f_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 594 595 Applies a binary callback accepting and returning double-precision floating-point numbers to unsigned 8-bit integer strided input arrays, 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. 596 597 ```c 598 #include <stdint.h> 599 600 // Create underlying byte arrays: 601 uint8_t x[] = { 0, 0, 0 }; 602 uint8_t y[] = { 0, 0, 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, y, 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 double add( double x, double y ) { 616 return x + y; 617 } 618 619 // Apply the callback: 620 stdlib_strided_bb_f_as_dd_d( arrays, shape, strides, (void *)add ); 621 ``` 622 623 The function accepts the following arguments: 624 625 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnFloat64` function to apply provided as a `void` pointer. 629 630 ```c 631 void stdlib_strided_bb_f_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 632 ``` 633 634 #### stdlib_strided_bb_f_as_ff_f( \*arrays[], \*shape, \*strides, \*fcn ) 635 636 Applies a binary callback accepting and returning single-precision floating-point numbers to unsigned 8-bit integer strided input arrays 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 y[] = { 0, 0, 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, y, 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 float add( float x, float y ) { 657 return x + y; 658 } 659 660 // Apply the callback: 661 stdlib_strided_bb_f_as_ff_f( arrays, shape, strides, (void *)add ); 662 ``` 663 664 The function accepts the following arguments: 665 666 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnFloat32` function to apply provided as a `void` pointer. 670 671 ```c 672 void stdlib_strided_bb_f_as_ff_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 673 ``` 674 675 #### stdlib_strided_bb_i( \*arrays[], \*shape, \*strides, \*fcn ) 676 677 Applies a binary callback accepting and returning unsigned 8-bit integers to unsigned 8-bit integer strided input arrays, 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. 678 679 ```c 680 #include <stdint.h> 681 682 // Create underlying byte arrays: 683 uint8_t x[] = { 0, 0, 0 }; 684 uint8_t y[] = { 0, 0, 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, y, out }; 689 690 // Define the strides: 691 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per int32 692 693 // Define the number of elements over which to iterate: 694 int64_t shape[] = { 3 }; 695 696 // Define a callback: 697 uint8_t add( uint8_t x, uint8_t y ) { 698 return x + y; 699 } 700 701 // Apply the callback: 702 stdlib_strided_bb_i( arrays, shape, strides, (void *)add ); 703 ``` 704 705 The function accepts the following arguments: 706 707 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnUint8` function to apply provided as a `void` pointer. 711 712 ```c 713 void stdlib_strided_bb_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 714 ``` 715 716 #### stdlib_strided_bb_i_as_ii_i( \*arrays[], \*shape, \*strides, \*fcn ) 717 718 Applies a binary callback accepting and returning signed 32-bit integers to unsigned 8-bit integer strided input arrays 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 y[] = { 0, 0, 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, y, 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 int32_t add( int32_t x, int32_t y ) { 739 return x + y; 740 } 741 742 // Apply the callback: 743 stdlib_strided_bb_i_as_ii_i( arrays, shape, strides, (void *)add ); 744 ``` 745 746 The function accepts the following arguments: 747 748 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnInt32` function to apply provided as a `void` pointer. 752 753 ```c 754 void stdlib_strided_bb_i_as_ii_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 755 ``` 756 757 #### stdlib_strided_bb_k( \*arrays[], \*shape, \*strides, \*fcn ) 758 759 Applies a binary callback accepting and returning unsigned 8-bit integers to unsigned 8-bit integer strided input arrays, 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. 760 761 ```c 762 #include <stdint.h> 763 764 // Create underlying byte arrays: 765 uint8_t x[] = { 0, 0, 0 }; 766 uint8_t y[] = { 0, 0, 0 }; 767 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 768 769 // Define a pointer to an array containing pointers to strided arrays: 770 uint8_t *arrays[] = { x, y, out }; 771 772 // Define the strides: 773 int64_t strides[] = { 1, 1, 2 }; // 1 byte per uint8, 2 bytes per int16 774 775 // Define the number of elements over which to iterate: 776 int64_t shape[] = { 3 }; 777 778 // Define a callback: 779 uint8_t add( uint8_t x, uint8_t y ) { 780 return x + y; 781 } 782 783 // Apply the callback: 784 stdlib_strided_bb_k( arrays, shape, strides, (void *)add ); 785 ``` 786 787 The function accepts the following arguments: 788 789 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnUint8` function to apply provided as a `void` pointer. 793 794 ```c 795 void stdlib_strided_bb_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 796 ``` 797 798 #### stdlib_strided_bb_k_as_kk_k( \*arrays[], \*shape, \*strides, \*fcn ) 799 800 Applies a binary callback accepting and returning signed 16-bit integers to unsigned 8-bit integer strided input arrays 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 y[] = { 0, 0, 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, y, 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 int16_t add( int16_t x, int16_t y ) { 821 return x + y; 822 } 823 824 // Apply the callback: 825 stdlib_strided_bb_k_as_kk_k( arrays, shape, strides, (void *)add ); 826 ``` 827 828 The function accepts the following arguments: 829 830 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnInt16` function to apply provided as a `void` pointer. 834 835 ```c 836 void stdlib_strided_bb_k_as_kk_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 837 ``` 838 839 #### stdlib_strided_bb_t( \*arrays[], \*shape, \*strides, \*fcn ) 840 841 Applies a binary callback accepting and returning unsigned 8-bit integers to unsigned 8-bit integer strided input arrays, 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. 842 843 ```c 844 #include <stdint.h> 845 846 // Create underlying byte arrays: 847 uint8_t x[] = { 0, 0, 0 }; 848 uint8_t y[] = { 0, 0, 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, y, out }; 853 854 // Define the strides: 855 int64_t strides[] = { 1, 1, 2 }; // 1 byte per uint8, 2 bytes per uint16 856 857 // Define the number of elements over which to iterate: 858 int64_t shape[] = { 3 }; 859 860 // Define a callback: 861 uint8_t add( uint8_t x, uint8_t y ) { 862 return x + y; 863 } 864 865 // Apply the callback: 866 stdlib_strided_bb_t( arrays, shape, strides, (void *)add ); 867 ``` 868 869 The function accepts the following arguments: 870 871 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnUint8` function to apply provided as a `void` pointer. 875 876 ```c 877 void stdlib_strided_bb_t( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 878 ``` 879 880 #### stdlib_strided_bb_t_as_tt_t( \*arrays[], \*shape, \*strides, \*fcn ) 881 882 Applies a binary callback accepting and returning unsigned 16-bit integers to unsigned 8-bit integer strided input arrays 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 y[] = { 0, 0, 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, y, 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 uint16_t add( uint16_t x, uint16_t y ) { 903 return x + y; 904 } 905 906 // Apply the callback: 907 stdlib_strided_bb_t_as_tt_t( arrays, shape, strides, (void *)add ); 908 ``` 909 910 The function accepts the following arguments: 911 912 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnUint16` function to apply provided as a `void` pointer. 916 917 ```c 918 void stdlib_strided_bb_t_as_tt_t( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 919 ``` 920 921 #### stdlib_strided_bb_u( \*arrays[], \*shape, \*strides, \*fcn ) 922 923 Applies a binary callback accepting and returning unsigned 8-bit integers to unsigned 8-bit integer strided input arrays, 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. 924 925 ```c 926 #include <stdint.h> 927 928 // Create underlying byte arrays: 929 uint8_t x[] = { 0, 0, 0 }; 930 uint8_t y[] = { 0, 0, 0 }; 931 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 932 933 // Define a pointer to an array containing pointers to strided arrays: 934 uint8_t *arrays[] = { x, y, out }; 935 936 // Define the strides: 937 int64_t strides[] = { 1, 1, 4 }; // 1 byte per uint8, 4 bytes per uint32 938 939 // Define the number of elements over which to iterate: 940 int64_t shape[] = { 3 }; 941 942 // Define a callback: 943 uint8_t add( uint8_t x, uint8_t y ) { 944 return x + y; 945 } 946 947 // Apply the callback: 948 stdlib_strided_bb_u( arrays, shape, strides, (void *)add ); 949 ``` 950 951 The function accepts the following arguments: 952 953 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnUint8` function to apply provided as a `void` pointer. 957 958 ```c 959 void stdlib_strided_bb_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 960 ``` 961 962 #### stdlib_strided_bb_u_as_uu_u( \*arrays[], \*shape, \*strides, \*fcn ) 963 964 Applies a binary callback accepting and returning unsigned 32-bit integers to unsigned 8-bit integer strided input arrays 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 y[] = { 0, 0, 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, y, 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 uint32_t add( uint32_t x, uint32_t y ) { 985 return x + y; 986 } 987 988 // Apply the callback: 989 stdlib_strided_bb_u_as_uu_u( arrays, shape, strides, (void *)add ); 990 ``` 991 992 The function accepts the following arguments: 993 994 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnUint32` function to apply provided as a `void` pointer. 998 999 ```c 1000 void stdlib_strided_bb_u_as_uu_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1001 ``` 1002 1003 #### stdlib_strided_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 1004 1005 Applies a binary callback accepting and returning double-precision floating-point numbers to double-precision floating-point strided input arrays and assigns results to elements in a double-precision floating-point strided output array. 1006 1007 ```c 1008 #include <stdint.h> 1009 1010 // Create underlying byte arrays: 1011 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 }; 1012 uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1013 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 }; 1014 1015 // Define a pointer to an array containing pointers to strided arrays: 1016 uint8_t *arrays[] = { x, y, out }; 1017 1018 // Define the strides: 1019 int64_t strides[] = { 8, 8, 8 }; // 8 bytes per double 1020 1021 // Define the number of elements over which to iterate: 1022 int64_t shape[] = { 3 }; 1023 1024 // Define a callback: 1025 double add( double x, double y ) { 1026 return x + y; 1027 } 1028 1029 // Apply the callback: 1030 stdlib_strided_dd_d( arrays, shape, strides, (void *)add ); 1031 ``` 1032 1033 The function accepts the following arguments: 1034 1035 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnFloat64` function to apply provided as a `void` pointer. 1039 1040 ```c 1041 void stdlib_strided_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1042 ``` 1043 1044 #### stdlib_strided_ff_f( \*arrays[], \*shape, \*strides, \*fcn ) 1045 1046 Applies a binary callback accepting and returning single-precision floating-point numbers to single-precision floating-point strided input arrays and assigns results to elements in a single-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 }; 1053 uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1054 uint8_t out[] = { 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, y, out }; 1058 1059 // Define the strides: 1060 int64_t strides[] = { 4, 4, 4 }; // 4 bytes per float 1061 1062 // Define the number of elements over which to iterate: 1063 int64_t shape[] = { 3 }; 1064 1065 // Define a callback: 1066 float add( float x, float y ) { 1067 return x + y; 1068 } 1069 1070 // Apply the callback: 1071 stdlib_strided_ff_f( arrays, shape, strides, (void *)add ); 1072 ``` 1073 1074 The function accepts the following arguments: 1075 1076 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays 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 `BinaryFcnFloat32` function to apply provided as a `void` pointer. 1080 1081 ```c 1082 void stdlib_strided_ff_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1083 ``` 1084 1085 #### stdlib_strided_ff_f_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 1086 1087 Applies a binary callback accepting and returning double-precision floating-point numbers to single-precision floating-point strided input arrays, 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. 1088 1089 ```c 1090 #include <stdint.h> 1091 1092 // Create underlying byte arrays: 1093 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1094 uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1095 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1096 1097 // Define a pointer to an array containing pointers to strided arrays: 1098 uint8_t *arrays[] = { x, y, out }; 1099 1100 // Define the strides: 1101 int64_t strides[] = { 4, 4, 4 }; // 4 bytes per float 1102 1103 // Define the number of elements over which to iterate: 1104 int64_t shape[] = { 3 }; 1105 1106 // Define a callback: 1107 double add( double x, double y ) { 1108 return x + y; 1109 } 1110 1111 // Apply the callback: 1112 stdlib_strided_ff_f_as_dd_d( arrays, shape, strides, (void *)add ); 1113 ``` 1114 1115 The function accepts the following arguments: 1116 1117 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1118 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1119 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1120 - **fcn**: `[in] void*` a `BinaryFcnFloat64` function to apply provided as a `void` pointer. 1121 1122 ```c 1123 void stdlib_strided_ff_f_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1124 ``` 1125 1126 #### stdlib_strided_ii_d( \*arrays[], \*shape, \*strides, \*fcn ) 1127 1128 Applies a binary callback accepting and returning signed 32-bit integers to signed 32-bit integer strided input arrays, 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. 1129 1130 ```c 1131 #include <stdint.h> 1132 1133 // Create underlying byte arrays: 1134 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1135 uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1136 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 }; 1137 1138 // Define a pointer to an array containing pointers to strided arrays: 1139 uint8_t *arrays[] = { x, y, out }; 1140 1141 // Define the strides: 1142 int64_t strides[] = { 4, 4, 8 }; // 4 bytes per int32, 8 bytes per double 1143 1144 // Define the number of elements over which to iterate: 1145 int64_t shape[] = { 3 }; 1146 1147 // Define a callback: 1148 int32_t add( int32_t x, int32_t y ) { 1149 return x + y; 1150 } 1151 1152 // Apply the callback: 1153 stdlib_strided_ii_d( arrays, shape, strides, (void *)add ); 1154 ``` 1155 1156 The function accepts the following arguments: 1157 1158 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1159 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1160 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1161 - **fcn**: `[in] void*` a `BinaryFcnInt32` function to apply provided as a `void` pointer. 1162 1163 ```c 1164 void stdlib_strided_ii_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1165 ``` 1166 1167 #### stdlib_strided_ii_d_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 1168 1169 Applies a binary callback accepting and returning double-precision floating-point numbers to signed 32-bit integer strided input arrays and assigns results to elements in a double-precision floating-point strided output array. 1170 1171 ```c 1172 #include <stdint.h> 1173 1174 // Create underlying byte arrays: 1175 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1176 uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1177 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 }; 1178 1179 // Define a pointer to an array containing pointers to strided arrays: 1180 uint8_t *arrays[] = { x, y, out }; 1181 1182 // Define the strides: 1183 int64_t strides[] = { 4, 4, 8 }; // 4 bytes per int32, 8 bytes per double 1184 1185 // Define the number of elements over which to iterate: 1186 int64_t shape[] = { 3 }; 1187 1188 // Define a callback: 1189 double add( double x, double y ) { 1190 return x + y; 1191 } 1192 1193 // Apply the callback: 1194 stdlib_strided_ii_d_as_dd_d( arrays, shape, strides, (void *)add ); 1195 ``` 1196 1197 The function accepts the following arguments: 1198 1199 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1200 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1201 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1202 - **fcn**: `[in] void*` a `BinaryFcnFloat64` function to apply provided as a `void` pointer. 1203 1204 ```c 1205 void stdlib_strided_ii_d_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1206 ``` 1207 1208 #### stdlib_strided_ii_i( \*arrays[], \*shape, \*strides, \*fcn ) 1209 1210 Applies a binary callback accepting and returning signed 32-bit integers to signed 32-bit integer strided input arrays and assigns results to elements in a signed 32-bit integer strided output array. 1211 1212 ```c 1213 #include <stdint.h> 1214 1215 // Create underlying byte arrays: 1216 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1217 uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1218 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1219 1220 // Define a pointer to an array containing pointers to strided arrays: 1221 uint8_t *arrays[] = { x, y, out }; 1222 1223 // Define the strides: 1224 int64_t strides[] = { 4, 4, 4 }; // 4 bytes per int32 1225 1226 // Define the number of elements over which to iterate: 1227 int64_t shape[] = { 3 }; 1228 1229 // Define a callback: 1230 int32_t add( int32_t x, int32_t y ) { 1231 return x + y; 1232 } 1233 1234 // Apply the callback: 1235 stdlib_strided_ii_i( arrays, shape, strides, (void *)add ); 1236 ``` 1237 1238 The function accepts the following arguments: 1239 1240 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1241 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1242 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1243 - **fcn**: `[in] void*` a `BinaryFcnInt32` function to apply provided as a `void` pointer. 1244 1245 ```c 1246 void stdlib_strided_ii_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1247 ``` 1248 1249 #### stdlib_strided_kk_d( \*arrays[], \*shape, \*strides, \*fcn ) 1250 1251 Applies a binary callback accepting and returning signed 16-bit integers to signed 16-bit integer strided input arrays, 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. 1252 1253 ```c 1254 #include <stdint.h> 1255 1256 // Create underlying byte arrays: 1257 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1258 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 1259 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 }; 1260 1261 // Define a pointer to an array containing pointers to strided arrays: 1262 uint8_t *arrays[] = { x, y, out }; 1263 1264 // Define the strides: 1265 int64_t strides[] = { 2, 2, 8 }; // 2 bytes per int16, 8 bytes per double 1266 1267 // Define the number of elements over which to iterate: 1268 int64_t shape[] = { 3 }; 1269 1270 // Define a callback: 1271 int16_t add( int16_t x, int16_t y ) { 1272 return x + y; 1273 } 1274 1275 // Apply the callback: 1276 stdlib_strided_kk_d( arrays, shape, strides, (void *)add ); 1277 ``` 1278 1279 The function accepts the following arguments: 1280 1281 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1282 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1283 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1284 - **fcn**: `[in] void*` a `BinaryFcnInt16` function to apply provided as a `void` pointer. 1285 1286 ```c 1287 void stdlib_strided_kk_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1288 ``` 1289 1290 #### stdlib_strided_kk_d_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 1291 1292 Applies a binary callback accepting and returning double-precision floating-point numbers to signed 16-bit integer strided input arrays and assigns results to elements in a double-precision floating-point strided output array. 1293 1294 ```c 1295 #include <stdint.h> 1296 1297 // Create underlying byte arrays: 1298 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1299 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 1300 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 }; 1301 1302 // Define a pointer to an array containing pointers to strided arrays: 1303 uint8_t *arrays[] = { x, y, out }; 1304 1305 // Define the strides: 1306 int64_t strides[] = { 2, 2, 8 }; // 2 bytes per int16, 8 bytes per double 1307 1308 // Define the number of elements over which to iterate: 1309 int64_t shape[] = { 3 }; 1310 1311 // Define a callback: 1312 double add( double x, double y ) { 1313 return x + y; 1314 } 1315 1316 // Apply the callback: 1317 stdlib_strided_kk_d_as_dd_d( arrays, shape, strides, (void *)add ); 1318 ``` 1319 1320 The function accepts the following arguments: 1321 1322 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1323 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1324 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1325 - **fcn**: `[in] void*` a `BinaryFcnFloat64` function to apply provided as a `void` pointer. 1326 1327 ```c 1328 void stdlib_strided_kk_d_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1329 ``` 1330 1331 #### stdlib_strided_kk_f( \*arrays[], \*shape, \*strides, \*fcn ) 1332 1333 Applies a binary callback accepting and returning signed 16-bit integers to signed 16-bit integer strided input arrays, 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. 1334 1335 ```c 1336 #include <stdint.h> 1337 1338 // Create underlying byte arrays: 1339 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1340 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 1341 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1342 1343 // Define a pointer to an array containing pointers to strided arrays: 1344 uint8_t *arrays[] = { x, y, out }; 1345 1346 // Define the strides: 1347 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per int16, 4 bytes per float 1348 1349 // Define the number of elements over which to iterate: 1350 int64_t shape[] = { 3 }; 1351 1352 // Define a callback: 1353 int16_t add( int16_t x, int16_t y ) { 1354 return x + y; 1355 } 1356 1357 // Apply the callback: 1358 stdlib_strided_kk_f( arrays, shape, strides, (void *)add ); 1359 ``` 1360 1361 The function accepts the following arguments: 1362 1363 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1364 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1365 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1366 - **fcn**: `[in] void*` a `BinaryFcnInt16` function to apply provided as a `void` pointer. 1367 1368 ```c 1369 void stdlib_strided_kk_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1370 ``` 1371 1372 #### stdlib_strided_kk_f_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 1373 1374 Applies a binary callback accepting and returning double-precision floating-point numbers to signed 16-bit integer strided input arrays, 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. 1375 1376 ```c 1377 #include <stdint.h> 1378 1379 // Create underlying byte arrays: 1380 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1381 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 1382 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1383 1384 // Define a pointer to an array containing pointers to strided arrays: 1385 uint8_t *arrays[] = { x, y, out }; 1386 1387 // Define the strides: 1388 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per int16, 4 bytes per float 1389 1390 // Define the number of elements over which to iterate: 1391 int64_t shape[] = { 3 }; 1392 1393 // Define a callback: 1394 double add( double x, double y ) { 1395 return x + y; 1396 } 1397 1398 // Apply the callback: 1399 stdlib_strided_kk_f_as_dd_d( arrays, shape, strides, (void *)add ); 1400 ``` 1401 1402 The function accepts the following arguments: 1403 1404 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1405 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1406 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1407 - **fcn**: `[in] void*` a `BinaryFcnFloat64` function to apply provided as a `void` pointer. 1408 1409 ```c 1410 void stdlib_strided_kk_f_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1411 ``` 1412 1413 #### stdlib_strided_kk_f_as_ff_f( \*arrays[], \*shape, \*strides, \*fcn ) 1414 1415 Applies a binary callback accepting and returning single-precision floating-point numbers to signed 16-bit integer strided input arrays and assigns results to elements in a single-precision floating-point strided output array. 1416 1417 ```c 1418 #include <stdint.h> 1419 1420 // Create underlying byte arrays: 1421 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1422 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 1423 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1424 1425 // Define a pointer to an array containing pointers to strided arrays: 1426 uint8_t *arrays[] = { x, y, out }; 1427 1428 // Define the strides: 1429 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per int16, 4 bytes per float 1430 1431 // Define the number of elements over which to iterate: 1432 int64_t shape[] = { 3 }; 1433 1434 // Define a callback: 1435 float add( float x, float y ) { 1436 return x + y; 1437 } 1438 1439 // Apply the callback: 1440 stdlib_strided_kk_f_as_ff_f( arrays, shape, strides, (void *)add ); 1441 ``` 1442 1443 The function accepts the following arguments: 1444 1445 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1446 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1447 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1448 - **fcn**: `[in] void*` a `BinaryFcnFloat32` function to apply provided as a `void` pointer. 1449 1450 ```c 1451 void stdlib_strided_kk_f_as_ff_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1452 ``` 1453 1454 #### stdlib_strided_kk_i( \*arrays[], \*shape, \*strides, \*fcn ) 1455 1456 Applies a binary callback accepting and returning signed 16-bit integers to signed 16-bit integer strided input arrays, 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. 1457 1458 ```c 1459 #include <stdint.h> 1460 1461 // Create underlying byte arrays: 1462 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1463 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 1464 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1465 1466 // Define a pointer to an array containing pointers to strided arrays: 1467 uint8_t *arrays[] = { x, y, out }; 1468 1469 // Define the strides: 1470 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per int16, 4 bytes per int32 1471 1472 // Define the number of elements over which to iterate: 1473 int64_t shape[] = { 3 }; 1474 1475 // Define a callback: 1476 int16_t add( int16_t x, int16_t y ) { 1477 return x + y; 1478 } 1479 1480 // Apply the callback: 1481 stdlib_strided_kk_i( arrays, shape, strides, (void *)add ); 1482 ``` 1483 1484 The function accepts the following arguments: 1485 1486 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1487 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1488 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1489 - **fcn**: `[in] void*` a `BinaryFcnInt16` function to apply provided as a `void` pointer. 1490 1491 ```c 1492 void stdlib_strided_kk_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1493 ``` 1494 1495 #### stdlib_strided_kk_i_as_ii_i( \*arrays[], \*shape, \*strides, \*fcn ) 1496 1497 Applies a binary callback accepting and returning signed 32-bit integers to signed 16-bit integer strided input arrays and assigns results to elements in a signed 32-bit integer strided output array. 1498 1499 ```c 1500 #include <stdint.h> 1501 1502 // Create underlying byte arrays: 1503 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1504 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 1505 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1506 1507 // Define a pointer to an array containing pointers to strided arrays: 1508 uint8_t *arrays[] = { x, y, out }; 1509 1510 // Define the strides: 1511 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per int16, 4 bytes per int32 1512 1513 // Define the number of elements over which to iterate: 1514 int64_t shape[] = { 3 }; 1515 1516 // Define a callback: 1517 int32_t add( int32_t x, int32_t y ) { 1518 return x + y; 1519 } 1520 1521 // Apply the callback: 1522 stdlib_strided_kk_i_as_ii_i( arrays, shape, strides, (void *)add ); 1523 ``` 1524 1525 The function accepts the following arguments: 1526 1527 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1528 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1529 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1530 - **fcn**: `[in] void*` a `BinaryFcnInt32` function to apply provided as a `void` pointer. 1531 1532 ```c 1533 void stdlib_strided_kk_i_as_ii_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1534 ``` 1535 1536 #### stdlib_strided_kk_k( \*arrays[], \*shape, \*strides, \*fcn ) 1537 1538 Applies a binary callback accepting and returning signed 16-bit integers to signed 16-bit integer strided input arrays and assigns results to elements in a signed 16-bit integer strided output array. 1539 1540 ```c 1541 #include <stdint.h> 1542 1543 // Create underlying byte arrays: 1544 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1545 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 1546 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 1547 1548 // Define a pointer to an array containing pointers to strided arrays: 1549 uint8_t *arrays[] = { x, y, out }; 1550 1551 // Define the strides: 1552 int64_t strides[] = { 2, 2, 2 }; // 2 bytes per int16 1553 1554 // Define the number of elements over which to iterate: 1555 int64_t shape[] = { 3 }; 1556 1557 // Define a callback: 1558 int16_t add( int16_t x, int16_t y ) { 1559 return x + y; 1560 } 1561 1562 // Apply the callback: 1563 stdlib_strided_kk_k( arrays, shape, strides, (void *)add ); 1564 ``` 1565 1566 The function accepts the following arguments: 1567 1568 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1569 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1570 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1571 - **fcn**: `[in] void*` a `BinaryFcnInt16` function to apply provided as a `void` pointer. 1572 1573 ```c 1574 void stdlib_strided_kk_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1575 ``` 1576 1577 #### stdlib_strided_ss_d( \*arrays[], \*shape, \*strides, \*fcn ) 1578 1579 Applies a binary callback accepting and returning signed 8-bit integers to signed 8-bit integer strided input arrays, 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. 1580 1581 ```c 1582 #include <stdint.h> 1583 1584 // Create underlying byte arrays: 1585 uint8_t x[] = { 0, 0, 0 }; 1586 uint8_t y[] = { 0, 0, 0 }; 1587 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 }; 1588 1589 // Define a pointer to an array containing pointers to strided arrays: 1590 uint8_t *arrays[] = { x, y, out }; 1591 1592 // Define the strides: 1593 int64_t strides[] = { 1, 1, 8 }; // 1 byte per int8, 8 bytes per double 1594 1595 // Define the number of elements over which to iterate: 1596 int64_t shape[] = { 3 }; 1597 1598 // Define a callback: 1599 int8_t add( int8_t x, int8_t y ) { 1600 return x + y; 1601 } 1602 1603 // Apply the callback: 1604 stdlib_strided_ss_d( arrays, shape, strides, (void *)add ); 1605 ``` 1606 1607 The function accepts the following arguments: 1608 1609 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1610 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1611 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1612 - **fcn**: `[in] void*` a `BinaryFcnInt8` function to apply provided as a `void` pointer. 1613 1614 ```c 1615 void stdlib_strided_ss_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1616 ``` 1617 1618 #### stdlib_strided_ss_d_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 1619 1620 Applies a binary callback accepting and returning double-precision floating-point numbers to signed 8-bit integer strided input arrays and assigns results to elements in a double-precision floating-point strided output array. 1621 1622 ```c 1623 #include <stdint.h> 1624 1625 // Create underlying byte arrays: 1626 uint8_t x[] = { 0, 0, 0 }; 1627 uint8_t y[] = { 0, 0, 0 }; 1628 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 }; 1629 1630 // Define a pointer to an array containing pointers to strided arrays: 1631 uint8_t *arrays[] = { x, y, out }; 1632 1633 // Define the strides: 1634 int64_t strides[] = { 1, 1, 8 }; // 1 byte per int8, 8 bytes per double 1635 1636 // Define the number of elements over which to iterate: 1637 int64_t shape[] = { 3 }; 1638 1639 // Define a callback: 1640 double add( double x, double y ) { 1641 return x + y; 1642 } 1643 1644 // Apply the callback: 1645 stdlib_strided_ss_d_as_dd_d( arrays, shape, strides, (void *)add ); 1646 ``` 1647 1648 The function accepts the following arguments: 1649 1650 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1651 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1652 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1653 - **fcn**: `[in] void*` a `BinaryFcnFloat64` function to apply provided as a `void` pointer. 1654 1655 ```c 1656 void stdlib_strided_ss_d_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1657 ``` 1658 1659 #### stdlib_strided_ss_f( \*arrays[], \*shape, \*strides, \*fcn ) 1660 1661 Applies a binary callback accepting and returning signed 8-bit integers to signed 8-bit integer strided input arrays, 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. 1662 1663 ```c 1664 #include <stdint.h> 1665 1666 // Create underlying byte arrays: 1667 uint8_t x[] = { 0, 0, 0 }; 1668 uint8_t y[] = { 0, 0, 0 }; 1669 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1670 1671 // Define a pointer to an array containing pointers to strided arrays: 1672 uint8_t *arrays[] = { x, y, out }; 1673 1674 // Define the strides: 1675 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 4 bytes per float 1676 1677 // Define the number of elements over which to iterate: 1678 int64_t shape[] = { 3 }; 1679 1680 // Define a callback: 1681 int8_t add( int8_t x, int8_t y ) { 1682 return x + y; 1683 } 1684 1685 // Apply the callback: 1686 stdlib_strided_ss_f( arrays, shape, strides, (void *)add ); 1687 ``` 1688 1689 The function accepts the following arguments: 1690 1691 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1692 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1693 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1694 - **fcn**: `[in] void*` a `BinaryFcnInt8` function to apply provided as a `void` pointer. 1695 1696 ```c 1697 void stdlib_strided_ss_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1698 ``` 1699 1700 #### stdlib_strided_ss_f_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 1701 1702 Applies a binary callback accepting and returning double-precision floating-point numbers to signed 8-bit integer strided input arrays, 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. 1703 1704 ```c 1705 #include <stdint.h> 1706 1707 // Create underlying byte arrays: 1708 uint8_t x[] = { 0, 0, 0 }; 1709 uint8_t y[] = { 0, 0, 0 }; 1710 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1711 1712 // Define a pointer to an array containing pointers to strided arrays: 1713 uint8_t *arrays[] = { x, y, out }; 1714 1715 // Define the strides: 1716 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 4 bytes per float 1717 1718 // Define the number of elements over which to iterate: 1719 int64_t shape[] = { 3 }; 1720 1721 // Define a callback: 1722 double add( double x, double y ) { 1723 return x + y; 1724 } 1725 1726 // Apply the callback: 1727 stdlib_strided_ss_f_as_dd_d( arrays, shape, strides, (void *)add ); 1728 ``` 1729 1730 The function accepts the following arguments: 1731 1732 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1733 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1734 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1735 - **fcn**: `[in] void*` a `BinaryFcnFloat64` function to apply provided as a `void` pointer. 1736 1737 ```c 1738 void stdlib_strided_ss_f_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1739 ``` 1740 1741 #### stdlib_strided_ss_f_as_ff_f( \*arrays[], \*shape, \*strides, \*fcn ) 1742 1743 Applies a binary callback accepting and returning single-precision floating-point numbers to signed 8-bit integer strided input arrays and assigns results to elements in a single-precision floating-point strided output array. 1744 1745 ```c 1746 #include <stdint.h> 1747 1748 // Create underlying byte arrays: 1749 uint8_t x[] = { 0, 0, 0 }; 1750 uint8_t y[] = { 0, 0, 0 }; 1751 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1752 1753 // Define a pointer to an array containing pointers to strided arrays: 1754 uint8_t *arrays[] = { x, y, out }; 1755 1756 // Define the strides: 1757 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 4 bytes per float 1758 1759 // Define the number of elements over which to iterate: 1760 int64_t shape[] = { 3 }; 1761 1762 // Define a callback: 1763 float add( float x, float y ) { 1764 return x + y; 1765 } 1766 1767 // Apply the callback: 1768 stdlib_strided_ss_f_as_ff_f( arrays, shape, strides, (void *)add ); 1769 ``` 1770 1771 The function accepts the following arguments: 1772 1773 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1774 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1775 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1776 - **fcn**: `[in] void*` a `BinaryFcnFloat32` function to apply provided as a `void` pointer. 1777 1778 ```c 1779 void stdlib_strided_ss_f_as_ff_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1780 ``` 1781 1782 #### stdlib_strided_ss_i( \*arrays[], \*shape, \*strides, \*fcn ) 1783 1784 Applies a binary callback accepting and returning signed 8-bit integers to signed 8-bit integer strided input arrays, 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. 1785 1786 ```c 1787 #include <stdint.h> 1788 1789 // Create underlying byte arrays: 1790 uint8_t x[] = { 0, 0, 0 }; 1791 uint8_t y[] = { 0, 0, 0 }; 1792 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1793 1794 // Define a pointer to an array containing pointers to strided arrays: 1795 uint8_t *arrays[] = { x, y, out }; 1796 1797 // Define the strides: 1798 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 4 bytes per int32 1799 1800 // Define the number of elements over which to iterate: 1801 int64_t shape[] = { 3 }; 1802 1803 // Define a callback: 1804 int8_t add( int8_t x, int8_t y ) { 1805 return x + y; 1806 } 1807 1808 // Apply the callback: 1809 stdlib_strided_ss_i( arrays, shape, strides, (void *)add ); 1810 ``` 1811 1812 The function accepts the following arguments: 1813 1814 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1815 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1816 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1817 - **fcn**: `[in] void*` a `BinaryFcnInt8` function to apply provided as a `void` pointer. 1818 1819 ```c 1820 void stdlib_strided_ss_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1821 ``` 1822 1823 #### stdlib_strided_ss_i_as_ii_i( \*arrays[], \*shape, \*strides, \*fcn ) 1824 1825 Applies a binary callback accepting and returning signed 32-bit integers to signed 8-bit integer strided input arrays and assigns results to elements in a signed 32-bit integer strided output array. 1826 1827 ```c 1828 #include <stdint.h> 1829 1830 // Create underlying byte arrays: 1831 uint8_t x[] = { 0, 0, 0 }; 1832 uint8_t y[] = { 0, 0, 0 }; 1833 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1834 1835 // Define a pointer to an array containing pointers to strided arrays: 1836 uint8_t *arrays[] = { x, y, out }; 1837 1838 // Define the strides: 1839 int64_t strides[] = { 1, 1, 4 }; // 1 byte per int8, 4 bytes per int32 1840 1841 // Define the number of elements over which to iterate: 1842 int64_t shape[] = { 3 }; 1843 1844 // Define a callback: 1845 int32_t add( int32_t x, int32_t y ) { 1846 return x + y; 1847 } 1848 1849 // Apply the callback: 1850 stdlib_strided_ss_i_as_ii_i( arrays, shape, strides, (void *)add ); 1851 ``` 1852 1853 The function accepts the following arguments: 1854 1855 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1856 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1857 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1858 - **fcn**: `[in] void*` a `BinaryFcnInt32` function to apply provided as a `void` pointer. 1859 1860 ```c 1861 void stdlib_strided_ss_i_as_ii_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1862 ``` 1863 1864 #### stdlib_strided_ss_k( \*arrays[], \*shape, \*strides, \*fcn ) 1865 1866 Applies a binary callback accepting and returning signed 8-bit integers to signed 8-bit integer strided input arrays, 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. 1867 1868 ```c 1869 #include <stdint.h> 1870 1871 // Create underlying byte arrays: 1872 uint8_t x[] = { 0, 0, 0 }; 1873 uint8_t y[] = { 0, 0, 0 }; 1874 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 1875 1876 // Define a pointer to an array containing pointers to strided arrays: 1877 uint8_t *arrays[] = { x, y, out }; 1878 1879 // Define the strides: 1880 int64_t strides[] = { 1, 1, 2 }; // 1 byte per int8, 2 bytes per int16 1881 1882 // Define the number of elements over which to iterate: 1883 int64_t shape[] = { 3 }; 1884 1885 // Define a callback: 1886 int8_t add( int8_t x, int8_t y ) { 1887 return x + y; 1888 } 1889 1890 // Apply the callback: 1891 stdlib_strided_ss_k( arrays, shape, strides, (void *)add ); 1892 ``` 1893 1894 The function accepts the following arguments: 1895 1896 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1897 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1898 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1899 - **fcn**: `[in] void*` a `BinaryFcnInt8` function to apply provided as a `void` pointer. 1900 1901 ```c 1902 void stdlib_strided_ss_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1903 ``` 1904 1905 #### stdlib_strided_ss_k_as_kk_k( \*arrays[], \*shape, \*strides, \*fcn ) 1906 1907 Applies a binary callback accepting and returning signed 16-bit integers to signed 8-bit integer strided input arrays and assigns results to elements in a signed 16-bit integer strided output array. 1908 1909 ```c 1910 #include <stdint.h> 1911 1912 // Create underlying byte arrays: 1913 uint8_t x[] = { 0, 0, 0 }; 1914 uint8_t y[] = { 0, 0, 0 }; 1915 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 1916 1917 // Define a pointer to an array containing pointers to strided arrays: 1918 uint8_t *arrays[] = { x, y, out }; 1919 1920 // Define the strides: 1921 int64_t strides[] = { 1, 1, 2 }; // 1 byte per int8, 2 bytes per int16 1922 1923 // Define the number of elements over which to iterate: 1924 int64_t shape[] = { 3 }; 1925 1926 // Define a callback: 1927 int16_t add( int16_t x, int16_t y ) { 1928 return x + y; 1929 } 1930 1931 // Apply the callback: 1932 stdlib_strided_ss_k_as_kk_k( arrays, shape, strides, (void *)add ); 1933 ``` 1934 1935 The function accepts the following arguments: 1936 1937 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1938 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1939 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1940 - **fcn**: `[in] void*` a `BinaryFcnInt16` function to apply provided as a `void` pointer. 1941 1942 ```c 1943 void stdlib_strided_ss_k_as_kk_k( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1944 ``` 1945 1946 #### stdlib_strided_ss_s( \*arrays[], \*shape, \*strides, \*fcn ) 1947 1948 Applies a binary callback accepting and returning signed 8-bit integers to signed 8-bit integer strided input arrays and assigns results to elements in a signed 8-bit integer strided output array. 1949 1950 ```c 1951 #include <stdint.h> 1952 1953 // Create underlying byte arrays: 1954 uint8_t x[] = { 0, 0, 0 }; 1955 uint8_t y[] = { 0, 0, 0 }; 1956 uint8_t out[] = { 0, 0, 0 }; 1957 1958 // Define a pointer to an array containing pointers to strided arrays: 1959 uint8_t *arrays[] = { x, y, out }; 1960 1961 // Define the strides: 1962 int64_t strides[] = { 1, 1, 1 }; // 1 byte per int8 1963 1964 // Define the number of elements over which to iterate: 1965 int64_t shape[] = { 3 }; 1966 1967 // Define a callback: 1968 int8_t add( int8_t x, int8_t y ) { 1969 return x + y; 1970 } 1971 1972 // Apply the callback: 1973 stdlib_strided_ss_s( arrays, shape, strides, (void *)add ); 1974 ``` 1975 1976 The function accepts the following arguments: 1977 1978 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 1979 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 1980 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 1981 - **fcn**: `[in] void*` a `BinaryFcnInt8` function to apply provided as a `void` pointer. 1982 1983 ```c 1984 void stdlib_strided_ss_s( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 1985 ``` 1986 1987 #### stdlib_strided_tt_d( \*arrays[], \*shape, \*strides, \*fcn ) 1988 1989 Applies a binary callback accepting and returning unsigned 16-bit integers to unsigned 16-bit integer strided input arrays, 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. 1990 1991 ```c 1992 #include <stdint.h> 1993 1994 // Create underlying byte arrays: 1995 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 1996 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 1997 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 }; 1998 1999 // Define a pointer to an array containing pointers to strided arrays: 2000 uint8_t *arrays[] = { x, y, out }; 2001 2002 // Define the strides: 2003 int64_t strides[] = { 2, 2, 8 }; // 2 bytes per uint16, 8 bytes per double 2004 2005 // Define the number of elements over which to iterate: 2006 int64_t shape[] = { 3 }; 2007 2008 // Define a callback: 2009 uint16_t add( uint16_t x, uint16_t y ) { 2010 return x + y; 2011 } 2012 2013 // Apply the callback: 2014 stdlib_strided_tt_d( arrays, shape, strides, (void *)add ); 2015 ``` 2016 2017 The function accepts the following arguments: 2018 2019 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2020 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2021 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2022 - **fcn**: `[in] void*` a `BinaryFcnUint16` function to apply provided as a `void` pointer. 2023 2024 ```c 2025 void stdlib_strided_tt_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2026 ``` 2027 2028 #### stdlib_strided_tt_d_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 2029 2030 Applies a binary callback accepting and returning double-precision floating-point numbers to unsigned 16-bit integer strided input arrays and assigns results to elements in a double-precision floating-point strided output array. 2031 2032 ```c 2033 #include <stdint.h> 2034 2035 // Create underlying byte arrays: 2036 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2037 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 2038 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 }; 2039 2040 // Define a pointer to an array containing pointers to strided arrays: 2041 uint8_t *arrays[] = { x, y, out }; 2042 2043 // Define the strides: 2044 int64_t strides[] = { 2, 2, 8 }; // 2 bytes per uint16, 8 bytes per double 2045 2046 // Define the number of elements over which to iterate: 2047 int64_t shape[] = { 3 }; 2048 2049 // Define a callback: 2050 double add( double x, double y ) { 2051 return x + y; 2052 } 2053 2054 // Apply the callback: 2055 stdlib_strided_tt_d_as_dd_d( arrays, shape, strides, (void *)add ); 2056 ``` 2057 2058 The function accepts the following arguments: 2059 2060 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2061 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2062 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2063 - **fcn**: `[in] void*` a `BinaryFcnFloat64` function to apply provided as a `void` pointer. 2064 2065 ```c 2066 void stdlib_strided_tt_d_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2067 ``` 2068 2069 #### stdlib_strided_tt_f( \*arrays[], \*shape, \*strides, \*fcn ) 2070 2071 Applies a binary callback accepting and returning unsigned 16-bit integers to unsigned 16-bit integer strided input arrays, 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. 2072 2073 ```c 2074 #include <stdint.h> 2075 2076 // Create underlying byte arrays: 2077 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2078 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 2079 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2080 2081 // Define a pointer to an array containing pointers to strided arrays: 2082 uint8_t *arrays[] = { x, y, out }; 2083 2084 // Define the strides: 2085 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per uint16, 4 bytes per float 2086 2087 // Define the number of elements over which to iterate: 2088 int64_t shape[] = { 3 }; 2089 2090 // Define a callback: 2091 uint16_t add( uint16_t x, uint16_t y ) { 2092 return x + y; 2093 } 2094 2095 // Apply the callback: 2096 stdlib_strided_tt_f( arrays, shape, strides, (void *)add ); 2097 ``` 2098 2099 The function accepts the following arguments: 2100 2101 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2102 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2103 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2104 - **fcn**: `[in] void*` a `BinaryFcnUint16` function to apply provided as a `void` pointer. 2105 2106 ```c 2107 void stdlib_strided_tt_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2108 ``` 2109 2110 #### stdlib_strided_tt_f_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 2111 2112 Applies a binary callback accepting and returning double-precision floating-point numbers to unsigned 16-bit integer strided input arrays, 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. 2113 2114 ```c 2115 #include <stdint.h> 2116 2117 // Create underlying byte arrays: 2118 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2119 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 2120 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2121 2122 // Define a pointer to an array containing pointers to strided arrays: 2123 uint8_t *arrays[] = { x, y, out }; 2124 2125 // Define the strides: 2126 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per uint16, 4 bytes per float 2127 2128 // Define the number of elements over which to iterate: 2129 int64_t shape[] = { 3 }; 2130 2131 // Define a callback: 2132 double add( double x, double y ) { 2133 return x + y; 2134 } 2135 2136 // Apply the callback: 2137 stdlib_strided_tt_f_as_dd_d( arrays, shape, strides, (void *)add ); 2138 ``` 2139 2140 The function accepts the following arguments: 2141 2142 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2143 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2144 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2145 - **fcn**: `[in] void*` a `BinaryFcnFloat64` function to apply provided as a `void` pointer. 2146 2147 ```c 2148 void stdlib_strided_tt_f_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2149 ``` 2150 2151 #### stdlib_strided_tt_f_as_ff_f( \*arrays[], \*shape, \*strides, \*fcn ) 2152 2153 Applies a binary callback accepting and returning single-precision floating-point numbers to unsigned 16-bit integer strided input arrays and assigns results to elements in a single-precision floating-point strided output array. 2154 2155 ```c 2156 #include <stdint.h> 2157 2158 // Create underlying byte arrays: 2159 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2160 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 2161 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2162 2163 // Define a pointer to an array containing pointers to strided arrays: 2164 uint8_t *arrays[] = { x, y, out }; 2165 2166 // Define the strides: 2167 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per uint16, 4 bytes per float 2168 2169 // Define the number of elements over which to iterate: 2170 int64_t shape[] = { 3 }; 2171 2172 // Define a callback: 2173 float add( float x, float y ) { 2174 return x + y; 2175 } 2176 2177 // Apply the callback: 2178 stdlib_strided_tt_f_as_ff_f( arrays, shape, strides, (void *)add ); 2179 ``` 2180 2181 The function accepts the following arguments: 2182 2183 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2184 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2185 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2186 - **fcn**: `[in] void*` a `BinaryFcnFloat32` function to apply provided as a `void` pointer. 2187 2188 ```c 2189 void stdlib_strided_tt_f_as_ff_f( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2190 ``` 2191 2192 #### stdlib_strided_tt_i( \*arrays[], \*shape, \*strides, \*fcn ) 2193 2194 Applies a binary callback accepting and returning unsigned 16-bit integers to unsigned 16-bit integer strided input arrays, 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. 2195 2196 ```c 2197 #include <stdint.h> 2198 2199 // Create underlying byte arrays: 2200 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2201 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 2202 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2203 2204 // Define a pointer to an array containing pointers to strided arrays: 2205 uint8_t *arrays[] = { x, y, out }; 2206 2207 // Define the strides: 2208 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per uint16, 4 bytes per int32 2209 2210 // Define the number of elements over which to iterate: 2211 int64_t shape[] = { 3 }; 2212 2213 // Define a callback: 2214 uint16_t add( uint16_t x, uint16_t y ) { 2215 return x + y; 2216 } 2217 2218 // Apply the callback: 2219 stdlib_strided_tt_i( arrays, shape, strides, (void *)add ); 2220 ``` 2221 2222 The function accepts the following arguments: 2223 2224 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2225 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2226 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2227 - **fcn**: `[in] void*` a `BinaryFcnUint16` function to apply provided as a `void` pointer. 2228 2229 ```c 2230 void stdlib_strided_tt_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2231 ``` 2232 2233 #### stdlib_strided_tt_i_as_ii_i( \*arrays[], \*shape, \*strides, \*fcn ) 2234 2235 Applies a binary callback accepting and returning signed 32-bit integers to unsigned 16-bit integer strided input arrays and assigns results to elements in a signed 32-bit integer strided output array. 2236 2237 ```c 2238 #include <stdint.h> 2239 2240 // Create underlying byte arrays: 2241 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2242 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 2243 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2244 2245 // Define a pointer to an array containing pointers to strided arrays: 2246 uint8_t *arrays[] = { x, y, out }; 2247 2248 // Define the strides: 2249 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per uint16, 4 bytes per int32 2250 2251 // Define the number of elements over which to iterate: 2252 int64_t shape[] = { 3 }; 2253 2254 // Define a callback: 2255 int32_t add( int32_t x, int32_t y ) { 2256 return x + y; 2257 } 2258 2259 // Apply the callback: 2260 stdlib_strided_tt_i_as_ii_i( arrays, shape, strides, (void *)add ); 2261 ``` 2262 2263 The function accepts the following arguments: 2264 2265 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2266 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2267 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2268 - **fcn**: `[in] void*` a `BinaryFcnInt32` function to apply provided as a `void` pointer. 2269 2270 ```c 2271 void stdlib_strided_tt_i_as_ii_i( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2272 ``` 2273 2274 #### stdlib_strided_tt_t( \*arrays[], \*shape, \*strides, \*fcn ) 2275 2276 Applies a binary callback accepting and returning unsigned 16-bit integers to unsigned 16-bit integer strided input arrays and assigns results to elements in an unsigned 16-bit integer strided output array. 2277 2278 ```c 2279 #include <stdint.h> 2280 2281 // Create underlying byte arrays: 2282 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2283 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 2284 uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; 2285 2286 // Define a pointer to an array containing pointers to strided arrays: 2287 uint8_t *arrays[] = { x, y, out }; 2288 2289 // Define the strides: 2290 int64_t strides[] = { 2, 2, 2 }; // 2 bytes per uint16 2291 2292 // Define the number of elements over which to iterate: 2293 int64_t shape[] = { 3 }; 2294 2295 // Define a callback: 2296 uint16_t add( uint16_t x, uint16_t y ) { 2297 return x + y; 2298 } 2299 2300 // Apply the callback: 2301 stdlib_strided_tt_t( arrays, shape, strides, (void *)add ); 2302 ``` 2303 2304 The function accepts the following arguments: 2305 2306 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2307 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2308 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2309 - **fcn**: `[in] void*` a `BinaryFcnUint16` function to apply provided as a `void` pointer. 2310 2311 ```c 2312 void stdlib_strided_tt_t( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2313 ``` 2314 2315 #### stdlib_strided_tt_u( \*arrays[], \*shape, \*strides, \*fcn ) 2316 2317 Applies a binary callback accepting and returning unsigned 16-bit integers to unsigned 16-bit integer strided input arrays, 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. 2318 2319 ```c 2320 #include <stdint.h> 2321 2322 // Create underlying byte arrays: 2323 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2324 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 2325 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2326 2327 // Define a pointer to an array containing pointers to strided arrays: 2328 uint8_t *arrays[] = { x, y, out }; 2329 2330 // Define the strides: 2331 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per uint16, 4 bytes per uint32 2332 2333 // Define the number of elements over which to iterate: 2334 int64_t shape[] = { 3 }; 2335 2336 // Define a callback: 2337 uint16_t add( uint16_t x, uint16_t y ) { 2338 return x + y; 2339 } 2340 2341 // Apply the callback: 2342 stdlib_strided_tt_u( arrays, shape, strides, (void *)add ); 2343 ``` 2344 2345 The function accepts the following arguments: 2346 2347 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2348 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2349 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2350 - **fcn**: `[in] void*` a `BinaryFcnUint16` function to apply provided as a `void` pointer. 2351 2352 ```c 2353 void stdlib_strided_tt_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2354 ``` 2355 2356 #### stdlib_strided_tt_u_as_uu_u( \*arrays[], \*shape, \*strides, \*fcn ) 2357 2358 Applies a binary callback accepting and returning unsigned 32-bit integers to unsigned 16-bit integer strided input arrays and assigns results to elements in an unsigned 32-bit integer strided output array. 2359 2360 ```c 2361 #include <stdint.h> 2362 2363 // Create underlying byte arrays: 2364 uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; 2365 uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; 2366 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2367 2368 // Define a pointer to an array containing pointers to strided arrays: 2369 uint8_t *arrays[] = { x, y, out }; 2370 2371 // Define the strides: 2372 int64_t strides[] = { 2, 2, 4 }; // 2 bytes per uint16, 4 bytes per uint32 2373 2374 // Define the number of elements over which to iterate: 2375 int64_t shape[] = { 3 }; 2376 2377 // Define a callback: 2378 uint32_t add( uint32_t x, uint32_t y ) { 2379 return x + y; 2380 } 2381 2382 // Apply the callback: 2383 stdlib_strided_tt_u_as_uu_u( arrays, shape, strides, (void *)add ); 2384 ``` 2385 2386 The function accepts the following arguments: 2387 2388 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2389 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2390 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2391 - **fcn**: `[in] void*` a `BinaryFcnUint32` function to apply provided as a `void` pointer. 2392 2393 ```c 2394 void stdlib_strided_tt_u_as_uu_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2395 ``` 2396 2397 #### stdlib_strided_uu_d( \*arrays[], \*shape, \*strides, \*fcn ) 2398 2399 Applies a binary callback accepting and returning unsigned 32-bit integers to unsigned 32-bit integer strided input arrays, 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. 2400 2401 ```c 2402 #include <stdint.h> 2403 2404 // Create underlying byte arrays: 2405 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2406 uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2407 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 }; 2408 2409 // Define a pointer to an array containing pointers to strided arrays: 2410 uint8_t *arrays[] = { x, y, out }; 2411 2412 // Define the strides: 2413 int64_t strides[] = { 4, 4, 8 }; // 4 bytes per uint32, 8 bytes per double 2414 2415 // Define the number of elements over which to iterate: 2416 int64_t shape[] = { 3 }; 2417 2418 // Define a callback: 2419 uint32_t add( uint32_t x, uint32_t y ) { 2420 return x + y; 2421 } 2422 2423 // Apply the callback: 2424 stdlib_strided_uu_d( arrays, shape, strides, (void *)add ); 2425 ``` 2426 2427 The function accepts the following arguments: 2428 2429 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2430 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2431 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2432 - **fcn**: `[in] void*` a `BinaryFcnUint32` function to apply provided as a `void` pointer. 2433 2434 ```c 2435 void stdlib_strided_uu_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2436 ``` 2437 2438 #### stdlib_strided_uu_d_as_dd_d( \*arrays[], \*shape, \*strides, \*fcn ) 2439 2440 Applies a binary callback accepting and returning double-precision floating-point numbers to unsigned 32-bit integer strided input arrays and assigns results to elements in a double-precision floating-point strided output array. 2441 2442 ```c 2443 #include <stdint.h> 2444 2445 // Create underlying byte arrays: 2446 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2447 uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2448 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 }; 2449 2450 // Define a pointer to an array containing pointers to strided arrays: 2451 uint8_t *arrays[] = { x, y, out }; 2452 2453 // Define the strides: 2454 int64_t strides[] = { 4, 4, 8 }; // 4 bytes per uint32, 8 bytes per double 2455 2456 // Define the number of elements over which to iterate: 2457 int64_t shape[] = { 3 }; 2458 2459 // Define a callback: 2460 double add( double x, double y ) { 2461 return x + y; 2462 } 2463 2464 // Apply the callback: 2465 stdlib_strided_uu_d_as_dd_d( arrays, shape, strides, (void *)add ); 2466 ``` 2467 2468 The function accepts the following arguments: 2469 2470 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2471 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2472 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2473 - **fcn**: `[in] void*` a `BinaryFcnFloat64` function to apply provided as a `void` pointer. 2474 2475 ```c 2476 void stdlib_strided_uu_d_as_dd_d( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2477 ``` 2478 2479 #### stdlib_strided_uu_u( \*arrays[], \*shape, \*strides, \*fcn ) 2480 2481 Applies a binary callback accepting and returning unsigned 32-bit integers to unsigned 32-bit integer strided input arrays and assigns results to elements in an unsigned 32-bit integer strided output array. 2482 2483 ```c 2484 #include <stdint.h> 2485 2486 // Create underlying byte arrays: 2487 uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2488 uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2489 uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2490 2491 // Define a pointer to an array containing pointers to strided arrays: 2492 uint8_t *arrays[] = { x, y, out }; 2493 2494 // Define the strides: 2495 int64_t strides[] = { 4, 4, 4 }; // 4 bytes per uint32 2496 2497 // Define the number of elements over which to iterate: 2498 int64_t shape[] = { 3 }; 2499 2500 // Define a callback: 2501 uint32_t add( uint32_t x, uint32_t y ) { 2502 return x + y; 2503 } 2504 2505 // Apply the callback: 2506 stdlib_strided_uu_u( arrays, shape, strides, (void *)add ); 2507 ``` 2508 2509 The function accepts the following arguments: 2510 2511 - **arrays**: `[inout] uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array 2512 - **shape**: `[in] int64_t*` array whose only element is the number of elements over which to iterate. 2513 - **strides**: `[in] int64_t*` array containing strides (in bytes) for each strided array. 2514 - **fcn**: `[in] void*` a `BinaryFcnUint32` function to apply provided as a `void` pointer. 2515 2516 ```c 2517 void stdlib_strided_uu_u( uint8_t *arrays[], int64_t *shape, int64_t *strides, void *fcn ); 2518 ``` 2519 2520 <!-- macros --> 2521 2522 * * * 2523 2524 #### STDLIB_STRIDED_BINARY_LOOP_PREAMBLE 2525 2526 Macro containing the preamble for a loop which operates on strided array elements. 2527 2528 ```c 2529 STDLIB_STRIDED_BINARY_LOOP_PREMABLE { 2530 // Loop body... 2531 } 2532 ``` 2533 2534 The macro expects the following variables to be defined: 2535 2536 - **arrays**: `uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array. 2537 - **shape**: `int64_t*` array whose only element is the number of elements over which to iterate. 2538 - **strides**: `int64_t*` array containing strides (in bytes) for each strided array. 2539 2540 The macro defines the following variables: 2541 2542 - **ip1**: `uint8_t*` pointer to the first indexed element of the first input strided array. 2543 - **ip2**: `uint8_t*` pointer to the first indexed element of the second input strided array. 2544 - **op1**: `uint8_t*` pointer to the first indexed element of the output strided array. 2545 - **is1**: `int64_t` index increment for the first input strided array. 2546 - **is2**: `int64_t` index increment for the second input strided array. 2547 - **os1**: `int64_t` index increment for the output strided array. 2548 - **n**: `int64_t` number of indexed elements. 2549 - **i**: `int64_t` loop counter. 2550 2551 ```c 2552 #define STDLIB_STRIDED_BINARY_LOOP_PREAMBLE \ 2553 uint8_t *ip1 = arrays[ 0 ]; \ 2554 uint8_t *ip2 = arrays[ 1 ]; \ 2555 uint8_t *op1 = arrays[ 2 ]; \ 2556 int64_t is1 = strides[ 0 ]; \ 2557 int64_t is2 = strides[ 1 ]; \ 2558 int64_t os1 = strides[ 2 ]; \ 2559 int64_t n = shape[ 0 ]; \ 2560 int64_t i; \ 2561 if ( n <= 0 ) { \ 2562 return; \ 2563 } \ 2564 if ( is1 < 0 ) { \ 2565 ip1 += (1-n) * is1; \ 2566 } \ 2567 if ( is2 < 0 ) { \ 2568 ip2 += (1-n) * is2; \ 2569 } \ 2570 if ( os1 < 0 ) { \ 2571 op1 += (1-n) * os1; \ 2572 } \ 2573 for ( i = 0; i < n; i++, ip1 += is1, ip2 += is2, op1 += os1 ) 2574 ``` 2575 2576 #### STDLIB_STRIDED_BINARY_LOOP_TWO_OUT_PREAMBLE 2577 2578 Macro containing the preamble for a loop which operates on strided array elements and updates two strided output arrays. 2579 2580 ```c 2581 STDLIB_STRIDED_BINARY_LOOP_TWO_OUT_PREAMBLE { 2582 // Loop body... 2583 } 2584 ``` 2585 2586 The macro expects the following variables to be defined: 2587 2588 - **arrays**: `uint8_t**` array whose first two elements are pointers to strided input arrays and whose last element is a pointer to a strided output array. 2589 - **shape**: `int64_t*` array whose only element is the number of elements over which to iterate. 2590 - **strides**: `int64_t*` array containing strides (in bytes) for each strided array. 2591 2592 The macro defines the following variables: 2593 2594 - **ip1**: `uint8_t*` pointer to the first indexed element of the first input strided array. 2595 - **ip2**: `uint8_t*` pointer to the first indexed element of the second input strided array. 2596 - **op1**: `uint8_t*` pointer to the first indexed element of the first output strided array. 2597 - **op2**: `uint8_t*` pointer to the first indexed element of the second output strided array. 2598 - **is1**: `int64_t` index increment for the first input strided array. 2599 - **is2**: `int64_t` index increment for the second input strided array. 2600 - **os1**: `int64_t` index increment for the first output strided array. 2601 - **os2**: `int64_t` index increment for the second output strided array. 2602 - **n**: `int64_t` number of indexed elements. 2603 - **i**: `int64_t` loop counter. 2604 2605 ```c 2606 #define STDLIB_STRIDED_BINARY_LOOP_TWO_OUT_PREAMBLE \ 2607 uint8_t *ip1 = arrays[ 0 ]; \ 2608 uint8_t *ip2 = arrays[ 1 ]; \ 2609 uint8_t *op1 = arrays[ 2 ]; \ 2610 uint8_t *op2 = arrays[ 3 ]; \ 2611 int64_t is1 = strides[ 0 ]; \ 2612 int64_t is2 = strides[ 1 ]; \ 2613 int64_t os1 = strides[ 2 ]; \ 2614 int64_t os2 = strides[ 3 ]; \ 2615 int64_t n = shape[ 0 ]; \ 2616 int64_t i; \ 2617 if ( n <= 0 ) { \ 2618 return; \ 2619 } \ 2620 if ( is1 < 0 ) { \ 2621 ip1 += (1-n) * is1; \ 2622 } \ 2623 if ( is2 < 0 ) { \ 2624 ip2 += (1-n) * is2; \ 2625 } \ 2626 if ( os1 < 0 ) { \ 2627 op1 += (1-n) * os1; \ 2628 } \ 2629 if ( os2 < 0 ) { \ 2630 op2 += (1-n) * os2; \ 2631 } \ 2632 for ( i = 0; i < n; i++, ip1 += is1, ip2 += is2, op1 += os1, op2 += os2 ) 2633 ``` 2634 2635 #### STDLIB_STRIDED_BINARY_LOOP_INLINE( tin, tout, expr ) 2636 2637 Macro for a binary loop which inlines an expression. 2638 2639 ```c 2640 STDLIB_STRIDED_BINARY_LOOP_INLINE( double, double, *out = in1 * in1 ) 2641 ``` 2642 2643 The macro expects the following arguments: 2644 2645 - **tin**: input strided array element type. 2646 - **tout**: output strided array element type. 2647 - **expr**: expression to inline. 2648 2649 In addition to the variables defined by the `STDLIB_STRIDED_BINARY_LOOP_PREAMBLE` macro, the macro defines the following variables: 2650 2651 - **in1**: `<tin>` first input strided array element. 2652 - **in2**: `<tin>` second input strided array element. 2653 - **out**: `<tout>*` pointer to an output strided array element. 2654 2655 The macro expects a provided expression to operate on `in1` and `in2` and to store the result via `*out`. 2656 2657 ```c 2658 #define STDLIB_STRIDED_BINARY_LOOP_INLINE( tin, tout, expr ) \ 2659 STDLIB_STRIDED_BINARY_LOOP_PREAMBLE { \ 2660 const tin in1 = *(tin *)ip1; \ 2661 const tin in2 = *(tin *)ip2; \ 2662 tout *out = (tout *)op1; \ 2663 expr; \ 2664 } 2665 ``` 2666 2667 #### STDLIB_STRIDED_BINARY_LOOP_CLBK( tin, tout ) 2668 2669 Macro for a binary loop which invokes a callback. 2670 2671 ```c 2672 STDLIB_STRIDED_BINARY_LOOP_CLBK( double, double ) 2673 ``` 2674 2675 The macro expects the following arguments: 2676 2677 - **tin**: input strided array element data type. 2678 - **tout**: output strided array element data type. 2679 2680 In addition to the variables expected by `STDLIB_STRIDED_BINARY_LOOP_PREAMBLE`, the macro expects the following variables to be defined: 2681 2682 - **f**: binary callback. 2683 2684 In addition to the variables defined by the `STDLIB_STRIDED_BINARY_LOOP_PREAMBLE`, the macro defines the following variables: 2685 2686 - **x**: `<tin>` first input strided array element. 2687 - **y**: `<tin>` second input strided array element. 2688 2689 ```c 2690 #define STDLIB_STRIDED_BINARY_LOOP_CLBK( tin, tout ) \ 2691 STDLIB_STRIDED_BINARY_LOOP_PREAMBLE { \ 2692 const tin x = *(tin *)ip1; \ 2693 const tin y = *(tin *)ip2; \ 2694 *(tout *)op1 = (tout)f( x, y ); \ 2695 } 2696 ``` 2697 2698 #### STDLIB_STRIDED_BINARY_LOOP_CLBK_ARG_CAST( tin, tout, fin ) 2699 2700 Macro for a binary loop which invokes a callback requiring arguments be explicitly cast to a different type. 2701 2702 ```c 2703 STDLIB_STRIDED_BINARY_LOOP_CLBK_ARG_CAST( float, float, double ) 2704 ``` 2705 2706 The macro expects the following arguments: 2707 2708 - **tin**: input strided array element data type. 2709 - **tout**: output strided array element data type. 2710 - **fin**: callback argument data type. 2711 2712 In addition to the variables expected by `STDLIB_STRIDED_BINARY_LOOP_PREAMBLE`, the macro expects the following variables to be defined: 2713 2714 - **f**: binary callback. 2715 2716 In addition to the variables defined by the `STDLIB_STRIDED_BINARY_LOOP_PREAMBLE`, the macro defines the following variables: 2717 2718 - **x**: `<tin>` first input strided array element. 2719 - **y**: `<tin>` second input strided array element. 2720 2721 ```c 2722 #define STDLIB_STRIDED_BINARY_LOOP_CLBK_ARG_CAST( tin, tout, fin ) \ 2723 STDLIB_STRIDED_BINARY_LOOP_PREAMBLE { \ 2724 const tin x = *(tin *)ip1; \ 2725 const tin y = *(tin *)ip2; \ 2726 *(tout *)op1 = (tout)f( (fin)x, (fin)y ); \ 2727 } 2728 ``` 2729 2730 #### STDLIB_STRIDED_BINARY_LOOP_CLBK_MIXED( tin1, tin2, tout ) 2731 2732 Macro for a binary loop which invokes a callback while operating on mixed (typed) strided input arrays. 2733 2734 ```c 2735 STDLIB_STRIDED_BINARY_LOOP_CLBK_MIXED( double, uint32_t, double ) 2736 ``` 2737 2738 The macro expects the following arguments: 2739 2740 - **tin1**: first input strided array element data type. 2741 - **tin2**: second input strided array element data type. 2742 - **tout**: output strided array element data type. 2743 2744 In addition to the variables expected by `STDLIB_STRIDED_BINARY_LOOP_PREAMBLE`, the macro expects the following variables to be defined: 2745 2746 - **f**: binary callback. 2747 2748 In addition to the variables defined by the `STDLIB_STRIDED_BINARY_LOOP_PREAMBLE`, the macro defines the following variables: 2749 2750 - **x**: `<tin1>` first input strided array element. 2751 - **y**: `<tin2>` second input strided array element. 2752 2753 ```c 2754 #define STDLIB_STRIDED_BINARY_LOOP_CLBK_MIXED( tin1, tin2, tout ) \ 2755 STDLIB_STRIDED_BINARY_LOOP_PREAMBLE { \ 2756 const tin1 x = *(tin1 *)ip1; \ 2757 const tin2 y = *(tin2 *)ip2; \ 2758 *(tout *)op1 = (tout)f( x, y ); \ 2759 } 2760 ``` 2761 2762 #### STDLIB_STRIDED_BINARY_LOOP_CLBK_MIXED_ARG_CAST( tin1, tin2, tout, fin1, fin2 ) 2763 2764 Macro for a binary loop which invokes a callback requiring arguments be explicitly cast to a different type while operating on mixed (typed) strided input arrays. 2765 2766 ```c 2767 STDLIB_STRIDED_BINARY_LOOP_CLBK_MIXED_ARG_CAST( float, uint16_t, double, uint32_t, float ) 2768 ``` 2769 2770 The macro expects the following arguments: 2771 2772 - **tin1**: first input strided array element data type. 2773 - **tin2**: second input strided array element data type. 2774 - **tout**: output strided array element data type. 2775 - **fin1**: first callback argument data type. 2776 - **fin2**: second callback argument data type. 2777 2778 In addition to the variables expected by `STDLIB_STRIDED_BINARY_LOOP_PREAMBLE`, the macro expects the following variables to be defined: 2779 2780 - **f**: binary callback. 2781 2782 In addition to the variables defined by the `STDLIB_STRIDED_BINARY_LOOP_PREAMBLE`, the macro defines the following variables: 2783 2784 - **x**: `<tin1>` first input strided array element. 2785 - **y**: `<tin2>` second input strided array element. 2786 2787 ```c 2788 #define STDLIB_STRIDED_BINARY_LOOP_CLBK_MIXED_ARG_CAST( tin1, tin2, tout, fin1, fin2 ) \ 2789 STDLIB_STRIDED_BINARY_LOOP_PREAMBLE { \ 2790 const tin1 x = *(tin1 *)ip1; \ 2791 const tin2 y = *(tin2 *)ip2; \ 2792 *(tout *)op1 = (tout)f( (fin1)x, (fin2)y ); \ 2793 } 2794 ``` 2795 2796 </section> 2797 2798 <!-- /.usage --> 2799 2800 <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 2801 2802 <section class="notes"> 2803 2804 </section> 2805 2806 <!-- /.notes --> 2807 2808 <!-- C API usage examples. --> 2809 2810 * * * 2811 2812 <section class="examples"> 2813 2814 ### Examples 2815 2816 ```c 2817 #include "stdlib/strided/base/binary.h" 2818 #include <stdint.h> 2819 #include <stdio.h> 2820 #include <inttypes.h> 2821 2822 // Define a callback: 2823 static double add( double x, double y ) { 2824 return x + y; 2825 } 2826 2827 int main() { 2828 // Create underlying byte arrays: 2829 uint8_t x[] = { 1, 4, 7 }; 2830 uint8_t y[] = { 101, 104, 107 }; 2831 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 }; 2832 2833 // Define a pointer to an array containing pointers to strided arrays: 2834 uint8_t *arrays[] = { x, y, out }; 2835 2836 // Define the strides: 2837 int64_t strides[] = { 1, 1, 8 }; // 1 byte per uint8, 8 bytes per double 2838 2839 // Define the number of elements over which to iterate: 2840 int64_t shape[] = { 3 }; 2841 2842 // Apply the callback: 2843 stdlib_strided_bb_d_as_dd_d( arrays, shape, strides, (void *)add ); 2844 2845 // Print the contents of the output array: 2846 uint8_t *op1 = out; 2847 for ( int64_t i = 0; i < shape[0]; i++, op1 += strides[2] ) { 2848 const double v = *(double *)op1; 2849 printf( "out[ %"PRId64" ] = %lf\n", i, v ); 2850 } 2851 } 2852 ``` 2853 2854 </section> 2855 2856 <!-- /.examples --> 2857 2858 </section> 2859 2860 <!-- /.c --> 2861 2862 <section class="links"> 2863 2864 [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray 2865 2866 </section> 2867 2868 <!-- /.links -->