]> www.ginac.de Git - ginac.git/blobdiff - ginac/symmetry.cpp
canonicalize() failed to return zero for an antisymmetric combination of two
[ginac.git] / ginac / symmetry.cpp
index e0f1ba3e338029ebfe5cd6e4a0a07ed19d55d5a4..c953953a2e55eebf2ee081a84ab6904658cb7adb 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's symmetry definitions. */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2002 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
@@ -20,9 +20,9 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <iostream>
 #include <stdexcept>
 #include <functional>
-#include <algorithm>
 
 #include "symmetry.h"
 #include "lst.h"
@@ -30,7 +30,6 @@
 #include "print.h"
 #include "archive.h"
 #include "utils.h"
-#include "debugmsg.h"
 
 namespace GiNaC {
 
@@ -51,12 +50,11 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(symmetry, basic)
 */
 
 //////////
-// default constructor, destructor, copy constructor assignment operator and helpers
+// default ctor, dtor, copy ctor, assignment operator and helpers
 //////////
 
 symmetry::symmetry() : type(none)
 {
-       debugmsg("symmetry default constructor", LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_symmetry;
 }
 
@@ -76,14 +74,12 @@ DEFAULT_DESTROY(symmetry)
 
 symmetry::symmetry(unsigned i) : type(none)
 {
-       debugmsg("symmetry constructor from unsigned", LOGLEVEL_CONSTRUCT);
        indices.insert(i);
        tinfo_key = TINFO_symmetry;
 }
 
 symmetry::symmetry(symmetry_type t, const symmetry &c1, const symmetry &c2) : type(t)
 {
-       debugmsg("symmetry constructor from symmetry_type,symmetry &,symmetry &", LOGLEVEL_CONSTRUCT);
        add(c1); add(c2);
        tinfo_key = TINFO_symmetry;
 }
@@ -95,8 +91,6 @@ symmetry::symmetry(symmetry_type t, const symmetry &c1, const symmetry &c2) : ty
 /** Construct object from archive_node. */
 symmetry::symmetry(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
-       debugmsg("symmetry ctor from archive_node", LOGLEVEL_CONSTRUCT);
-
        unsigned t;
        if (!(n.find_unsigned("type", t)))
                throw (std::runtime_error("unknown symmetry type in archive"));
@@ -163,8 +157,6 @@ int symmetry::compare_same_type(const basic & other) const
 
 void symmetry::print(const print_context & c, unsigned level) const
 {
-       debugmsg("symmetry print", LOGLEVEL_PRINT);
-
        if (is_a<print_tree>(c)) {
 
                c.s << std::string(level, ' ') << class_name()
@@ -312,7 +304,7 @@ public:
 
 int canonicalize(exvector::iterator v, const symmetry &symm)
 {
-       // Less than two indices? Then do nothing
+       // Less than two elements? Then do nothing
        if (symm.indices.size() < 2)
                return INT_MAX;
 
@@ -342,6 +334,8 @@ int canonicalize(exvector::iterator v, const symmetry &symm)
                case symmetry::antisymmetric:
                        // Sort the children in ascending order, keeping track of the signum
                        sign *= permutation_sign(first, last, sy_is_less(v), sy_swap(v, something_changed));
+                       if (sign == 0)
+                               return 0;
                        break;
                case symmetry::cyclic:
                        // Permute the smallest child to the front