23#ifdef __cpp_lib_execution
27template<sp_i IT,
typename F>
void suanpan_for(
const IT start,
const IT
end, F&& FN) {
29 static tbb::affinity_partitioner ap;
30 tbb::parallel_for(start,
end, std::forward<F>(FN), ap);
32 for(IT I = start; I <
end; ++I) FN(I);
37#ifdef __cpp_lib_execution
38 return std::max_element(std::execution::par, start,
end);
40 return std::max_element(start,
end);
45 template<
typename T> [[maybe_unused]]
const std::vector<T>&
unique(std::vector<T>& container) {
46 std::sort(container.begin(), container.end());
47 container.erase(std::unique(container.begin(), container.end()), container.end());
48 container.shrink_to_fit();
52 template<
typename T>
constexpr T&
hacker(
const T& I) {
return const_cast<T&
>(I); }
54 template<
typename T>
constexpr T*&
hacker(
const T*
const& I) {
return const_cast<T*&
>(I); }
56 template<
typename T>
T sign(
const T& I) {
return (I >
T(0)) - (I <
T(0)); }
58 template<
typename T> std::enable_if_t<!std::numeric_limits<T>::is_integer,
bool>
approx_equal(
T x,
T y,
int ulp = 2) {
return fabs(x - y) <= std::numeric_limits<T>::epsilon() * fabs(x + y) * ulp || fabs(x - y) < std::numeric_limits<T>::min(); }
60 unsigned long long binomial(
unsigned long long,
unsigned long long);
72 namespace expression {
73 std::vector<std::pair<string, unsigned>>
split(
const std::string_view& variable_string);
77template<
typename T>
bool get_input(istringstream& I,
T& O) {
return static_cast<bool>(I >> O); }
79template<
typename T>
bool get_input(istringstream& I, Col<T>& O) {
81 for(
auto&
P : O) code &=
static_cast<bool>(I >>
P);
85template<
typename T,
typename...
U>
bool get_input(istringstream& I,
T& O,
U&... R) {
return static_cast<bool>(I >> O) ?
get_input(I, R...) :
false; }
96 if(I.eof())
return true;
98 return static_cast<bool>(I >> O);
103 for(
auto&
P : O) code &= I.eof() ? true :
static_cast<bool>(I >>
P);
108 if(I.eof())
return true;
113bool is_equal(
const char*,
const char*);
116bool is_equal(
const string&,
const char*);
117bool is_equal(
const string&,
const string&);
123template<std::equality_comparable T> std::pair<bool, std::int64_t>
if_contain(
const std::vector<T>& container,
const T target) {
124 auto position = std::find(container.begin(), container.end(), target);
126 return {position != container.end() && container.size() > 0, position - container.begin()};
Storage< T >::iterator end(Storage< T > &S)
Definition: Storage.hpp:202
std::vector< std::pair< string, unsigned > > split(const std::string_view &variable_string)
Definition: utility.cpp:69
Definition: MatrixModifier.hpp:36
std::enable_if_t<!std::numeric_limits< T >::is_integer, bool > approx_equal(T x, T y, int ulp=2)
Definition: utility.h:58
const std::vector< T > & unique(std::vector< T > &container)
Definition: utility.h:45
char to_lower(char)
Definition: utility.cpp:37
T sign(const T &I)
Definition: utility.h:56
unsigned long long binomial(unsigned long long, unsigned long long)
Definition: utility.cpp:21
char to_upper(char)
Definition: utility.cpp:35
constexpr T & hacker(const T &I)
Definition: utility.h:52
bool get_input(istringstream &I, T &O)
Definition: utility.h:77
bool is_integer(const string &)
Definition: utility.cpp:122
constexpr T suanpan_max_element(T start, T end)
Definition: utility.h:36
bool is_false(const char *)
Definition: utility.cpp:116
void ignore_whitespace(istringstream &)
Definition: utility.cpp:92
bool if_contain(const string &, const char *)
Definition: utility.cpp:108
bool is_equal(const char *, const char *)
Definition: utility.cpp:98
void suanpan_for(const IT start, const IT end, F &&FN)
Definition: utility.h:27
bool get_optional_input(istringstream &I, T &O)
Definition: utility.h:95
bool is_true(const char *)
Definition: utility.cpp:114