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 REDUNDANT_BASE_POINT_INSERTION_STRATEGY_H_
00034 #define REDUNDANT_BASE_POINT_INSERTION_STRATEGY_H_
00035
00036 namespace permlib {
00037
00038 template <class PERM, class TRANS>
00039 struct BSGS;
00040
00042 template <class PERM, class TRANS>
00043 class RedundantBasePointInsertionStrategy {
00044 public:
00046
00049 RedundantBasePointInsertionStrategy(const BSGS<PERM,TRANS> &bsgs) : m_bsgs(bsgs) {}
00050
00051
00052 virtual ~RedundantBasePointInsertionStrategy() {}
00053
00055
00060 virtual int findInsertionPoint(uint beta, PERMlist &S_i) const = 0;
00061 protected:
00063 const BSGS<PERM,TRANS> &m_bsgs;
00064 };
00065
00067 template <class PERM, class TRANS>
00068 class TrivialRedundantBasePointInsertionStrategy : public RedundantBasePointInsertionStrategy<PERM,TRANS> {
00069 public:
00071 TrivialRedundantBasePointInsertionStrategy(const BSGS<PERM,TRANS> &bsgs) : RedundantBasePointInsertionStrategy<PERM,TRANS>(bsgs) {}
00072
00073 virtual int findInsertionPoint(uint beta, PERMlist &S_i) const {
00074 const std::vector<ulong> &B = RedundantBasePointInsertionStrategy<PERM,TRANS>::m_bsgs.B;
00075 const std::vector<TRANS> &U = RedundantBasePointInsertionStrategy<PERM,TRANS>::m_bsgs.U;
00076 for (uint i=0; i<B.size(); ++i) {
00077 if (beta == B[i])
00078 return -i-1;
00079 }
00080 int pos = B.size();
00081 while (pos > 0 && U[pos-1].size() == 1)
00082 --pos;
00083 return pos;
00084 }
00085 };
00086
00088 template <class PERM, class TRANS>
00089 class FirstRedundantBasePointInsertionStrategy : public RedundantBasePointInsertionStrategy<PERM,TRANS> {
00090 public:
00092 FirstRedundantBasePointInsertionStrategy(const BSGS<PERM,TRANS> &bsgs) : RedundantBasePointInsertionStrategy<PERM,TRANS>(bsgs) {}
00093
00094 virtual int findInsertionPoint(uint beta, PERMlist &S_i) const {
00095 const std::vector<ulong> &B = RedundantBasePointInsertionStrategy<PERM,TRANS>::m_bsgs.B;
00096 const PERMlist &S = RedundantBasePointInsertionStrategy<PERM,TRANS>::m_bsgs.S;
00097 typename std::vector<ulong>::const_iterator bIt = B.begin();
00098 int pos = B.size();
00099 for (uint i=0; i<B.size(); ++i) {
00100 if (beta == B[i])
00101 return -i-1;
00102
00103 ++bIt;
00104 const PointwiseStabilizerPredicate<PERM> stab_i(B.begin(), bIt);
00105 S_i.clear();
00106
00107
00108
00109 std::copy_if(S.begin(), S.end(), std::back_inserter(S_i), stab_i);
00110
00111 StabilizesPointPredicate<PERM> stab_beta(S_i.begin(), S_i.end());
00112 if (stab_beta(beta)) {
00113 pos = i+1;
00114 break;
00115 }
00116 }
00117 return pos;
00118 }
00119 };
00120
00121 }
00122
00123 #endif // -- REDUNDANT_BASE_POINT_INSERTION_STRATEGY_H_