@@ -878,7 +878,8 @@ def cumlogsumexp(
878878 Parameters
879879 ----------
880880 x : {dpnp.ndarray, usm_ndarray}
881- Input array, expected to have a boolean or real-valued data type.
881+ Input array, expected to have a boolean or real-valued floating-point
882+ data type.
882883 axis : {None, int}, optional
883884 Axis or axes along which values must be computed. If a tuple of unique
884885 integers, values are computed over multiple axes. If ``None``, the
@@ -924,15 +925,15 @@ def cumlogsumexp(
924925 has the data type as described in the `dtype` parameter description
925926 above.
926927
927- Note
928- ----
929- This function is equivalent of `numpy.logaddexp.accumulate`.
930-
931928 See Also
932929 --------
933930 :obj:`dpnp.logsumexp` : Logarithm of the sum of elements of the inputs,
934931 element-wise.
935932
933+ Note
934+ ----
935+ This function is equivalent of `numpy.logaddexp.accumulate`.
936+
936937 Examples
937938 --------
938939 >>> import dpnp as np
@@ -1667,13 +1668,10 @@ def cumlogsumexp(
16671668)
16681669
16691670
1670- _LOGADDEXP_DOCSTRING = """
1671- Calculates the natural logarithm of the sum of exponents for each element `x1_i`
1672- of the input array `x1` with the respective element `x2_i` of the input
1673- array `x2`.
1674-
1675- This function calculates `log(exp(x1) + exp(x2))` more accurately for small
1676- values of `x`.
1671+ _LOGADDEXP_DOCSTRING = r"""
1672+ Calculates the natural logarithm of the sum of exponentiations
1673+ :math:`\log(e^{x1} + e^{x2})` for each element :math:`x1_i` of the input array
1674+ `x1` with the respective element :math:`x2_i` of the input array `x2`.
16771675
16781676For full documentation refer to :obj:`numpy.logaddexp`.
16791677
@@ -1682,13 +1680,9 @@ def cumlogsumexp(
16821680x1 : {dpnp.ndarray, usm_ndarray, scalar}
16831681 First input array, expected to have a real-valued floating-point
16841682 data type.
1685- Both inputs `x1` and `x2` can not be scalars at the same time.
16861683x2 : {dpnp.ndarray, usm_ndarray, scalar}
1687- Second input array, also expected to have a real-valued
1688- floating-point data type.
1689- Both inputs `x1` and `x2` can not be scalars at the same time.
1690- If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1691- (which becomes the shape of the output).
1684+ Second input array, also expected to have a real-valued floating-point data
1685+ type.
16921686out : {None, dpnp.ndarray, usm_ndarray}, optional
16931687 Output array to populate.
16941688 Array must have the correct shape and the expected data type.
@@ -1702,8 +1696,8 @@ def cumlogsumexp(
17021696Returns
17031697-------
17041698out : dpnp.ndarray
1705- An array containing the element-wise results. The data type
1706- of the returned array is determined by the Type Promotion Rules.
1699+ An array containing the element-wise results. The data type of the returned
1700+ array is determined by the Type Promotion Rules.
17071701
17081702Limitations
17091703-----------
@@ -1713,12 +1707,23 @@ def cumlogsumexp(
17131707
17141708See Also
17151709--------
1716- :obj:`dpnp.log` : Natural logarithm, element-wise.
1717- :obj:`dpnp.exp` : Exponential, element-wise.
1718- :obj:`dpnp.logaddexp2`: Logarithm of the sum of exponentiation of inputs in
1719- base-2, element-wise.
1720- :obj:`dpnp.logsumexp` : Logarithm of the sum of exponents of elements in the
1721- input array.
1710+ :obj:`dpnp.log` : Calculate :math:`\log(x)`, element-wise.
1711+ :obj:`dpnp.exp` : Calculate :math:`e^x`, element-wise.
1712+ :obj:`dpnp.logaddexp2`: Calculate :math:`\log_2(2^{x1} + 2^{x2})`, element-wise.
1713+ :obj:`dpnp.logsumexp` : Logarithm of the sum of exponentials of elements in the
1714+ input array.
1715+
1716+ Notes
1717+ -----
1718+ At least one of `x1` or `x2` must be an array.
1719+
1720+ If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1721+ (which becomes the shape of the output).
1722+
1723+ This function is useful in statistics where the calculated probabilities of
1724+ events may be so small as to exceed the range of normal floating-point numbers.
1725+ In such cases the natural logarithm of the calculated probability is stored.
1726+ This function allows adding probabilities stored in such a fashion.
17221727
17231728Examples
17241729--------
@@ -1741,16 +1746,10 @@ def cumlogsumexp(
17411746)
17421747
17431748
1744- _LOGADDEXP2_DOCSTRING = """
1745- Calculates the logarithm of the sum of exponents in base-2 for each element
1746- `x1_i` of the input array `x1` with the respective element `x2_i` of the input
1747- array `x2`.
1748-
1749- This function calculates `log2(2**x1 + 2**x2)`. It is useful in machine
1750- learning when the calculated probabilities of events may be so small as
1751- to exceed the range of normal floating point numbers. In such cases the base-2
1752- logarithm of the calculated probability can be used instead. This function
1753- allows adding probabilities stored in such a fashion.
1749+ _LOGADDEXP2_DOCSTRING = r"""
1750+ Calculates the base-2 logarithm of the sum of exponentiations
1751+ :math:`\log_2(2^{x1} + 2^{x2})` for each element :math:`x1_i` of the input
1752+ array `x1` with the respective element :math:`x2_i` of the input array `x2`.
17541753
17551754For full documentation refer to :obj:`numpy.logaddexp2`.
17561755
@@ -1759,13 +1758,9 @@ def cumlogsumexp(
17591758x1 : {dpnp.ndarray, usm_ndarray, scalar}
17601759 First input array, expected to have a real-valued floating-point
17611760 data type.
1762- Both inputs `x1` and `x2` can not be scalars at the same time.
17631761x2 : {dpnp.ndarray, usm_ndarray, scalar}
1764- Second input array, also expected to have a real-valued
1765- floating-point data type.
1766- Both inputs `x1` and `x2` can not be scalars at the same time.
1767- If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1768- (which becomes the shape of the output).
1762+ Second input array, also expected to have a real-valued floating-point data
1763+ type.
17691764out : {None, dpnp.ndarray, usm_ndarray}, optional
17701765 Output array to populate.
17711766 Array must have the correct shape and the expected data type.
@@ -1790,9 +1785,22 @@ def cumlogsumexp(
17901785
17911786See Also
17921787--------
1793- :obj:`dpnp.logaddexp`: Natural logarithm of the sum of exponentiation of
1794- inputs, element-wise.
1795- :obj:`dpnp.logsumexp` : Logarithm of the sum of exponentiation of the inputs.
1788+ :obj:`dpnp.logaddexp`: Calculate :math:`\log(e^{x1} + e^{x2})`, element-wise.
1789+ :obj:`dpnp.logsumexp` : Logarithm of the sum of exponentials of elements in the
1790+ input array.
1791+
1792+ Notes
1793+ -----
1794+ At least one of `x1` or `x2` must be an array.
1795+
1796+ If ``x1.shape != x2.shape``, they must be broadcastable to a common shape
1797+ (which becomes the shape of the output).
1798+
1799+ This function is useful in machine learning when the calculated probabilities
1800+ of events may be so small as to exceed the range of normal floating-point
1801+ numbers. In such cases the base-2 logarithm of the calculated probability can
1802+ be used instead. This function allows adding probabilities stored in such a
1803+ fashion.
17961804
17971805Examples
17981806--------
@@ -1816,14 +1824,15 @@ def cumlogsumexp(
18161824
18171825
18181826def logsumexp (x , / , * , axis = None , dtype = None , keepdims = False , out = None ):
1819- """
1820- Calculates the logarithm of the sum of exponents of elements in
1827+ r """
1828+ Calculates the natural logarithm of the sum of exponentials of elements in
18211829 the input array.
18221830
18231831 Parameters
18241832 ----------
18251833 x : {dpnp.ndarray, usm_ndarray}
1826- Input array, expected to have a real-valued floating-point data type.
1834+ Input array, expected to have a boolean or real-valued floating-point
1835+ data type.
18271836 axis : {None, int or tuple of ints}, optional
18281837 Axis or axes along which values must be computed. If a tuple of unique
18291838 integers, values are computed over multiple axes. If ``None``, the
@@ -1868,19 +1877,21 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
18681877 has the data type as described in the `dtype` parameter description
18691878 above.
18701879
1880+ See Also
1881+ --------
1882+ :obj:`dpnp.log` : Calculate :math:`\log(x)`, element-wise.
1883+ :obj:`dpnp.exp` : Calculate :math:`e^x`, element-wise.
1884+ :obj:`dpnp.logaddexp`: Calculate :math:`\log(e^{x1} + e^{x2})`,
1885+ element-wise.
1886+ :obj:`dpnp.logaddexp2`: Calculate :math:`\log_2(2^{x1} + 2^{x2})`,
1887+ element-wise.
1888+ :obj:`dpnp.cumlogsumexp` : Cumulative the natural logarithm of the sum of
1889+ elements in the input array.
1890+
18711891 Note
18721892 ----
18731893 This function is equivalent of `numpy.logaddexp.reduce`.
18741894
1875- See Also
1876- --------
1877- :obj:`dpnp.log` : Natural logarithm, element-wise.
1878- :obj:`dpnp.exp` : Exponential, element-wise.
1879- :obj:`dpnp.logaddexp` : Logarithm of the sum of exponents of
1880- the inputs, element-wise.
1881- :obj:`dpnp.logaddexp2` : Logarithm of the sum of exponents of
1882- the inputs in base-2, element-wise.
1883-
18841895 Examples
18851896 --------
18861897 >>> import dpnp as np
0 commit comments