Array Manipulation Routines

Basic operations

cupy.copyto

Copies values from one array to another with broadcasting.

Changing array shape

cupy.reshape

Returns an array with new shape and same elements.

cupy.ravel

Returns a flattened array.

Transpose-like operations

cupy.moveaxis

Moves axes of an array to new positions.

cupy.rollaxis

Moves the specified axis backwards to the given place.

cupy.swapaxes

Swaps the two axes.

cupy.transpose

Permutes the dimensions of an array.

See also

cupy.ndarray.T

Changing number of dimensions

cupy.atleast_1d

Converts arrays to arrays with dimensions >= 1.

cupy.atleast_2d

Converts arrays to arrays with dimensions >= 2.

cupy.atleast_3d

Converts arrays to arrays with dimensions >= 3.

cupy.broadcast

Object that performs broadcasting.

cupy.broadcast_to

Broadcast an array to a given shape.

cupy.broadcast_arrays

Broadcasts given arrays.

cupy.expand_dims

Expands given arrays.

cupy.squeeze

Removes size-one axes from the shape of an array.

Changing kind of array

cupy.asarray

Converts an object to array.

cupy.asanyarray

Converts an object to array.

cupy.asfortranarray

Return an array laid out in Fortran order in memory.

cupy.ascontiguousarray

Returns a C-contiguous array.

cupy.require

Return an array which satisfies the requirements.

Joining arrays

cupy.concatenate

Joins arrays along an axis.

cupy.stack

Stacks arrays along a new axis.

cupy.column_stack

Stacks 1-D and 2-D arrays as columns into a 2-D array.

cupy.dstack

Stacks arrays along the third axis.

cupy.hstack

Stacks arrays horizontally.

cupy.vstack

Stacks arrays vertically.

Splitting arrays

cupy.split

Splits an array into multiple sub arrays along a given axis.

cupy.array_split

Splits an array into multiple sub arrays along a given axis.

cupy.dsplit

Splits an array into multiple sub arrays along the third axis.

cupy.hsplit

Splits an array into multiple sub arrays horizontally.

cupy.vsplit

Splits an array into multiple sub arrays along the first axis.

Tiling arrays

cupy.tile

Construct an array by repeating A the number of times given by reps.

cupy.repeat

Repeat arrays along an axis.

Adding and removing elements

cupy.append

Append values to the end of an array.

cupy.resize

Return a new array with the specified shape.

cupy.unique

Find the unique elements of an array.

cupy.trim_zeros

Trim the leading and/or trailing zeros from a 1-D array or sequence.

Rearranging elements

cupy.flip

Reverse the order of elements in an array along the given axis.

cupy.fliplr

Flip array in the left/right direction.

cupy.flipud

Flip array in the up/down direction.

cupy.reshape

Returns an array with new shape and same elements.

cupy.roll

Roll array elements along a given axis.

cupy.rot90

Rotate an array by 90 degrees in the plane specified by axes.