Matrix transpose

In linear algebra, the transpose of a matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix

Read full: wiki/transposeopen in new window

Time complexity

O(n^2)

Import

import {transposeMatrix} from "@raikuxq/alg-ds/lib/exports/algorithms";

API reference

Transpose matrix API: /api/algorithms/transpose-matrix

Example usage

import {transposeMatrix} from "@raikuxq/alg-ds/lib/exports/algorithms";

const srcMatrix = [
    [0, 1, 1],
    [0, 0, 1],
    [1, 0, 0],
];

const transposed = transposeMatrix(srcMatrix);
/*
    [0, 0, 1],
    [1, 0, 0],
    [1, 1, 0],
*/