(a, b)
| 247 | * @return {Matrix} |
| 248 | */ |
| 249 | export const add = (a, b) => { |
| 250 | validateSameShape(a, b); |
| 251 | const result = zeros(shape(a)); |
| 252 | |
| 253 | walk(a, (cellIndices, cellValue) => { |
| 254 | updateCellAtIndex(result, cellIndices, cellValue); |
| 255 | }); |
| 256 | |
| 257 | walk(b, (cellIndices, cellValue) => { |
| 258 | const currentCellValue = getCellAtIndex(result, cellIndices); |
| 259 | updateCellAtIndex(result, cellIndices, currentCellValue + cellValue); |
| 260 | }); |
| 261 | |
| 262 | return result; |
| 263 | }; |
| 264 | |
| 265 | /** |
| 266 | * Multiplies two matrices element-wise. |
nothing calls this directly
no test coverage detected