d_l.c (73027B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2021 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #include "stdlib/ndarray/base/unary/d_l.h" 20 #include "stdlib/ndarray/base/unary/typedefs.h" 21 #include "stdlib/ndarray/base/unary/macros.h" 22 #include "stdlib/ndarray/base/unary/dispatch_object.h" 23 #include "stdlib/ndarray/base/unary/dispatch.h" 24 #include "stdlib/ndarray/ctor.h" 25 #include <stdint.h> 26 27 /** 28 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a zero-dimensional double-precision floating-point input ndarray and assigns results to elements in a zero-dimensional signed 64-bit integer output ndarray. 29 * 30 * ## Notes 31 * 32 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 33 * 34 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 35 * @param fcn callback 36 * @return status code 37 * 38 * @example 39 * #include "stdlib/ndarray/base/unary/d_l.h" 40 * #include "stdlib/ndarray/dtypes.h" 41 * #include "stdlib/ndarray/index_modes.h" 42 * #include "stdlib/ndarray/orders.h" 43 * #include "stdlib/ndarray/ctor.h" 44 * #include <stdint.h> 45 * #include <stdlib.h> 46 * #include <stdio.h> 47 * #include <math.h> 48 * 49 * // Define the ndarray data types: 50 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 51 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 52 * 53 * // Create underlying byte arrays: 54 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 55 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 56 * 57 * // Define the number of dimensions: 58 * int64_t ndims = 0; 59 * 60 * // Define the array shapes: 61 * int64_t shape[] = {}; 62 * 63 * // Define the strides: 64 * int64_t sx[] = { 0 }; 65 * int64_t sy[] = { 0 }; 66 * 67 * // Define the offsets: 68 * int64_t ox = 0; 69 * int64_t oy = 0; 70 * 71 * // Define the array order: 72 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 73 * 74 * // Specify the index mode: 75 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 76 * 77 * // Specify the subscript index modes: 78 * int8_t submodes[] = { imode }; 79 * int64_t nsubmodes = 1; 80 * 81 * // Create an input ndarray: 82 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 83 * if ( x == NULL ) { 84 * fprintf( stderr, "Error allocating memory.\n" ); 85 * exit( EXIT_FAILURE ); 86 * } 87 * 88 * // Create an output ndarray: 89 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 90 * if ( y == NULL ) { 91 * fprintf( stderr, "Error allocating memory.\n" ); 92 * exit( EXIT_FAILURE ); 93 * } 94 * 95 * // Create an array containing the ndarrays: 96 * struct ndarray *arrays[] = { x, y }; 97 * 98 * // Apply a callback: 99 * int8_t status = stdlib_ndarray_d_l_0d( arrays, (void *)llrint ); 100 * if ( status != 0 ) { 101 * fprintf( stderr, "Error during computation.\n" ); 102 * exit( EXIT_FAILURE ); 103 * } 104 * 105 * // ... 106 * 107 * // Free allocated memory: 108 * stdlib_ndarray_free( x ); 109 * stdlib_ndarray_free( y ); 110 */ 111 int8_t stdlib_ndarray_d_l_0d( struct ndarray *arrays[], void *fcn ) { 112 double v; 113 int8_t status = stdlib_ndarray_iget_float64( arrays[ 0 ], 0, &v ); 114 if ( status != 0 ) { 115 return -1; 116 } 117 typedef int64_t func_type( const double x ); 118 func_type *f = (func_type *)fcn; 119 status = stdlib_ndarray_iset_int64( arrays[ 1 ], 0, f( v ) ); 120 if ( status != 0 ) { 121 return -1; 122 } 123 return 0; 124 } 125 126 /** 127 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a one-dimensional double-precision floating-point input ndarray and assigns results to elements in a one-dimensional signed 64-bit integer output ndarray. 128 * 129 * ## Notes 130 * 131 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 132 * 133 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 134 * @param fcn callback 135 * @return status code 136 * 137 * @example 138 * #include "stdlib/ndarray/base/unary/d_l.h" 139 * #include "stdlib/ndarray/dtypes.h" 140 * #include "stdlib/ndarray/index_modes.h" 141 * #include "stdlib/ndarray/orders.h" 142 * #include "stdlib/ndarray/ctor.h" 143 * #include <stdint.h> 144 * #include <stdlib.h> 145 * #include <stdio.h> 146 * #include <math.h> 147 * 148 * // Define the ndarray data types: 149 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 150 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 151 * 152 * // Create underlying byte arrays: 153 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 154 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 155 * 156 * // Define the number of dimensions: 157 * int64_t ndims = 1; 158 * 159 * // Define the array shapes: 160 * int64_t shape[] = { 2 }; 161 * 162 * // Define the strides: 163 * int64_t sx[] = { 8 }; 164 * int64_t sy[] = { 8 }; 165 * 166 * // Define the offsets: 167 * int64_t ox = 0; 168 * int64_t oy = 0; 169 * 170 * // Define the array order: 171 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 172 * 173 * // Specify the index mode: 174 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 175 * 176 * // Specify the subscript index modes: 177 * int8_t submodes[] = { imode }; 178 * int64_t nsubmodes = 1; 179 * 180 * // Create an input ndarray: 181 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 182 * if ( x == NULL ) { 183 * fprintf( stderr, "Error allocating memory.\n" ); 184 * exit( EXIT_FAILURE ); 185 * } 186 * 187 * // Create an output ndarray: 188 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 189 * if ( y == NULL ) { 190 * fprintf( stderr, "Error allocating memory.\n" ); 191 * exit( EXIT_FAILURE ); 192 * } 193 * 194 * // Create an array containing the ndarrays: 195 * struct ndarray *arrays[] = { x, y }; 196 * 197 * // Apply a callback: 198 * int8_t status = stdlib_ndarray_d_l_1d( arrays, (void *)llrint ); 199 * if ( status != 0 ) { 200 * fprintf( stderr, "Error during computation.\n" ); 201 * exit( EXIT_FAILURE ); 202 * } 203 * 204 * // ... 205 * 206 * // Free allocated memory: 207 * stdlib_ndarray_free( x ); 208 * stdlib_ndarray_free( y ); 209 */ 210 int8_t stdlib_ndarray_d_l_1d( struct ndarray *arrays[], void *fcn ) { 211 typedef int64_t func_type( const double x ); 212 func_type *f = (func_type *)fcn; 213 STDLIB_NDARRAY_UNARY_1D_LOOP_CLBK( double, int64_t ) 214 return 0; 215 } 216 217 /** 218 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a two-dimensional double-precision floating-point input ndarray and assigns results to elements in a two-dimensional signed 64-bit integer output ndarray. 219 * 220 * ## Notes 221 * 222 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 223 * 224 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 225 * @param fcn callback 226 * @return status code 227 * 228 * @example 229 * #include "stdlib/ndarray/base/unary/d_l.h" 230 * #include "stdlib/ndarray/dtypes.h" 231 * #include "stdlib/ndarray/index_modes.h" 232 * #include "stdlib/ndarray/orders.h" 233 * #include "stdlib/ndarray/ctor.h" 234 * #include <stdint.h> 235 * #include <stdlib.h> 236 * #include <stdio.h> 237 * #include <math.h> 238 * 239 * // Define the ndarray data types: 240 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 241 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 242 * 243 * // Create underlying byte arrays: 244 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 245 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 246 * 247 * // Define the number of dimensions: 248 * int64_t ndims = 2; 249 * 250 * // Define the array shapes: 251 * int64_t shape[] = { 2, 2 }; 252 * 253 * // Define the strides: 254 * int64_t sx[] = { 16, 8 }; 255 * int64_t sy[] = { 16, 8 }; 256 * 257 * // Define the offsets: 258 * int64_t ox = 0; 259 * int64_t oy = 0; 260 * 261 * // Define the array order: 262 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 263 * 264 * // Specify the index mode: 265 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 266 * 267 * // Specify the subscript index modes: 268 * int8_t submodes[] = { imode }; 269 * int64_t nsubmodes = 1; 270 * 271 * // Create an input ndarray: 272 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 273 * if ( x == NULL ) { 274 * fprintf( stderr, "Error allocating memory.\n" ); 275 * exit( EXIT_FAILURE ); 276 * } 277 * 278 * // Create an output ndarray: 279 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 280 * if ( y == NULL ) { 281 * fprintf( stderr, "Error allocating memory.\n" ); 282 * exit( EXIT_FAILURE ); 283 * } 284 * 285 * // Create an array containing the ndarrays: 286 * struct ndarray *arrays[] = { x, y }; 287 * 288 * // Apply a callback: 289 * int8_t status = stdlib_ndarray_d_l_2d( arrays, (void *)llrint ); 290 * if ( status != 0 ) { 291 * fprintf( stderr, "Error during computation.\n" ); 292 * exit( EXIT_FAILURE ); 293 * } 294 * 295 * // ... 296 * 297 * // Free allocated memory: 298 * stdlib_ndarray_free( x ); 299 * stdlib_ndarray_free( y ); 300 */ 301 int8_t stdlib_ndarray_d_l_2d( struct ndarray *arrays[], void *fcn ) { 302 typedef int64_t func_type( const double x ); 303 func_type *f = (func_type *)fcn; 304 STDLIB_NDARRAY_UNARY_2D_LOOP_CLBK( double, int64_t ) 305 return 0; 306 } 307 308 /** 309 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a two-dimensional double-precision floating-point input ndarray and assigns results to elements in a two-dimensional signed 64-bit integer output ndarray. 310 * 311 * ## Notes 312 * 313 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 314 * 315 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 316 * @param fcn callback 317 * @return status code 318 * 319 * @example 320 * #include "stdlib/ndarray/base/unary/d_l.h" 321 * #include "stdlib/ndarray/dtypes.h" 322 * #include "stdlib/ndarray/index_modes.h" 323 * #include "stdlib/ndarray/orders.h" 324 * #include "stdlib/ndarray/ctor.h" 325 * #include <stdint.h> 326 * #include <stdlib.h> 327 * #include <stdio.h> 328 * #include <math.h> 329 * 330 * // Define the ndarray data types: 331 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 332 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 333 * 334 * // Create underlying byte arrays: 335 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 336 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 337 * 338 * // Define the number of dimensions: 339 * int64_t ndims = 2; 340 * 341 * // Define the array shapes: 342 * int64_t shape[] = { 2, 2 }; 343 * 344 * // Define the strides: 345 * int64_t sx[] = { 16, 8 }; 346 * int64_t sy[] = { 16, 8 }; 347 * 348 * // Define the offsets: 349 * int64_t ox = 0; 350 * int64_t oy = 0; 351 * 352 * // Define the array order: 353 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 354 * 355 * // Specify the index mode: 356 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 357 * 358 * // Specify the subscript index modes: 359 * int8_t submodes[] = { imode }; 360 * int64_t nsubmodes = 1; 361 * 362 * // Create an input ndarray: 363 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 364 * if ( x == NULL ) { 365 * fprintf( stderr, "Error allocating memory.\n" ); 366 * exit( EXIT_FAILURE ); 367 * } 368 * 369 * // Create an output ndarray: 370 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 371 * if ( y == NULL ) { 372 * fprintf( stderr, "Error allocating memory.\n" ); 373 * exit( EXIT_FAILURE ); 374 * } 375 * 376 * // Create an array containing the ndarrays: 377 * struct ndarray *arrays[] = { x, y }; 378 * 379 * // Apply a callback: 380 * int8_t status = stdlib_ndarray_d_l_2d_blocked( arrays, (void *)llrint ); 381 * if ( status != 0 ) { 382 * fprintf( stderr, "Error during computation.\n" ); 383 * exit( EXIT_FAILURE ); 384 * } 385 * 386 * // ... 387 * 388 * // Free allocated memory: 389 * stdlib_ndarray_free( x ); 390 * stdlib_ndarray_free( y ); 391 */ 392 int8_t stdlib_ndarray_d_l_2d_blocked( struct ndarray *arrays[], void *fcn ) { 393 typedef int64_t func_type( const double x ); 394 func_type *f = (func_type *)fcn; 395 STDLIB_NDARRAY_UNARY_2D_BLOCKED_LOOP_CLBK( double, int64_t ) 396 return 0; 397 } 398 399 /** 400 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a three-dimensional double-precision floating-point input ndarray and assigns results to elements in a three-dimensional signed 64-bit integer output ndarray. 401 * 402 * ## Notes 403 * 404 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 405 * 406 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 407 * @param fcn callback 408 * @return status code 409 * 410 * @example 411 * #include "stdlib/ndarray/base/unary/d_l.h" 412 * #include "stdlib/ndarray/dtypes.h" 413 * #include "stdlib/ndarray/index_modes.h" 414 * #include "stdlib/ndarray/orders.h" 415 * #include "stdlib/ndarray/ctor.h" 416 * #include <stdint.h> 417 * #include <stdlib.h> 418 * #include <stdio.h> 419 * #include <math.h> 420 * 421 * // Define the ndarray data types: 422 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 423 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 424 * 425 * // Create underlying byte arrays: 426 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 427 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 428 * 429 * // Define the number of dimensions: 430 * int64_t ndims = 3; 431 * 432 * // Define the array shapes: 433 * int64_t shape[] = { 2, 2, 2 }; 434 * 435 * // Define the strides: 436 * int64_t sx[] = { 32, 16, 8 }; 437 * int64_t sy[] = { 32, 16, 8 }; 438 * 439 * // Define the offsets: 440 * int64_t ox = 0; 441 * int64_t oy = 0; 442 * 443 * // Define the array order: 444 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 445 * 446 * // Specify the index mode: 447 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 448 * 449 * // Specify the subscript index modes: 450 * int8_t submodes[] = { imode }; 451 * int64_t nsubmodes = 1; 452 * 453 * // Create an input ndarray: 454 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 455 * if ( x == NULL ) { 456 * fprintf( stderr, "Error allocating memory.\n" ); 457 * exit( EXIT_FAILURE ); 458 * } 459 * 460 * // Create an output ndarray: 461 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 462 * if ( y == NULL ) { 463 * fprintf( stderr, "Error allocating memory.\n" ); 464 * exit( EXIT_FAILURE ); 465 * } 466 * 467 * // Create an array containing the ndarrays: 468 * struct ndarray *arrays[] = { x, y }; 469 * 470 * // Apply a callback: 471 * int8_t status = stdlib_ndarray_d_l_3d( arrays, (void *)llrint ); 472 * if ( status != 0 ) { 473 * fprintf( stderr, "Error during computation.\n" ); 474 * exit( EXIT_FAILURE ); 475 * } 476 * 477 * // ... 478 * 479 * // Free allocated memory: 480 * stdlib_ndarray_free( x ); 481 * stdlib_ndarray_free( y ); 482 */ 483 int8_t stdlib_ndarray_d_l_3d( struct ndarray *arrays[], void *fcn ) { 484 typedef int64_t func_type( const double x ); 485 func_type *f = (func_type *)fcn; 486 STDLIB_NDARRAY_UNARY_3D_LOOP_CLBK( double, int64_t ) 487 return 0; 488 } 489 490 /** 491 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a three-dimensional double-precision floating-point input ndarray and assigns results to elements in a three-dimensional signed 64-bit integer output ndarray. 492 * 493 * ## Notes 494 * 495 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 496 * 497 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 498 * @param fcn callback 499 * @return status code 500 * 501 * @example 502 * #include "stdlib/ndarray/base/unary/d_l.h" 503 * #include "stdlib/ndarray/dtypes.h" 504 * #include "stdlib/ndarray/index_modes.h" 505 * #include "stdlib/ndarray/orders.h" 506 * #include "stdlib/ndarray/ctor.h" 507 * #include <stdint.h> 508 * #include <stdlib.h> 509 * #include <stdio.h> 510 * #include <math.h> 511 * 512 * // Define the ndarray data types: 513 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 514 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 515 * 516 * // Create underlying byte arrays: 517 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 518 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 519 * 520 * // Define the number of dimensions: 521 * int64_t ndims = 3; 522 * 523 * // Define the array shapes: 524 * int64_t shape[] = { 2, 2, 2 }; 525 * 526 * // Define the strides: 527 * int64_t sx[] = { 32, 16, 8 }; 528 * int64_t sy[] = { 32, 16, 8 }; 529 * 530 * // Define the offsets: 531 * int64_t ox = 0; 532 * int64_t oy = 0; 533 * 534 * // Define the array order: 535 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 536 * 537 * // Specify the index mode: 538 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 539 * 540 * // Specify the subscript index modes: 541 * int8_t submodes[] = { imode }; 542 * int64_t nsubmodes = 1; 543 * 544 * // Create an input ndarray: 545 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 546 * if ( x == NULL ) { 547 * fprintf( stderr, "Error allocating memory.\n" ); 548 * exit( EXIT_FAILURE ); 549 * } 550 * 551 * // Create an output ndarray: 552 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 553 * if ( y == NULL ) { 554 * fprintf( stderr, "Error allocating memory.\n" ); 555 * exit( EXIT_FAILURE ); 556 * } 557 * 558 * // Create an array containing the ndarrays: 559 * struct ndarray *arrays[] = { x, y }; 560 * 561 * // Apply a callback: 562 * int8_t status = stdlib_ndarray_d_l_3d_blocked( arrays, (void *)llrint ); 563 * if ( status != 0 ) { 564 * fprintf( stderr, "Error during computation.\n" ); 565 * exit( EXIT_FAILURE ); 566 * } 567 * 568 * // ... 569 * 570 * // Free allocated memory: 571 * stdlib_ndarray_free( x ); 572 * stdlib_ndarray_free( y ); 573 */ 574 int8_t stdlib_ndarray_d_l_3d_blocked( struct ndarray *arrays[], void *fcn ) { 575 typedef int64_t func_type( const double x ); 576 func_type *f = (func_type *)fcn; 577 STDLIB_NDARRAY_UNARY_3D_BLOCKED_LOOP_CLBK( double, int64_t ) 578 return 0; 579 } 580 581 /** 582 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a four-dimensional double-precision floating-point input ndarray and assigns results to elements in a four-dimensional signed 64-bit integer output ndarray. 583 * 584 * ## Notes 585 * 586 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 587 * 588 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 589 * @param fcn callback 590 * @return status code 591 * 592 * @example 593 * #include "stdlib/ndarray/base/unary/d_l.h" 594 * #include "stdlib/ndarray/dtypes.h" 595 * #include "stdlib/ndarray/index_modes.h" 596 * #include "stdlib/ndarray/orders.h" 597 * #include "stdlib/ndarray/ctor.h" 598 * #include <stdint.h> 599 * #include <stdlib.h> 600 * #include <stdio.h> 601 * #include <math.h> 602 * 603 * // Define the ndarray data types: 604 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 605 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 606 * 607 * // Create underlying byte arrays: 608 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 609 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 610 * 611 * // Define the number of dimensions: 612 * int64_t ndims = 4; 613 * 614 * // Define the array shapes: 615 * int64_t shape[] = { 1, 2, 2, 2 }; 616 * 617 * // Define the strides: 618 * int64_t sx[] = { 32, 32, 16, 8 }; 619 * int64_t sy[] = { 32, 32, 16, 8 }; 620 * 621 * // Define the offsets: 622 * int64_t ox = 0; 623 * int64_t oy = 0; 624 * 625 * // Define the array order: 626 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 627 * 628 * // Specify the index mode: 629 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 630 * 631 * // Specify the subscript index modes: 632 * int8_t submodes[] = { imode }; 633 * int64_t nsubmodes = 1; 634 * 635 * // Create an input ndarray: 636 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 637 * if ( x == NULL ) { 638 * fprintf( stderr, "Error allocating memory.\n" ); 639 * exit( EXIT_FAILURE ); 640 * } 641 * 642 * // Create an output ndarray: 643 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 644 * if ( y == NULL ) { 645 * fprintf( stderr, "Error allocating memory.\n" ); 646 * exit( EXIT_FAILURE ); 647 * } 648 * 649 * // Create an array containing the ndarrays: 650 * struct ndarray *arrays[] = { x, y }; 651 * 652 * // Apply a callback: 653 * int8_t status = stdlib_ndarray_d_l_4d( arrays, (void *)llrint ); 654 * if ( status != 0 ) { 655 * fprintf( stderr, "Error during computation.\n" ); 656 * exit( EXIT_FAILURE ); 657 * } 658 * 659 * // ... 660 * 661 * // Free allocated memory: 662 * stdlib_ndarray_free( x ); 663 * stdlib_ndarray_free( y ); 664 */ 665 int8_t stdlib_ndarray_d_l_4d( struct ndarray *arrays[], void *fcn ) { 666 typedef int64_t func_type( const double x ); 667 func_type *f = (func_type *)fcn; 668 STDLIB_NDARRAY_UNARY_4D_LOOP_CLBK( double, int64_t ) 669 return 0; 670 } 671 672 /** 673 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a four-dimensional double-precision floating-point input ndarray and assigns results to elements in a four-dimensional signed 64-bit integer output ndarray. 674 * 675 * ## Notes 676 * 677 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 678 * 679 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 680 * @param fcn callback 681 * @return status code 682 * 683 * @example 684 * #include "stdlib/ndarray/base/unary/d_l.h" 685 * #include "stdlib/ndarray/dtypes.h" 686 * #include "stdlib/ndarray/index_modes.h" 687 * #include "stdlib/ndarray/orders.h" 688 * #include "stdlib/ndarray/ctor.h" 689 * #include <stdint.h> 690 * #include <stdlib.h> 691 * #include <stdio.h> 692 * #include <math.h> 693 * 694 * // Define the ndarray data types: 695 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 696 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 697 * 698 * // Create underlying byte arrays: 699 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 700 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 701 * 702 * // Define the number of dimensions: 703 * int64_t ndims = 4; 704 * 705 * // Define the array shapes: 706 * int64_t shape[] = { 1, 2, 2, 2 }; 707 * 708 * // Define the strides: 709 * int64_t sx[] = { 32, 32, 16, 8 }; 710 * int64_t sy[] = { 32, 32, 16, 8 }; 711 * 712 * // Define the offsets: 713 * int64_t ox = 0; 714 * int64_t oy = 0; 715 * 716 * // Define the array order: 717 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 718 * 719 * // Specify the index mode: 720 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 721 * 722 * // Specify the subscript index modes: 723 * int8_t submodes[] = { imode }; 724 * int64_t nsubmodes = 1; 725 * 726 * // Create an input ndarray: 727 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 728 * if ( x == NULL ) { 729 * fprintf( stderr, "Error allocating memory.\n" ); 730 * exit( EXIT_FAILURE ); 731 * } 732 * 733 * // Create an output ndarray: 734 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 735 * if ( y == NULL ) { 736 * fprintf( stderr, "Error allocating memory.\n" ); 737 * exit( EXIT_FAILURE ); 738 * } 739 * 740 * // Create an array containing the ndarrays: 741 * struct ndarray *arrays[] = { x, y }; 742 * 743 * // Apply a callback: 744 * int8_t status = stdlib_ndarray_d_l_4d_blocked( arrays, (void *)llrint ); 745 * if ( status != 0 ) { 746 * fprintf( stderr, "Error during computation.\n" ); 747 * exit( EXIT_FAILURE ); 748 * } 749 * 750 * // ... 751 * 752 * // Free allocated memory: 753 * stdlib_ndarray_free( x ); 754 * stdlib_ndarray_free( y ); 755 */ 756 int8_t stdlib_ndarray_d_l_4d_blocked( struct ndarray *arrays[], void *fcn ) { 757 typedef int64_t func_type( const double x ); 758 func_type *f = (func_type *)fcn; 759 STDLIB_NDARRAY_UNARY_4D_BLOCKED_LOOP_CLBK( double, int64_t ) 760 return 0; 761 } 762 763 /** 764 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a five-dimensional double-precision floating-point input ndarray and assigns results to elements in a five-dimensional signed 64-bit integer output ndarray. 765 * 766 * ## Notes 767 * 768 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 769 * 770 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 771 * @param fcn callback 772 * @return status code 773 * 774 * @example 775 * #include "stdlib/ndarray/base/unary/d_l.h" 776 * #include "stdlib/ndarray/dtypes.h" 777 * #include "stdlib/ndarray/index_modes.h" 778 * #include "stdlib/ndarray/orders.h" 779 * #include "stdlib/ndarray/ctor.h" 780 * #include <stdint.h> 781 * #include <stdlib.h> 782 * #include <stdio.h> 783 * #include <math.h> 784 * 785 * // Define the ndarray data types: 786 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 787 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 788 * 789 * // Create underlying byte arrays: 790 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 791 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 792 * 793 * // Define the number of dimensions: 794 * int64_t ndims = 5; 795 * 796 * // Define the array shapes: 797 * int64_t shape[] = { 1, 1, 2, 2, 2 }; 798 * 799 * // Define the strides: 800 * int64_t sx[] = { 32, 32, 32, 16, 8 }; 801 * int64_t sy[] = { 32, 32, 32, 16, 8 }; 802 * 803 * // Define the offsets: 804 * int64_t ox = 0; 805 * int64_t oy = 0; 806 * 807 * // Define the array order: 808 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 809 * 810 * // Specify the index mode: 811 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 812 * 813 * // Specify the subscript index modes: 814 * int8_t submodes[] = { imode }; 815 * int64_t nsubmodes = 1; 816 * 817 * // Create an input ndarray: 818 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 819 * if ( x == NULL ) { 820 * fprintf( stderr, "Error allocating memory.\n" ); 821 * exit( EXIT_FAILURE ); 822 * } 823 * 824 * // Create an output ndarray: 825 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 826 * if ( y == NULL ) { 827 * fprintf( stderr, "Error allocating memory.\n" ); 828 * exit( EXIT_FAILURE ); 829 * } 830 * 831 * // Create an array containing the ndarrays: 832 * struct ndarray *arrays[] = { x, y }; 833 * 834 * // Apply a callback: 835 * int8_t status = stdlib_ndarray_d_l_5d( arrays, (void *)llrint ); 836 * if ( status != 0 ) { 837 * fprintf( stderr, "Error during computation.\n" ); 838 * exit( EXIT_FAILURE ); 839 * } 840 * 841 * // ... 842 * 843 * // Free allocated memory: 844 * stdlib_ndarray_free( x ); 845 * stdlib_ndarray_free( y ); 846 */ 847 int8_t stdlib_ndarray_d_l_5d( struct ndarray *arrays[], void *fcn ) { 848 typedef int64_t func_type( const double x ); 849 func_type *f = (func_type *)fcn; 850 STDLIB_NDARRAY_UNARY_5D_LOOP_CLBK( double, int64_t ) 851 return 0; 852 } 853 854 /** 855 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a five-dimensional double-precision floating-point input ndarray and assigns results to elements in a five-dimensional signed 64-bit integer output ndarray. 856 * 857 * ## Notes 858 * 859 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 860 * 861 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 862 * @param fcn callback 863 * @return status code 864 * 865 * @example 866 * #include "stdlib/ndarray/base/unary/d_l.h" 867 * #include "stdlib/ndarray/dtypes.h" 868 * #include "stdlib/ndarray/index_modes.h" 869 * #include "stdlib/ndarray/orders.h" 870 * #include "stdlib/ndarray/ctor.h" 871 * #include <stdint.h> 872 * #include <stdlib.h> 873 * #include <stdio.h> 874 * #include <math.h> 875 * 876 * // Define the ndarray data types: 877 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 878 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 879 * 880 * // Create underlying byte arrays: 881 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 882 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 883 * 884 * // Define the number of dimensions: 885 * int64_t ndims = 5; 886 * 887 * // Define the array shapes: 888 * int64_t shape[] = { 1, 1, 2, 2, 2 }; 889 * 890 * // Define the strides: 891 * int64_t sx[] = { 32, 32, 32, 16, 8 }; 892 * int64_t sy[] = { 32, 32, 32, 16, 8 }; 893 * 894 * // Define the offsets: 895 * int64_t ox = 0; 896 * int64_t oy = 0; 897 * 898 * // Define the array order: 899 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 900 * 901 * // Specify the index mode: 902 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 903 * 904 * // Specify the subscript index modes: 905 * int8_t submodes[] = { imode }; 906 * int64_t nsubmodes = 1; 907 * 908 * // Create an input ndarray: 909 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 910 * if ( x == NULL ) { 911 * fprintf( stderr, "Error allocating memory.\n" ); 912 * exit( EXIT_FAILURE ); 913 * } 914 * 915 * // Create an output ndarray: 916 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 917 * if ( y == NULL ) { 918 * fprintf( stderr, "Error allocating memory.\n" ); 919 * exit( EXIT_FAILURE ); 920 * } 921 * 922 * // Create an array containing the ndarrays: 923 * struct ndarray *arrays[] = { x, y }; 924 * 925 * // Apply a callback: 926 * int8_t status = stdlib_ndarray_d_l_5d_blocked( arrays, (void *)llrint ); 927 * if ( status != 0 ) { 928 * fprintf( stderr, "Error during computation.\n" ); 929 * exit( EXIT_FAILURE ); 930 * } 931 * 932 * // ... 933 * 934 * // Free allocated memory: 935 * stdlib_ndarray_free( x ); 936 * stdlib_ndarray_free( y ); 937 */ 938 int8_t stdlib_ndarray_d_l_5d_blocked( struct ndarray *arrays[], void *fcn ) { 939 typedef int64_t func_type( const double x ); 940 func_type *f = (func_type *)fcn; 941 STDLIB_NDARRAY_UNARY_5D_BLOCKED_LOOP_CLBK( double, int64_t ) 942 return 0; 943 } 944 945 /** 946 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a six-dimensional double-precision floating-point input ndarray and assigns results to elements in a six-dimensional signed 64-bit integer output ndarray. 947 * 948 * ## Notes 949 * 950 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 951 * 952 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 953 * @param fcn callback 954 * @return status code 955 * 956 * @example 957 * #include "stdlib/ndarray/base/unary/d_l.h" 958 * #include "stdlib/ndarray/dtypes.h" 959 * #include "stdlib/ndarray/index_modes.h" 960 * #include "stdlib/ndarray/orders.h" 961 * #include "stdlib/ndarray/ctor.h" 962 * #include <stdint.h> 963 * #include <stdlib.h> 964 * #include <stdio.h> 965 * #include <math.h> 966 * 967 * // Define the ndarray data types: 968 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 969 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 970 * 971 * // Create underlying byte arrays: 972 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 973 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 974 * 975 * // Define the number of dimensions: 976 * int64_t ndims = 6; 977 * 978 * // Define the array shapes: 979 * int64_t shape[] = { 1, 1, 1, 2, 2, 2 }; 980 * 981 * // Define the strides: 982 * int64_t sx[] = { 32, 32, 32, 32, 16, 8 }; 983 * int64_t sy[] = { 32, 32, 32, 32, 16, 8 }; 984 * 985 * // Define the offsets: 986 * int64_t ox = 0; 987 * int64_t oy = 0; 988 * 989 * // Define the array order: 990 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 991 * 992 * // Specify the index mode: 993 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 994 * 995 * // Specify the subscript index modes: 996 * int8_t submodes[] = { imode }; 997 * int64_t nsubmodes = 1; 998 * 999 * // Create an input ndarray: 1000 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1001 * if ( x == NULL ) { 1002 * fprintf( stderr, "Error allocating memory.\n" ); 1003 * exit( EXIT_FAILURE ); 1004 * } 1005 * 1006 * // Create an output ndarray: 1007 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1008 * if ( y == NULL ) { 1009 * fprintf( stderr, "Error allocating memory.\n" ); 1010 * exit( EXIT_FAILURE ); 1011 * } 1012 * 1013 * // Create an array containing the ndarrays: 1014 * struct ndarray *arrays[] = { x, y }; 1015 * 1016 * // Apply a callback: 1017 * int8_t status = stdlib_ndarray_d_l_6d( arrays, (void *)llrint ); 1018 * if ( status != 0 ) { 1019 * fprintf( stderr, "Error during computation.\n" ); 1020 * exit( EXIT_FAILURE ); 1021 * } 1022 * 1023 * // ... 1024 * 1025 * // Free allocated memory: 1026 * stdlib_ndarray_free( x ); 1027 * stdlib_ndarray_free( y ); 1028 */ 1029 int8_t stdlib_ndarray_d_l_6d( struct ndarray *arrays[], void *fcn ) { 1030 typedef int64_t func_type( const double x ); 1031 func_type *f = (func_type *)fcn; 1032 STDLIB_NDARRAY_UNARY_6D_LOOP_CLBK( double, int64_t ) 1033 return 0; 1034 } 1035 1036 /** 1037 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a six-dimensional double-precision floating-point input ndarray and assigns results to elements in a six-dimensional signed 64-bit integer output ndarray. 1038 * 1039 * ## Notes 1040 * 1041 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1042 * 1043 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1044 * @param fcn callback 1045 * @return status code 1046 * 1047 * @example 1048 * #include "stdlib/ndarray/base/unary/d_l.h" 1049 * #include "stdlib/ndarray/dtypes.h" 1050 * #include "stdlib/ndarray/index_modes.h" 1051 * #include "stdlib/ndarray/orders.h" 1052 * #include "stdlib/ndarray/ctor.h" 1053 * #include <stdint.h> 1054 * #include <stdlib.h> 1055 * #include <stdio.h> 1056 * #include <math.h> 1057 * 1058 * // Define the ndarray data types: 1059 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1060 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1061 * 1062 * // Create underlying byte arrays: 1063 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1064 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1065 * 1066 * // Define the number of dimensions: 1067 * int64_t ndims = 6; 1068 * 1069 * // Define the array shapes: 1070 * int64_t shape[] = { 1, 1, 1, 2, 2, 2 }; 1071 * 1072 * // Define the strides: 1073 * int64_t sx[] = { 32, 32, 32, 32, 16, 8 }; 1074 * int64_t sy[] = { 32, 32, 32, 32, 16, 8 }; 1075 * 1076 * // Define the offsets: 1077 * int64_t ox = 0; 1078 * int64_t oy = 0; 1079 * 1080 * // Define the array order: 1081 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1082 * 1083 * // Specify the index mode: 1084 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1085 * 1086 * // Specify the subscript index modes: 1087 * int8_t submodes[] = { imode }; 1088 * int64_t nsubmodes = 1; 1089 * 1090 * // Create an input ndarray: 1091 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1092 * if ( x == NULL ) { 1093 * fprintf( stderr, "Error allocating memory.\n" ); 1094 * exit( EXIT_FAILURE ); 1095 * } 1096 * 1097 * // Create an output ndarray: 1098 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1099 * if ( y == NULL ) { 1100 * fprintf( stderr, "Error allocating memory.\n" ); 1101 * exit( EXIT_FAILURE ); 1102 * } 1103 * 1104 * // Create an array containing the ndarrays: 1105 * struct ndarray *arrays[] = { x, y }; 1106 * 1107 * // Apply a callback: 1108 * int8_t status = stdlib_ndarray_d_l_6d_blocked( arrays, (void *)llrint ); 1109 * if ( status != 0 ) { 1110 * fprintf( stderr, "Error during computation.\n" ); 1111 * exit( EXIT_FAILURE ); 1112 * } 1113 * 1114 * // ... 1115 * 1116 * // Free allocated memory: 1117 * stdlib_ndarray_free( x ); 1118 * stdlib_ndarray_free( y ); 1119 */ 1120 int8_t stdlib_ndarray_d_l_6d_blocked( struct ndarray *arrays[], void *fcn ) { 1121 typedef int64_t func_type( const double x ); 1122 func_type *f = (func_type *)fcn; 1123 STDLIB_NDARRAY_UNARY_6D_BLOCKED_LOOP_CLBK( double, int64_t ) 1124 return 0; 1125 } 1126 1127 /** 1128 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a seven-dimensional double-precision floating-point input ndarray and assigns results to elements in a seven-dimensional signed 64-bit integer output ndarray. 1129 * 1130 * ## Notes 1131 * 1132 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1133 * 1134 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1135 * @param fcn callback 1136 * @return status code 1137 * 1138 * @example 1139 * #include "stdlib/ndarray/base/unary/d_l.h" 1140 * #include "stdlib/ndarray/dtypes.h" 1141 * #include "stdlib/ndarray/index_modes.h" 1142 * #include "stdlib/ndarray/orders.h" 1143 * #include "stdlib/ndarray/ctor.h" 1144 * #include <stdint.h> 1145 * #include <stdlib.h> 1146 * #include <stdio.h> 1147 * #include <math.h> 1148 * 1149 * // Define the ndarray data types: 1150 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1151 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1152 * 1153 * // Create underlying byte arrays: 1154 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1155 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1156 * 1157 * // Define the number of dimensions: 1158 * int64_t ndims = 7; 1159 * 1160 * // Define the array shapes: 1161 * int64_t shape[] = { 1, 1, 1, 1, 2, 2, 2 }; 1162 * 1163 * // Define the strides: 1164 * int64_t sx[] = { 32, 32, 32, 32, 32, 16, 8 }; 1165 * int64_t sy[] = { 32, 32, 32, 32, 32, 16, 8 }; 1166 * 1167 * // Define the offsets: 1168 * int64_t ox = 0; 1169 * int64_t oy = 0; 1170 * 1171 * // Define the array order: 1172 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1173 * 1174 * // Specify the index mode: 1175 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1176 * 1177 * // Specify the subscript index modes: 1178 * int8_t submodes[] = { imode }; 1179 * int64_t nsubmodes = 1; 1180 * 1181 * // Create an input ndarray: 1182 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1183 * if ( x == NULL ) { 1184 * fprintf( stderr, "Error allocating memory.\n" ); 1185 * exit( EXIT_FAILURE ); 1186 * } 1187 * 1188 * // Create an output ndarray: 1189 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1190 * if ( y == NULL ) { 1191 * fprintf( stderr, "Error allocating memory.\n" ); 1192 * exit( EXIT_FAILURE ); 1193 * } 1194 * 1195 * // Create an array containing the ndarrays: 1196 * struct ndarray *arrays[] = { x, y }; 1197 * 1198 * // Apply a callback: 1199 * int8_t status = stdlib_ndarray_d_l_7d( arrays, (void *)llrint ); 1200 * if ( status != 0 ) { 1201 * fprintf( stderr, "Error during computation.\n" ); 1202 * exit( EXIT_FAILURE ); 1203 * } 1204 * 1205 * // ... 1206 * 1207 * // Free allocated memory: 1208 * stdlib_ndarray_free( x ); 1209 * stdlib_ndarray_free( y ); 1210 */ 1211 int8_t stdlib_ndarray_d_l_7d( struct ndarray *arrays[], void *fcn ) { 1212 typedef int64_t func_type( const double x ); 1213 func_type *f = (func_type *)fcn; 1214 STDLIB_NDARRAY_UNARY_7D_LOOP_CLBK( double, int64_t ) 1215 return 0; 1216 } 1217 1218 /** 1219 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a seven-dimensional double-precision floating-point input ndarray and assigns results to elements in a seven-dimensional signed 64-bit integer output ndarray. 1220 * 1221 * ## Notes 1222 * 1223 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1224 * 1225 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1226 * @param fcn callback 1227 * @return status code 1228 * 1229 * @example 1230 * #include "stdlib/ndarray/base/unary/d_l.h" 1231 * #include "stdlib/ndarray/dtypes.h" 1232 * #include "stdlib/ndarray/index_modes.h" 1233 * #include "stdlib/ndarray/orders.h" 1234 * #include "stdlib/ndarray/ctor.h" 1235 * #include <stdint.h> 1236 * #include <stdlib.h> 1237 * #include <stdio.h> 1238 * #include <math.h> 1239 * 1240 * // Define the ndarray data types: 1241 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1242 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1243 * 1244 * // Create underlying byte arrays: 1245 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1246 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1247 * 1248 * // Define the number of dimensions: 1249 * int64_t ndims = 7; 1250 * 1251 * // Define the array shapes: 1252 * int64_t shape[] = { 1, 1, 1, 1, 2, 2, 2 }; 1253 * 1254 * // Define the strides: 1255 * int64_t sx[] = { 32, 32, 32, 32, 32, 16, 8 }; 1256 * int64_t sy[] = { 32, 32, 32, 32, 32, 16, 8 }; 1257 * 1258 * // Define the offsets: 1259 * int64_t ox = 0; 1260 * int64_t oy = 0; 1261 * 1262 * // Define the array order: 1263 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1264 * 1265 * // Specify the index mode: 1266 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1267 * 1268 * // Specify the subscript index modes: 1269 * int8_t submodes[] = { imode }; 1270 * int64_t nsubmodes = 1; 1271 * 1272 * // Create an input ndarray: 1273 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1274 * if ( x == NULL ) { 1275 * fprintf( stderr, "Error allocating memory.\n" ); 1276 * exit( EXIT_FAILURE ); 1277 * } 1278 * 1279 * // Create an output ndarray: 1280 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1281 * if ( y == NULL ) { 1282 * fprintf( stderr, "Error allocating memory.\n" ); 1283 * exit( EXIT_FAILURE ); 1284 * } 1285 * 1286 * // Create an array containing the ndarrays: 1287 * struct ndarray *arrays[] = { x, y }; 1288 * 1289 * // Apply a callback: 1290 * int8_t status = stdlib_ndarray_d_l_7d_blocked( arrays, (void *)llrint ); 1291 * if ( status != 0 ) { 1292 * fprintf( stderr, "Error during computation.\n" ); 1293 * exit( EXIT_FAILURE ); 1294 * } 1295 * 1296 * // ... 1297 * 1298 * // Free allocated memory: 1299 * stdlib_ndarray_free( x ); 1300 * stdlib_ndarray_free( y ); 1301 */ 1302 int8_t stdlib_ndarray_d_l_7d_blocked( struct ndarray *arrays[], void *fcn ) { 1303 typedef int64_t func_type( const double x ); 1304 func_type *f = (func_type *)fcn; 1305 STDLIB_NDARRAY_UNARY_7D_BLOCKED_LOOP_CLBK( double, int64_t ) 1306 return 0; 1307 } 1308 1309 /** 1310 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to an eight-dimensional double-precision floating-point input ndarray and assigns results to elements in an eight-dimensional signed 64-bit integer output ndarray. 1311 * 1312 * ## Notes 1313 * 1314 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1315 * 1316 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1317 * @param fcn callback 1318 * @return status code 1319 * 1320 * @example 1321 * #include "stdlib/ndarray/base/unary/d_l.h" 1322 * #include "stdlib/ndarray/dtypes.h" 1323 * #include "stdlib/ndarray/index_modes.h" 1324 * #include "stdlib/ndarray/orders.h" 1325 * #include "stdlib/ndarray/ctor.h" 1326 * #include <stdint.h> 1327 * #include <stdlib.h> 1328 * #include <stdio.h> 1329 * #include <math.h> 1330 * 1331 * // Define the ndarray data types: 1332 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1333 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1334 * 1335 * // Create underlying byte arrays: 1336 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1337 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1338 * 1339 * // Define the number of dimensions: 1340 * int64_t ndims = 8; 1341 * 1342 * // Define the array shapes: 1343 * int64_t shape[] = { 1, 1, 1, 1, 1, 2, 2, 2 }; 1344 * 1345 * // Define the strides: 1346 * int64_t sx[] = { 32, 32, 32, 32, 32, 32, 16, 8 }; 1347 * int64_t sy[] = { 32, 32, 32, 32, 32, 32, 16, 8 }; 1348 * 1349 * // Define the offsets: 1350 * int64_t ox = 0; 1351 * int64_t oy = 0; 1352 * 1353 * // Define the array order: 1354 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1355 * 1356 * // Specify the index mode: 1357 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1358 * 1359 * // Specify the subscript index modes: 1360 * int8_t submodes[] = { imode }; 1361 * int64_t nsubmodes = 1; 1362 * 1363 * // Create an input ndarray: 1364 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1365 * if ( x == NULL ) { 1366 * fprintf( stderr, "Error allocating memory.\n" ); 1367 * exit( EXIT_FAILURE ); 1368 * } 1369 * 1370 * // Create an output ndarray: 1371 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1372 * if ( y == NULL ) { 1373 * fprintf( stderr, "Error allocating memory.\n" ); 1374 * exit( EXIT_FAILURE ); 1375 * } 1376 * 1377 * // Create an array containing the ndarrays: 1378 * struct ndarray *arrays[] = { x, y }; 1379 * 1380 * // Apply a callback: 1381 * int8_t status = stdlib_ndarray_d_l_8d( arrays, (void *)llrint ); 1382 * if ( status != 0 ) { 1383 * fprintf( stderr, "Error during computation.\n" ); 1384 * exit( EXIT_FAILURE ); 1385 * } 1386 * 1387 * // ... 1388 * 1389 * // Free allocated memory: 1390 * stdlib_ndarray_free( x ); 1391 * stdlib_ndarray_free( y ); 1392 */ 1393 int8_t stdlib_ndarray_d_l_8d( struct ndarray *arrays[], void *fcn ) { 1394 typedef int64_t func_type( const double x ); 1395 func_type *f = (func_type *)fcn; 1396 STDLIB_NDARRAY_UNARY_8D_LOOP_CLBK( double, int64_t ) 1397 return 0; 1398 } 1399 1400 /** 1401 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to an eight-dimensional double-precision floating-point input ndarray and assigns results to elements in an eight-dimensional signed 64-bit integer output ndarray. 1402 * 1403 * ## Notes 1404 * 1405 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1406 * 1407 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1408 * @param fcn callback 1409 * @return status code 1410 * 1411 * @example 1412 * #include "stdlib/ndarray/base/unary/d_l.h" 1413 * #include "stdlib/ndarray/dtypes.h" 1414 * #include "stdlib/ndarray/index_modes.h" 1415 * #include "stdlib/ndarray/orders.h" 1416 * #include "stdlib/ndarray/ctor.h" 1417 * #include <stdint.h> 1418 * #include <stdlib.h> 1419 * #include <stdio.h> 1420 * #include <math.h> 1421 * 1422 * // Define the ndarray data types: 1423 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1424 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1425 * 1426 * // Create underlying byte arrays: 1427 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1428 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1429 * 1430 * // Define the number of dimensions: 1431 * int64_t ndims = 8; 1432 * 1433 * // Define the array shapes: 1434 * int64_t shape[] = { 1, 1, 1, 1, 1, 2, 2, 2 }; 1435 * 1436 * // Define the strides: 1437 * int64_t sx[] = { 32, 32, 32, 32, 32, 32, 16, 8 }; 1438 * int64_t sy[] = { 32, 32, 32, 32, 32, 32, 16, 8 }; 1439 * 1440 * // Define the offsets: 1441 * int64_t ox = 0; 1442 * int64_t oy = 0; 1443 * 1444 * // Define the array order: 1445 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1446 * 1447 * // Specify the index mode: 1448 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1449 * 1450 * // Specify the subscript index modes: 1451 * int8_t submodes[] = { imode }; 1452 * int64_t nsubmodes = 1; 1453 * 1454 * // Create an input ndarray: 1455 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1456 * if ( x == NULL ) { 1457 * fprintf( stderr, "Error allocating memory.\n" ); 1458 * exit( EXIT_FAILURE ); 1459 * } 1460 * 1461 * // Create an output ndarray: 1462 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1463 * if ( y == NULL ) { 1464 * fprintf( stderr, "Error allocating memory.\n" ); 1465 * exit( EXIT_FAILURE ); 1466 * } 1467 * 1468 * // Create an array containing the ndarrays: 1469 * struct ndarray *arrays[] = { x, y }; 1470 * 1471 * // Apply a callback: 1472 * int8_t status = stdlib_ndarray_d_l_8d_blocked( arrays, (void *)llrint ); 1473 * if ( status != 0 ) { 1474 * fprintf( stderr, "Error during computation.\n" ); 1475 * exit( EXIT_FAILURE ); 1476 * } 1477 * 1478 * // ... 1479 * 1480 * // Free allocated memory: 1481 * stdlib_ndarray_free( x ); 1482 * stdlib_ndarray_free( y ); 1483 */ 1484 int8_t stdlib_ndarray_d_l_8d_blocked( struct ndarray *arrays[], void *fcn ) { 1485 typedef int64_t func_type( const double x ); 1486 func_type *f = (func_type *)fcn; 1487 STDLIB_NDARRAY_UNARY_8D_BLOCKED_LOOP_CLBK( double, int64_t ) 1488 return 0; 1489 } 1490 1491 /** 1492 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a nine-dimensional double-precision floating-point input ndarray and assigns results to elements in a nine-dimensional signed 64-bit integer output ndarray. 1493 * 1494 * ## Notes 1495 * 1496 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1497 * 1498 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1499 * @param fcn callback 1500 * @return status code 1501 * 1502 * @example 1503 * #include "stdlib/ndarray/base/unary/d_l.h" 1504 * #include "stdlib/ndarray/dtypes.h" 1505 * #include "stdlib/ndarray/index_modes.h" 1506 * #include "stdlib/ndarray/orders.h" 1507 * #include "stdlib/ndarray/ctor.h" 1508 * #include <stdint.h> 1509 * #include <stdlib.h> 1510 * #include <stdio.h> 1511 * #include <math.h> 1512 * 1513 * // Define the ndarray data types: 1514 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1515 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1516 * 1517 * // Create underlying byte arrays: 1518 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1519 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1520 * 1521 * // Define the number of dimensions: 1522 * int64_t ndims = 9; 1523 * 1524 * // Define the array shapes: 1525 * int64_t shape[] = { 1, 1, 1, 1, 1, 1, 2, 2, 2 }; 1526 * 1527 * // Define the strides: 1528 * int64_t sx[] = { 32, 32, 32, 32, 32, 32, 32, 16, 8 }; 1529 * int64_t sy[] = { 32, 32, 32, 32, 32, 32, 32, 16, 8 }; 1530 * 1531 * // Define the offsets: 1532 * int64_t ox = 0; 1533 * int64_t oy = 0; 1534 * 1535 * // Define the array order: 1536 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1537 * 1538 * // Specify the index mode: 1539 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1540 * 1541 * // Specify the subscript index modes: 1542 * int8_t submodes[] = { imode }; 1543 * int64_t nsubmodes = 1; 1544 * 1545 * // Create an input ndarray: 1546 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1547 * if ( x == NULL ) { 1548 * fprintf( stderr, "Error allocating memory.\n" ); 1549 * exit( EXIT_FAILURE ); 1550 * } 1551 * 1552 * // Create an output ndarray: 1553 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1554 * if ( y == NULL ) { 1555 * fprintf( stderr, "Error allocating memory.\n" ); 1556 * exit( EXIT_FAILURE ); 1557 * } 1558 * 1559 * // Create an array containing the ndarrays: 1560 * struct ndarray *arrays[] = { x, y }; 1561 * 1562 * // Apply a callback: 1563 * int8_t status = stdlib_ndarray_d_l_9d( arrays, (void *)llrint ); 1564 * if ( status != 0 ) { 1565 * fprintf( stderr, "Error during computation.\n" ); 1566 * exit( EXIT_FAILURE ); 1567 * } 1568 * 1569 * // ... 1570 * 1571 * // Free allocated memory: 1572 * stdlib_ndarray_free( x ); 1573 * stdlib_ndarray_free( y ); 1574 */ 1575 int8_t stdlib_ndarray_d_l_9d( struct ndarray *arrays[], void *fcn ) { 1576 typedef int64_t func_type( const double x ); 1577 func_type *f = (func_type *)fcn; 1578 STDLIB_NDARRAY_UNARY_9D_LOOP_CLBK( double, int64_t ) 1579 return 0; 1580 } 1581 1582 /** 1583 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a nine-dimensional double-precision floating-point input ndarray and assigns results to elements in a nine-dimensional signed 64-bit integer output ndarray. 1584 * 1585 * ## Notes 1586 * 1587 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1588 * 1589 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1590 * @param fcn callback 1591 * @return status code 1592 * 1593 * @example 1594 * #include "stdlib/ndarray/base/unary/d_l.h" 1595 * #include "stdlib/ndarray/dtypes.h" 1596 * #include "stdlib/ndarray/index_modes.h" 1597 * #include "stdlib/ndarray/orders.h" 1598 * #include "stdlib/ndarray/ctor.h" 1599 * #include <stdint.h> 1600 * #include <stdlib.h> 1601 * #include <stdio.h> 1602 * #include <math.h> 1603 * 1604 * // Define the ndarray data types: 1605 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1606 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1607 * 1608 * // Create underlying byte arrays: 1609 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1610 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1611 * 1612 * // Define the number of dimensions: 1613 * int64_t ndims = 9; 1614 * 1615 * // Define the array shapes: 1616 * int64_t shape[] = { 1, 1, 1, 1, 1, 1, 2, 2, 2 }; 1617 * 1618 * // Define the strides: 1619 * int64_t sx[] = { 32, 32, 32, 32, 32, 32, 32, 16, 8 }; 1620 * int64_t sy[] = { 32, 32, 32, 32, 32, 32, 32, 16, 8 }; 1621 * 1622 * // Define the offsets: 1623 * int64_t ox = 0; 1624 * int64_t oy = 0; 1625 * 1626 * // Define the array order: 1627 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1628 * 1629 * // Specify the index mode: 1630 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1631 * 1632 * // Specify the subscript index modes: 1633 * int8_t submodes[] = { imode }; 1634 * int64_t nsubmodes = 1; 1635 * 1636 * // Create an input ndarray: 1637 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1638 * if ( x == NULL ) { 1639 * fprintf( stderr, "Error allocating memory.\n" ); 1640 * exit( EXIT_FAILURE ); 1641 * } 1642 * 1643 * // Create an output ndarray: 1644 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1645 * if ( y == NULL ) { 1646 * fprintf( stderr, "Error allocating memory.\n" ); 1647 * exit( EXIT_FAILURE ); 1648 * } 1649 * 1650 * // Create an array containing the ndarrays: 1651 * struct ndarray *arrays[] = { x, y }; 1652 * 1653 * // Apply a callback: 1654 * int8_t status = stdlib_ndarray_d_l_9d_blocked( arrays, (void *)llrint ); 1655 * if ( status != 0 ) { 1656 * fprintf( stderr, "Error during computation.\n" ); 1657 * exit( EXIT_FAILURE ); 1658 * } 1659 * 1660 * // ... 1661 * 1662 * // Free allocated memory: 1663 * stdlib_ndarray_free( x ); 1664 * stdlib_ndarray_free( y ); 1665 */ 1666 int8_t stdlib_ndarray_d_l_9d_blocked( struct ndarray *arrays[], void *fcn ) { 1667 typedef int64_t func_type( const double x ); 1668 func_type *f = (func_type *)fcn; 1669 STDLIB_NDARRAY_UNARY_9D_BLOCKED_LOOP_CLBK( double, int64_t ) 1670 return 0; 1671 } 1672 1673 /** 1674 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a ten-dimensional double-precision floating-point input ndarray and assigns results to elements in a ten-dimensional signed 64-bit integer output ndarray. 1675 * 1676 * ## Notes 1677 * 1678 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1679 * 1680 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1681 * @param fcn callback 1682 * @return status code 1683 * 1684 * @example 1685 * #include "stdlib/ndarray/base/unary/d_l.h" 1686 * #include "stdlib/ndarray/dtypes.h" 1687 * #include "stdlib/ndarray/index_modes.h" 1688 * #include "stdlib/ndarray/orders.h" 1689 * #include "stdlib/ndarray/ctor.h" 1690 * #include <stdint.h> 1691 * #include <stdlib.h> 1692 * #include <stdio.h> 1693 * #include <math.h> 1694 * 1695 * // Define the ndarray data types: 1696 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1697 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1698 * 1699 * // Create underlying byte arrays: 1700 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1701 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1702 * 1703 * // Define the number of dimensions: 1704 * int64_t ndims = 10; 1705 * 1706 * // Define the array shapes: 1707 * int64_t shape[] = { 1, 1, 1, 1, 1, 1, 1, 2, 2, 2 }; 1708 * 1709 * // Define the strides: 1710 * int64_t sx[] = { 32, 32, 32, 32, 32, 32, 32, 32, 16, 8 }; 1711 * int64_t sy[] = { 32, 32, 32, 32, 32, 32, 32, 32, 16, 8 }; 1712 * 1713 * // Define the offsets: 1714 * int64_t ox = 0; 1715 * int64_t oy = 0; 1716 * 1717 * // Define the array order: 1718 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1719 * 1720 * // Specify the index mode: 1721 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1722 * 1723 * // Specify the subscript index modes: 1724 * int8_t submodes[] = { imode }; 1725 * int64_t nsubmodes = 1; 1726 * 1727 * // Create an input ndarray: 1728 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1729 * if ( x == NULL ) { 1730 * fprintf( stderr, "Error allocating memory.\n" ); 1731 * exit( EXIT_FAILURE ); 1732 * } 1733 * 1734 * // Create an output ndarray: 1735 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1736 * if ( y == NULL ) { 1737 * fprintf( stderr, "Error allocating memory.\n" ); 1738 * exit( EXIT_FAILURE ); 1739 * } 1740 * 1741 * // Create an array containing the ndarrays: 1742 * struct ndarray *arrays[] = { x, y }; 1743 * 1744 * // Apply a callback: 1745 * int8_t status = stdlib_ndarray_d_l_10d( arrays, (void *)llrint ); 1746 * if ( status != 0 ) { 1747 * fprintf( stderr, "Error during computation.\n" ); 1748 * exit( EXIT_FAILURE ); 1749 * } 1750 * 1751 * // ... 1752 * 1753 * // Free allocated memory: 1754 * stdlib_ndarray_free( x ); 1755 * stdlib_ndarray_free( y ); 1756 */ 1757 int8_t stdlib_ndarray_d_l_10d( struct ndarray *arrays[], void *fcn ) { 1758 typedef int64_t func_type( const double x ); 1759 func_type *f = (func_type *)fcn; 1760 STDLIB_NDARRAY_UNARY_10D_LOOP_CLBK( double, int64_t ) 1761 return 0; 1762 } 1763 1764 /** 1765 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a ten-dimensional double-precision floating-point input ndarray and assigns results to elements in a ten-dimensional signed 64-bit integer output ndarray. 1766 * 1767 * ## Notes 1768 * 1769 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1770 * 1771 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1772 * @param fcn callback 1773 * @return status code 1774 * 1775 * @example 1776 * #include "stdlib/ndarray/base/unary/d_l.h" 1777 * #include "stdlib/ndarray/dtypes.h" 1778 * #include "stdlib/ndarray/index_modes.h" 1779 * #include "stdlib/ndarray/orders.h" 1780 * #include "stdlib/ndarray/ctor.h" 1781 * #include <stdint.h> 1782 * #include <stdlib.h> 1783 * #include <stdio.h> 1784 * #include <math.h> 1785 * 1786 * // Define the ndarray data types: 1787 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1788 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1789 * 1790 * // Create underlying byte arrays: 1791 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1792 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1793 * 1794 * // Define the number of dimensions: 1795 * int64_t ndims = 10; 1796 * 1797 * // Define the array shapes: 1798 * int64_t shape[] = { 1, 1, 1, 1, 1, 1, 1, 2, 2, 2 }; 1799 * 1800 * // Define the strides: 1801 * int64_t sx[] = { 32, 32, 32, 32, 32, 32, 32, 32, 16, 8 }; 1802 * int64_t sy[] = { 32, 32, 32, 32, 32, 32, 32, 32, 16, 8 }; 1803 * 1804 * // Define the offsets: 1805 * int64_t ox = 0; 1806 * int64_t oy = 0; 1807 * 1808 * // Define the array order: 1809 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1810 * 1811 * // Specify the index mode: 1812 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1813 * 1814 * // Specify the subscript index modes: 1815 * int8_t submodes[] = { imode }; 1816 * int64_t nsubmodes = 1; 1817 * 1818 * // Create an input ndarray: 1819 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1820 * if ( x == NULL ) { 1821 * fprintf( stderr, "Error allocating memory.\n" ); 1822 * exit( EXIT_FAILURE ); 1823 * } 1824 * 1825 * // Create an output ndarray: 1826 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1827 * if ( y == NULL ) { 1828 * fprintf( stderr, "Error allocating memory.\n" ); 1829 * exit( EXIT_FAILURE ); 1830 * } 1831 * 1832 * // Create an array containing the ndarrays: 1833 * struct ndarray *arrays[] = { x, y }; 1834 * 1835 * // Apply a callback: 1836 * int8_t status = stdlib_ndarray_d_l_10d_blocked( arrays, (void *)llrint ); 1837 * if ( status != 0 ) { 1838 * fprintf( stderr, "Error during computation.\n" ); 1839 * exit( EXIT_FAILURE ); 1840 * } 1841 * 1842 * // ... 1843 * 1844 * // Free allocated memory: 1845 * stdlib_ndarray_free( x ); 1846 * stdlib_ndarray_free( y ); 1847 */ 1848 int8_t stdlib_ndarray_d_l_10d_blocked( struct ndarray *arrays[], void *fcn ) { 1849 typedef int64_t func_type( const double x ); 1850 func_type *f = (func_type *)fcn; 1851 STDLIB_NDARRAY_UNARY_10D_BLOCKED_LOOP_CLBK( double, int64_t ) 1852 return 0; 1853 } 1854 1855 /** 1856 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to an n-dimensional double-precision floating-point input ndarray and assigns results to elements in an n-dimensional signed 64-bit integer output ndarray. 1857 * 1858 * ## Notes 1859 * 1860 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1861 * 1862 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1863 * @param fcn callback 1864 * @return status code 1865 * 1866 * @example 1867 * #include "stdlib/ndarray/base/unary/d_l.h" 1868 * #include "stdlib/ndarray/dtypes.h" 1869 * #include "stdlib/ndarray/index_modes.h" 1870 * #include "stdlib/ndarray/orders.h" 1871 * #include "stdlib/ndarray/ctor.h" 1872 * #include <stdint.h> 1873 * #include <stdlib.h> 1874 * #include <stdio.h> 1875 * #include <math.h> 1876 * 1877 * // Define the ndarray data types: 1878 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 1879 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 1880 * 1881 * // Create underlying byte arrays: 1882 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1883 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 1884 * 1885 * // Define the number of dimensions: 1886 * int64_t ndims = 3; 1887 * 1888 * // Define the array shapes: 1889 * int64_t shape[] = { 2, 2, 2 }; 1890 * 1891 * // Define the strides: 1892 * int64_t sx[] = { 32, 16, 8 }; 1893 * int64_t sy[] = { 32, 16, 8 }; 1894 * 1895 * // Define the offsets: 1896 * int64_t ox = 0; 1897 * int64_t oy = 0; 1898 * 1899 * // Define the array order: 1900 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 1901 * 1902 * // Specify the index mode: 1903 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 1904 * 1905 * // Specify the subscript index modes: 1906 * int8_t submodes[] = { imode }; 1907 * int64_t nsubmodes = 1; 1908 * 1909 * // Create an input ndarray: 1910 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 1911 * if ( x == NULL ) { 1912 * fprintf( stderr, "Error allocating memory.\n" ); 1913 * exit( EXIT_FAILURE ); 1914 * } 1915 * 1916 * // Create an output ndarray: 1917 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 1918 * if ( y == NULL ) { 1919 * fprintf( stderr, "Error allocating memory.\n" ); 1920 * exit( EXIT_FAILURE ); 1921 * } 1922 * 1923 * // Create an array containing the ndarrays: 1924 * struct ndarray *arrays[] = { x, y }; 1925 * 1926 * // Apply a callback: 1927 * int8_t status = stdlib_ndarray_d_l_nd( arrays, (void *)llrint ); 1928 * if ( status != 0 ) { 1929 * fprintf( stderr, "Error during computation.\n" ); 1930 * exit( EXIT_FAILURE ); 1931 * } 1932 * 1933 * // ... 1934 * 1935 * // Free allocated memory: 1936 * stdlib_ndarray_free( x ); 1937 * stdlib_ndarray_free( y ); 1938 */ 1939 int8_t stdlib_ndarray_d_l_nd( struct ndarray *arrays[], void *fcn ) { 1940 typedef int64_t func_type( const double x ); 1941 func_type *f = (func_type *)fcn; 1942 STDLIB_NDARRAY_UNARY_ND_LOOP_CLBK( double, int64_t ) 1943 return 0; 1944 } 1945 1946 // Define a list of unary ndarray functions: 1947 static ndarrayUnaryFcn functions[] = { 1948 stdlib_ndarray_d_l_0d, 1949 stdlib_ndarray_d_l_1d, 1950 stdlib_ndarray_d_l_2d, 1951 stdlib_ndarray_d_l_3d, 1952 stdlib_ndarray_d_l_4d, 1953 stdlib_ndarray_d_l_5d, 1954 stdlib_ndarray_d_l_6d, 1955 stdlib_ndarray_d_l_7d, 1956 stdlib_ndarray_d_l_8d, 1957 stdlib_ndarray_d_l_9d, 1958 stdlib_ndarray_d_l_10d, 1959 stdlib_ndarray_d_l_nd 1960 }; 1961 1962 // Define a list of unary ndarray functions implementing loop blocking... 1963 static ndarrayUnaryFcn blocked_functions[] = { 1964 stdlib_ndarray_d_l_2d_blocked, 1965 stdlib_ndarray_d_l_3d_blocked, 1966 stdlib_ndarray_d_l_4d_blocked, 1967 stdlib_ndarray_d_l_5d_blocked, 1968 stdlib_ndarray_d_l_6d_blocked, 1969 stdlib_ndarray_d_l_7d_blocked, 1970 stdlib_ndarray_d_l_8d_blocked, 1971 stdlib_ndarray_d_l_9d_blocked, 1972 stdlib_ndarray_d_l_10d_blocked 1973 }; 1974 1975 // Create a unary function dispatch object: 1976 static const struct ndarrayUnaryDispatchObject obj = { 1977 // Array containing unary ndarray functions: 1978 functions, 1979 1980 // Number of unary ndarray functions: 1981 12, 1982 1983 // Array containing unary ndarray functions using loop blocking: 1984 blocked_functions, 1985 1986 // Number of unary ndarray functions using loop blocking: 1987 9 1988 }; 1989 1990 /** 1991 * Applies a unary callback accepting a double-precision floating-point number and returning a signed 64-bit integer to a double-precision floating-point input ndarray and assigns results to elements in a signed 64-bit integer output ndarray. 1992 * 1993 * ## Notes 1994 * 1995 * - If successful, the functions returns `0`; otherwise, the function returns an error code. 1996 * 1997 * @param arrays array whose first element is a pointer to an input ndarray and whose last element is a pointer to an output ndarray 1998 * @param fcn callback 1999 * @return status code 2000 * 2001 * @example 2002 * #include "stdlib/ndarray/base/unary/d_l.h" 2003 * #include "stdlib/ndarray/dtypes.h" 2004 * #include "stdlib/ndarray/index_modes.h" 2005 * #include "stdlib/ndarray/orders.h" 2006 * #include "stdlib/ndarray/ctor.h" 2007 * #include <stdint.h> 2008 * #include <stdlib.h> 2009 * #include <stdio.h> 2010 * #include <math.h> 2011 * 2012 * // Define the ndarray data types: 2013 * enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_FLOAT64; 2014 * enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_INT64; 2015 * 2016 * // Create underlying byte arrays: 2017 * uint8_t xbuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2018 * uint8_t ybuf[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 2019 * 2020 * // Define the number of dimensions: 2021 * int64_t ndims = 2; 2022 * 2023 * // Define the array shapes: 2024 * int64_t shape[] = { 2, 2 }; 2025 * 2026 * // Define the strides: 2027 * int64_t sx[] = { 16, 8 }; 2028 * int64_t sy[] = { 16, 8 }; 2029 * 2030 * // Define the offsets: 2031 * int64_t ox = 0; 2032 * int64_t oy = 0; 2033 * 2034 * // Define the array order: 2035 * enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; 2036 * 2037 * // Specify the index mode: 2038 * enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; 2039 * 2040 * // Specify the subscript index modes: 2041 * int8_t submodes[] = { imode }; 2042 * int64_t nsubmodes = 1; 2043 * 2044 * // Create an input ndarray: 2045 * struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes ); 2046 * if ( x == NULL ) { 2047 * fprintf( stderr, "Error allocating memory.\n" ); 2048 * exit( EXIT_FAILURE ); 2049 * } 2050 * 2051 * // Create an output ndarray: 2052 * struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes ); 2053 * if ( y == NULL ) { 2054 * fprintf( stderr, "Error allocating memory.\n" ); 2055 * exit( EXIT_FAILURE ); 2056 * } 2057 * 2058 * // Create an array containing the ndarrays: 2059 * struct ndarray *arrays[] = { x, y }; 2060 * 2061 * // Apply a callback: 2062 * int8_t status = stdlib_ndarray_d_l( arrays, (void *)llrint ); 2063 * if ( status != 0 ) { 2064 * fprintf( stderr, "Error during computation.\n" ); 2065 * exit( EXIT_FAILURE ); 2066 * } 2067 * 2068 * // ... 2069 * 2070 * // Free allocated memory: 2071 * stdlib_ndarray_free( x ); 2072 * stdlib_ndarray_free( y ); 2073 */ 2074 int8_t stdlib_ndarray_d_l( struct ndarray *arrays[], void *fcn ) { 2075 return stdlib_ndarray_unary_dispatch( &obj, arrays, fcn ); 2076 }