linspace¶
- linspace(start: int | float, stop: int | float, /, num: int, *, dtype: dtype | None = None, device: device | None = None, endpoint: bool = True) array ¶
Returns evenly spaced numbers over a specified interval.
- Parameters:
start (Union[int, float]) – the start of the interval.
stop (Union[int, float]) –
the end of the interval. If
endpoint
isFalse
, the function must generate a sequence ofnum+1
evenly spaced numbers starting withstart
and ending withstop
and exclude thestop
from the returned array such that the returned array consists of evenly spaced numbers over the half-open interval[start, stop)
. Ifendpoint
isTrue
, the output array must consist of evenly spaced numbers over the closed interval[start, stop]
. Default:True
.Note
The step size changes when
endpoint
isFalse
.num (int) – number of samples. Must be a non-negative integer value; otherwise, the function must raise an exception.
dtype (Optional[dtype]) – output array data type. Should be a floating-point data type. If
dtype
isNone
, the output array data type must be the default floating-point data type. Default:None
.device (Optional[device]) – device on which to place the created array. Default:
None
.endpoint (bool) – boolean indicating whether to include
stop
in the interval. Default:True
.
- Returns:
out (array) – a one-dimensional array containing evenly spaced values.
Note
While this specification recommends that this function only return arrays having a floating-point data type, specification-compliant array libraries may choose to support output arrays having an integer data type (e.g., due to backward compatibility concerns). However, function behavior when generating integer output arrays is unspecified and, thus, is implementation-defined. Accordingly, using this function to generate integer output arrays is not portable.
Note
As mixed data type promotion is implementation-defined, behavior when
start
orstop
exceeds the maximum safe integer of an output floating-point data type is implementation-defined. An implementation may choose to overflow or raise an exception.