PermLib
abstract_permutation_group.h
00001 // ---------------------------------------------------------------------------
00002 //
00003 //  This file is part of PermLib.
00004 //
00005 // Copyright (c) 2009-2012 Thomas Rehn <thomas@carmen76.de>
00006 // All rights reserved.
00007 // 
00008 // Redistribution and use in source and binary forms, with or without
00009 // modification, are permitted provided that the following conditions
00010 // are met:
00011 // 1. Redistributions of source code must retain the above copyright
00012 //    notice, this list of conditions and the following disclaimer.
00013 // 2. Redistributions in binary form must reproduce the above copyright
00014 //    notice, this list of conditions and the following disclaimer in the
00015 //    documentation and/or other materials provided with the distribution.
00016 // 3. The name of the author may not be used to endorse or promote products
00017 //    derived from this software without specific prior written permission.
00018 // 
00019 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00020 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00021 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00022 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00023 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00024 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00028 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // ---------------------------------------------------------------------------
00031 
00032 #include <vector>
00033 #include <list>
00034 #include <set>
00035 
00036 #include <boost/cstdint.hpp>
00037 #include <boost/foreach.hpp>
00038 #include <boost/dynamic_bitset.hpp>
00039 
00040 #include <permlib/common.h>
00041 
00042 #ifndef ABSTRACT_PERMUTATION_GROUP_H_
00043 #define ABSTRACT_PERMUTATION_GROUP_H_
00044 
00045 namespace permlib {
00046 
00048 enum AbstractGroupType {
00049         AGT_BSGS = 1,
00050         AGT_SymmetricProduct = 2
00051 };
00052 
00054 class AbstractPermutationGroup {
00055 public:
00057         virtual ~AbstractPermutationGroup() {}
00058         
00060         template<typename Integer>
00061         Integer order() const;
00062         
00064         boost::uint64_t order() const;
00065         
00067 
00071         virtual AbstractPermutationGroup* setStabilizer(const std::vector<dom_int>& s) const = 0;
00072         
00074         typedef std::list<std::set<dom_int> > OrbitList;
00076         virtual OrbitList* orbits() const = 0;
00078 
00082         virtual OrbitList* orbits(const std::vector<dom_int>& s) const = 0;
00083         
00085 
00090         virtual bool isLexMinSet(const std::vector<dom_int>& setIndices, const std::vector<dom_int>& rankIndices) const = 0;
00091 
00093         virtual AbstractGroupType type() const = 0;
00094 protected:
00096         virtual void transversalSizes(std::vector<unsigned long>& sizes) const = 0;
00097 };
00098 
00099 
00100 template <typename Integer>
00101 Integer AbstractPermutationGroup::order() const {
00102         Integer orderValue(1);
00103         std::vector<unsigned long> sizes;
00104         transversalSizes(sizes);
00105         BOOST_FOREACH(const unsigned long &s, sizes) {
00106                 orderValue *= s;
00107         }
00108         return orderValue;
00109 }
00110 
00111 inline boost::uint64_t AbstractPermutationGroup::order() const {
00112         return order<boost::uint64_t>();
00113 }
00114 
00115 } // end NS
00116 
00117 #endif