Skip to content

Commit db6721f

Browse files
committed
Attempt #3
1 parent 9f66bfa commit db6721f

File tree

4 files changed

+50
-24
lines changed

4 files changed

+50
-24
lines changed

action.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "ext.h"
1313
#include "unionfind.h"
1414
#include "group.h"
15+
#include "multi.h"
1516

1617
template<typename T>
1718
using action_set = std::vector<T>;
@@ -531,12 +532,11 @@ std::vector<std::vector<typename NaturalArrayAction<k>::value_type>> NaturalArra
531532
}
532533
i++;
533534
}
534-
std::cout << "yo" << std::endl;
535535
std::unordered_map<int,int> indices;
536536
i = 0;
537537
int j = 0;
538538
r.resize( c );
539-
for( const auto& x : all_arrays<k>( n ) ) {
539+
for( const auto& x : domain() ) {
540540
int a = uf.find( i++ );
541541
if( indices.count(a) == 0 )
542542
indices[a] = j++;

johnson.cc

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,29 @@
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

johnson.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@
3939
std::vector<int> JordanLiebeckSet( RestrictedNaturalSetAction, int x );
4040
RestrictedNaturalSetAction JohnsonStandardBlocks( RestrictedNaturalSetAction phi );
4141
RestrictedNaturalSetAction CameronReduction( NaturalAction phi );
42+
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 );

multi.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
#define THREADED
3+
#ifdef THREADED
4+
#define THREADS 32
5+
#include <future>
6+
#endif

0 commit comments

Comments
 (0)