GF2::Matrix — Transpose a Bit-Matrix

Member function to transpose a square bit-matrix in place and a free function that transposes an arbitrary bit-matrix.

constexpr Matrix &to_transpose();                       (1)

template<std::unsigned_integral Block, typename Allocator>
constexpr Matrix<Block, Allocator>
transpose(const Matrix<Block, Allocator> &M);           (2)
1 Member function to transpose a square bit-matrix in place.
2 Free function that returns the transpose of an arbitrary bit-matrix.

The transpose of a matrix \(M\) with elements \(M_{ij}\) is the matrix \(M^T\) whose elements are

\[M^T_{ij} = M_{ji}\]
Example
#include <GF2/GF2.h>
int main()
{
    GF2::Matrix<> m(4, [](std::size_t i, std::size_t) { return (i + 1)%2; });
    auto m1 = m;
    std::cout << "Original and transposed matrices:\n";
    GF2::print(m, m1.to_transpose());

    GF2::Matrix<> m2(4, 8, [](std::size_t i, std::size_t) { return (i + 1)%2; });
    std::cout << "Original and transposed matrices:\n";
    GF2::print(m2, GF2::transpose(m2));
}
Output
Original and transposed matrices:
1111    1010
0000    1010
1111    1010
0000    1010
Original and transposed matrices:
11111111        1010
00000000        1010
11111111        1010
00000000        1010
                1010
                1010
                1010
                1010