GF2::Matrix — Upper & Lower Triangles
Methods to extract the upper or lower triangular sub-matrix as a stand-alone, distinct copy of elements from this bit-matrix.
constexpr Matrix lower() const; (1)
constexpr Matrix strictly_lower() const; (2)
constexpr Matrix upper() const; (3)
constexpr Matrix strictly_lower() const; (4)
| 1 | Returns a copy the lower triangular elements of this bit-matrix with zeros everywhere above the diagonal. |
| 2 | Returns a copy the lower triangular elements of this bit-matrix with zeros everywhere on or above the diagonal. |
| 3 | Returns a copy the upper triangular elements of this bit-matrix with zeros everywhere below the diagonal. |
| 4 | Returns a copy the upper triangular elements of this bit-matrix with zeros everywhere on or below the diagonal. |
These methods work with arbitrary rectangular bit-matrices always starting with the top left (0, 0) element as the anchor for the diagonal.
|
Example
#include <GF2/GF2.h>
int main()
{
std::size_t M = 6; (1)
std::size_t N = 16; (2)
GF2::Matrix A(M, N);
A.set(); (3)
std::cout << "Matrix, lower triangular sub-matrix, and the strictly lower triangular sub-matrix:\n";
print(A, A.lower(), A.strictly_lower());
std::cout << "Matrix, upper triangular sub-matrix, and the strictly upper triangular sub-matrix:\n";
print(A, A.upper(), A.strictly_upper());
return 0;
}
| 1 | Number of rows. |
| 2 | Number of columns. |
| 3 | A is an M x N bit-matrix of all ones. |
Output
Matrix, lower triangular sub-matrix, and the strictly lower triangular sub-matrix:
1111111111111111 1000000000000000 0000000000000000
1111111111111111 1100000000000000 1000000000000000
1111111111111111 1110000000000000 1100000000000000
1111111111111111 1111000000000000 1110000000000000
1111111111111111 1111100000000000 1111000000000000
1111111111111111 1111110000000000 1111100000000000
Matrix, upper triangular sub-matrix, and the strictly upper triangular sub-matrix:
1111111111111111 1111111111111111 0111111111111111
1111111111111111 0111111111111111 0011111111111111
1111111111111111 0011111111111111 0001111111111111
1111111111111111 0001111111111111 0000111111111111
1111111111111111 0000111111111111 0000011111111111
1111111111111111 0000011111111111 0000001111111111
See Also