Array Creation Routines

Basic creation routines

cupy.empty

Returns an array without initializing the elements.

cupy.empty_like

Returns a new array with same shape and dtype of a given array.

cupy.eye

Returns a 2-D array with ones on the diagonals and zeros elsewhere.

cupy.identity

Returns a 2-D identity array.

cupy.ones

Returns a new array of given shape and dtype, filled with ones.

cupy.ones_like

Returns an array of ones with same shape and dtype as a given array.

cupy.zeros

Returns a new array of given shape and dtype, filled with zeros.

cupy.zeros_like

Returns an array of zeros with same shape and dtype as a given array.

cupy.full

Returns a new array of given shape and dtype, filled with a given value.

cupy.full_like

Returns a full array with same shape and dtype as a given array.

Creation from other data

cupy.array

Creates an array on the current device.

cupy.asarray

Converts an object to array.

cupy.asanyarray

Converts an object to array.

cupy.ascontiguousarray

Returns a C-contiguous array.

cupy.copy

Creates a copy of a given array on the current device.

cupy.fromfile

Reads an array from a file.

Numerical ranges

cupy.arange

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

cupy.linspace

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

cupy.logspace

Returns an array with evenly-spaced values on a log-scale.

cupy.meshgrid

Return coordinate matrices from coordinate vectors.

cupy.mgrid

Construct a multi-dimensional “meshgrid”.

cupy.ogrid

Construct a multi-dimensional “meshgrid”.

Matrix creation

cupy.diag

Returns a diagonal or a diagonal array.

cupy.diagflat

Creates a diagonal array from the flattened input.

cupy.tri

Creates an array with ones at and below the given diagonal.

cupy.tril

Returns a lower triangle of an array.

cupy.triu

Returns an upper triangle of an array.