dpnp.ravel

dpnp.ravel(a, order='C')[source]

Return a contiguous flattened array.

For full documentation refer to numpy.ravel.

Parameters:
  • x ({dpnp.ndarray, usm_ndarray}) -- Input array. The elements in a are read in the order specified by order, and packed as a 1-D array.

  • order ({"C", "F"}, optional) -- The elements of a are read using this index order. "C" means to index the elements in row-major, C-style order, with the last axis index changing fastest, back to the first axis index changing slowest. "F" means to index the elements in column-major, Fortran-style order, with the first index changing fastest, and the last index changing slowest. By default, "C" index order is used.

Returns:

out -- A contiguous 1-D array of the same subtype as a, with shape (a.size,).

Return type:

dpnp.ndarray

See also

dpnp.reshape

Change the shape of an array without changing its data.

Examples

>>> import dpnp as np
>>> x = np.array([[1, 2, 3], [4, 5, 6]])
>>> np.ravel(x)
array([1, 2, 3, 4, 5, 6])
>>> x.reshape(-1)
array([1, 2, 3, 4, 5, 6])
>>> np.ravel(x, order='F')
array([1, 4, 2, 5, 3, 6])