onesLike<T extends SizedNativeType> function

VARP onesLike<T extends SizedNativeType>(
  1. VARP a, {
  2. String order = "K",
  3. List<int>? shape,
})

ones_like(a, dtype=None, order='K', subok=True, shape=None) Return an array of ones with the same shape and type as a given array.

Parameters

a : var_like The shape and data-type of a define these same attributes of the returned array. dtype : data-type, optional Overrides the data type of the result. order : {'C', 'F', 'A', or 'K'}, optional Compatible with numpy. subok : bool, optional. Compatible with numpy. shape : int or sequence of ints, optional. Overrides the shape of the result.

Returns

out : Var Var of ones with the same shape and type as a.

Examples

x = np.arange(6) x = x.reshape((2, 3)) x var([0, 1, 2, 3, 4, 5]) np.ones_like(x) var([1, 1, 1, 1, 1, 1]) y = np.arange(3, dtype=float) y var(0., 1., 2.) np.ones_like(y) var(1., 1., 1.)

Implementation

VARP onesLike<T extends ffi.SizedNativeType>(
  VARP a, {
  String order = "K",
  List<int>? shape,
}) {
  return fullLike<T>(a, 1, order: order, shape: shape);
}