dpnp.ufunc
- class dpnp.ufunc[source]
Functions that operate element by element on whole arrays.
Calling ufuncs: op(*x[, out], **kwargs)
Apply op to the arguments *x elementwise, broadcasting the arguments.
- Parameters:
x ({dpnp.ndarray, usm_ndarray}) -- One or two input arrays.
out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Output array to populate. Array must have the correct shape and the expected data type.
order ({None, "C", "F", "A", "K"}, optional) -- Memory layout of the newly output array, Cannot be provided together with out. Default:
"K".dtype ({None, dtype}, optional) -- If provided, the destination array will have this dtype. Cannot be provided together with out. Default:
None.casting ({"no", "equiv", "safe", "same_kind", "unsafe"}, optional) -- Controls what kind of data casting may occur. Cannot be provided together with out. Default:
"same_kind".
Limitations
Keyword arguments where and subok are supported with their default values. Other keyword arguments is currently unsupported. Otherwise
NotImplementedErrorexception will be raised.Methods
- outer(x1, x2, out=None, where=True, order='K', dtype=None, subok=True, **kwargs)[source]
Apply the ufunc op to all pairs (a, b) with a in A and b in B.
- Parameters:
x1 ({dpnp.ndarray, usm_ndarray}) -- First input array.
x2 ({dpnp.ndarray, usm_ndarray}) -- Second input array.
out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Output array to populate. Array must have the correct shape and the expected data type.
**kwargs -- For other keyword-only arguments, see the
dpnp.ufunc.
- Returns:
out -- Output array. 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
NotImplementedErrorexception will be raised.See also
dpnp.outerA less powerful version of dpnp.multiply.outer that ravels all inputs to 1D. This exists primarily for compatibility with old code.
dpnp.tensordotdpnp.tensordot(a, b, axes=((), ())) and dpnp.multiply.outer(a, b) behave same for all dimensions of a and b.
Examples
>>> import dpnp as np >>> A = np.array([1, 2, 3]) >>> B = np.array([4, 5, 6]) >>> np.multiply.outer(A, B) array([[ 4, 5, 6], [ 8, 10, 12], [12, 15, 18]])
A multi-dimensional example:
>>> A = np.array([[1, 2, 3], [4, 5, 6]]) >>> A.shape (2, 3) >>> B = np.array([[1, 2, 3, 4]]) >>> B.shape (1, 4) >>> C = np.multiply.outer(A, B) >>> C.shape; C (2, 3, 1, 4) array([[[[ 1, 2, 3, 4]], [[ 2, 4, 6, 8]], [[ 3, 6, 9, 12]]], [[[ 4, 8, 12, 16]], [[ 5, 10, 15, 20]], [[ 6, 12, 18, 24]]]])
- __eq__(value, /)
Return self==value.
- __ne__(value, /)
Return self!=value.
- __lt__(value, /)
Return self<value.
- __le__(value, /)
Return self<=value.
- __gt__(value, /)
Return self>value.
- __ge__(value, /)
Return self>=value.
Attributes
- nargs
Returns the number of arguments treated.
Examples
>>> import dpnp as np >>> np.add.nin 3 >>> np.multiply.nin 3 >>> np.power.nin 3 >>> np.exp.nin 2
- nin
Returns the number of arguments treated as inputs.
Examples
>>> import dpnp as np >>> np.add.nin 2 >>> np.multiply.nin 2 >>> np.power.nin 2 >>> np.exp.nin 1
- nout
Returns the number of arguments treated as outputs.
Examples
>>> import dpnp as np >>> np.add.nin 1 >>> np.multiply.nin 1 >>> np.power.nin 1 >>> np.exp.nin 1
- ntypes
The number of types.
Examples
>>> import dpnp as np >>> np.add.ntypes 14 >>> np.multiply.ntypes 14 >>> np.power.ntypes 13 >>> np.exp.ntypes 5 >>> np.remainder.ntypes 11
- types
Returns information about types supported by implementation function, using NumPy's character encoding for data types, e.g.
Examples
>>> import dpnp as np >>> np.add.types ['??->?', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L', 'ee->e', 'ff->f', 'dd->d', 'FF->F', 'DD->D']
>>> np.multiply.types ['??->?', 'bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L', 'ee->e', 'ff->f', 'dd->d', 'FF->F', 'DD->D']
>>> np.power.types ['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L', 'ee->e', 'ff->f', 'dd->d', 'FF->F', 'DD->D']
>>> np.exp.types ['e->e', 'f->f', 'd->d', 'F->F', 'D->D']
>>> np.remainder.types ['bb->b', 'BB->B', 'hh->h', 'HH->H', 'ii->i', 'II->I', 'll->l', 'LL->L', 'ee->e', 'ff->f', 'dd->d']