1 | /**
|
2 | * Create a new column x row matrix.
|
3 | *
|
4 | * @private
|
5 | * @param {number} columns
|
6 | * @param {number} rows
|
7 | * @return {Array<Array<number>>} matrix
|
8 | * @example
|
9 | * makeMatrix(10, 10);
|
10 | */
|
11 | function makeMatrix(columns, rows) {
|
12 | const matrix = [];
|
13 | for (let i = 0; i < columns; i++) {
|
14 | const column = [];
|
15 | for (let j = 0; j < rows; j++) {
|
16 | column.push(0);
|
17 | }
|
18 | matrix.push(column);
|
19 | }
|
20 | return matrix;
|
21 | }
|
22 |
|
23 | export default makeMatrix;
|