#include "symmetry.h"
#include "lst.h"
+#include "add.h"
#include "numeric.h" // for factorial()
#include "operators.h"
#include "archive.h"
// non-virtual functions in this class
//////////
+bool symmetry::has_nonsymmetric() const
+{
+ if (type == antisymmetric || type == cyclic)
+ return true;
+
+ for (exvector::const_iterator i=children.begin(); i!=children.end(); ++i)
+ if (ex_to<symmetry>(*i).has_nonsymmetric())
+ return true;
+
+ return false;
+}
+
bool symmetry::has_cyclic() const
{
if (type == cyclic)
// Loop over all permutations (the first permutation, which is the
// identity, is unrolled)
- ex sum = e;
+ exvector sum_v;
+ sum_v.push_back(e);
while (std::next_permutation(iv, iv + num)) {
lst new_lst;
for (unsigned i=0; i<num; i++)
memcpy(iv2, iv, num * sizeof(unsigned));
term *= permutation_sign(iv2, iv2 + num);
}
- sum += term;
+ sum_v.push_back(term);
}
+ ex sum = (new add(sum_v))->setflag(status_flags::dynallocated);
delete[] iv;
delete[] iv2;