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
Falsenum + 1values 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:
50.dtype ({None, str, dtype object}, 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, Device}, optional) --
An array API concept of device where the output array is created. device can be
None, a oneAPI filter selector string, an instance ofdpctl.SyclDevicecorresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue, or adpctl.tensor.Deviceobject returned bydpnp.ndarray.device.Default:
None.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.
endpoint (bool, optional) -- If
True, stop is the last sample. Otherwise, it is not included. Default: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.logspaceSimilar to
dpnp.geomspace, but with endpoints specified using log and base.dpnp.linspaceSimilar to
dpnp.geomspace, but with arithmetic instead of geometric progression.dpnp.arangeSimilar 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')