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:
- startarray_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.
- stoparray_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 + 1values are spaced over the interval in log-space, of which all but the last (a sequence of length num) are returned.- numint, optional
Number of samples to generate.
Default:
50.- 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 adpnp.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.
Default:
None.- 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, 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).
Default:
None.- axisint, 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.
Default:
0.
- Returns:
- out: dpnp.ndarray
num samples, equally spaced on a log scale.
See also
dpnp.arangeSimilar 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.linspaceSimilar to
dpnp.logspace, but with the samples uniformly distributed in linear space, instead of log space.dpnp.geomspaceSimilar 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')