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