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

Function t

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

Source from the content-addressed store, hash-verified

160 * @throws {Error}
161 */
162export const t = (m) => {
163 validate2D(m);
164 const mShape = shape(m);
165 const transposed = zeros([mShape[1], mShape[0]]);
166 for (let row = 0; row < m.length; row += 1) {
167 for (let col = 0; col < m[0].length; col += 1) {
168 transposed[col][row] = m[row][col];
169 }
170 }
171 return transposed;
172};
173
174/**
175 * Traverses the matrix.

Callers

nothing calls this directly

Calls 3

validate2DFunction · 0.85
shapeFunction · 0.85
zerosFunction · 0.85

Tested by

no test coverage detected