X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Fsymmetry.cpp;h=a44cfcc5df87d0a8b02d9518d965972883c66620;hp=23f9df903b98bd1d12a4f60532e6809b69d5ac23;hb=5bf87cea66bb2071222c2910ed68c2649a98906c;hpb=67edef78ce992a8f6ad704bfac228b8dec6eacd2 diff --git a/ginac/symmetry.cpp b/ginac/symmetry.cpp index 23f9df90..a44cfcc5 100644 --- a/ginac/symmetry.cpp +++ b/ginac/symmetry.cpp @@ -3,7 +3,7 @@ * Implementation of GiNaC's symmetry definitions. */ /* - * GiNaC Copyright (C) 1999-2010 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "symmetry.h" #include "lst.h" +#include "add.h" #include "numeric.h" // for factorial() #include "operators.h" #include "archive.h" @@ -160,7 +161,7 @@ int symmetry::compare_same_type(const basic & other) const return 1; if (this_size < that_size) return -1; - typedef std::set::iterator set_it; + typedef std::set::const_iterator set_it; set_it end = indices.end(); for (set_it i=indices.begin(),j=othersymm.indices.begin(); i!=end; ++i,++j) { if(*i < *j) @@ -269,6 +270,18 @@ void symmetry::do_print_tree(const print_tree & c, unsigned level) const // 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(*i).has_nonsymmetric()) + return true; + + return false; +} + bool symmetry::has_cyclic() const { if (type == cyclic) @@ -495,7 +508,8 @@ static ex symm(const ex & e, exvector::const_iterator first, exvector::const_ite // 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; isetflag(status_flags::dynallocated); delete[] iv; delete[] iv2;