GF2::Matrix — Is a Bit-Matrix Special?
Check to see if this bit-matrix is special in some way.
constexpr bool is_zero() const; // (1)
constexpr bool is_ones() const; // (2)
constexpr bool is_identity() const; // (3)
constexpr bool is_symmetric() const; // (4)
| 1 | Are all the bit-matrix elements all 0? |
| 2 | Are all the bit-matrix elements all 1? |
| 3 | Is this the identity bit-matrix? Matrix must be square with ones on the diagonal and zeros everywhere else. |
| 4 | Is this the bit-matrix symmetric. Matrix must be square. |
Example
#include <GF2/GF2.h>
#include <GF2/GF2.h>
int main()
{
auto ident = GF2::Matrix<>::identity(8);
// Little lambda that turns a bool into a string
auto b2s = [](bool x) { return x ? "YES" : "NO"; };
std::cout << "Matrix is_zero? " << b2s(ident.is_zero()) << "\n";
std::cout << "Matrix is_ones? " << b2s(ident.is_ones()) << "\n";
std::cout << "Matrix is_identity? " << b2s(ident.is_identity()) << "\n";
std::cout << "Matrix is_symmetric? " << b2s(ident.is_symmetric()) << "\n";
}
Output
Matrix is_zero? NO
Matrix is_ones? NO
Matrix is_identity? YES
Matrix is_symmetric? YES