ones<T extends SizedNativeType> function

VARP ones<T extends SizedNativeType>(
  1. List<int> shape, {
  2. String order = "C",
})

ones(shape, dtype=None, order='C') Return a new array of given shape and type, filled with ones.

Parameters

shape : int or sequence of ints Shape of the new array, e.g., (2, 3) or 2. dtype : data-type, optional The desired data-type for the array, e.g., np.int8. Default is np.float32. order : {'C', 'F'}, optional, default: C Compatible with numpy.

Returns

out : Var Var of ones with the given shape, dtype, and order.

Examples

np.ones(5) var(1., 1., 1., 1., 1.) np.ones((5,), dtype=int) var(1, 1, 1, 1, 1) np.ones((2, 1)) var([1., 1.]) s = (2,2) np.ones(s) var([1., 1., 1., 1.])

Implementation

VARP ones<T extends ffi.SizedNativeType>(
  List<int> shape, {
  String order = "C",
}) {
  _orderAssert(order);
  return full<T>(shape, F.scalar<T>(1), order: order);
}