dpnp.sqrt

dpnp.sqrt(x, out=None, where=True, order='K', dtype=None, subok=True, **kwargs)

Computes the principal square-root for each element \(x_i\) of input array x.

For full documentation refer to numpy.sqrt.

Parameters:
  • x ({dpnp.ndarray, usm_ndarray}) -- Input array, expected to have a floating-point data type.

  • out ({None, dpnp.ndarray, usm_ndarray}, optional) --

    Output array to populate. Array must have the correct shape and the expected data type.

    Default: None.

  • order ({None, "C", "F", "A", "K"}, optional) --

    Memory layout of the newly output array, if parameter out is None.

    Default: "K".

Returns:

out -- An array containing the element-wise principal square-roots of x. The data type of the returned array is determined by the Type Promotion Rules.

Return type:

dpnp.ndarray

Limitations

Parameters where and subok are supported with their default values. Keyword argument kwargs is currently unsupported. Otherwise NotImplementedError exception will be raised.

See also

dpnp.cbrt

Calculate \(\sqrt[3]{x}\), element-wise.

dpnp.rsqrt

Calculate \(\frac{1}{\sqrt{x}}\), element-wise.

Notes

This function is equivalent to \(\sqrt{x}\), element-wise.

By convention, the branch cut of the square root is the negative real axis \((-\infty, 0)\).

The square root is a continuous function from above the branch cut, taking into account the sign of the imaginary component.

Accordingly, for complex arguments, the function returns the square root in the range of the right half-plane, including the imaginary axis (i.e., the plane defined by \([0, +\infty)\) along the real axis and \((-\infty, +\infty)\) along the imaginary axis).

Examples

>>> import dpnp as np
>>> x = np.array([1, 4, 9])
>>> np.sqrt(x)
array([1., 2., 3.])
>>> x2 = np.array([4, -1, np.inf])
>>> np.sqrt(x2)
array([ 2., nan, inf])