Array creation routines

From shape or value

empty

Return a new array of given shape and type, without initializing entries.

empty_like

Return a new array with the same shape and type as a given array.

eye

Return a 2-D array with ones on the diagonal and zeros elsewhere.

identity

Return the identity array.

ones

Return a new array of given shape and type, filled with ones.

ones_like

Return an array of ones with the same shape and type as a given array.

zeros

Return a new array of given shape and type, filled with zeros.

zeros_like

Return an array of zeros with the same shape and type as a given array.

full

Return a new array of given shape and type, filled with fill_value.

full_like

Return a full array with the same shape and type as a given array.

From existing data

array

Create an array.

asarray

Converts an input object into array.

asanyarray

Convert the input to an dpnp.ndarray.

ascontiguousarray

Return a contiguous array (ndim >= 1) in memory (C order).

astype

Copy the array with data type casting.

copy

Return an array copy of the given object.

frombuffer

Interpret a buffer as a 1-dimensional array.

from_dlpack

Constructs dpnp.ndarray or numpy.ndarray instance from a Python object x that implements __dlpack__ protocol.

fromfile

Construct an array from data in a text or binary file.

fromfunction

Construct an array by executing a function over each coordinate.

fromiter

Create a new 1-dimensional array from an iterable object.

fromstring

A new 1-D array initialized from text data in a string.

loadtxt

Load data from a text file.

Numerical ranges

arange

Returns an array with evenly spaced values within a given interval.

linspace

Return evenly spaced numbers over a specified interval.

logspace

Return numbers spaced evenly on a log scale.

geomspace

Return numbers spaced evenly on a log scale (a geometric progression).

meshgrid

Return coordinate matrices from coordinate vectors.

mgrid

Construct a dense multi-dimensional "meshgrid".

ogrid

Construct an open multi-dimensional "meshgrid".

Building matrices

diag

Extract a diagonal or construct a diagonal array.

diagflat

Create a two-dimensional array with the flattened input as a diagonal.

tri

An array with ones at and below the given diagonal and zeros elsewhere.

tril

Lower triangle of an array.

triu

Upper triangle of an array.

vander

Generate a Vandermonde matrix.

The Matrix class