row_sum
result = row_mean(M)
Input: M · Output: result
What it is
Collapses each row of M (an r×c Mat, or anything coercible to one) to one number, returning an r×1 column Mat (not a plain Vec). mean(M, axis = 0) collapses columns instead and returns a plain Vec — the axes are 0 and 1, not 1 and 2, and note the different return container (Mat here vs. Vec for the axis= form).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = row_mean(M) | M Mat, number, or Vecnot documented yet | result Mat | Returns an r×1 column Mat, one entry per row of M. |
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
row_mean — documented in the same entry.