|
16 | 16 | "bitwise_xor",
|
17 | 17 | "ceil",
|
18 | 18 | "conj",
|
| 19 | + "copysign", |
19 | 20 | "cos",
|
20 | 21 | "cosh",
|
21 | 22 | "divide",
|
@@ -804,6 +805,47 @@ def conj(x: array, /) -> array:
|
804 | 805 | """
|
805 | 806 |
|
806 | 807 |
|
| 808 | +def copysign(x1: array, x2: array, /) -> array: |
| 809 | + r""" |
| 810 | + Composes a floating-point value with the magnitude of ``x1_i`` and the sign of ``x2_i`` for each element of the input array ``x1``. |
| 811 | +
|
| 812 | + Parameters |
| 813 | + ---------- |
| 814 | + x1: array |
| 815 | + input array containing magnitudes. Should have a real-valued floating-point data type. |
| 816 | + x2: array |
| 817 | + input array whose sign bits are applied to the magnitudes of ``x1``. Must be compatible with ``x1`` (see :ref:`broadcasting`). Should have a real-valued floating-point data type. |
| 818 | +
|
| 819 | + Returns |
| 820 | + ------- |
| 821 | + out: array |
| 822 | + an array containing the element-wise results. The returned array must have a floating-point data type determined by :ref:`type-promotion`. |
| 823 | +
|
| 824 | + Notes |
| 825 | + ----- |
| 826 | +
|
| 827 | + **Special cases** |
| 828 | +
|
| 829 | + For real-valued floating-point operands, let ``|x|`` be the absolute value, and if ``x1_i`` is not ``NaN``, |
| 830 | +
|
| 831 | + - If ``x2_i`` is less than ``0``, the result is ``-|x1_i|``. |
| 832 | + - If ``x2_i`` is ``-0``, the result is ``-|x1_i|``. |
| 833 | + - If ``x2_i`` is ``+0``, the result is ``|x1_i|``. |
| 834 | + - If ``x2_i`` is greater than ``0``, the result is ``|x1_i|``. |
| 835 | + - If ``x2_i`` is ``NaN`` and the sign bit of ``x2_i`` is ``1``, the result is ``-|x1_i|``. |
| 836 | + - If ``x2_i`` is ``NaN`` and the sign bit of ``x2_i`` is ``0``, the result is ``|x1_i|``. |
| 837 | +
|
| 838 | + If ``x1_i`` is ``NaN``, |
| 839 | +
|
| 840 | + - If ``x2_i`` is less than ``0``, the result is ``NaN`` with a sign bit of ``1``. |
| 841 | + - If ``x2_i`` is ``-0``, the result is ``NaN`` with a sign bit of ``1``. |
| 842 | + - If ``x2_i`` is ``+0``, the result is ``NaN`` with a sign bit of ``0``. |
| 843 | + - If ``x2_i`` is greater than ``0``, the result is ``NaN`` with a sign bit of ``0``. |
| 844 | + - If ``x2_i`` is ``NaN`` and the sign bit of ``x2_i`` is ``1``, the result is ``NaN`` with a sign bit of ``1``. |
| 845 | + - If ``x2_i`` is ``NaN`` and the sign bit of ``x2_i`` is ``0``, the result is ``NaN`` with a sign bit of ``0``. |
| 846 | + """ |
| 847 | + |
| 848 | + |
807 | 849 | def cos(x: array, /) -> array:
|
808 | 850 | r"""
|
809 | 851 | Calculates an implementation-dependent approximation to the cosine for each element ``x_i`` of the input array ``x``.
|
|
0 commit comments