Closed thegodone closed 4 years ago
matrix.sum('row')
or matrix.sum('column')
.
All methods are documented here: https://mljs.github.io/matrix/classes/matrix.html
Full example:
const { Matrix } = require('ml-matrix');
let matrix = new Matrix([
[1, 2],
[3, 4]
]);
let sunColumn = matrix.sum('column');
console.log(sunColumn);
let sunRow = matrix.sum('row');
console.log(sunRow);
How to sum per row or column ?