dpnp.logspace
- dpnp.logspace(start, stop, /, num=50, *, device=None, usm_type=None, sycl_queue=None, endpoint=True, base=10.0, dtype=None, axis=0)[source]
Return numbers spaced evenly on a log scale.
For full documentation refer to
numpy.logspace
.- Parameters:
start (array_like) -- Input data, 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. base ** start is the starting value of the sequence.
stop (array_like) -- Input data, 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. base ** stop is the final value of the sequence, unless endpoint is
False
. In that case,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:
50
.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.
endpoint ({bool}, optional) -- If
True
, stop is the last sample. Otherwise, it is not included. Default:True
.base ({array_like}, optional) -- Input data, 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. The base of the log space, 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. The step size between the elements in
ln(samples) / ln(base)
(or log_base(samples)) is uniform. Default:10.0
.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).
axis (int, optional) -- The axis in the result to store the samples. Relevant only if start, stop, or base 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.arange
Similar to
dpnp.linspace
, with the step size specified instead of the number of samples. Note that, when used with a float endpoint, the endpoint may or may not be included.dpnp.linspace
Similar to
dpnp.logspace
, but with the samples uniformly distributed in linear space, instead of log space.dpnp.geomspace
Similar to
dpnp.logspace
, but with endpoints specified directly.
Examples
>>> import dpnp as np >>> np.logspace(2.0, 3.0, num=4) array([ 100. , 215.443469 , 464.15888336, 1000. ])
>>> np.logspace(2.0, 3.0, num=4, endpoint=False) array([100. , 177.827941 , 316.22776602, 562.34132519])
>>> np.logspace(2.0, 3.0, num=4, base=2.0) array([4. , 5.0396842 , 6.34960421, 8. ])
>>> np.logspace(2.0, 3.0, num=4, base=[2.0, 3.0], axis=-1) array([[ 4. , 5.0396842 , 6.34960421, 8. ], [ 9. , 12.98024613, 18.72075441, 27. ]])
Creating an array on a different device or with a specified usm_type
>>> x = np.logspace(1.0, 3.0, num=3) # default case >>> x, x.device, x.usm_type (array([ 10., 100., 1000.]), Device(level_zero:gpu:0), 'device')
>>> y = np.logspace(1.0, 3.0, num=3, device="cpu") >>> y, y.device, y.usm_type (array([ 10., 100., 1000.]), Device(opencl:cpu:0), 'device')
>>> z = np.logspace(1.0, 3.0, num=3, usm_type="host") >>> z, z.device, z.usm_type (array([ 10., 100., 1000.]), Device(level_zero:gpu:0), 'host')