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>>>
176 static constexpr size_t N = BitSet<1>::max_size();
183 using type = detail::StaticVector1<BitSet<N>,
N>;
200 template <
typename Mat>
201#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
202 struct RhoValue<Mat,
std::enable_if_t<IsBMat<Mat>>>
231 template <
typename Mat,
typename Container>
232#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
233 struct Lambda<Mat, Container,
std::enable_if_t<IsBMat<Mat>>>
243 using value_type =
typename Container::value_type;
244 size_t const N = value_type().size();
245 if (x.number_of_rows() > N) {
247 "expected matrix of dimension at most {}, found {}",
252 for (
size_t i = 0; i < x.number_of_rows(); ++i) {
255 for (
size_t j = 0; j < x.number_of_rows(); ++j) {
279 template <
typename Mat,
typename Container>
280#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
281 struct Rho<Mat, Container,
std::enable_if_t<IsBMat<Mat>>>
283 struct
Rho<Mat, Container>
290 void operator()(Container& res, Mat
const& x)
const noexcept {
291 const_cast<Mat*
>(&x)->transpose();
293 const_cast<Mat*
>(&x)->transpose();
314 template <
size_t N,
typename Mat>
315#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
316 struct ImageRightAction<Mat, BitSet<N>,
std::enable_if_t<IsBMat<Mat>>>
330 Mat
const& x)
const {
331 static thread_local detail::StaticVector1<BitSet<N>, N> x_rows;
333 for (
size_t i = 0; i < x.number_of_rows(); ++i) {
335 for (
size_t j = 0; j < x.number_of_rows(); ++j) {
343 pt.apply([&res](
size_t i) { res |= x_rows[i]; });
358 template <
typename Mat>
359#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
360 class RankState<Mat,
std::enable_if_t<IsBMat<Mat>>>
400 template <
typename T>
403 LIBSEMIGROUPS_ASSERT(_orb.empty());
406 "expected a positive number of generators in the second argument");
408 for (
auto it = first; it < last; ++it) {
409 _orb.add_generator(*it);
411 for (
size_t i = 0; i < first->number_of_rows(); ++i) {
423 LIBSEMIGROUPS_ASSERT(_orb.finished());
440 template <
typename Mat>
441#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
442 struct Rank<Mat, RankState<Mat>,
std::enable_if_t<IsBMat<Mat>>>
444 struct
Rank<Mat, RankState<Mat>>
455 using bitset_type = BitSet<BitSet<1>::max_size()>;
461 orb_type
const& orb = state.get();
462 LIBSEMIGROUPS_ASSERT(orb.finished());
463 seen.
resize(orb.current_size());
464 for (
size_t i = 0; i < x.number_of_rows(); ++i) {
466 for (
size_t j = 0; j < x.number_of_rows(); ++j) {
474 for (
size_t i = 0; i < orb.current_size(); ++i) {
475 bitset_type
const& row = orb[i];
478 row.apply([&cup](
size_t j) { cup |= x_rows[j]; });
479 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:369
RightAction< Mat, MaxBitSet, ImageRightAction< Mat, MaxBitSet > > type
Type of the RankState.
Definition bmat-adapters.hpp:372
type const & get() const
Returns the row orbit.
Definition bmat-adapters.hpp:421
RankState()=delete
Deleted.
RankState(RankState &&)=delete
Deleted.
RankState(T first, T last)
Construct a RankState instance using iterators.
Definition bmat-adapters.hpp:401
Base class for states for ranks.
Definition adapters.hpp:882
void type
Definition adapters.hpp:886
void run()
Run until finished.
Action< Element, Point, Func, Traits, side::right > RightAction
Definition action.hpp:933
Undefined const UNDEFINED
Value for something undefined.
#define LIBSEMIGROUPS_EXCEPTION(...)
Throw a LibsemigroupsException.
Definition exception.hpp:99
void bitset_row_basis(Container &&rows, std::decay_t< Container > &result)
Appends a basis for the space spanned by some bitsets to a container.
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:355
BitSet< N > result_type
The type of result.
Definition bmat-adapters.hpp:322
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:328
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:397
static constexpr size_t N
The maximum width of BitSet on the system.
Definition bmat-adapters.hpp:176
detail::StaticVector1< BitSet< N >, N > type
The type of Lambda Values.
Definition bmat-adapters.hpp:183
Adapter for lambda functions.
Definition adapters.hpp:798
void operator()(Container &res, Mat const &x) const
Modifies res in-place to contain the row space basis of x.
Definition bmat-adapters.hpp:242
Adapter for the action on LambdaValue's.
Definition adapters.hpp:838
size_t operator()(RankState< Mat > const &state, Mat const &x) const
Returns the rank of x.
Definition bmat-adapters.hpp:454
Adapter for calculating ranks.
Definition adapters.hpp:935
typename LambdaValue< Mat >::type type
The type of Rho Values.
Definition bmat-adapters.hpp:212
Adapter for rho functions.
Definition adapters.hpp:817
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:290
Adapter for the action on RhoValue's.
Definition adapters.hpp:859