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 EXPLICITTRANSVERSAL_H_
00034 #define EXPLICITTRANSVERSAL_H_
00035
00036 #include <permlib/transversal/transversal.h>
00037
00038 namespace permlib {
00039
00041 template <class PERM>
00042 class ExplicitTransversal : public Transversal<PERM> {
00043 public:
00045 ExplicitTransversal(unsigned int n);
00046
00047 virtual PERM* at(ulong val) const;
00048 virtual bool trivialByDefinition(const PERM& x, ulong to) const;
00049
00050 virtual void permute(const PERM& g, const PERM& gInv);
00051
00053
00056 ExplicitTransversal<PERM> clone(const std::map<PERM*,PERMptr>& generatorChange) const;
00057
00059 static const uint m_statMaxDepth;
00060 protected:
00061 virtual void registerMove(ulong from, ulong to, const PERMptr &p);
00062 };
00063
00064
00065
00066
00067
00068 template <class PERM>
00069 const uint ExplicitTransversal<PERM>::m_statMaxDepth = 1;
00070
00071 template <class PERM>
00072 ExplicitTransversal<PERM>::ExplicitTransversal(unsigned int n)
00073 : Transversal<PERM>(n)
00074 { }
00075
00076 template <class PERM>
00077 bool ExplicitTransversal<PERM>::trivialByDefinition(const PERM& x, ulong to) const {
00078
00079 return false;
00080 }
00081
00082 template <class PERM>
00083 PERM* ExplicitTransversal<PERM>::at(ulong val) const {
00084 if (!Transversal<PERM>::m_transversal[val])
00085 return 0;
00086 return new PERM(*(Transversal<PERM>::m_transversal[val]));
00087 }
00088
00089 template <class PERM>
00090 void ExplicitTransversal<PERM>::registerMove(ulong from, ulong to, const PERMptr &p) {
00091 Transversal<PERM>::registerMove(from, to, p);
00092
00093 std::vector<boost::shared_ptr<PERM> > &transversal = Transversal<PERM>::m_transversal;
00094
00095 if (!transversal[from])
00096 transversal[to] = boost::shared_ptr<PERM>(new PERM(*p));
00097 else {
00098 transversal[to] = boost::shared_ptr<PERM>(new PERM(*transversal[from]));
00099 (*transversal[to]) *= *p;
00100 }
00101 }
00102
00103 template <class PERM>
00104 void ExplicitTransversal<PERM>::permute(const PERM& g, const PERM& gInv) {
00105 Transversal<PERM>::permute(g, gInv);
00106 BOOST_FOREACH(PERMptr& p, Transversal<PERM>::m_transversal) {
00107 if (p) {
00108 *p ^= gInv;
00109 *p *= g;
00110 }
00111 }
00112 }
00113
00114 template <class PERM>
00115 ExplicitTransversal<PERM> ExplicitTransversal<PERM>::clone(const std::map<PERM*,PERMptr>& generatorChange) const {
00116 ExplicitTransversal<PERM> ret(*this);
00117 BOOST_FOREACH(PERMptr& p, ret.m_transversal) {
00118 if (!p)
00119 continue;
00120 p = boost::shared_ptr<PERM>(new PERM(*p));
00121 }
00122 return ret;
00123 }
00124
00125 }
00126
00127 #endif // -- EXPLICITTRANSVERSAL_H_