HPCombi
High Performance Combinatorics in C++ using vector instructions v1.1.2
Toggle main menu visibility
Loading...
Searching...
No Matches
stringmonoid.cpp
how to use pow with a non numerical Monoid.
how to use pow with a non numerical Monoid.
//****************************************************************************//
// Copyright (C) 2016-2024 Florent Hivert <Florent.Hivert@lisn.fr>, //
// //
// This file is part of HP-Combi <https://github.com/libsemigroups/HPCombi> //
// //
// HP-Combi 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. //
// //
// HP-Combi 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 HP-Combi. If not, see <https://www.gnu.org/licenses/>. //
//****************************************************************************//
#include <cassert>
#include <string>
#include "
hpcombi/power.hpp
"
namespace
HPCombi
{
namespace
power_helper {
// Algebraic monoid for string with concatenation
template
<>
struct
Monoid<
std
::string> {
// The one of the string monoid
static
std::string
one
() {
return
{}; };
/* The product of two strings that is their concatenation
* @param a the first string to be concatenated
* @param b the second string to be concatenated
* @return the concatenation of \a a and \a b
*/
static
std::string
prod
(std::string a, std::string b) {
return
a + b; }
};
}
// namespace power_helper
}
// namespace HPCombi
int
main
() {
assert(
HPCombi::pow<0>
(std::string(
"ab"
)) ==
""
);
assert(
HPCombi::pow<4>
(std::string(
"ab"
)) ==
"abababab"
);
assert(
HPCombi::pow<5>
(std::string(
"abc"
)) ==
"abcabcabcabcabc"
);
}
main
int main()
Definition
CF.cpp:75
HPCombi
Definition
bmat16.hpp:39
HPCombi::pow
const T pow(const T x)
A generic compile time exponentiation function.
Definition
power.hpp:91
std
Definition
bmat16_impl.hpp:362
power.hpp
Generic compile-time unrolling of the fast exponentiation algorithm.
HPCombi::power_helper::Monoid::prod
static const T prod(T a, T b)
the product of two elements of type T
Definition
power.hpp:120
HPCombi::power_helper::Monoid::one
static const T one()
The one of type T.
Definition
power.hpp:113
Generated by
1.17.0