# bitset_rows¶

This page contains details of the function templates for finding the rows of a boolean matrix as bitsets that belong to the namespace matrix_helper.

The main function is:

template <typename Mat, size_t R, size_t C, typename Container> void bitset_rows(Container&&, detail::StaticVector1<BitSet<C>, R>&)

which converts the rows stored in the first argument to bitsets and appends them to the second argument.

There are several helper functions which allow the main function to be called without specifying the second argument or where a matrix is given instead of a container of rowviews.

## The main function¶

template<typename Mat, size_t R, size_t C, typename Container>
void bitset_rows(Container &&views, detail::StaticVector1<BitSet<C>, R> &result)

Converts the rows represented by the items in views to bit sets.

Template Parameters
• Mat – the type of matrix. This must be a type so that IsBMat<Mat> is true.

• R – an upper bound for the number of rows in views. This value must be at most BitSet<1>::max_size.

• C – an upper bound for the number of columns in each row represented in views. This value must be at most BitSet<1>::max_size.

• Container – the type of the container views, should be std::vector or detail::StaticVector1.

Parameters
• views – a container of Mat::RowView or std::vector<bool>.

• result – a static vector of bitsets to contain the resulting bit sets.

Returns

(None).

Exceptions

Throws if Container::push_back throws, or the BitSet constructor throws.

Complexity

$$O(mn)$$ where $$m$$ is the number of rows in views and and $$n$$ is the number of columns in any vector in views.

## Helpers¶

template<typename Mat, size_t R, size_t C, typename Container>
auto bitset_rows(Container &&views)

Returns a detail::StaticVector1<BitSet<C>, R> containing the rows in views converted to BitSet<C> s.

Template Parameters
• Mat – the type of matrix. This must be a type so that IsBMat<Mat> is true.

• R – an upper bound for the number of rows in views. This value must be at most BitSet<1>::max_size.

• C – an upper bound for the number of columns in each row represented in views. This value must be at most BitSet<1>::max_size.

• Container – the type of the container views, should be std::vector or detail::StaticVector1.

Parameters

views – a container of Mat::RowView or std::vector<bool>.

Returns

A value of type detail::StaticVector1<BitSet<C>, R>.

Exceptions

Throws if void bitset_rows(Container&&, detail::StaticVector1<BitSet<C>, R>&) throws, or std::bad_alloc is thrown by the detail::StaticVector1<BitSet<C>, R> constructor throws.

Complexity

$$O(mn)$$ where $$m$$ is the number of rows in views and and $$n$$ is the number of columns in any vector in views.

template<typename Mat, size_t R, size_t C>
void bitset_rows(Mat const &x, detail::StaticVector1<BitSet<C>, R> &result)

Computes the rows of the matrix x as bitsets and appends them to result.

Template Parameters
• Mat – the type of matrix. This must be a type so that IsBMat<Mat> is true.

• R – an upper bound for the number of rows in views. This value must be at most BitSet<1>::max_size.

• C – an upper bound for the number of columns in each row represented in views. This value must be at most BitSet<1>::max_size.

Parameters
• x – the boolean matrix.

• result – the container to append the rows of x to.

Returns

(None).

Exceptions

Throws if void bitset_rows(Container&&, detail::StaticVector1<BitSet<C>, R>&) throws.

Complexity

$$O(mn)$$ where $$m$$ is the number of rows in x and and $$n$$ is the number of columns in x.

template<typename Mat>
auto bitset_rows(Mat const &x)

Computes the rows of the matrix x as bitsets.

Template Parameters

Mat – the type of matrix. This must be a type so that IsBMat<Mat> is true.

Parameters

x – the boolean matrix.

Returns

A value of type detail::StaticVector1<BitSet<C>, R>.

Exceptions

Throws if void bitset_rows(Container&&, detail::StaticVector1<BitSet<C>, R>&) throws, or std::bad_alloc is thrown by the detail::StaticVector1<BitSet<C>, R> constructor throws.

Complexity

$$O(mn)$$ where $$m$$ is the number of rows in x and and $$n$$ is the number of columns in x.