ones

Construct a new slice, filled with ones, of element type E and shape(lengths ...).

pure
ones
(
E = double
size_t N
)
(
size_t[N] lengths...
)

Parameters

lengths size_t[N]

elements of shape

Return Value

Type: auto

new ones slice

Examples

import mir.algorithm.iteration : all;

//  -------
// | 1 1 1 |
// | 1 1 1 |
//  -------
auto o = ones(2, 3);
assert(o.all!(x => x == 1));
assert(o.shape == [2, 3]);
assert(o == ones([2, 3]));

Meta