From 50569875ca3df105dbc97c2f3b8054b29de031b2 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 19 Oct 2020 00:21:46 -0700 Subject: [PATCH 1/2] Add bitwise elementwise specifications --- .../elementwise_functions.md | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/spec/API_specification/elementwise_functions.md b/spec/API_specification/elementwise_functions.md index 861ff87fe..4c53714a0 100644 --- a/spec/API_specification/elementwise_functions.md +++ b/spec/API_specification/elementwise_functions.md @@ -259,6 +259,122 @@ Calculates an implementation-dependent approximation to the inverse hyperbolic t - an array containing the inverse hyperbolic tangent of each element in `x`. +### # bitwise_and(x1, x2, /) + +Computes the bitwise AND of the underlying binary representation of each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. + +#### Parameters + +- **x1**: _<array>_ + + - first input array. Must have an integer or boolean data type. + +- **x2**: _<array>_ + + - second input array. Must be compatible with `x1` (see :ref:`broadcasting`). Must have an integer or boolean data type. + +#### Returns + +- **out**: _<array>_ + + - an array containing the element-wise results. + +### # bitwise_lshift(x1, x2, /) + +Shifts the bits of each element `x1_i` of the input array `x1` to the left by appending `x2_i` (i.e., the respective element in the input array `x2`) zeros to the right of `x1_i`. + +#### Parameters + +- **x1**: _<array>_ + + - first input array. Must have an integer data type. + +- **x2**: _<array>_ + + - second input array. Must be compatible with `x1` (see :ref:`broadcasting`). Must have an integer or boolean data type. Each element must be greater than or equal to `0`. + +#### Returns + +- **out**: _<array>_ + + - an array containing the element-wise results. + +### # bitwise_invert(x, /) + +Inverts (flips) each bit for each element `x_i` of the input array `x`. + +#### Parameters + +- **x**: _<array>_ + + - input array. Must have an integer or boolean data type. + +#### Returns + +- **out**: _<array>_ + + - an array containing the element-wise results. Must have the same data type as `x`. + +### # bitwise_or(x1, x2, /) + +Computes the bitwise OR of the underlying binary representation of each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. + +#### Parameters + +- **x1**: _<array>_ + + - first input array. Must have an integer or boolean data type. + +- **x2**: _<array>_ + + - second input array. Must be compatible with `x1` (see :ref:`broadcasting`). Must have an integer or boolean data type. + +#### Returns + +- **out**: _<array>_ + + - an array containing the element-wise results. + +### # bitwise_rshift(x1, x2, /) + +Shifts the bits of each element `x1_i` of the input array `x1` to the right according to the respective element `x2_i` of the input array `x2`. + +#### Parameters + +- **x1**: _<array>_ + + - first input array. Must have an integer data type. + +- **x2**: _<array>_ + + - second input array. Must be compatible with `x1` (see :ref:`broadcasting`). Must have an integer or boolean data type. Each element must be greater than or equal to `0`. + +#### Returns + +- **out**: _<array>_ + + - an array containing the element-wise results. + +### # bitwise_xor(x1, x2, /) + +Computes the bitwise XOR of the underlying binary representation of each element `x1_i` of the input array `x1` with the respective element `x2_i` of the input array `x2`. + +#### Parameters + +- **x1**: _<array>_ + + - first input array. Must have an integer or boolean data type. + +- **x2**: _<array>_ + + - second input array. Must be compatible with `x1` (see :ref:`broadcasting`). Must have an integer or boolean data type. + +#### Returns + +- **out**: _<array>_ + + - an array containing the element-wise results. + ### # ceil(x, /) Rounds each element `x_i` of the input array `x` to the smallest (i.e., closest to `-infinity`) integer-valued number that is not less than `x_i`. From 6313d676ecdb25242a772ddee3d1580fe08b7806 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 26 Oct 2020 12:47:57 -0600 Subject: [PATCH 2/2] Rename functions --- spec/API_specification/elementwise_functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/elementwise_functions.md b/spec/API_specification/elementwise_functions.md index 49523b93d..454363488 100644 --- a/spec/API_specification/elementwise_functions.md +++ b/spec/API_specification/elementwise_functions.md @@ -298,7 +298,7 @@ Computes the bitwise AND of the underlying binary representation of each element - an array containing the element-wise results. -### # bitwise_lshift(x1, x2, /) +### # bitwise_left_shift(x1, x2, /) Shifts the bits of each element `x1_i` of the input array `x1` to the left by appending `x2_i` (i.e., the respective element in the input array `x2`) zeros to the right of `x1_i`. @@ -354,7 +354,7 @@ Computes the bitwise OR of the underlying binary representation of each element - an array containing the element-wise results. -### # bitwise_rshift(x1, x2, /) +### # bitwise_right_shift(x1, x2, /) Shifts the bits of each element `x1_i` of the input array `x1` to the right according to the respective element `x2_i` of the input array `x2`.