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 GROUPINTERSECTIONPREDICATE_H_
00034 #define GROUPINTERSECTIONPREDICATE_H_
00035
00036 #include "bsgs.h"
00037 #include "predicate/subgroup_predicate.h"
00038
00039 #include <boost/foreach.hpp>
00040
00041 namespace permlib {
00042
00044 template <class PERM, class TRANS>
00045 class GroupIntersectionPredicate : public SubgroupPredicate<PERM> {
00046 public:
00048
00052 GroupIntersectionPredicate(const BSGS<PERM, TRANS> &g, const BSGS<PERM, TRANS> &h);
00053
00054 virtual bool operator()(const PERM &p) const;
00055 virtual bool childRestriction(const PERM &h, uint i, ulong beta_i) const;
00056 virtual uint limit() const;
00057 private:
00058 const BSGS<PERM, TRANS> &m_G;
00059 const BSGS<PERM, TRANS> &m_H;
00060 };
00061
00062
00063
00064
00065
00066 template <class PERM, class TRANS>
00067 GroupIntersectionPredicate<PERM,TRANS>::GroupIntersectionPredicate(const BSGS<PERM, TRANS> &g, const BSGS<PERM, TRANS> &h)
00068 : m_G(g), m_H(h)
00069 {
00070 BOOST_ASSERT(m_G.n == m_H.n);
00071 BOOST_ASSERT(m_G.order() <= m_H.order());
00072 }
00073
00074 template <class PERM, class TRANS>
00075 bool GroupIntersectionPredicate<PERM,TRANS>::operator()(const PERM &p) const {
00076 return m_G.sifts(p) && m_H.sifts(p);
00077 }
00078
00079 template <class PERM, class TRANS>
00080 bool GroupIntersectionPredicate<PERM,TRANS>::childRestriction(const PERM &h, uint i, ulong beta_i) const {
00081
00082
00083 PERM siftee(m_H.n);
00084 const uint m = m_H.sift(h, siftee, 0, i+1);
00085 return i+1 == m;
00086 }
00087
00088 template <class PERM, class TRANS>
00089 uint GroupIntersectionPredicate<PERM,TRANS>::limit() const {
00090 return m_G.B.size();
00091 }
00092
00093 }
00094
00095 #endif // -- GROUPINTERSECTIONPREDICATE_H_