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