| 228 | * @param {Cell} cellValue - New cell value |
| 229 | */ |
| 230 | export const updateCellAtIndex = (m, cellIndices, cellValue) => { |
| 231 | // We start from the row at specific index. |
| 232 | let cell = m[cellIndices[0]]; |
| 233 | // Going deeper into the next dimensions but not to the last one to preserve |
| 234 | // the pointer to the last dimension array. |
| 235 | for (let dimIdx = 1; dimIdx < cellIndices.length - 1; dimIdx += 1) { |
| 236 | cell = cell[cellIndices[dimIdx]]; |
| 237 | } |
| 238 | // At this moment the cell variable points to the array at the last needed dimension. |
| 239 | cell[cellIndices[cellIndices.length - 1]] = cellValue; |
| 240 | }; |
| 241 | |
| 242 | /** |
| 243 | * Adds two matrices element-wise. |