@@ -172,6 +172,7 @@ Character codes for data types:
172
172
173
173
<!-- charcodes -->
174
174
175
+ - ** x** : ` bool ` (boolean).
175
176
- ** c** : ` complex64 ` (single-precision floating-point complex number).
176
177
- ** z** : ` complex128 ` (double-precision floating-point complex number).
177
178
- ** f** : ` float32 ` (single-precision floating-point number).
@@ -4503,6 +4504,90 @@ The function accepts the following arguments:
4503
4504
int8_t stdlib_ndarray_assign_u_z( struct ndarray *arrays[] );
4504
4505
```
4505
4506
4507
+ #### stdlib_ndarray_assign_x_x( \* arrays\[ ] )
4508
+
4509
+ Assigns elements in an input ndarray to elements in an output ndarray.
4510
+
4511
+ ``` c
4512
+ #include " stdlib/ndarray/dtypes.h"
4513
+ #include " stdlib/ndarray/index_modes.h"
4514
+ #include " stdlib/ndarray/orders.h"
4515
+ #include " stdlib/ndarray/ctor.h"
4516
+ #include < stdint.h>
4517
+ #include < stdlib.h>
4518
+ #include < stdio.h>
4519
+
4520
+ // Define the ndarray data types:
4521
+ enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_BOOL;
4522
+ enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_BOOL;
4523
+
4524
+ // Create underlying byte arrays:
4525
+ uint8_t xbuf[] = { 0, 0, 0, 0 };
4526
+ uint8_t ybuf[ ] = { 0, 0, 0, 0 };
4527
+
4528
+ // Define the number of dimensions:
4529
+ int64_t ndims = 2;
4530
+
4531
+ // Define the array shapes:
4532
+ int64_t shape[ ] = { 2, 2 };
4533
+
4534
+ // Define the strides:
4535
+ int64_t sx[ ] = { 2, 1 };
4536
+ int64_t sy[ ] = { 2, 1 };
4537
+
4538
+ // Define the offsets:
4539
+ int64_t ox = 0;
4540
+ int64_t oy = 0;
4541
+
4542
+ // Define the array order:
4543
+ enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR;
4544
+
4545
+ // Specify the index mode:
4546
+ enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR;
4547
+
4548
+ // Specify the subscript index modes:
4549
+ int8_t submodes[ ] = { imode };
4550
+ int64_t nsubmodes = 1;
4551
+
4552
+ // Create an input ndarray:
4553
+ struct ndarray * x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes );
4554
+ if ( x == NULL ) {
4555
+ fprintf( stderr, "Error allocating memory.\n" );
4556
+ exit( EXIT_FAILURE );
4557
+ }
4558
+
4559
+ // Create an output ndarray:
4560
+ struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes );
4561
+ if ( y == NULL ) {
4562
+ fprintf ( stderr, "Error allocating memory.\n" );
4563
+ exit( EXIT_FAILURE );
4564
+ }
4565
+
4566
+ // Create an array containing the ndarrays:
4567
+ struct ndarray *arrays[] = { x, y };
4568
+
4569
+ // Copy elements:
4570
+ int8_t status = stdlib_ndarray_assign_x_x( arrays );
4571
+ if ( status != 0 ) {
4572
+ fprintf( stderr, "Error during computation.\n" );
4573
+ exit( EXIT_FAILURE );
4574
+ }
4575
+
4576
+ // ...
4577
+
4578
+ // Free allocated memory:
4579
+ stdlib_ndarray_free ( x );
4580
+ stdlib_ndarray_free( y );
4581
+ ```
4582
+
4583
+ The function accepts the following arguments:
4584
+
4585
+ - **arrays**: `[inout] struct ndarray**` array whose first element is a pointer to an input ndarray and whose second element is a pointer to an output ndarray.
4586
+
4587
+ ```c
4588
+ int8_t stdlib_ndarray_assign_x_x( struct ndarray *arrays[] );
4589
+ ```
4590
+
4506
4591
#### stdlib_ndarray_assign_z_c( \* arrays\[ ] )
4507
4592
4508
4593
Assigns elements in an input ndarray to elements in an output ndarray.
0 commit comments