@rayyamhk/matrix
Version:
A professional, comprehensive and high-performance library for you to manipulate matrices.
22 lines (16 loc) • 441 B
JavaScript
var _require = require('../Error'),
INVALID_ROW_COL = _require.INVALID_ROW_COL;
module.exports = function empty(row, col) {
if (!Number.isInteger(row) || row < 0 || !Number.isInteger(col) || col < 0) {
throw new Error(INVALID_ROW_COL);
}
if (row === 0 || col === 0) {
return [];
}
var matrix = new Array(row);
for (var i = 0; i < row; i++) {
matrix[i] = new Array(col);
}
return matrix;
};
;