Binary Operations
Binary operations take two arrays as input, perform element-wise binary operations, and return a new array. All binary operations work on real valued as well as complex valued arrays. These operations support automatic broadcasting based on common broadcasting rules (similar to NumPy and PyTorch).
add
def add(arg0: Array, arg1: Array) -> Array
Performs element-wise addition of two arrays.
div
def div(arg0: Array, arg1: Array) -> Array
Performs element-wise division of two arrays.
Args
arg0: The numerator array. arg1: The denominator array.
Returns
An array containing the element-wise division of the input arrays.
Note
- Supports automatic broadcasting.
- Works with real and complex valued arrays.
- Supports automatic differentiation (forward and reverse modes).
- Division by zero results in IEEE 754 standard behavior.
matmul
def matmul(arg0: Array, arg1: Array) -> Array
Performs matrix multiplication of two arrays.
Args
arg0: The first input array. arg1: The second input array.
Returns
An array containing the result of matrix multiplication of the input arrays.
Note
- Supports automatic broadcasting for batch dimensions.
- Works with real and complex valued arrays.
- Supports automatic differentiation (forward and reverse modes).
- Shape constraint: The last dimension of arg0 must match the second-to-last dimension of arg1.
mul
def mul(arg0: Array, arg1: Array) -> Array
Performs element-wise multiplication of two arrays.
pow
def pow(arg0: Array, arg1: Array) -> Array
Performs element-wise exponentiation of two arrays.
Args
arg0: The base array. arg1: The exponent array.
Returns
An array containing the element-wise power of the input arrays.
Note
- Supports automatic broadcasting.
- Works with real and complex valued arrays.
- Supports automatic differentiation (forward and reverse modes).
- Special cases (0^0, neg^fractional) follow IEEE 754 standard behavior.
sub
def sub(arg0: Array, arg1: Array) -> Array
Performs element-wise subtraction of two arrays.
Args
arg0: The first input array (minuend). arg1: The second input array (subtrahend).
Returns
An array containing the element-wise difference of the input arrays.
Note
- Supports automatic broadcasting.
- Works with real and complex valued arrays.
- Supports automatic differentiation (forward and reverse modes).