1.2.0 • Published 3 years ago

transpose-matrix v1.2.0

Weekly downloads
1
License
ISC
Repository
github
Last release
3 years ago

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.

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago