Qu

zeros_like

Builtin index · Core maths

result = zeros_like(x)

Input: x · Output: result

What it is

A vector or matrix of the same shape as x (a Vec or Mat), filled with one or zero respectively — the shape is read directly from x, so it cannot fall out of step with it.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = zeros_like(x)
x vector, matrix, Vec, or Matnot documented yet
result —
Returns the same type and shape as x.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

g = meshgrid([1, 2, 3], [1, 2])
print(g.x)   # x-coordinate at every grid point

print(g.y)   # y-coordinate at every grid point


M = [1, 2, 3; 4, 5, 6]
print(ones_like(M))
print(zeros_like(M))
print("row_mean={row_mean(M)}  row_sum={row_sum(M)}")
output
[1, 2, 3; 1, 2, 3]
[1, 1, 1; 2, 2, 2]
[1, 1, 1; 1, 1, 1]
[0, 0, 0; 0, 0, 0]
row_mean=[2; 5]  row_sum=[6; 15]

from core-math

See also

ones_like — documented in the same entry.