dpnp.geomspace

dpnp.geomspace(start, stop, /, num=50, *, dtype=None, device=None, usm_type=None, sycl_queue=None, endpoint=True, axis=0)[source]

Return numbers spaced evenly on a log scale (a geometric progression).

For full documentation refer to numpy.geomspace.

Parameters:
  • start (array_like) -- The starting value of the sequence, 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.

  • stop (array_like) -- The final value of the sequence, 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. If endpoint is False num + 1 values are spaced over the interval in log-space, of which all but the last (a sequence of length num) are returned.

  • num (int, optional) -- Number of samples to generate. Default is 50.

  • dtype ({None, dtype}, optional) -- The desired dtype for the array. If not given, a default dtype will be used that can represent the values (by considering Promotion Type Rule and device capabilities when necessary).

  • 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 of dpctl.SyclDevice corresponding to a non-partitioned SYCL device, an instance of dpctl.SyclQueue, or a Device object returned by dpnp.dpnp_array.dpnp_array.device property.

  • usm_type ({None, "device", "shared", "host"}, optional) -- The type of SYCL USM allocation for the output array. Default is None.

  • sycl_queue ({None, SyclQueue}, optional) -- A SYCL queue to use for output array allocation and copying.

  • endpoint ({bool}, optional) -- If True, stop is the last sample. Otherwise, it is not included. Default is True.

  • axis ({int}, optional) -- The axis in the result to store the samples. Relevant only if start or stop are array-like. By default (0), the samples will be along a new axis inserted at the beginning. Use -1 to get an axis at the end.

Returns:

out -- num samples, equally spaced on a log scale.

Return type:

dpnp.ndarray

See also

dpnp.logspace

Similar to dpnp.geomspace, but with endpoints specified using log and base.

dpnp.linspace

Similar to dpnp.geomspace, but with arithmetic instead of geometric progression.

dpnp.arange

Similar to dpnp.linspace, with the step size specified instead of the number of samples.

Examples

>>> import dpnp as np
>>> np.geomspace(1, 1000, num=4)
array([   1.,   10.,  100., 1000.])
>>> np.geomspace(1, 1000, num=3, endpoint=False)
array([  1.,  10., 100.])
>>> np.geomspace(1, 1000, num=4, endpoint=False)
array([  1.        ,   5.62341325,  31.6227766 , 177.827941  ])
>>> np.geomspace(1, 256, num=9)
array([  1.,   2.,   4.,   8.,  16.,  32.,  64., 128., 256.])
>>> np.geomspace(1, 256, num=9, dtype=int)
array([  1,   2,   4,   7,  16,  32,  63, 127, 256])
>>> np.around(np.geomspace(1, 256, num=9)).astype(int)
array([  1,   2,   4,   8,  16,  32,  64, 128, 256])
>>> np.geomspace(1000, 1, num=4)
array([1000.,  100.,   10.,    1.])
>>> np.geomspace(-1000, -1, num=4)
array([-1000.,  -100.,   -10.,    -1.])

Creating an array on a different device or with a specified usm_type

>>> x = np.geomspace(1000, 1, num=4) # default case
>>> x, x.device, x.usm_type
(array([1000.,  100.,   10.,    1.]), Device(level_zero:gpu:0), 'device')
>>> y = np.geomspace(1000, 1, num=4, device="cpu")
>>> y, y.device, y.usm_type
(array([1000.,  100.,   10.,    1.]), Device(opencl:cpu:0), 'device')
>>> z = np.geomspace(1000, 1, num=4, usm_type="host")
>>> z, z.device, z.usm_type
(array([1000.,  100.,   10.,    1.]), Device(level_zero:gpu:0), 'host')