00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef SYMMETRICGROUP_H_
00034 #define SYMMETRICGROUP_H_
00035
00036 #include "bsgs_core.h"
00037 #include "transversal/symmetric_group_transversal.h"
00038
00039 namespace permlib {
00040
00042
00049 template<class PERM>
00050 struct SymmetricGroup : public BSGSCore<PERM, SymmetricGroupTransversal<PERM> > {
00052 explicit SymmetricGroup(uint n);
00054 SymmetricGroup(const SymmetricGroup<PERM>& symGroup);
00056 SymmetricGroup& operator=(const SymmetricGroup<PERM>& symGroup);
00057
00059 typedef SymmetricGroupTransversal<PERM> TRANS;
00060
00061 virtual bool isSymmetricGroup() const { return true; }
00062 private:
00063 void copy(const SymmetricGroup<PERM>& symGroup);
00064 };
00065
00066 template<class PERM>
00067 inline SymmetricGroup<PERM>::SymmetricGroup(uint n)
00068 : BSGSCore<PERM,TRANS>(-n, n, n)
00069 {
00070 BSGSCore<PERM,TRANS>::U.reserve(n);
00071 for (uint i = 0; i < n; ++i) {
00072 BSGSCore<PERM,TRANS>::B[i] = n-1-i;
00073 BSGSCore<PERM,TRANS>::U.push_back(SymmetricGroupTransversal<PERM>(this, i));
00074 if (i < n-1) {
00075 boost::shared_ptr<PERM> gen(new PERM(n));
00076 gen->setTransposition(i, i+1);
00077 BSGSCore<PERM,TRANS>::S.push_back(gen);
00078 }
00079 }
00080 }
00081
00082 template<class PERM>
00083 inline void SymmetricGroup<PERM>::copy(const SymmetricGroup<PERM>& symGroup)
00084 {
00085 const ulong& n = symGroup.n;
00086 BSGSCore<PERM,TRANS>::U.reserve(n);
00087 for (uint i = 0; i < n; ++i) {
00088 BSGSCore<PERM,TRANS>::B[i] = symGroup.B[i];
00089 BSGSCore<PERM,TRANS>::U.push_back(SymmetricGroupTransversal<PERM>(this, i));
00090 if (i < n-1) {
00091 boost::shared_ptr<PERM> gen(new PERM(n));
00092 gen->setTransposition(i, i+1);
00093 BSGSCore<PERM,TRANS>::S.push_back(gen);
00094 }
00095 }
00096 }
00097
00098 template<class PERM>
00099 inline SymmetricGroup<PERM>::SymmetricGroup(const SymmetricGroup<PERM>& symGroup)
00100 : BSGSCore<PERM,TRANS>(-symGroup.n, symGroup.n, symGroup.n)
00101 {
00102 copy(symGroup);
00103 }
00104
00105 template<class PERM>
00106 inline SymmetricGroup<PERM>& SymmetricGroup<PERM>::operator=(const SymmetricGroup<PERM>& symGroup)
00107 {
00108 BOOST_ASSERT(symGroup.n == this->n);
00109
00110 BSGSCore<PERM,TRANS>::n = symGroup.n;
00111 BSGSCore<PERM,TRANS>::m_id = symGroup.m_id;
00112 copy(symGroup);
00113 return *this;
00114 }
00115
00116 }
00117
00118
00119 #endif // SYMMETRICGROUP_H_