55#include " group.h"
66#include " action.h"
77#include " ext.h"
8+ #include " multi.h"
89
9- RestrictedNaturalSetAction CameronReduction ( NaturalAction phi ) {
10- int n = phi.domain ().size ();
11- std::cerr << " M" ;
12- NaturalArrayAction<2 > psi ( phi.group () );
13- std::cerr << " E" ;
14- auto orbitals = psi.orbits ();
15- std::sort ( orbitals.begin (), orbitals.end (), size_compare<std::vector<NaturalArrayAction<2 >::value_type>> );
16- const auto & Gamma = orbitals[1 ];
17- const auto & Delta_prime = orbitals.back ();
18- std::unordered_map<int ,std::deque<int >> Delta;
19- for ( const auto & delta : Delta_prime )
20- Delta[delta[0 ]].push_back ( delta[1 ] );
10+ std::deque<std::vector<int >> CameronReductionPart ( std::vector<std::array<int ,2 >>::const_iterator beg, std::vector<std::array<int ,2 >>::const_iterator end, const std::unordered_map<int ,std::deque<int >>& Delta, int n ) {
11+ int counter = 0 ;
2112 std::vector<bool > B (n);
2213 std::vector<bool > C_prime (n);
2314 size_t setsize = 0 ;
2415 std::vector<int > C;
2516 std::deque<std::vector<int >> D_prime;
26- std::cerr << " |Gamma|=" << Gamma.size () << std::endl;
27- std::cerr << " |Delta|=" << Delta_prime.size () << std::endl;
28- int counter = 0 ;
29- for ( const auto & p : Gamma ) {
30- if ( (++counter) % 1000 )
17+ for ( ; beg != end; beg++ ) {
18+ if ( (++counter) % 100 == 0 )
3119 std::cerr << counter << std::endl;
32- int x = p[ 0 ] ;
33- int y = p[ 1 ] ;
20+ int x = beg-> at ( 0 ) ;
21+ int y = beg-> at ( 1 ) ;
3422 B.assign ( n, false );
3523 C_prime.assign ( n, true );
36- for ( int q : Delta[y] )
24+ for ( int q : Delta. at (y) )
3725 B[q] = true ;
38- for ( int q : Delta[x] )
26+ for ( int q : Delta. at (x) )
3927 B[q] = false ;
4028 for ( int z = 0 ; z < n; z++ )
4129 if ( B[z] )
42- for ( int q : Delta[z] )
30+ for ( int q : Delta. at (z) )
4331 C_prime[q] = false ;
4432 C.reserve ( setsize );
4533 for ( int i = 0 ; i < n; i++ )
@@ -49,6 +37,37 @@ RestrictedNaturalSetAction CameronReduction( NaturalAction phi ) {
4937 if ( std::find ( D_prime.begin (), D_prime.end (), C ) == D_prime.end () )
5038 D_prime.emplace_back ( std::move ( C ) );
5139 }
40+ return D_prime;
41+ }
42+
43+ RestrictedNaturalSetAction CameronReduction ( NaturalAction phi ) {
44+ int n = phi.domain ().size ();
45+ NaturalArrayAction<2 > psi ( phi.group () );
46+ auto orbitals = psi.orbits ();
47+ std::cerr << " orbitals done" << std::endl;
48+ std::sort ( orbitals.begin (), orbitals.end (), size_compare<std::vector<NaturalArrayAction<2 >::value_type>> );
49+ const auto & Gamma = orbitals[1 ];
50+ const auto & Delta_prime = orbitals.back ();
51+ std::unordered_map<int ,std::deque<int >> Delta;
52+ for ( const auto & delta : Delta_prime )
53+ Delta[delta[0 ]].push_back ( delta[1 ] );
54+ std::deque<std::vector<int >> D_prime;
55+ std::cerr << " |Gamma|=" << Gamma.size () << std::endl;
56+ std::cerr << " |Delta|=" << Delta_prime.size () << std::endl;
57+ #ifdef THREADED
58+ std::future<std::deque<std::vector<int >>> res[THREADS];
59+ auto beg = Gamma.cbegin ();
60+ auto end = Gamma.cbegin ();
61+ for ( size_t i = 0 ; i < THREADS-1 ; i++ ) {
62+ end += Gamma.size ()/THREADS;
63+ res[i] = std::async ( CameronReductionPart, beg, end, Delta, n );
64+ beg = end;
65+ }
66+ auto resl = CameronReductionPart ( end, Gamma.cend (), Delta, n );
67+ #else
68+ auto res = CameronReductionPart ( Gamma.cbegin (), Gamma.cend (), Delta, n );
69+ #endif
70+
5271 std::cout << " Done" << std::endl;
5372 return RestrictedNaturalSetAction ( phi.group (), D_prime );
5473
0 commit comments