__add__¶
- array.__add__(other: int | float | array, /) array¶
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
selfequalx1andotherequalx2.If either
x1_iorx2_iisNaN, the result isNaN.If
x1_iis+infinityandx2_iis-infinity, the result isNaN.If
x1_iis-infinityandx2_iis+infinity, the result isNaN.If
x1_iis+infinityandx2_iis+infinity, the result is+infinity.If
x1_iis-infinityandx2_iis-infinity, the result is-infinity.If
x1_iis+infinityandx2_iis a finite number, the result is+infinity.If
x1_iis-infinityandx2_iis a finite number, the result is-infinity.If
x1_iis a finite number andx2_iis+infinity, the result is+infinity.If
x1_iis a finite number andx2_iis-infinity, the result is-infinity.If
x1_iis-0andx2_iis-0, the result is-0.If
x1_iis-0andx2_iis+0, the result is+0.If
x1_iis+0andx2_iis-0, the result is+0.If
x1_iis+0andx2_iis+0, the result is+0.If
x1_iis either+0or-0andx2_iis a nonzero finite number, the result isx2_i.If
x1_iis a nonzero finite number andx2_iis either+0or-0, the result isx1_i.If
x1_iis a nonzero finite number andx2_iis-x1_i, the result is+0.In the remaining cases, when neither
infinity,+0,-0, nor aNaNis 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 aninfinityof appropriate mathematical sign.
Note
Floating-point addition is a commutative operation, but not always associative.
- Parameters:
self (array) – array instance (augend array). Should have a numeric data type.
other (Union[int, float, array]) – addend array. Must be compatible with
self(see Broadcasting). Should have a numeric data type.
- 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().