pub fn ones_single_input(n: Dynamic) -> Result<Array, Box<EvalAltResult>>
Expand description
Return a matrix of ones. Can be called with a single integer argument (indicating the square matrix of that size) or with an array argument (indicating the size for each dimension).
let matrix = ones(3);
assert_eq(matrix, [[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0]]);
let matrix = ones([3, 3]);
assert_eq(matrix, [[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0]]);
let matrix = ones([3]);
assert_eq(matrix, [1.0, 1.0, 1.0]);
let matrix = ones([3, 3, 3]);
assert_eq(matrix, [[[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0]],
[[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0]],
[[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
[1.0, 1.0, 1.0]]]);