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 TEST_COMMON_H_
00034 #define TEST_COMMON_H_
00035
00036 struct GroupInformation {
00037 std::string filename;
00038 uint n;
00039 uint order;
00040
00041 GroupInformation(const std::string &f, uint _n, uint _order) : filename(f), n(_n), order(_order) {}
00042 };
00043
00044 const GroupInformation info_psu4_3("../data/G_psu4_3", 820, 3265920);
00045 const GroupInformation info_1997("../data/G_test1997", 13, 13*12*9*4);
00046 const GroupInformation info_cyclic500("../data/G_cyclic500", 500, 500);
00047
00048
00049 #include <list>
00050 #include <boost/shared_ptr.hpp>
00051
00052 #include <permlib/common.h>
00053 #include <permlib/bsgs.h>
00054 #include <permlib/construct/schreier_sims_construction.h>
00055
00056 template<class PERM>
00057 uint read(const std::string &filename, PERMlist &groupGenerators) {
00058 std::ifstream file;
00059 file.open(filename.c_str());
00060 if (!file.is_open()) {
00061 std::cerr << "opening " << filename << " failed" << std::endl;
00062 BOOST_REQUIRE(file.is_open());
00063 return 0;
00064 }
00065
00066 uint n;
00067 file >> n;
00068
00069 std::string line;
00070 while (!file.eof()) {
00071 std::getline(file, line);
00072 if (line.length() < 1)
00073 continue;
00074 boost::shared_ptr<PERM> gen(new PERM(n, line));
00075 groupGenerators.push_back(gen);
00076 }
00077 file.close();
00078
00079 return n;
00080 }
00081
00082 using namespace permlib;
00083
00084 template<class PERM,class TRANS>
00085 BSGS<PERM,TRANS> construct(const std::string &filename) {
00086 PERMlist groupGenerators;
00087 const uint n = read(filename, groupGenerators);
00088
00089 SchreierSimsConstruction<PERM, TRANS> ssc(n);
00090 BSGS<PERM, TRANS> bsgs = ssc.construct(groupGenerators.begin(), groupGenerators.end());
00091
00092 return bsgs;
00093 }
00094
00095 template<class PERM>
00096 void checkImage(const ulong* Delta, ulong DeltaSize, const ulong* Phi, const boost::shared_ptr<PERM> &repr) {
00097 std::list<ulong> imgList(Phi, Phi+DeltaSize);
00098 for (uint j = 0; j < DeltaSize; ++j) {
00099 std::list<ulong>::iterator it = std::find(imgList.begin(), imgList.end(), *repr / Delta[j]);
00100 BOOST_REQUIRE( it != imgList.end() );
00101 imgList.erase(it);
00102 }
00103 BOOST_CHECK( imgList.size() == 0 );
00104 }
00105
00106 #endif // - TEST_COMMON_H_