dpnp.vander
- dpnp.vander(x, /, N=None, increasing=False, *, device=None, usm_type=None, sycl_queue=None)[source]
Generate a Vandermonde matrix.
For full documentation refer to
numpy.vander
.- Parameters:
x (array_like) -- 1-D input array, in any form that can be converted to an array. This includes scalars, lists, lists of tuples, tuples, tuples of tuples, tuples of lists, and ndarrays.
N ({None, int}, optional) -- Number of columns in the output. If N is not specified, a square array is returned
(N = len(x))
.increasing (bool, optional) -- Order of the powers of the columns. If
True,
the powers increase from left to right, ifFalse
(the default) they are reversed.device ({None, string, SyclDevice, SyclQueue}, optional) -- An array API concept of device where the output array is created. The device can be
None
(the default), an OneAPI filter selector string, an instance ofdpctl.SyclDevice
corresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue
, or a Device object returned bydpnp.dpnp_array.dpnp_array.device
property.usm_type ({None, "device", "shared", "host"}, optional) -- The type of SYCL USM allocation for the output array. Default:
None
.sycl_queue ({None, SyclQueue}, optional) -- A SYCL queue to use for output array allocation and copying. The sycl_queue can be passed as
None
(the default), which means to get the SYCL queue from device keyword if present or to use a default queue. Default:None
.
- Returns:
out -- Vandermonde matrix.
- Return type:
dpnp.ndarray
Examples
>>> import dpnp as np >>> x0 = np.array([1, 2, 3, 5]) >>> N = 3 >>> np.vander(x0, N) array([[ 1, 1, 1], [ 4, 2, 1], [ 9, 3, 1], [25, 5, 1]])
>>> np.vander(x0) array([[ 1, 1, 1, 1], [ 8, 4, 2, 1], [ 27, 9, 3, 1], [125, 25, 5, 1]])
>>> np.vander(x0, increasing=True) array([[ 1, 1, 1, 1], [ 1, 2, 4, 8], [ 1, 3, 9, 27], [ 1, 5, 25, 125]])
Creating an array on a different device or with a specified usm_type
>>> x = np.vander(x0) # default case >>> x, x.device, x.usm_type (array([[ 1, 1, 1, 1], [ 8, 4, 2, 1], [ 27, 9, 3, 1], [125, 25, 5, 1]]), Device(level_zero:gpu:0), 'device')
>>> y = np.vander(x0, device="cpu") >>> y, y.device, y.usm_type (array([[ 1, 1, 1, 1], [ 8, 4, 2, 1], [ 27, 9, 3, 1], [125, 25, 5, 1]]), Device(opencl:cpu:0), 'device')
>>> z = np.vander(x0, usm_type="host") >>> z, z.device, z.usm_type (array([[ 1, 1, 1, 1], [ 8, 4, 2, 1], [ 27, 9, 3, 1], [125, 25, 5, 1]]), Device(level_zero:gpu:0), 'host')