]> www.ginac.de Git - ginac.git/commitdiff
- permutation_sign() and shaker_sort() are no longer inlined
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 30 May 2001 22:38:28 +0000 (22:38 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 30 May 2001 22:38:28 +0000 (22:38 +0000)
- symmetrize() no longer limited to 32-bit integers

ginac/clifford.cpp
ginac/inifcns.cpp
ginac/utils.h

index 3af4fcae1eab2b374e900d58192cf107a3406974..e62def5047707a969d313bafd0759b37e071112c 100644 (file)
@@ -524,7 +524,7 @@ ex canonicalize_clifford(const ex & e)
                        for (unsigned j=0; j<rhs.nops(); j++)
                                v.push_back(rhs.op(j));
 
-                       // Stupid bubble sort because we only want to swap adjacent gammas
+                       // Stupid recursive bubble sort because we only want to swap adjacent gammas
                        exvector::iterator it = v.begin(), next_to_last = v.end() - 1;
                        if (is_ex_of_type(it->op(0), diracgamma5))
                                it++;
index beb51d6289dcb56d63e3b12f6d1762ed399e71a9..03acbc7f2f42d4c221905652a39b21cdd3e041e2 100644 (file)
@@ -538,25 +538,18 @@ static ex symm(const ex & e, exvector::const_iterator first, exvector::const_ite
        shaker_sort(iv_lst.begin(), iv_lst.end(), ex_is_less());
        lst orig_lst(iv_lst);
 
-       // With n objects there are n! possible permutations
-       int num_perms = factorial(numeric(num)).to_int();
-
        // Loop over all permutations (the first permutation, which is the
        // identity, is unrolled)
        ex sum = e;
-       int i = 1;
-       do {
-               next_permutation(iv_lst.begin(), iv_lst.end(), ex_is_less());
+       while (next_permutation(iv_lst.begin(), iv_lst.end(), ex_is_less())) {
                ex term = e.subs(orig_lst, lst(iv_lst));
                if (asymmetric) {
                        exlist test_lst = iv_lst;
                        term *= permutation_sign(test_lst.begin(), test_lst.end(), ex_is_less());
                }
                sum += term;
-               i++;
-       } while (i < num_perms);
-
-       return sum / num_perms;
+       }
+       return sum / factorial(numeric(num));
 }
 
 ex symmetrize(const ex & e, exvector::const_iterator first, exvector::const_iterator last)
index c0bc2efecf49c00ec10328bc5b51674b00341acb..ac7aecdfacf5a128fd1aa73f238f5d42cd065fa4 100644 (file)
@@ -131,7 +131,7 @@ inline unsigned golden_ratio_hash(unsigned n)
    explicitly supplied comparison function. If the sign returned is 1 or -1,
    the container is sorted after the operation. */
 template <class It>
-inline int permutation_sign(It first, It last)
+int permutation_sign(It first, It last)
 {
        if (first == last)
                return 0;
@@ -184,7 +184,7 @@ inline int permutation_sign(It first, It last)
 }
 
 template <class It, class Cmp>
-inline int permutation_sign(It first, It last, Cmp comp)
+int permutation_sign(It first, It last, Cmp comp)
 {
        if (first == last)
                return 0;
@@ -238,7 +238,7 @@ inline int permutation_sign(It first, It last, Cmp comp)
 
 /* Implementation of shaker sort, only compares adjacent elements. */
 template <class It, class Cmp>
-inline void shaker_sort(It first, It last, Cmp comp)
+void shaker_sort(It first, It last, Cmp comp)
 {
        if (first == last)
                return;