# mindspore.numpy.linspace¶

mindspore.numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)[source]

Returns evenly spaced values within a given interval.

Parameters
• start (Union[int, list(int), tuple(int), tensor]) – The starting value of the sequence.

• stop (Union[int, list(int), tuple(int), tensor]) – The end value of the sequence, unless endpoint is set to False. In that case, the sequence consists of all but the last of num + 1 evenly spaced samples, so that stop is excluded. Note that the step size changes when endpoint is False.

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

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

• retstep (bool, optional) – If True, return (samples, step), where step is the spacing between samples.

• dtype (Union[mindspore.dtype, str], optional) – Designated tensor dtype, If dtype is None, infer the data type from other input arguments. Default is None.

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

Returns

Tensor, with num equally spaced samples in the closed interval $$[start, stop]$$ or the half-open interval $$[start, stop)$$ (depending on whether endpoint is True or False).

Step, the size of spacing between samples, only returned if retstep is True.

Raises

TypeError – If input arguments have types not specified above.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore.numpy as np
>>> print(np.linspace(0, 5, 6))
[0. 1. 2. 3. 4. 5.]