MCPcopy
hub / github.com/trekhleb/javascript-algorithms / mul

Function mul

src/algorithms/math/matrix/Matrix.js:272–286  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

270 * @return {Matrix}
271 */
272export const mul = (a, b) => {
273 validateSameShape(a, b);
274 const result = zeros(shape(a));
275
276 walk(a, (cellIndices, cellValue) => {
277 updateCellAtIndex(result, cellIndices, cellValue);
278 });
279
280 walk(b, (cellIndices, cellValue) => {
281 const currentCellValue = getCellAtIndex(result, cellIndices);
282 updateCellAtIndex(result, cellIndices, currentCellValue * cellValue);
283 });
284
285 return result;
286};
287
288/**
289 * Subtract two matrices element-wise.

Callers

nothing calls this directly

Calls 6

validateSameShapeFunction · 0.85
zerosFunction · 0.85
shapeFunction · 0.85
walkFunction · 0.85
updateCellAtIndexFunction · 0.85
getCellAtIndexFunction · 0.85

Tested by

no test coverage detected