reduceSumByAxis method
Return Matrix.column of sums of the elements of this
reduced by rows
(if axis
is 0) or columns
(if axis
is 1)
Return Matrix.column for row-wise reduction and Matrix.row for column-wise reduction
Implementation
Matrix reduceSumByAxis(int axis) {
if (axis == 1) {
return Matrix.column(
List<double>.generate(m, (index) => getColumn(index).reduceSum()));
} else if (axis == 0) {
return Matrix.column(
List<double>.generate(n, (index) => getRow(index).reduceSum()));
} else {
throw Exception('Axis error: axis shoud be 0 or 1');
}
}