GF2::Matrix — Change the Size of a Bit-Matrix

Resizes the bit-matrix. Any added elements are initialized to 0.

constexpr Matrix &resize(std::size_t r, std::size_t c); (1)
constexpr Matrix &resize(std::size_t n);                (2)
1 Resizes the bit-matrix to be r x c.
2 Resizes the bit-matrix to be n x n.

If r < rows() the bit-matrix is reduced in size to the first r elements.
If r > rows() extra rows of zeros are appended to the end of the bit-matrix.
If c < cols() the bit-matrix is reduced in size to the first c columns.
If c > cols() extra columns of zeros are appended to the end of the bit-matrix.

This method returns a reference to *this so it can be chained with other calls.

Example
#include <GF2/GF2.h>
int main()
{
    auto m = GF2::Matrix<>::random(4);   (1)
    std::cout << "m:\n" << m << '\n';
    m.resize(6,8);                       (2)
    std::cout << "m:\n" << m << '\n';
    m.resize(4);                         (3)
    std::cout << "m:\n" << m << '\n';
}
1 Construct a 4 x 4 bit-matrix with a random fill.
2 Resize the bit-matrix to have 6 x 8. The extra 2 rows and columns are initialized with zeros.
3 Resize the bit-matrix back down to the original 4 x 4 size.
Output
m:
1001
0011
0001
0011
m:
10010000
00110000
00010000
00110000
00000000
00000000
m:
1001
0011
0001
0011