MCPcopy Index your code
hub / github.com/trekhleb/javascript-algorithms / sub

Function sub

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

Source from the content-addressed store, hash-verified

293 * @return {Matrix}
294 */
295export const sub = (a, b) => {
296 validateSameShape(a, b);
297 const result = zeros(shape(a));
298
299 walk(a, (cellIndices, cellValue) => {
300 updateCellAtIndex(result, cellIndices, cellValue);
301 });
302
303 walk(b, (cellIndices, cellValue) => {
304 const currentCellValue = getCellAtIndex(result, cellIndices);
305 updateCellAtIndex(result, cellIndices, currentCellValue - cellValue);
306 });
307
308 return result;
309};

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