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

Function shape

src/algorithms/math/matrix/Matrix.js:14–22  ·  view source on GitHub ↗
(m)

Source from the content-addressed store, hash-verified

12 * @returns {Shape}
13 */
14export const shape = (m) => {
15 const shapes = [];
16 let dimension = m;
17 while (dimension && Array.isArray(dimension)) {
18 shapes.push(dimension.length);
19 dimension = (dimension.length && [...dimension][0]) || null;
20 }
21 return shapes;
22};
23
24/**
25 * Checks if matrix has a correct type.

Callers 8

validate2DFunction · 0.85
validateSameShapeFunction · 0.85
dotFunction · 0.85
tFunction · 0.85
recWalkFunction · 0.85
addFunction · 0.85
mulFunction · 0.85
subFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected