+ Array object + + ¶ + +
++++++ Array API specification for array object attributes and methods. +
+
+ A conforming implementation of the array API standard must provide and support an array object having the following attributes and methods adhering to the following conventions. +
+-
+
-
+
+ Positional parameters must be + + positional-only + + parameters. Positional-only parameters have no externally-usable name. When a method accepting positional-only parameters is called, positional arguments are mapped to these parameters based solely on their order. +
+
+ -
+
+ Optional parameters must be + + keyword-only + + arguments. +
+
+ -
+
+ Broadcasting semantics must follow the semantics defined in + + + Broadcasting + + + . +
+
+ -
+
+ Unless stated otherwise, methods must support the data types defined in + + + Data Types + + + . +
+
+ -
+
+ Unless stated otherwise, methods must adhere to the type promotion rules defined in + + + Type Promotion Rules + + + . +
+
+ -
+
+ Unless stated otherwise, floating-point operations must adhere to IEEE 754-2019. +
+
+
+
+ Operators + + ¶ + +
++ A conforming implementation of the array API standard must provide and support an array object supporting the following Python operators: +
+-
+
-
+
+
++ + x1 + + + < + + + x2 + +
+ : + + ++ + __lt__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + <= + + + x2 + +
+ : + + ++ + __le__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + > + + + x2 + +
+ : + + ++ + __gt__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + >= + + + x2 + +
+ : + + ++ + __ge__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + == + + + x2 + +
+ : + + ++ + __eq__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + != + + + x2 + +
+ : + + ++ + __ne__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + +x + +
+ : + + ++ + __pos__(x) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + -x + +
+ : + + ++ + __neg__(x) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + + + + + x2 + +
+ : + + ++ + __add__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + - + + + x2 + +
+ : + + ++ + __sub__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + * + + + x2 + +
+ : + + ++ + __mul__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + / + + + x2 + +
+ : + + ++ + __truediv__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + // + + + x2 + +
+ : + + ++ + __floordiv__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + % + + + x2 + +
+ : + + ++ + __mod__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + ** + + + x2 + +
+ : + + ++ + __pow__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + @ + + + x2 + +
+ : + + ++ + __matmul__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + ~x + +
+ : + + ++ + __invert__(x) + +
+ + +-
+
- + + +
- + + +
- + + +
- + + +
+ -
+
+
++ + x1 + + + & + + + x2 + +
+ : + + ++ + __and__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + | + + + x2 + +
+ : + + ++ + __or__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + ^ + + + x2 + +
+ : + + ++ + __xor__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + << + + + x2 + +
+ : + + ++ + __lshift__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+ -
+
+
++ + x1 + + + >> + + + x2 + +
+ : + + ++ + __rshift__(x1, + + + x2) + +
+ + +-
+
- + + +
- + + +
+
+ In-place Operators + + ¶ + +
++ A conforming implementation of the array API standard must provide and support +an array object supporting the following in-place Python operators: +
+-
+
-
+
+
++ + += + +
+ . May be implemented via ++ + __iadd__ + +
+ . +
+ -
+
+
++ + -= + +
+ . May be implemented via ++ + __isub__ + +
+ . +
+ -
+
+
++ + *= + +
+ . May be implemented via ++ + __imul__ + +
+ . +
+ -
+
+
++ + /= + +
+ . May be implemented via ++ + __itruediv__ + +
+ . +
+ -
+
+
++ + //= + +
+ . May be implemented via ++ + __ifloordiv__ + +
+ . +
+ -
+
+
++ + **= + +
+ . May be implemented via ++ + __ipow__ + +
+ . +
+ -
+
+
++ + @= + +
+ . May be implemented via ++ + __imatmul__ + +
+ . +
+ -
+
+
++ + %= + +
+ . May be implemented via ++ + __imod__ + +
+ . +
+ -
+
+
++ + &= + +
+ . May be implemented via ++ + __iand__ + +
+ . +
+ -
+
+
++ + |= + +
+ . May be implemented via ++ + __ior__ + +
+ . +
+ -
+
+
++ + ^= + +
+ . May be implemented via ++ + __ixor__ + +
+ . +
+ -
+
+
++ + <<= + +
+ . May be implemented via ++ + __ilshift__ + +
+ . +
+ -
+
+
++ + >>= + +
+ . May be implemented via ++ + __irshift__ + +
+ . +
+
+ Note +
++ In-place operators must be supported as discussed in + + + Copy-view behaviour and mutability + + + . +
++ Reflected Operators + + ¶ + +
++ A conforming implementation of the array API standard must provide and support +an array object supporting the following reflected operators: +
+-
+
-
+
+
++ + __radd__ + +
+
+ -
+
+
++ + __rsub__ + +
+
+ -
+
+
++ + __rmul__ + +
+
+ -
+
+
++ + __rtruediv__ + +
+
+ -
+
+
++ + __rfloordiv__ + +
+
+ -
+
+
++ + __rpow__ + +
+
+ -
+
+
++ + __rmatmul__ + +
+
+ -
+
+
++ + __rmod__ + +
+
+ -
+
+
++ + __rand__ + +
+
+ -
+
+
++ + __ror__ + +
+
+ -
+
+
++ + __rxor__ + +
+
+ -
+
+
++ + __rlshift__ + +
+
+ -
+
+
++ + __rrshift__ + +
+
+
+ The results of applying reflected operators must match their non-reflected equivalents. +
++ Note +
+
+ All operators for which
+
+
+ array
+
+
+ <op>
+
+
+ scalar
+
+
+ is implemented must have an equivalent reflected operator implementation.
+
+
+ Attributes + + ¶ + +
+ ++ dtype + + ¶ + +
++ Data type of the array elements. +
++ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <dtype> + +
+-
+
-
+
+ array data type. +
+
+
+ -
+
+ device + + ¶ + +
++ Hardware device the array data resides on. +
++ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <device> + +
+-
+
-
+
+ a +
++ + device + +
+ object (see + + + Device support + + + ). +
+
+ -
+
+ ndim + + ¶ + +
++ Number of array dimensions (axes). +
++ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + int + +
+-
+
-
+
+ number of array dimensions (axes). +
+
+
+ -
+
+ + TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where the number of dimensions may be dynamic. + +
++ shape + + ¶ + +
++ Array dimensions. +
++ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + Union[ Tuple[ int, …], <shape> ] + +
+-
+
-
+
+ array dimensions as either a tuple or a custom shape object. If a shape object, the object must be immutable and must support indexing for dimension retrieval. +
+
+
+ -
+
+ + TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where a shape may be dynamic. + +
++ size + + ¶ + +
++ Number of elements in an array. This must equal the product of the array’s dimensions. +
++ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + int + +
+-
+
-
+
+ number of elements in an array. +
+
+
+ -
+
+ + TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where the number of elements may be dynamic. + +
++ T + + ¶ + +
++ Transpose of the array. +
++ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ array whose dimensions (axes) are permuted in reverse order relative to original array. The returned array must have the same data type as the original array. +
+
+
+ -
+
+
+ Methods + + ¶ + +
+ ++ __abs__(self, /) + + ¶ + +
++ Calculates the absolute value for each element of an array instance (i.e., the element-wise result has the same magnitude as the respective element but has positive sign). +
++ Special Cases + + ¶ + +
+
+ For floating-point operands, let
+
+
+ self
+
+
+ equal
+
+
+ x
+
+
+ .
+
-
+
-
+
+ If +
++ + x_i + +
+ is ++ + NaN + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x_i + +
+ is ++ + -0 + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x_i + +
+ is ++ + -infinity + +
+ , the result is ++ + +infinity + +
+ . +
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise absolute value. The returned array must have the same data type as +
++ + self + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ abs(x)
+
+
+
+
+ .
+
+ __add__(self, other, /) + + ¶ + +
+
+ Calculates the sum for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Special Cases + + ¶ + +
+
+ For floating-point operands, let
+
+
+ self
+
+
+ equal
+
+
+ x1
+
+
+ and
+
+
+ other
+
+
+ equal
+
+
+ x2
+
+
+ .
+
-
+
-
+
+ If either +
++ + x1_i + +
+ or ++ + x2_i + +
+ is ++ + NaN + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +infinity + +
+ and ++ + x2_i + +
+ is ++ + -infinity + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -infinity + +
+ and ++ + x2_i + +
+ is ++ + +infinity + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +infinity + +
+ and ++ + x2_i + +
+ is ++ + +infinity + +
+ , the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -infinity + +
+ and ++ + x2_i + +
+ is ++ + -infinity + +
+ , the result is ++ + -infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +infinity + +
+ and ++ + x2_i + +
+ is a finite number, the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -infinity + +
+ and ++ + x2_i + +
+ is a finite number, the result is ++ + -infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is a finite number and ++ + x2_i + +
+ is ++ + +infinity + +
+ , the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is a finite number and ++ + x2_i + +
+ is ++ + -infinity + +
+ , the result is ++ + -infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -0 + +
+ and ++ + x2_i + +
+ is ++ + -0 + +
+ , the result is ++ + -0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -0 + +
+ and ++ + x2_i + +
+ is ++ + +0 + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +0 + +
+ and ++ + x2_i + +
+ is ++ + -0 + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +0 + +
+ and ++ + x2_i + +
+ is ++ + +0 + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is either ++ + +0 + +
+ or ++ + -0 + +
+ and ++ + x2_i + +
+ is a nonzero finite number, the result is ++ + x2_i + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is a nonzero finite number and ++ + x2_i + +
+ is either ++ + +0 + +
+ or ++ + -0 + +
+ , the result is ++ + x1_i + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is a nonzero finite number and ++ + x2_i + +
+ is ++ + -x1_i + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ In the remaining cases, when neither +
++ + infinity + +
+ , ++ + +0 + +
+ , ++ + -0 + +
+ , nor a ++ + NaN + +
+ is involved, and the operands have the same mathematical sign or have different magnitudes, the sum must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported round mode. If the magnitude is too large to represent, the operation overflows and the result is an ++ + infinity + +
+ of appropriate mathematical sign. +
+
+ Note +
++ Floating-point addition is a commutative operation, but not always associative. +
++ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance (augend array). +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ addend array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise sums. The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ add(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __and__(self, other, /) + + ¶ + +
+
+ Evaluates
+
+
+ self_i
+
+
+ &
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. Must have an integer or boolean data type. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). Must have an integer or boolean data type. +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ bitwise_and(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __array_namespace__(self, /, *, api_version=None) + + ¶ + +
++ Returns an object that has all the array API functions on it. +
++ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + api_version + + : + + <Optional[str]> + +
+-
+
-
+
+ string representing the version of the array API specification to be returned, in +
++ + 'YYYY.MM' + +
+ form, for example, ++ + '2020.10' + +
+ . If it is ++ + None + +
+ , it should return the namespace corresponding to latest version of the array API specification. If the given version is invalid or not implemented for the given module, an error should be raised. Default: ++ + None + +
+ . +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <object> + +
+-
+
-
+
+ an object representing the array API namespace. It should have every top-level function defined in the specification as an attribute. It may contain other public names as well, but it is recommended to only include those names that are part of the specification. +
+
+
+ -
+
+ __bool__(self, /) + + ¶ + +
+
+ Converts a zero-dimensional boolean array to a Python
+
+
+ bool
+
+
+ object.
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ zero-dimensional array instance. Must have a boolean data type. +
+
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <bool> + +
+-
+
-
+
+ a Python +
++ + bool + +
+ object representing the single element of the array. +
+
+ -
+
+ __dlpack__(self, /, *, stream=None) + + ¶ + +
++ Exports the array for consumption by + + + from_dlpack(x, /) + + + as a DLPack capsule. +
++ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + stream + + : + + Optional[ int ] + +
+-
+
-
+
+ a Python integer representing a pointer to a stream. +
++ + stream + +
+ is provided by the consumer to the producer to instruct the producer to ensure that operations can safely be performed on the array. The pointer must be a positive integer or ++ + -1 + +
+ . If ++ + stream + +
+ is ++ + -1 + +
+ , the value may be used by the consumer to signal “producer must not perform any synchronization”. Device-specific notes: ++++ CUDA +
+-
+
-
+
+
++ + None + +
+ : producer must assume the legacy default stream (default). +
+ -
+
+
++ + 1 + +
+ : the legacy default stream. +
+ -
+
+
++ + 2 + +
+ : the per-thread default stream. +
+ -
+
+
++ + > + + + 2 + +
+ : stream number represented as a Python integer. +
+
+
++ + 0 + +
+ is disallowed due to its ambiguity: ++ + 0 + +
+ could mean either ++ + None + +
+ , ++ + 1 + +
+ , or ++ + 2 + +
+ . ++++ ROCm +
+-
+
-
+
+
++ + None + +
+ : producer must assume the legacy default stream (default). +
+ -
+
+
++ + 0 + +
+ : the default stream. +
+ -
+
+
++ + > + + + 2 + +
+ : stream number represented as a Python integer. +
+
+ Using +
++ + 1 + +
+ and ++ + 2 + +
+ is not supported. ++++ Tip +
++ It is recommended that implementers explicitly handle streams. If +they use the legacy default stream, specifying +
++ + 1 + +
+ (CUDA) or ++ + 0 + +
+ (ROCm) is preferred. ++ + None + +
+ is a safe default for developers who do +not want to think about stream handling at all, potentially at the +cost of more synchronization than necessary. +
+ -
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + capsule + + : + + <PyCapsule> + +
+-
+
-
+
+ a DLPack capsule for the array. See + + + Data interchange mechanisms + + + for details. +
+
+
+ -
+
+ __dlpack_device__(self, /) + + ¶ + +
++ Returns device type and device ID in DLPack format. Meant for use within + + + from_dlpack(x, /) + + + . +
++ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + device + + : + + Tuple[enum.IntEnum, int] + +
+-
+
-
+
+ a tuple +
++ + (device_type, + + + device_id) + +
+ in DLPack format. Valid device type enum members are: +++++CPU = 1 +CUDA = 2 +CPU_PINNED = 3 +OPENCL = 4 +VULKAN = 7 +METAL = 8 +VPI = 9 +ROCM = 10 +
+
+
+ -
+
+ __eq__(self, other, /) + + ¶ + +
+
+ Computes the truth value of
+
+
+ self_i
+
+
+ ==
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type of +
++ + bool + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ equal(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __float__(self, /) + + ¶ + +
+
+ Converts a zero-dimensional floating-point array to a Python
+
+
+ float
+
+
+ object.
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ zero-dimensional array instance. Must have a floating-point data type. +
+
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <float> + +
+-
+
-
+
+ a Python +
++ + float + +
+ object representing the single element of the array instance. +
+
+ -
+
+ __floordiv__(self, other, /) + + ¶ + +
+
+ Evaluates
+
+
+ self_i
+
+
+ //
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ floor_divide(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __ge__(self, other, /) + + ¶ + +
+
+ Computes the truth value of
+
+
+ self_i
+
+
+ >=
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type of +
++ + bool + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ greater_equal(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __getitem__(self, key, /) + + ¶ + +
+
+ Returns
+
+
+ self[key]
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array;> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + key + + : + + Union[ int, slice, ellipsis, Tuple[ Union[ int, slice, ellipsis ], … ], <array> ] + +
+-
+
-
+
+ index key. +
+
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the accessed value(s). The returned array must have the same data type as +
++ + self + +
+ . +
+
+ -
+
+ __gt__(self, other, /) + + ¶ + +
+
+ Computes the truth value of
+
+
+ self_i
+
+
+ >
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type of +
++ + bool + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ greater(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __int__(self, /) + + ¶ + +
+
+ Converts a zero-dimensional integer array to a Python
+
+
+ int
+
+
+ object.
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ zero-dimensional array instance. Must have an integer data type. +
+
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <int> + +
+-
+
-
+
+ a Python +
++ + int + +
+ object representing the single element of the array instance. +
+
+ -
+
+ __invert__(self, /) + + ¶ + +
+
+ Evaluates
+
+
+ ~self_i
+
+
+ for each element of an array instance.
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. Must have an integer or boolean data type. +
+
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have the same data type as +
++ + self + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ bitwise_invert(x)
+
+
+
+
+ .
+
+ __le__(self, other, /) + + ¶ + +
+
+ Computes the truth value of
+
+
+ self_i
+
+
+ <=
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type of +
++ + bool + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ less_equal(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __len__(self, /) + + ¶ + +
++ + TODO: need to more carefully consider this in order to accommodate, e.g., graph tensors where a shape may be dynamic. Furthermore, not clear whether this should be implemented, as, e.g., NumPy’s behavior of returning the size of the first dimension is not necessarily intuitive, as opposed to, say, the total number of elements. + +
++ __lshift__(self, other, /) + + ¶ + +
+
+ Evaluates
+
+
+ self_i
+
+
+ <<
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. Must have an integer data type. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). Must have an integer data type. Each element must be greater than or equal to ++ + 0 + +
+ . +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have the same data type as +
++ + self + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ less_equal(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __lt__(self, other, /) + + ¶ + +
+
+ Computes the truth value of
+
+
+ self_i
+
+
+ <
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type of +
++ + bool + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ less(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __matmul__(self, other, /) + + ¶ + +
+
+
+ TODO: awaiting
+
+
+ matmul
+
+
+ functional equivalent.
+
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ + TODO + +
+
+
+ -
+
+ __mod__(self, other, /) + + ¶ + +
+
+ Evaluates
+
+
+ self_i
+
+
+ %
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. Each element-wise result must have the same sign as the respective element +
++ + other_i + +
+ . The returned array must have a floating-point data type determined by + + + Type Promotion Rules + + + . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ remainder(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __mul__(self, other, /) + + ¶ + +
+
+ Calculates the product for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Special Cases + + ¶ + +
+
+ For floating-point operands, let
+
+
+ self
+
+
+ equal
+
+
+ x1
+
+
+ and
+
+
+ other
+
+
+ equal
+
+
+ x2
+
+
+ .
+
-
+
-
+
+ If either +
++ + x1_i + +
+ or ++ + x2_i + +
+ is ++ + NaN + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is either ++ + +infinity + +
+ or ++ + -infinity + +
+ and ++ + x2_i + +
+ is either ++ + +0 + +
+ or ++ + -0 + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is either ++ + +0 + +
+ or ++ + -0 + +
+ and ++ + x2_i + +
+ is either ++ + +infinity + +
+ or ++ + -infinity + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ and ++ + x2_i + +
+ have the same mathematical sign, the result has a positive mathematical sign, unless the result is ++ + NaN + +
+ . If the result is ++ + NaN + +
+ , the “sign” of ++ + NaN + +
+ is implementation-defined. +
+ -
+
+ If +
++ + x1_i + +
+ and ++ + x2_i + +
+ have different mathematical signs, the result has a negative mathematical sign, unless the result is ++ + NaN + +
+ . If the result is ++ + NaN + +
+ , the “sign” of ++ + NaN + +
+ is implementation-defined. +
+ -
+
+ If +
++ + x1_i + +
+ is either ++ + +infinity + +
+ or ++ + -infinity + +
+ and ++ + x2_i + +
+ is either ++ + +infinity + +
+ or ++ + -infinity + +
+ , the result is a signed infinity with the mathematical sign determined by the rule already stated above. +
+ -
+
+ If +
++ + x1_i + +
+ is either ++ + +infinity + +
+ or ++ + -infinity + +
+ and ++ + x2_i + +
+ is a nonzero finite number, the result is a signed infinity with the mathematical sign determined by the rule already stated above. +
+ -
+
+ If +
++ + x1_i + +
+ is a nonzero finite number and ++ + x2_i + +
+ is either ++ + +infinity + +
+ or ++ + -infinity + +
+ , the result is a signed infinity with the mathematical sign determined by the rule already stated above. +
+ -
+
+ In the remaining cases, where neither +
++ + infinity + +
+ nor ++ + NaN + +
+ is involved, the product must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported rounding mode. If the magnitude is too large to represent, the result is an ++ + infinity + +
+ of appropriate mathematical sign. If the magnitude is too small to represent, the result is a zero of appropriate mathematical sign. +
+
+ Note +
++ Floating-point multiplication is not always associative due to finite precision. +
++ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise products. The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ multiply(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __ne__(self, other, /) + + ¶ + +
+
+ Computes the truth value of
+
+
+ self_i
+
+
+ !=
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type of +
++ + bool + +
+ (i.e., must be a boolean array). +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ not_equal(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __neg__(self, /) + + ¶ + +
+
+ Evaluates
+
+
+ -self_i
+
+
+ for each element of an array instance.
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the evaluated result for each element in +
++ + self + +
+ . The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ negative(x)
+
+
+
+
+ .
+
+ __or__(self, other, /) + + ¶ + +
+
+ Evaluates
+
+
+ self_i
+
+
+ |
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. Must have an integer or boolean data type. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). Must have an integer or boolean data type. +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ positive(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __pos__(self, /) + + ¶ + +
+
+ Evaluates
+
+
+ +self_i
+
+
+ for each element of an array instance.
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the evaluated result for each element. The returned array must have the same data type as +
++ + self + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ positive(x)
+
+
+
+
+ .
+
+ __pow__(self, other, /) + + ¶ + +
+
+ Calculates an implementation-dependent approximation of exponentiation by raising each element (the base) of an array instance to the power of
+
+
+ other_i
+
+
+ (the exponent), where
+
+
+ other_i
+
+
+ is the corresponding element of the array
+
+
+ other
+
+
+ .
+
+ Special Cases + + ¶ + +
+
+ For floating-point operands, let
+
+
+ self
+
+
+ equal
+
+
+ x1
+
+
+ and
+
+
+ other
+
+
+ equal
+
+
+ x2
+
+
+ .
+
-
+
-
+
+ If +
++ + x1_i + +
+ is not equal to ++ + 1 + +
+ and ++ + x2_i + +
+ is ++ + NaN + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x2_i + +
+ is ++ + +0 + +
+ , the result is ++ + 1 + +
+ , even if ++ + x1_i + +
+ is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x2_i + +
+ is ++ + -0 + +
+ , the result is ++ + 1 + +
+ , even if ++ + x1_i + +
+ is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + NaN + +
+ and ++ + x2_i + +
+ is not equal to ++ + 0 + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + abs(x1_i) + +
+ is greater than ++ + 1 + +
+ and ++ + x2_i + +
+ is ++ + +infinity + +
+ , the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + abs(x1_i) + +
+ is greater than ++ + 1 + +
+ and ++ + x2_i + +
+ is ++ + -infinity + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + abs(x1_i) + +
+ is ++ + 1 + +
+ and ++ + x2_i + +
+ is ++ + +infinity + +
+ , the result is ++ + 1 + +
+ . +
+ -
+
+ If +
++ + abs(x1_i) + +
+ is ++ + 1 + +
+ and ++ + x2_i + +
+ is ++ + -infinity + +
+ , the result is ++ + 1 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + 1 + +
+ and ++ + x2_i + +
+ is not ++ + NaN + +
+ , the result is ++ + 1 + +
+ . +
+ -
+
+ If +
++ + abs(x1_i) + +
+ is less than ++ + 1 + +
+ and ++ + x2_i + +
+ is ++ + +infinity + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + abs(x1_i) + +
+ is less than ++ + 1 + +
+ and ++ + x2_i + +
+ is ++ + -infinity + +
+ , the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +infinity + +
+ and ++ + x2_i + +
+ is greater than ++ + 0 + +
+ , the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +infinity + +
+ and ++ + x2_i + +
+ is less than ++ + 0 + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -infinity + +
+ and ++ + x2_i + +
+ is greater than ++ + 0 + +
+ , the result is ++ + -infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -infinity + +
+ , ++ + x2_i + +
+ is greater than ++ + 0 + +
+ , and ++ + x2_i + +
+ is not an odd integer value, the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -infinity + +
+ , ++ + x2_i + +
+ is less than ++ + 0 + +
+ , and ++ + x2_i + +
+ is an odd integer value, the result is ++ + -0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -infinity + +
+ , ++ + x2_i + +
+ is less than ++ + 0 + +
+ , and ++ + x2_i + +
+ is not an odd integer value, the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +0 + +
+ and ++ + x2_i + +
+ is greater than ++ + 0 + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +0 + +
+ and ++ + x2_i + +
+ is less than ++ + 0 + +
+ , the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -0 + +
+ , ++ + x2_i + +
+ is greater than ++ + 0 + +
+ , and ++ + x2_i + +
+ is an odd integer value, the result is ++ + -0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -0 + +
+ , ++ + x2_i + +
+ is greater than ++ + 0 + +
+ , and ++ + x2_i + +
+ is not an odd integer value, the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -0 + +
+ , ++ + x2_i + +
+ is less than ++ + 0 + +
+ , and ++ + x2_i + +
+ is an odd integer value, the result is ++ + -infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -0 + +
+ , ++ + x2_i + +
+ is less than ++ + 0 + +
+ , and ++ + x2_i + +
+ is not an odd integer value, the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is less than ++ + 0 + +
+ , ++ + x1_i + +
+ is a finite number, ++ + x2_i + +
+ is a finite number, and ++ + x2_i + +
+ is not an integer value, the result is ++ + NaN + +
+ . +
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance whose elements correspond to the exponentiation base. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array whose elements correspond to the exponentiation exponent. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ pow(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __rshift__(self, other, /) + + ¶ + +
+
+ Evaluates
+
+
+ self_i
+
+
+ >>
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. Must have an integer data type. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). Must have an integer data type. Each element must be greater than or equal to ++ + 0 + +
+ . +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have the same data type as +
++ + self + +
+ . +
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ bitwise_right_shift(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __setitem__(self, key, value, /) + + ¶ + +
++ + TODO: dependent on the indexing specification. + +
++ __sub__(self, other, /) + + ¶ + +
+
+ Calculates the difference for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ . The result of
+
+
+ self_i
+
+
+ -
+
+
+ other_i
+
+
+ must be the same as
+
+
+ self_i
+
+
+ +
+
+
+ (-other_i)
+
+
+ and must be governed by the same floating-point rules as addition (see
+
+
+
+
+ __add__()
+
+
+
+
+ ).
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance (minuend array). +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ subtrahend array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise differences. The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ subtract(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __truediv__(self, other, /) + + ¶ + +
+
+ Evaluates
+
+
+ self_i
+
+
+ /
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Special Cases + + ¶ + +
+
+ For floating-point operands, let
+
+
+ self
+
+
+ equal
+
+
+ x1
+
+
+ and
+
+
+ other
+
+
+ equal
+
+
+ x2
+
+
+ .
+
-
+
-
+
+ If either +
++ + x1_i + +
+ or ++ + x2_i + +
+ is ++ + NaN + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is either ++ + +infinity + +
+ or ++ + -infinity + +
+ and ++ + x2_i + +
+ is either ++ + +infinity + +
+ or ++ + -infinity + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is either ++ + +0 + +
+ or ++ + -0 + +
+ and ++ + x2_i + +
+ is either ++ + +0 + +
+ or ++ + -0 + +
+ , the result is ++ + NaN + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +0 + +
+ and ++ + x2_i + +
+ is greater than ++ + 0 + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -0 + +
+ and ++ + x2_i + +
+ is greater than ++ + 0 + +
+ , the result ++ + -0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +0 + +
+ and ++ + x2_i + +
+ is less than ++ + 0 + +
+ , the result is ++ + -0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -0 + +
+ and ++ + x2_i + +
+ is less than ++ + 0 + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is greater than ++ + 0 + +
+ and ++ + x2_i + +
+ is ++ + +0 + +
+ , the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is greater than ++ + 0 + +
+ and ++ + x2_i + +
+ is ++ + -0 + +
+ , the result is ++ + -infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is less than ++ + 0 + +
+ and ++ + x2_i + +
+ is ++ + +0 + +
+ , the result is ++ + -infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is less than ++ + 0 + +
+ and ++ + x2_i + +
+ is ++ + -0 + +
+ , the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +infinity + +
+ and ++ + x2_i + +
+ is a positive (i.e., greater than ++ + 0 + +
+ ) finite number, the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + +infinity + +
+ and ++ + x2_i + +
+ is a negative (i.e., less than ++ + 0 + +
+ ) finite number, the result is ++ + -infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -infinity + +
+ and ++ + x2_i + +
+ is a positive (i.e., greater than ++ + 0 + +
+ ) finite number, the result is ++ + -infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is ++ + -infinity + +
+ and ++ + x2_i + +
+ is a negative (i.e., less than ++ + 0 + +
+ ) finite number, the result is ++ + +infinity + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is a positive (i.e., greater than ++ + 0 + +
+ ) finite number and ++ + x2_i + +
+ is ++ + +infinity + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is a positive (i.e., greater than ++ + 0 + +
+ ) finite number and ++ + x2_i + +
+ is ++ + -infinity + +
+ , the result is ++ + -0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is a negative (i.e., less than ++ + 0 + +
+ ) finite number and ++ + x2_i + +
+ is ++ + +infinity + +
+ , the result is ++ + -0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ is a negative (i.e., less than ++ + 0 + +
+ ) finite number and ++ + x2_i + +
+ is ++ + -infinity + +
+ , the result is ++ + +0 + +
+ . +
+ -
+
+ If +
++ + x1_i + +
+ and ++ + x2_i + +
+ have the same mathematical sign and are both nonzero finite numbers, the result has a positive mathematical sign. +
+ -
+
+ If +
++ + x1_i + +
+ and ++ + x2_i + +
+ have different mathematical signs and are both nonzero finite numbers, the result has a negative mathematical sign. +
+ -
+
+ In the remaining cases, where neither +
++ + -infinity + +
+ , ++ + +0 + +
+ , ++ + -0 + +
+ , nor ++ + NaN + +
+ is involved, the quotient must be computed and rounded to the nearest representable value according to IEEE 754-2019 and a supported rounding mode. If the magnitude is too larger to represent, the operation overflows and the result is an ++ + infinity + +
+ of appropriate mathematical sign. If the magnitude is too small to represent, the operation underflows and the result is a zero of appropriate mathematical sign. +
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ divide(x1,
+
+
+ x2)
+
+
+
+
+ .
+
+ __xor__(self, other, /) + + ¶ + +
+
+ Evaluates
+
+
+ self_i
+
+
+ ^
+
+
+ other_i
+
+
+ for each element of an array instance with the respective element of the array
+
+
+ other
+
+
+ .
+
+ Parameters + + ¶ + +
+-
+
-
+
+ + self + + : + + <array> + +
+-
+
-
+
+ array instance. Must have an integer or boolean data type. +
+
+
+ -
+
-
+
+ + other + + : + + <array> + +
+-
+
-
+
+ other array. Must be compatible with +
++ + self + +
+ (see + + + Broadcasting + + + ). Must have an integer or boolean data type. +
+
+ -
+
+ Returns + + ¶ + +
+-
+
-
+
+ + out + + : + + <array> + +
+-
+
-
+
+ an array containing the element-wise results. The returned array must have a data type determined by + + + Type Promotion Rules + + + . +
+
+
+ -
+
+ Note +
+
+ Element-wise results must equal the results returned by the equivalent element-wise function
+
+
+
+
+ bitwise_xor(x1,
+
+
+ x2)
+
+
+
+
+ .
+