def hypot(x1, x2, dtype=None, out=None, where=True, **kwargs): """ Given the "legs" of a right triangle, return its hypotenuse. For full documentation refer to :obj:`numpy.hypot`. Limitations ----------- Parameters ``x1`` and ``x2`` are supported as either :obj:`dpnp.ndarray` or scalar. Parameters ``dtype``, ``out`` and ``where`` are supported with their default values. Keyword arguments ``kwargs`` are currently unsupported. Otherwise the functions will be executed sequentially on CPU. Input array data types are limited by supported DPNP :ref:`Data types`. Examples -------- >>> import dpnp as np >>> x1 = 3 * np.ones(3) >>> x2 = 4 * np.ones(3) >>> out = np.hypot(x1, x2) >>> [i for i in out] [5.0, 5.0, 5.0] """ x1_is_scalar = dpnp.isscalar(x1) x2_is_scalar = dpnp.isscalar(x2) x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_strides=False) x2_desc = dpnp.get_dpnp_descriptor(x2, copy_when_strides=False) if x1_desc and x2_desc and not kwargs: if not x1_desc and not x1_is_scalar: pass elif not x2_desc and not x2_is_scalar: pass elif x1_is_scalar and x2_is_scalar: pass elif x1_desc and x1_desc.ndim == 0: pass elif x2_desc and x2_desc.ndim == 0: pass elif dtype is not None: pass elif out is not None: pass elif not where: pass else: out_desc = dpnp.get_dpnp_descriptor( out) if out is not None else None return dpnp_hypot(x1_desc, x2_desc, dtype, out_desc, where).get_pyobj() return call_origin(numpy.hypot, x1, x2, dtype=dtype, out=out, where=where, **kwargs)
def tan(x1, out=None, **kwargs): """ Compute tangent element-wise. For full documentation refer to :obj:`numpy.tan`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Keyword arguments ``kwargs`` are currently unsupported. Input array data types are limited by supported DPNP :ref:`Data types`. Examples -------- >>> import numpy >>> import dpnp as np >>> x = np.array([-numpy.pi, numpy.pi/2, numpy.pi]) >>> out = np.tan(x) >>> [i for i in out] [1.22460635e-16, 1.63317787e+16, -1.22460635e-16] """ x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_strides=False) if x1_desc: out_desc = dpnp.get_dpnp_descriptor(out) if out is not None else None return dpnp_tan(x1_desc, out_desc).get_pyobj() return call_origin(numpy.tan, x1, out=out, **kwargs)
def exp(x1, out=None, **kwargs): """ Trigonometric exponent, element-wise. For full documentation refer to :obj:`numpy.exp`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Input array data types are limited by supported DPNP :ref:`Data types`. See Also -------- :obj:`dpnp.expm1` : Calculate ``exp(x) - 1`` for all elements in the array. :obj:`dpnp.exp2` : Calculate `2**x` for all elements in the array. Examples -------- >>> import dpnp as np >>> x = np.arange(3.) >>> out = np.exp(x) >>> [i for i in out] [1.0, 2.718281828, 7.389056099] """ x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_strides=False) if x1_desc: out_desc = dpnp.get_dpnp_descriptor(out) if out is not None else None return dpnp_exp(x1_desc, out_desc).get_pyobj() return call_origin(numpy.exp, x1, out=out, **kwargs)
def take_along_axis(x1, indices, axis): """ Take values from the input array by matching 1d index and data slices. For full documentation refer to :obj:`numpy.take_along_axis`. See Also -------- :obj:`dpnp.take` : Take along an axis, using the same indices for every 1d slice. :obj:`put_along_axis` : Put values into the destination array by matching 1d index and data slices. """ x1_desc = dpnp.get_dpnp_descriptor(x1) indices_desc = dpnp.get_dpnp_descriptor(indices) if x1_desc and indices_desc: if x1_desc.ndim != indices_desc.ndim: pass elif not isinstance(axis, int): pass elif axis >= x1_desc.ndim: pass elif x1_desc.ndim == indices_desc.ndim: val_list = [] for i in list(indices_desc.shape)[:-1]: if i == 1: val_list.append(True) else: val_list.append(False) if not all(val_list): pass else: return dpnp_take_along_axis(x1, indices, axis) else: return dpnp_take_along_axis(x1, indices, axis) return call_origin(numpy.take_along_axis, x1, indices, axis)
def arctan(x1, out=None, **kwargs): """ Trigonometric inverse tangent, element-wise. For full documentation refer to :obj:`numpy.arctan`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Keyword arguments ``kwargs`` are currently unsupported. Input array data types are limited by supported DPNP :ref:`Data types`. See Also -------- :obj:`dpnp.arctan2` : Element-wise arc tangent of ``x1/x2`` choosing the quadrant correctly. :obj:`dpnp.angle` : Argument of complex values. Examples -------- >>> import dpnp as np >>> x = np.array([0, 1]) >>> out = np.arctan(x) >>> [i for i in out] [0.0, 0.78539816] """ x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_strides=False) if x1_desc: out_desc = dpnp.get_dpnp_descriptor(out) if out is not None else None return dpnp_arctan(x1_desc, out_desc).get_pyobj() return call_origin(numpy.arctan, x1, out=out, **kwargs)
def diagflat(x1, k=0): """ Create a two-dimensional array with the flattened input as a diagonal. For full documentation refer to :obj:`numpy.diagflat`. Examples -------- >>> import dpnp as np >>> np.diagflat([[1,2], [3,4]]) array([[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]) >>> np.diagflat([1,2], 1) array([[0, 1, 0], [0, 0, 2], [0, 0, 0]]) """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: input_ravel = dpnp.ravel(x1) input_ravel_desc = dpnp.get_dpnp_descriptor(input_ravel) return dpnp_diag(input_ravel_desc, k).get_pyobj() return call_origin(numpy.diagflat, x1, k)
def put_along_axis(x1, indices, values, axis): """ Put values into the destination array by matching 1d index and data slices. For full documentation refer to :obj:`numpy.put_along_axis`. See Also -------- :obj:`take_along_axis` : Take values from the input array by matching 1d index and data slices. """ x1_desc = dpnp.get_dpnp_descriptor(x1) indices_desc = dpnp.get_dpnp_descriptor(indices) values_desc = dpnp.get_dpnp_descriptor(values) if x1_desc and indices_desc and values_desc: if x1_desc.ndim != indices_desc.ndim: pass elif not isinstance(axis, int): pass elif axis >= x1_desc.ndim: pass elif indices_desc.size != values_desc.size: pass else: return dpnp_put_along_axis(x1_desc, indices_desc, values_desc, axis) return call_origin(numpy.put_along_axis, x1, indices, values, axis, dpnp_inplace=True)
def take(x1, indices, axis=None, out=None, mode='raise'): """ Take elements from an array. For full documentation refer to :obj:`numpy.take`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Parameters ``axis``, ``out`` and ``mode`` are supported only with default values. Parameter ``indices`` is supported as :obj:`dpnp.ndarray`. See Also -------- :obj:`dpnp.compress` : Take elements using a boolean mask. :obj:`take_along_axis` : Take elements by matching the array and the index arrays. """ x1_desc = dpnp.get_dpnp_descriptor(x1) indices_desc = dpnp.get_dpnp_descriptor(indices) if x1_desc and indices_desc: if axis is not None: pass elif out is not None: pass elif mode != 'raise': pass else: return dpnp_take(x1_desc, indices_desc).get_pyobj() return call_origin(numpy.take, x1, indices, axis, out, mode)
def searchsorted(x1, x2, side='left', sorter=None): """ Find indices where elements should be inserted to maintain order. For full documentation refer to :obj:`numpy.searchsorted`. Limitations ----------- Input arrays is supported as :obj:`dpnp.ndarray`. Input array is supported only sorted. Input side is supported only values ``left``, ``right``. Parameters ``sorter`` is supported only with default values. """ x1_desc = dpnp.get_dpnp_descriptor(x1) x2_desc = dpnp.get_dpnp_descriptor(x2) if 0 and x1_desc and x2_desc: if x1_desc.ndim != 1: pass elif x1_desc.dtype != x2_desc.dtype: pass elif side not in ['left', 'right']: pass elif sorter is not None: pass elif x1_desc.size < 2: pass else: return dpnp_searchsorted(x1_desc, x2_desc, side=side).get_pyobj() return call_origin(numpy.searchsorted, x1, x2, side=side, sorter=sorter)
def cos(x1, out=None, **kwargs): """ Trigonometric cosine, element-wise. For full documentation refer to :obj:`numpy.cos`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Input array data types are limited by supported DPNP :ref:`Data types`. Examples -------- >>> import numpy >>> import dpnp as np >>> x = np.array([0, numpy.pi/2, numpy.pi]) >>> out = np.cos(x) >>> [i for i in out] [1.0, 6.123233995736766e-17, -1.0] """ x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_strides=False) if x1_desc: out_desc = dpnp.get_dpnp_descriptor(out) if out is not None else None return dpnp_cos(x1_desc, out_desc).get_pyobj() return call_origin(numpy.cos, x1, out=out, **kwargs)
def outer(x1, x2, **kwargs): """ Returns the outer product of two arrays. For full documentation refer to :obj:`numpy.outer`. Limitations ----------- Parameters ``x1`` and ``x2`` are supported as :obj:`dpnp.ndarray`. Keyword arguments ``kwargs`` are currently unsupported. Otherwise the functions will be executed sequentially on CPU. Input array data types are limited by supported DPNP :ref:`Data types`. See Also -------- :obj:`dpnp.einsum` : Evaluates the Einstein summation convention on the operands. :obj:`dpnp.inner` : Returns the inner product of two arrays. Examples -------- >>> import dpnp as np >>> a = np.array([1, 1, 1]) >>> b = np.array([1, 2, 3]) >>> result = np.outer(a, b) >>> [x for x in result] [1, 2, 3, 1, 2, 3, 1, 2, 3] """ x1_desc = dpnp.get_dpnp_descriptor(x1) x2_desc = dpnp.get_dpnp_descriptor(x2) if x1_desc and x2_desc and not kwargs: return dpnp_outer(x1_desc, x2_desc).get_pyobj() return call_origin(numpy.outer, x1, x2, **kwargs)
def rfftn(x1, s=None, axes=None, norm=None): """ Compute the N-dimensional discrete Fourier Transform for real input. Multi-dimensional arrays computed as batch of 1-D arrays Limitations ----------- Parameter ``norm`` is unsupported. Parameter ``x1`` supports ``dpnp.int32``, ``dpnp.int64``, ``dpnp.float32``, ``dpnp.float64`` and ``dpnp.complex128`` datatypes only. For full documentation refer to :obj:`numpy.fft.rfftn`. """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: if s is None: boundaries = tuple([x1_desc.shape[i] for i in range(x1_desc.ndim)]) else: boundaries = s if axes is None: axes_param = tuple([i for i in range(x1_desc.ndim)]) else: axes_param = axes if norm is not None: pass elif len(axes) < 1: pass # let fallback to handle exception else: x1_iter = x1 iteration_list = list(range(len(axes_param))) iteration_list.reverse() # inplace operation for it in iteration_list: param_axis = axes_param[it] try: param_n = boundaries[param_axis] except IndexError: checker_throw_axis_error("fft.rfftn", "is out of bounds", param_axis, f"< {len(boundaries)}") x1_iter_desc = dpnp.get_dpnp_descriptor(x1_iter) x1_iter = rfft(x1_iter_desc.get_pyobj(), n=param_n, axis=param_axis, norm=norm) return x1_iter return call_origin(numpy.fft.rfftn, x1, s, axes, norm)
def _check_nd_call(origin_func, dpnp_func, x1, x2, dtype=None, out=None, where=True, **kwargs): """Choose function to call based on input and call chosen fucntion.""" x1_is_scalar = dpnp.isscalar(x1) x2_is_scalar = dpnp.isscalar(x2) x1_desc = dpnp.get_dpnp_descriptor(x1) x2_desc = dpnp.get_dpnp_descriptor(x2) if x1_desc and x2_desc and not kwargs: if not x1_desc and not x1_is_scalar: pass elif not x2_desc and not x2_is_scalar: pass elif x1_is_scalar and x2_is_scalar: pass elif x1_desc and x1_desc.ndim == 0: pass elif x2_desc and x2_desc.ndim == 0: pass elif x1_desc and x2_desc and x1_desc.size != x2_desc.size: pass elif x1_desc and x2_desc and x1_desc.shape != x2_desc.shape: pass elif out is not None and not isinstance(out, dparray): pass elif dtype is not None: pass elif out is not None: pass elif not where: pass else: return dpnp_func(x1_desc, x2_desc, dtype=dtype, out=out, where=where) return call_origin(origin_func, x1, x2, dtype=dtype, out=out, where=where, **kwargs)
def fill_diagonal(x1, val, wrap=False): """ Fill the main diagonal of the given array of any dimensionality. For full documentation refer to :obj:`numpy.fill_diagonal`. Limitations ----------- Parameter ``wrap`` is supported only with default values. See Also -------- :obj:`dpnp.diag_indices` : Return the indices to access the main diagonal of an array. :obj:`dpnp.diag_indices_from` : Return the indices to access the main diagonal of an n-dimensional array. """ x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_strides=False) if x1_desc: if not dpnp.isscalar(val): pass elif wrap: pass else: return dpnp_fill_diagonal(x1_desc, val) return call_origin(numpy.fill_diagonal, x1, val, wrap, dpnp_inplace=True)
def arccosh(x1): """ Trigonometric inverse hyperbolic cosine, element-wise. For full documentation refer to :obj:`numpy.arccosh`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Input array data types are limited by supported DPNP :ref:`Data types`. See Also -------- :obj:`dpnp.cosh` : Hyperbolic cosine, element-wise. :obj:`dpnp.arcsinh` : Inverse hyperbolic sine element-wise. :obj:`dpnp.sinh` : Hyperbolic sine, element-wise. :obj:`dpnp.arctanh` : Inverse hyperbolic tangent element-wise. :obj:`dpnp.tanh` : Compute hyperbolic tangent element-wise. Examples -------- >>> import numpy >>> import dpnp as np >>> x = np.array([numpy.e, 10.0]) >>> out = np.arccosh(x) >>> [i for i in out] [1.65745445, 2.99322285] """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: return dpnp_arccosh(x1_desc) return call_origin(numpy.arccosh, x1, **kwargs)
def diag_indices_from(x1): """ Return the indices to access the main diagonal of an n-dimensional array. For full documentation refer to :obj:`numpy.diag_indices_from`. See also -------- :obj:`diag_indices` : Return the indices to access the main diagonal of an array. """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: # original limitation if not x1_desc.ndim >= 2: pass # original limitation # For more than d=2, the strided formula is only valid for arrays with # all dimensions equal, so we check first. elif not numpy.alltrue( numpy.diff(x1_desc.shape) == 0): # TODO: replace alltrue and diff funcs with dpnp own ones pass else: return dpnp_diag_indices(x1_desc.shape[0], x1_desc.ndim) return call_origin(numpy.diag_indices_from, x1)
def diagonal(x1, offset=0, axis1=0, axis2=1): """ Return specified diagonals. For full documentation refer to :obj:`numpy.diagonal`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Parameters ``axis1`` and ``axis2`` are supported only with default values. Otherwise the function will be executed sequentially on CPU. """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: if not isinstance(offset, int): pass elif offset < 0: pass elif axis1 != 0: pass elif axis2 != 1: pass else: return dpnp_diagonal(x1_desc, offset).get_pyobj() return call_origin(numpy.diagonal, x1, offset, axis1, axis2)
def square(x1): """ Return the element-wise square of the input. For full documentation refer to :obj:`numpy.square`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Input array data types are limited by supported DPNP :ref:`Data types`. See Also -------- :obj:`dpnp.sqrt` : Return the positive square-root of an array, element-wise. :obj:`dpnp.power` : First array elements raised to powers from second array, element-wise. Examples -------- >>> import dpnp as np >>> x = np.array([1, 2, 3]) >>> out = np.square(x) >>> [i for i in out] [1, 4, 9] """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: return dpnp_square(x1_desc) return call_origin(numpy.square, x1, **kwargs)
def count_nonzero(x1, axis=None, *, keepdims=False): """ Counts the number of non-zero values in the array ``in_array1``. For full documentation refer to :obj:`numpy.count_nonzero`. Limitations ----------- Parameter ``x1`` is supported as :obj:`dpnp.ndarray`. Otherwise the function will be executed sequentially on CPU. Parameter ``axis`` is supported only with default value `None`. Parameter ``keepdims`` is supported only with default value `False`. Examples -------- >>> import dpnp as np >>> np.count_nonzero(np.array([1, 0, 3, 0, 5]) 3 >>> np.count_nonzero(np.array([[1, 0, 3, 0, 5],[0, 9, 0, 7, 0]])) 5 """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: if axis is not None: pass elif keepdims is not False: pass else: result_obj = dpnp_count_nonzero(x1_desc).get_pyobj() result = dpnp.convert_single_elem_array_to_scalar(result_obj) return result return call_origin(numpy.count_nonzero, x1, axis, keepdims=keepdims)
def tan(x1): """ Compute tangent element-wise. For full documentation refer to :obj:`numpy.tan`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Input array data types are limited by supported DPNP :ref:`Data types`. Examples -------- >>> import numpy >>> import dpnp as np >>> x = np.array([-numpy.pi, numpy.pi/2, numpy.pi]) >>> out = np.tan(x) >>> [i for i in out] [1.22460635e-16, 1.63317787e+16, -1.22460635e-16] """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: return dpnp_tan(x1_desc) return call_origin(numpy.tan, x1, **kwargs)
def ifftshift(x1, axes=None): """ Inverse shift the zero-frequency component to the center of the spectrum. Limitations ----------- Parameter ``axes`` is unsupported. Parameter ``x1`` supports ``dpnp.int32``, ``dpnp.int64``, ``dpnp.float32``, ``dpnp.float64`` and ``dpnp.complex128`` datatypes only. For full documentation refer to :obj:`numpy.fft.ifftshift`. """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc and 0: if axis is None: axis_param = -1 # the most right dimension (default value) else: axis_param = axes if x1_desc.size < 1: pass # let fallback to handle exception else: return dpnp_fft(x1_desc, input_boundarie, output_boundarie, axis_param, False).get_pyobj() return call_origin(numpy.fft.ifftshift, x1, axes)
def qr(x1, mode='reduced'): """ Compute the qr factorization of a matrix. Factor the matrix `a` as *qr*, where `q` is orthonormal and `r` is upper-triangular. For full documentation refer to :obj:`numpy.linalg.qr`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Parameter mode='complete' is supported. """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: if mode != 'reduced': pass else: result_tup = dpnp_qr(x1, mode) return result_tup return call_origin(numpy.linalg.qr, x1, mode)
def partition(x1, kth, axis=-1, kind='introselect', order=None): """ Return a partitioned copy of an array. For full documentation refer to :obj:`numpy.partition`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Input kth is supported as :obj:`int`. Parameters ``axis``, ``kind`` and ``order`` are supported only with default values. """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: if not isinstance(kth, int): pass elif x1_desc.ndim == 0: pass elif kth >= x1_desc.shape[x1_desc.ndim - 1] or x1_desc.ndim + kth < 0: pass elif axis != -1: pass elif kind != 'introselect': pass elif order is not None: pass else: return dpnp_partition(x1_desc, kth, axis, kind, order).get_pyobj() return call_origin(numpy.partition, x1, kth, axis, kind, order)
def sqrt(x1): """ Return the positive square-root of an array, element-wise. For full documentation refer to :obj:`numpy.sqrt`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Otherwise the function will be executed sequentially on CPU. Input array data types are limited by supported DPNP :ref:`Data types`. Examples -------- >>> import dpnp as np >>> x = np.array([1, 4, 9]) >>> out = np.sqrt(x) >>> [i for i in out] [1.0, 2.0, 3.0] """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: return dpnp_sqrt(x1_desc) return call_origin(numpy.sqrt, x1, **kwargs)
def tanh(x1): """ Compute hyperbolic tangent element-wise. For full documentation refer to :obj:`numpy.tanh`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Input array data types are limited by supported DPNP :ref:`Data types`. Examples -------- >>> import numpy >>> import dpnp as np >>> x = np.array([-numpy.pi, numpy.pi/2, numpy.pi]) >>> out = np.tanh(x) >>> [i for i in out] [-0.996272, 0.917152, 0.996272] """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: return dpnp_tanh(x1_desc) return call_origin(numpy.tanh, x1, **kwargs)
def ptp(arr, axis=None, out=None, keepdims=numpy._NoValue): """ Range of values (maximum - minimum) along an axis. For full documentation refer to :obj:`numpy.ptp`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Parameters ``out`` and ``keepdims`` are supported only with default values. """ arr_desc = dpnp.get_dpnp_descriptor(arr) if not arr_desc: pass elif axis is not None and not isinstance(axis, int): pass elif out is not None: pass elif keepdims is not numpy._NoValue: pass else: result_obj = dpnp_ptp(arr_desc, axis=axis).get_pyobj() result = dpnp.convert_single_elem_array_to_scalar(result_obj) return result return call_origin(numpy.ptp, arr, axis, out, keepdims)
def triu(x1, k=0): """ Upper triangle of an array. Return a copy of a matrix with the elements below the `k`-th diagonal zeroed. For full documentation refer to :obj:`numpy.triu`. Examples -------- >>> import dpnp as np >>> np.triu([[1,2,3],[4,5,6],[7,8,9],[10,11,12]], -1) array([[ 1, 2, 3], [ 4, 5, 6], [ 0, 8, 9], [ 0, 0, 12]]) """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: if not isinstance(k, int): pass else: return dpnp_triu(x1_desc, k).get_pyobj() return call_origin(numpy.triu, x1, k)
def trace(x1, offset=0, axis1=0, axis2=1, dtype=None, out=None): """ Return the sum along diagonals of the array. For full documentation refer to :obj:`numpy.trace`. Limitations ----------- Input array is supported as :obj:`dpnp.ndarray`. Parameters ``axis1``, ``axis2``, ``out`` and ``dtype`` are supported only with default values. """ x1_desc = dpnp.get_dpnp_descriptor(x1) if x1_desc: if x1_desc.size == 0: pass elif x1_desc.ndim < 2: pass elif axis1 != 0: pass elif axis2 != 1: pass elif out is not None: pass else: return dpnp_trace(x1_desc, offset, axis1, axis2, dtype, out).get_pyobj() return call_origin(numpy.trace, x1, offset, axis1, axis2, dtype, out)
def copy(x1, order='K', subok=False): """ Return an array copy of the given object. For full documentation refer to :obj:`numpy.copy`. Limitations ----------- Parameter ``order`` is supported only with default value ``"C"``. Parameter ``subok`` is supported only with default value ``False``. Examples -------- >>> import dpnp as np >>> x = np.array([1, 2, 3]) >>> y = x >>> z = np.copy(x) >>> x[0] = 10 >>> x[0] == y[0] True >>> x[0] == z[0] False """ x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_strides=False) if x1_desc: if order != 'K': pass elif subok: pass else: return dpnp_copy(x1_desc).get_pyobj() return call_origin(numpy.copy, x1, order, subok)
def eigvals(input): """ Compute the eigenvalues of a general matrix. Main difference between `eigvals` and `eig`: the eigenvectors aren't returned. Parameters ---------- input : (..., M, M) array_like A complex- or real-valued matrix whose eigenvalues will be computed. Returns ------- w : (..., M,) ndarray The eigenvalues, each repeated according to its multiplicity. They are not necessarily ordered, nor are they necessarily real for real matrices. """ x1_desc = dpnp.get_dpnp_descriptor(input) if x1_desc: if x1_desc.size > 0: return dpnp_eigvals(x1_desc).get_pyobj() return call_origin(numpy.linalg.eigvals, input)