|
32 | 32 |
|
33 | 33 | from ._elementwise_common import BinaryElementwiseFunc, UnaryElementwiseFunc |
34 | 34 | from ._type_utils import ( |
| 35 | + _acceptance_fn_divide, |
35 | 36 | _acceptance_fn_negative, |
36 | 37 | _acceptance_fn_reciprocal, |
| 38 | + _resolve_weak_types_all_py_ints, |
37 | 39 | ) |
38 | 40 |
|
39 | 41 | # U01: ==== ABS (x) |
|
637 | 639 | ) |
638 | 640 | del _cosh_docstring |
639 | 641 |
|
| 642 | +# B08: ==== DIVIDE (x1, x2) |
| 643 | +_divide_docstring_ = r""" |
| 644 | +divide(x1, x2, /, \*, out=None, order='K') |
| 645 | +
|
| 646 | +Calculates the ratio for each element `x1_i` of the input array `x1` with |
| 647 | +the respective element `x2_i` of the input array `x2`. |
| 648 | +
|
| 649 | +Args: |
| 650 | + x1 (usm_ndarray): |
| 651 | + First input array, expected to have a floating-point data type. |
| 652 | + x2 (usm_ndarray): |
| 653 | + Second input array, also expected to have a floating-point data type. |
| 654 | + out (Union[usm_ndarray, None], optional): |
| 655 | + Output array to populate. |
| 656 | + Array must have the correct shape and the expected data type. |
| 657 | + order ("C","F","A","K", optional): |
| 658 | + Memory layout of the new output array, if parameter |
| 659 | + `out` is ``None``. |
| 660 | + Default: "K". |
| 661 | +
|
| 662 | +Returns: |
| 663 | + usm_ndarray: |
| 664 | + An array containing the result of element-wise division. The data type |
| 665 | + of the returned array is determined by the Type Promotion Rules. |
| 666 | +""" |
| 667 | + |
| 668 | +divide = BinaryElementwiseFunc( |
| 669 | + "divide", |
| 670 | + ti._divide_result_type, |
| 671 | + ti._divide, |
| 672 | + _divide_docstring_, |
| 673 | + binary_inplace_fn=ti._divide_inplace, |
| 674 | + acceptance_fn=_acceptance_fn_divide, |
| 675 | + weak_type_resolver=_resolve_weak_types_all_py_ints, |
| 676 | +) |
| 677 | +del _divide_docstring_ |
| 678 | + |
| 679 | +# B09: ==== EQUAL (x1, x2) |
| 680 | +_equal_docstring_ = r""" |
| 681 | +equal(x1, x2, /, \*, out=None, order='K') |
| 682 | +
|
| 683 | +Calculates equality test results for each element `x1_i` of the input array `x1` |
| 684 | +with the respective element `x2_i` of the input array `x2`. |
| 685 | +
|
| 686 | +Args: |
| 687 | + x1 (usm_ndarray): |
| 688 | + First input array. May have any data type. |
| 689 | + x2 (usm_ndarray): |
| 690 | + Second input array. May have any data type. |
| 691 | + out (Union[usm_ndarray, None], optional): |
| 692 | + Output array to populate. |
| 693 | + Array must have the correct shape and the expected data type. |
| 694 | + order ("C","F","A","K", optional): |
| 695 | + Memory layout of the new output array, if parameter |
| 696 | + `out` is ``None``. |
| 697 | + Default: "K". |
| 698 | +
|
| 699 | +Returns: |
| 700 | + usm_ndarray: |
| 701 | + An array containing the result of element-wise equality comparison. |
| 702 | + The returned array has a data type of `bool`. |
| 703 | +""" |
| 704 | + |
| 705 | +equal = BinaryElementwiseFunc( |
| 706 | + "equal", |
| 707 | + ti._equal_result_type, |
| 708 | + ti._equal, |
| 709 | + _equal_docstring_, |
| 710 | + weak_type_resolver=_resolve_weak_types_all_py_ints, |
| 711 | +) |
| 712 | +del _equal_docstring_ |
| 713 | + |
640 | 714 | # U13: ==== EXP (x) |
641 | 715 | _exp_docstring = r""" |
642 | 716 | exp(x, /, \*, out=None, order='K') |
|
664 | 738 | exp = UnaryElementwiseFunc("exp", ti._exp_result_type, ti._exp, _exp_docstring) |
665 | 739 | del _exp_docstring |
666 | 740 |
|
| 741 | +# B10: ==== FLOOR_DIVIDE (x1, x2) |
| 742 | +_floor_divide_docstring_ = r""" |
| 743 | +floor_divide(x1, x2, /, \*, out=None, order='K') |
| 744 | +
|
| 745 | +Calculates the ratio for each element `x1_i` of the input array `x1` with |
| 746 | +the respective element `x2_i` of the input array `x2` to the greatest |
| 747 | +integer-value number that is not greater than the division result. |
| 748 | +
|
| 749 | +Args: |
| 750 | + x1 (usm_ndarray): |
| 751 | + First input array, expected to have a real-valued data type. |
| 752 | + x2 (usm_ndarray): |
| 753 | + Second input array, also expected to have a real-valued data type. |
| 754 | + out (Union[usm_ndarray, None], optional): |
| 755 | + Output array to populate. |
| 756 | + Array must have the correct shape and the expected data type. |
| 757 | + order ("C","F","A","K", optional): |
| 758 | + Memory layout of the new output array, if parameter |
| 759 | + `out` is ``None``. |
| 760 | + Default: "K". |
| 761 | +
|
| 762 | +Returns: |
| 763 | + usm_ndarray: |
| 764 | + An array containing the result of element-wise floor of division. |
| 765 | + The data type of the returned array is determined by the Type |
| 766 | + Promotion Rules. |
| 767 | +""" |
| 768 | + |
| 769 | +floor_divide = BinaryElementwiseFunc( |
| 770 | + "floor_divide", |
| 771 | + ti._floor_divide_result_type, |
| 772 | + ti._floor_divide, |
| 773 | + _floor_divide_docstring_, |
| 774 | + binary_inplace_fn=ti._floor_divide_inplace, |
| 775 | +) |
| 776 | +del _floor_divide_docstring_ |
| 777 | + |
667 | 778 | # U14: ==== EXPM1 (x) |
668 | 779 | _expm1_docstring = r""" |
669 | 780 | expm1(x, /, \*, out=None, order='K') |
|
0 commit comments