// // libsemigroups - C++ library for semigroups and monoids // Copyright (C) 2019 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. //
namespace libsemigroups { using element_index_type = FroidurePinBase::element_index_type;
//////////////////////////////////////////////////////////////////////// // FroidurePinBase - constructors and destructor - public ////////////////////////////////////////////////////////////////////////
// Partial copy. // \p copy a semigroup // \p coll a collection of additional generators // // This is a constructor for a semigroup generated by the generators of the // FroidurePin copy and the (possibly) additional generators coll. // // The relevant parts of the data structure of copy are copied and // \c this will be corrupt unless add_generators or closure is called // subsequently. This is why this member function is private. // // The same effect can be obtained by copying copy using the copy // constructor and then calling add_generators or closure. However, // this constructor avoids copying those parts of the data structure of // copy that add_generators invalidates anyway. If copy has not been // enumerated at all, then these two routes for adding more generators are // equivalent. // // <add_generators> or <closure> should usually be called after this. void FroidurePinBase::partial_copy(FroidurePinBase const& S) {
_degree = S._degree; // copy for comparison in add_generators
_duplicate_gens = S._duplicate_gens;
_found_one = S._found_one; // copy in case degree doesn't change in // add_generators
_idempotents_found = S._idempotents_found;
_is_idempotent = S._is_idempotent;
_left = S._left;
_lenindex = {0, S._lenindex[1]};
_letter_to_pos = S._letter_to_pos;
_nr = S._nr;
_nr_rules = 0;
_pos = S._pos;
_pos_one = S._pos_one; // copy in case degree doesn't change in // add_generators
_reduced = S._reduced;
_right = S._right;
_wordlen = 0;
// the following are required for assignment to specific positions in // add_generators
_final.resize(S._nr, 0);
_first.resize(S._nr, 0);
_length.resize(S._nr, 0);
_prefix.resize(S._nr, 0);
_suffix.resize(S._nr, 0);
_enumerate_order.reserve(S._nr);
// add the distinct old generators to new _enumerate_order
LIBSEMIGROUPS_ASSERT(S._lenindex.size() > 1); for (enumerate_index_type i = 0; i < S._lenindex[1]; i++) {
_enumerate_order.push_back(S._enumerate_order[i]);
_final[_enumerate_order[i]] = S._final[S._enumerate_order[i]];
_first[_enumerate_order[i]] = S._first[S._enumerate_order[i]];
_prefix[_enumerate_order[i]] = UNDEFINED;
_suffix[_enumerate_order[i]] = UNDEFINED;
_length[_enumerate_order[i]] = 1;
}
}
//////////////////////////////////////////////////////////////////////// // FroidurePinBase - member functions - public ////////////////////////////////////////////////////////////////////////
element_index_type
FroidurePinBase::current_position(word_type const& w) const { // w is a word in the generators (i.e. a vector of letter_type's) if (w.size() == 0) {
LIBSEMIGROUPS_EXCEPTION("the given word has length 0");
} for (auto x : w) {
validate_letter_index(x);
}
element_index_type out = _letter_to_pos[w[0]]; for (auto it = w.cbegin() + 1; it < w.cend() && out != UNDEFINED; ++it) {
out = _right.get(out, *it);
} return out;
}
element_index_type
FroidurePinBase::product_by_reduction(element_index_type i,
element_index_type j) const {
validate_element_index(i);
validate_element_index(j);
if (current_length(i) <= current_length(j)) { while (i != UNDEFINED) {
j = _left.get(j, _final[i]);
i = _prefix[i];
} return j;
} else { while (j != UNDEFINED) {
i = _right.get(i, _first[j]);
j = _suffix[j];
} return i;
}
}
void FroidurePinBase::enumerate(size_t limit) { if (finished() || limit <= current_size()) { return;
} elseif (LIMIT_MAX - batch_size() > current_size()) {
limit = std::max(limit, current_size() + batch_size());
} else { // batch_size() is very big for some reason
limit = batch_size();
}
REPORT_DEFAULT( "limit = %llu (%s)\n", static_cast<uint64_t>(limit), __func__);
run_until([this, &limit]() -> bool { return current_size() >= limit; });
}
//////////////////////////////////////////////////////////////////////// // FroidurePinBase - settings - public ////////////////////////////////////////////////////////////////////////
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.