ones_like¶
- ones_like(x: array, /, *, dtype: dtype | None = None, device: device | None = None) array¶
Returns a new array filled with ones and having the same
shapeas an input arrayx.Note
An output array having a complex floating-point data type must contain complex numbers having a real component equal to one and an imaginary component equal to zero (i.e.,
1 + 0j).- Parameters:
x (array) – input array from which to derive the output array shape.
dtype (Optional[dtype]) – output array data type. If
dtypeisNone, the output array data type must be inferred fromx. Default:None.device (Optional[device]) – device on which to place the created array. If
deviceisNone, the output array device must be inferred fromx. Default:None.
- Returns:
out (array) – an array having the same shape as
xand filled with ones.
Notes
Changed in version 2022.12: Added complex data type support.