bit::matrix — Append to a Bit-Matrix

We have methods to append one or more columns to the right of a bit-matrix.

1constexpr bit::matrix &append(const bit::vector &v);
2constexpr bit::matrix &append(const bit::matrix &V);

3bit::matrix join(const bit::matrix& M, const bit::vector& v);
4bit::matrix join(const bit::matrix& M, const bit::vector& V);
1
bit::matrix \(M\) is augmented in place to become \(M|v\).
2
bit::matrix \(M\) is augmented in place to become \(M|V\).
3
Returns a new matrix, the augmented \(M|v\).
4
Returns a new matrix, the augmented \(M|V\).
The number of rows in v and V must match the number in M.

Example

#include <bit/bit.h>
int main()
{
    std::size_t n_rows = 12;
    auto M = bit::matrix<>::ones(n_rows);
    auto v = bit::vector<>::zeros(n_rows);
    auto V = bit::matrix<>::zeros(n_rows, 5);
    auto A = bit::join(M,v);
    auto B = bit::join(M,V);
    bit::print(M, A, B);
    return 0;
}

Output

111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000
111111111111    1111111111110   11111111111100000

See Also

matrix::replace

Back to top