Skip to content

Commit a360f04

Browse files
authored
feat: add boolean dtype support to ndarray/base/unary
PR-URL: #2587 Ref: #2547 Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 19d4a8d commit a360f04

File tree

295 files changed

+2735
-290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+2735
-290
lines changed

lib/node_modules/@stdlib/ndarray/base/unary/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Character codes for data types:
177177

178178
<!-- charcodes -->
179179

180+
- **x**: `bool` (boolean).
180181
- **c**: `complex64` (single-precision floating-point complex number).
181182
- **z**: `complex128` (double-precision floating-point complex number).
182183
- **f**: `float32` (single-precision floating-point number).
@@ -13086,6 +13087,97 @@ The function accepts the following arguments:
1308613087
int8_t stdlib_ndarray_u_z_as_z_z( struct ndarray *arrays[], void *fcn );
1308713088
```
1308813089

13090+
#### stdlib_ndarray_x_x( \*arrays\[], \*fcn )
13091+
13092+
Applies a unary callback to an input ndarray and assigns results to elements in an output ndarray.
13093+
13094+
```c
13095+
#include "stdlib/ndarray/dtypes.h"
13096+
#include "stdlib/ndarray/index_modes.h"
13097+
#include "stdlib/ndarray/orders.h"
13098+
#include "stdlib/ndarray/ctor.h"
13099+
#include <stdbool.h>
13100+
#include <stdint.h>
13101+
#include <stdlib.h>
13102+
#include <stdio.h>
13103+
13104+
// Define the ndarray data types:
13105+
enum STDLIB_NDARRAY_DTYPE xdtype = STDLIB_NDARRAY_BOOL;
13106+
enum STDLIB_NDARRAY_DTYPE ydtype = STDLIB_NDARRAY_BOOL;
13107+
13108+
// Create underlying byte arrays:
13109+
uint8_t xbuf[] = { 0, 0, 0, 0 };
13110+
uint8_t ybuf[] = { 0, 0, 0, 0 };
13111+
13112+
// Define the number of dimensions:
13113+
int64_t ndims = 2;
13114+
13115+
// Define the array shapes:
13116+
int64_t shape[] = { 2, 2 };
13117+
13118+
// Define the strides:
13119+
int64_t sx[] = { 2, 1 };
13120+
int64_t sy[] = { 2, 1 };
13121+
13122+
// Define the offsets:
13123+
int64_t ox = 0;
13124+
int64_t oy = 0;
13125+
13126+
// Define the array order:
13127+
enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR;
13128+
13129+
// Specify the index mode:
13130+
enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR;
13131+
13132+
// Specify the subscript index modes:
13133+
int8_t submodes[] = { imode };
13134+
int64_t nsubmodes = 1;
13135+
13136+
// Create an input ndarray:
13137+
struct ndarray *x = stdlib_ndarray_allocate( xdtype, xbuf, ndims, shape, sx, ox, order, imode, nsubmodes, submodes );
13138+
if ( x == NULL ) {
13139+
fprintf( stderr, "Error allocating memory.\n" );
13140+
exit( EXIT_FAILURE );
13141+
}
13142+
13143+
// Create an output ndarray:
13144+
struct ndarray *y = stdlib_ndarray_allocate( ydtype, ybuf, ndims, shape, sy, oy, order, imode, nsubmodes, submodes );
13145+
if ( y == NULL ) {
13146+
fprintf( stderr, "Error allocating memory.\n" );
13147+
exit( EXIT_FAILURE );
13148+
}
13149+
13150+
// Create an array containing the ndarrays:
13151+
struct ndarray *arrays[] = { x, y };
13152+
13153+
// Define a callback:
13154+
static bool fcn( const bool x ) {
13155+
return x;
13156+
}
13157+
13158+
// Apply the callback:
13159+
int8_t status = stdlib_ndarray_x_x( arrays, (void *)fcn );
13160+
if ( status != 0 ) {
13161+
fprintf( stderr, "Error during computation.\n" );
13162+
exit( EXIT_FAILURE );
13163+
}
13164+
13165+
// ...
13166+
13167+
// Free allocated memory:
13168+
stdlib_ndarray_free( x );
13169+
stdlib_ndarray_free( y );
13170+
```
13171+
13172+
The function accepts the following arguments:
13173+
13174+
- **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.
13175+
- **fcn**: `[in] void*` a `bool (*f)(bool)` function to apply provided as a `void` pointer.
13176+
13177+
```c
13178+
int8_t stdlib_ndarray_x_x( struct ndarray *arrays[], void *fcn );
13179+
```
13180+
1308913181
#### stdlib_ndarray_z_d_as_z_d( \*arrays\[], \*fcn )
1309013182

1309113183
Applies a unary callback to an input ndarray and assigns results to elements in an output ndarray.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@
183183
#include "unary/u_z_as_u_z.h"
184184
#include "unary/u_z_as_z_z.h"
185185

186+
#include "unary/x_x.h"
187+
186188
#include "unary/z_d_as_z_d.h"
187189
#include "unary/z_z.h"
188190
// END LOOPS

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_b.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_b_as_u_u.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_c_as_b_c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_c_as_c_c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_c_as_z_z.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_d_as_b_d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_d_as_d_d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_f.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_f_as_b_f.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_f_as_d_d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_f_as_f_f.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_i.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_i_as_b_i.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_i_as_i_i.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_k.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_k_as_b_k.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_k_as_i_i.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_k_as_k_k.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_t.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_t_as_b_t.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_t_as_t_t.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_t_as_u_u.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_u.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_u_as_b_u.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_u_as_u_u.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_z.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_z_as_b_z.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/b_z_as_z_z.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/c_c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2024 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)