transpose-matrix
v1.2.0
Published
Transpose a matrix
Downloads
5
Readme
Transpose a matrix
Pass a matrix in and get a transposed matrix out
const testMatrixSquare = [
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9],
[1,2,3,4,5,6,7,8,9]
];
transposeMatrix(testMatrixSquare)';
Will return
const expectedResults = [
[1,1,1,1,1,1,1,1,1],
[2,2,2,2,2,2,2,2,2],
[3,3,3,3,3,3,3,3,3],
[4,4,4,4,4,4,4,4,4],
[5,5,5,5,5,5,5,5,5],
[6,6,6,6,6,6,6,6,6],
[7,7,7,7,7,7,7,7,7],
[8,8,8,8,8,8,8,8,8],
[9,9,9,9,9,9,9,9,9]
];
See the test cases for other usages.