44 unsigned log2(
unsigned n);
50 return (
n & 0x80000000U) ? (
n << 1 | 0x00000001U) : (
n << 1);
60 if (std::less<const T *>()(a, b))
62 else if (std::less<const T *>()(b, a))
70 return n * UINT64_C(0x4f1bbcdd);
98 }
else if (!(*other < *i))
110 i = first; other = first;
119 }
else if (!(*i < *other))
129 }
while (first !=
last);
134 template <
class It,
class Cmp,
class Swap>
148 bool swapped =
false;
150 if (comp(*i, *other)) {
155 }
else if (!comp(*other, *i))
167 i = first; other = first;
171 if (comp(*other, *i)) {
176 }
else if (!comp(*i, *other))
186 }
while (first !=
last);
192 template <
class It,
class Cmp,
class Swap>
205 bool swapped =
false;
207 if (comp(*i, *other)) {
222 i = first; other = first;
226 if (comp(*other, *i)) {
239 }
while (first !=
last);
243 template <
class It,
class Swap>
246 unsigned num =
last - first;
248 if (first == new_first || num < 2)
251 unsigned num1 = new_first - first, num2 =
last - new_first;
253 It a = first, b = new_first;
264 It a = new_first, b =
last;
268 }
while (a != first);
286 std::vector<unsigned>
x;
290 :
x(m_+1),
n(n_),
m(m_)
292 for (
unsigned k=1;
k<
m; ++
k)
308 unsigned f =
x[
k] + 1;
337 const std::vector<unsigned>&
get()
const 340 for (
unsigned i = 0; i <
m -
mpgen.
m; ++i)
343 for (
unsigned i =
m -
mpgen.
m; i <
m; ++i)
375 const std::vector<unsigned>&
get()
const 378 for (
unsigned i = 0; i <
mpgen.
m; ++i)
415 explicit coolmulti(
const std::vector<unsigned>& partition)
418 for (
unsigned n = 0;
n < partition.size(); ++
n) {
437 before_k->
next =
k->next;
457 for (
unsigned i=1; i<partition.size(); ++i)
460 const std::vector<unsigned>&
get()
const 465 while (it !=
nullptr) {
528 extern const ex
_ex_9;
530 extern const ex
_ex_8;
532 extern const ex
_ex_7;
534 extern const ex
_ex_6;
536 extern const ex
_ex_5;
538 extern const ex
_ex_4;
540 extern const ex
_ex_3;
542 extern const ex
_ex_2;
544 extern const ex
_ex_1;
553 extern const ex
_ex0;
561 extern const ex
_ex1;
563 extern const ex
_ex2;
565 extern const ex
_ex3;
567 extern const ex
_ex4;
569 extern const ex
_ex5;
571 extern const ex
_ex6;
573 extern const ex
_ex7;
575 extern const ex
_ex8;
577 extern const ex
_ex9;
579 extern const ex
_ex10;
581 extern const ex
_ex11;
583 extern const ex
_ex12;
585 extern const ex
_ex15;
587 extern const ex
_ex18;
589 extern const ex
_ex20;
591 extern const ex
_ex24;
593 extern const ex
_ex25;
595 extern const ex
_ex30;
597 extern const ex
_ex48;
599 extern const ex
_ex60;
606 #define DEFAULT_CTOR(classname) \ 607 classname::classname() { setflag(status_flags::evaluated | status_flags::expanded); } 609 #define DEFAULT_COMPARE(classname) \ 610 int classname::compare_same_type(const basic & other) const \ 616 #define DEFAULT_PRINT(classname, text) \ 617 void classname::do_print(const print_context & c, unsigned level) const \ 622 #define DEFAULT_PRINT_LATEX(classname, text, latex) \ 623 DEFAULT_PRINT(classname, text) \ 624 void classname::do_print_latex(const print_latex & c, unsigned level) const \ 631 #endif // ndef GINAC_UTILS_H
coolmulti(const std::vector< unsigned > &partition)
const numeric * _num_48_p
std::vector< unsigned > composition
Generate all bounded combinatorial partitions of an integer n with exactly m parts (including zero pa...
int permutation_sign(It first, It last)
const numeric * _num1_4_p
std::vector< unsigned > partition
const numeric * _num1_2_p
const numeric * _num_11_p
Assertion macro definition.
const numeric * _num1_3_p
const numeric multinomial_coefficient(const std::vector< unsigned > &p)
Compute the multinomial coefficient n!/(p1!*p2!*...*pk!) where n = p1+p2+...+pk, i.e.
mpartition2(unsigned n_, unsigned m_)
const numeric * _num_60_p
element(unsigned val, element *n)
const numeric * _num_25_p
void swap(ex &e1, ex &e2)
const numeric * _num120_p
Generate all compositions of a partition of an integer n, starting with the compositions which has no...
const numeric * _num_15_p
const numeric * _num_120_p
std::vector< unsigned > x
std::vector< unsigned > partition
int compare_pointers(const T *a, const T *b)
Compare two pointers (just to establish some sort of canonical order).
partition_with_zero_parts_generator(unsigned n_, unsigned m_)
composition_generator(const std::vector< unsigned > &partition)
const numeric * _num_1_2_p
unsigned log2(unsigned n)
Integer binary logarithm.
partition_generator(unsigned n_, unsigned m_)
const numeric * _num_1_4_p
void shaker_sort(It first, It last, Cmp comp, Swap swapit)
const numeric * _num_24_p
unsigned golden_ratio_hash(uintptr_t n)
Truncated multiplication with golden ratio, for computing hash values.
const numeric * _num_18_p
const numeric * _num_12_p
unsigned rotate_left(unsigned n)
Rotate bits of unsigned value by one bit to the left.
const numeric * _num_1_3_p
Exception class thrown by functions to signal unimplemented functionality so the expression may just ...
struct GiNaC::composition_generator::coolmulti cmgen
const numeric * _num_10_p
void cyclic_permutation(It first, It last, It new_first, Swap swapit)
const numeric * _num_30_p
Generate all bounded combinatorial partitions of an integer n with exactly m parts (not including zer...
Base class for generating all bounded combinatorial partitions of an integer n with exactly m parts i...
basic_partition_generator(unsigned n_, unsigned m_)
const numeric * _num_20_p
void swap(GiNaC::ex &a, GiNaC::ex &b)
Specialization of std::swap() for ex objects.