GF2::Matrix — Add & Remove Rows and Columns
Adds/removes rows & columns from the end of the bit-matrix.
constexpr Matrix &add_row(); (1)
constexpr Matrix &add_col(); (2)
constexpr Matrix &pop_row(); (3)
constexpr Matrix &pop_col(); (4)
| 1 | Adds a new row of zeros to the end of the bit-matrix. |
| 2 | Adds a new column of zeros to the end of the bit-matrix. |
| 3 | Removes the last row from the bit-matrix. |
| 4 | Removes the last columns from the bit-matrix. |
These methods all return a reference to *this so can be chained with other calls.
Example
#include <GF2/GF2.h>
int main()
{
auto m = GF2::Matrix<>::ones(2,8);
std::cout << "m:\n" << m << '\n';
m.add_row();
std::cout << "m:\n" << m << '\n';
m.add_col();
std::cout << "m:\n" << m << '\n';
m.pop_row();
std::cout << "m:\n" << m << '\n';
m.pop_col();
std::cout << "m:\n" << m << '\n';
m.clear(); (1)
std::cout << "m:\n" << m << '\n';
m.add_row(); (2)
std::cout << "m:\n" << m << '\n';
m.pop_col(); (3)
std::cout << "m:\n" << m << '\n';
}
| 1 | Clears the bit-matrix. |
| 2 | Adding a row or a column to an empty bit-matrix does nothing. |
| 3 | Popping a row or a column from an empty bit-matrix does nothing. |
Output
m:
11111111
11111111
m:
11111111
11111111
00000000
m:
111111110
111111110
000000000
m:
111111110
111111110
m:
11111111
11111111
m:
m:
m: