Creation Functions

Array API specification for creating arrays.

A conforming implementation of the array API standard must provide and support the following functions.

Objects in API

arange(start, /, stop=None, step=1, *, dtype=None, device=None)

Returns evenly spaced values within the half-open interval [start, stop) as a one-dimensional array.

asarray(obj, /, *, dtype=None, device=None, copy=None)

Convert the input to an array.

empty(shape, *, dtype=None, device=None)

Returns an uninitialized array having a specified shape.

empty_like(x, /, *, dtype=None, device=None)

Returns an uninitialized array with the same shape as an input array x.

eye(n_rows, n_cols=None, /, *, k=0, dtype=None, device=None)

Returns a two-dimensional array with ones on the kth diagonal and zeros elsewhere.

from_dlpack(x, /, *, device=None, copy=None)

Returns a new array containing the data from another (array) object with a __dlpack__ method.

full(shape, fill_value, *, dtype=None, device=None)

Returns a new array having a specified shape and filled with fill_value.

full_like(x, /, fill_value, *, dtype=None, device=None)

Returns a new array filled with fill_value and having the same shape as an input array x.

linspace(start, stop, /, num, *, dtype=None, device=None, endpoint=True)

Returns evenly spaced numbers over a specified interval.

meshgrid(*arrays, indexing='xy')

Returns coordinate matrices from coordinate vectors.

ones(shape, *, dtype=None, device=None)

Returns a new array having a specified shape and filled with ones.

ones_like(x, /, *, dtype=None, device=None)

Returns a new array filled with ones and having the same shape as an input array x.

tril(x, /, *, k=0)

Returns the lower triangular part of a matrix (or a stack of matrices) x.

triu(x, /, *, k=0)

Returns the upper triangular part of a matrix (or a stack of matrices) x.

zeros(shape, *, dtype=None, device=None)

Returns a new array having a specified shape and filled with zeros.

zeros_like(x, /, *, dtype=None, device=None)

Returns a new array filled with zeros and having the same shape as an input array x.