22#ifndef LIBSEMIGROUPS_BMAT_ADAPTERS_HPP_
23#define LIBSEMIGROUPS_BMAT_ADAPTERS_HPP_
32#include "adapters.hpp"
35#include "exception.hpp"
38#include "libsemigroups/detail/containers.hpp"
72 template <
typename Mat,
typename Container>
73#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
77 std::enable_if_t<IsBMat<Mat> && IsBitSet<typename Container::value_type>>>
89 void operator()(Container& res, Container
const& pt, Mat
const& x)
const {
90 using value_type =
typename Container::value_type;
93 for (
auto const& v : pt) {
96 v.apply([&x, &cup](
size_t i) {
97 for (
size_t j = 0; j < x.number_of_rows(); ++j) {
98 cup.set(j, cup[j] || x(i, j));
121 template <
typename Mat,
typename Container>
122#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
123 struct ImageLeftAction<Mat, Container,
std::enable_if_t<IsBMat<Mat>>>
133 void operator()(Container& res, Container
const& pt, Mat
const& x)
const {
134 const_cast<Mat*
>(&x)->transpose();
138 const_cast<Mat*
>(&x)->transpose();
141 const_cast<Mat*
>(&x)->transpose();
168 template <
typename Mat>
169#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
170 struct LambdaValue<Mat,
std::enable_if_t<IsBMat<Mat>>>
175 static constexpr size_t N = BitSet<1>::max_size();
182 using type = detail::StaticVector1<BitSet<N>, N>;
199 template <
typename Mat>
200#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
201 struct RhoValue<Mat,
std::enable_if_t<IsBMat<Mat>>>
230 template <
typename Mat,
typename Container>
231#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
232 struct Lambda<Mat, Container,
std::enable_if_t<IsBMat<Mat>>>
242 using value_type =
typename Container::value_type;
243 size_t const N = value_type().size();
244 if (x.number_of_rows() > N) {
246 "expected matrix of dimension at most {}, found {}",
251 for (
size_t i = 0; i < x.number_of_rows(); ++i) {
254 for (
size_t j = 0; j < x.number_of_rows(); ++j) {
278 template <
typename Mat,
typename Container>
279#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
280 struct Rho<Mat, Container,
std::enable_if_t<IsBMat<Mat>>>
282 struct
Rho<Mat, Container>
289 void operator()(Container& res, Mat
const& x)
const noexcept {
290 const_cast<Mat*
>(&x)->transpose();
292 const_cast<Mat*
>(&x)->transpose();
313 template <
size_t N,
typename Mat>
314#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
315 struct ImageRightAction<Mat, BitSet<N>,
std::enable_if_t<IsBMat<Mat>>>
329 Mat
const& x)
const {
330 static thread_local detail::StaticVector1<BitSet<N>, N> x_rows;
332 for (
size_t i = 0; i < x.number_of_rows(); ++i) {
334 for (
size_t j = 0; j < x.number_of_rows(); ++j) {
342 pt.apply([&res](
size_t i) { res |= x_rows[i]; });
357 template <
typename Mat>
358#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
359 class RankState<Mat,
std::enable_if_t<IsBMat<Mat>>>
399 template <
typename T>
402 LIBSEMIGROUPS_ASSERT(_orb.empty());
405 "expected a positive number of generators in the second argument");
407 for (
auto it = first; it < last; ++it) {
408 _orb.add_generator(*it);
410 for (
size_t i = 0; i < first->number_of_rows(); ++i) {
422 LIBSEMIGROUPS_ASSERT(_orb.finished());
439 template <
typename Mat>
440#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
441 struct Rank<Mat, RankState<Mat>,
std::enable_if_t<IsBMat<Mat>>>
443 struct
Rank<Mat, RankState<Mat>>
454 using bitset_type = BitSet<BitSet<1>::max_size()>;
460 orb_type
const& orb = state.get();
461 LIBSEMIGROUPS_ASSERT(orb.finished());
462 seen.
resize(orb.current_size());
463 for (
size_t i = 0; i < x.number_of_rows(); ++i) {
465 for (
size_t j = 0; j < x.number_of_rows(); ++j) {
473 for (
size_t i = 0; i < orb.current_size(); ++i) {
474 bitset_type
const& row = orb[i];
477 row.apply([&cup](
size_t j) { cup |= x_rows[j]; });
478 size_t pos = orb.position(cup);
RankState & operator=(RankState const &)=delete
Deleted.
RankState(RankState const &)=default
Deleted.
RankState & operator=(RankState &&)=delete
Deleted.
BitSet< BitSet< 1 >::max_size()> MaxBitSet
The maximum size of a bit set.
Definition bmat-adapters.hpp:368
RightAction< Mat, MaxBitSet, ImageRightAction< Mat, MaxBitSet > > type
Type of the RankState
Definition bmat-adapters.hpp:371
type const & get() const
Returns the row orbit.
Definition bmat-adapters.hpp:420
RankState()=delete
Deleted.
RankState(RankState &&)=delete
Deleted.
RankState(T first, T last)
Construct a RankState instance using iterators.
Definition bmat-adapters.hpp:400
Base class for states for ranks.
Definition adapters.hpp:877
void type
Definition adapters.hpp:881
void run()
Run until finished.
Action< Element, Point, Func, Traits, side::right > RightAction
Definition action.hpp:870
Undefined const UNDEFINED
Value for something undefined.
#define LIBSEMIGROUPS_EXCEPTION(...)
Throw a LibsemigroupsException.
Definition exception.hpp:95
void bitset_row_basis(Container &&rows, std::decay_t< Container > &result)
Appends a basis for the space spanned by some bitsets to a container.
Definition matrix.hpp:7452
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
void operator()(Container &res, Container const &pt, Mat const &x) const
Store the image of pt under the left action of x.
Definition bmat-adapters.hpp:133
Adapter for the value of a left action.
Definition adapters.hpp:350
BitSet< N > result_type
The type of result.
Definition bmat-adapters.hpp:321
void operator()(result_type &res, result_type const &pt, Mat const &x) const
Store the image of pt under the right action of x.
Definition bmat-adapters.hpp:327
void operator()(Container &res, Container const &pt, Mat const &x) const
Store the image of pt under the right action of x.
Definition bmat-adapters.hpp:89
Adapter for the value of a right action.
Definition adapters.hpp:392
void operator()(Container &res, Mat const &x) const
Modifies res in-place to contain the row space basis of x.
Definition bmat-adapters.hpp:241
Adapter for the action on LambdaValue's.
Definition adapters.hpp:833
detail::StaticVector1< BitSet< N >, N > type
The type of Lambda Values.
Definition bmat-adapters.hpp:182
Adapter for lambda functions.
Definition adapters.hpp:793
size_t operator()(RankState< Mat > const &state, Mat const &x) const
Returns the rank of x.
Definition bmat-adapters.hpp:453
Adapter for calculating ranks.
Definition adapters.hpp:930
void operator()(Container &res, Mat const &x) const noexcept
Modifies res in-place to contain the column space basis of x.
Definition bmat-adapters.hpp:289
Adapter for the action on RhoValue's.
Definition adapters.hpp:854
typename LambdaValue< Mat >::type type
The type of Rho Values.
Definition bmat-adapters.hpp:211
Adapter for rho functions.
Definition adapters.hpp:812