GF2::Matrix: — Print Bit-Matrices Side-by-side

Functions that print a bit-matrix and some bit-vectors or two or three bit-matrices side by side to a stream.

Versions that print to an arbitrary stream
print(std::ostream &s,                                                                          (1)
      const GF2::Matrix &A, const GF2::Vector &b,
      std::string_view delim = "\t");
print(std::ostream &s,                                                                          (2)
      const GF2::Matrix &A, const GF2::Vector &b, const GF2::Vector &c,
      std::string_view delim = "\t");
print(std::ostream &s,                                                                          (3)
      const GF2::Matrix &A, const GF2::Vector &b, const GF2::Vector &c, const GF2::Vector &d,
      std::string_view delim = "\t");
print(std::ostream &s,                                                                          (4)
      const GF2::Matrix &A, const GF2::Matrix &B,
      std::string_view delim = "\t");
print(std::ostream &s,                                                                          (5)
      const GF2::Matrix &A, const GF2::Matrix &B, const GF2::Matrix &C,
      std::string_view delim = "\t");
1 Prints a bit-matrix and a bit-vector side by side to an arbitrary stream.
2 Prints a bit-matrix and two bit-vectors side by side to an arbitrary stream.
3 Prints a bit-matrix and three bit-vectors side by side to an arbitrary stream.
4 Prints two bit-matrices side by side to an arbitrary stream.
5 Prints three bit-matrices side by side to an arbitrary stream.
Versions that print to std::cout
print(const GF2::Matrix &A, const GF2::Vector &b,                                               (1)
      std::string_view delim = "\t");
print(const GF2::Matrix &A, const GF2::Vector &b, const GF2::Vector &c,                         (2)
      std::string_view delim = "\t");
print(const GF2::Matrix &A, const GF2::Vector &b, const GF2::Vector &c, const GF2::Vector &d,   (3)
      std::string_view delim = "\t");
print(const GF2::Matrix &A, const GF2::Matrix &B,                                               (4)
      std::string_view delim = "\t");
print(const GF2::Matrix &A, const GF2::Matrix &B, const GF2::Matrix &C,                         (5)
      std::string_view delim = "\t");
1 Prints a bit-matrix and a bit-vector side by side to std::cout.
2 Prints a bit-matrix and two bit-vectors side by side to std::cout.
3 Prints a bit-matrix and three bit-vectors side by side to std::cout.
4 Prints two bit-matrices side by side to std::cout.
5 Prints three bit-matrices side by side to std::cout.

Each of these non-member functions is void (i.e. returns nothing) and in practice, each has all the appropriate template parameters (not shown here for the sake of brevity).

The delimiter string delim separates the various bit-matrices and bit-vectors in the output stream.

The need for this sort of printing turns up often enough to make it sensible to include the code in the library directly. In particular, these functions gracefully handle the case where the number of rows in the A, B, and C bit-matrices etc. are different from each other.
Example
#include <GF2/GF2.h>
int main()
{
    auto M1 = GF2::Matrix<>::random(8, 6);
    auto M2 = GF2::Matrix<>::random(10);
    auto M3 = GF2::Matrix<>::random(6, 8);
    std::cout << "M1, M2, M3:\n";
    print(M1, M2, M3, " | ");
}
Output where the specific numbers vary from run to run
M1, M2, M3:
010101 | 1101010111 | 00001100
011101 | 1111100110 | 00011110
011111 | 0010010110 | 00011100
110001 | 1000111101 | 00110011
100010 | 0100101001 | 11110011
101001 | 0001010111 | 11000111
101110 | 1010011010 |
000101 | 1110000000 |
       | 0011110001 |
       | 0001001011 |
See Also

operator<<