mapFolding 0.15.0__py3-none-any.whl → 0.15.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mapFolding/__init__.py +1 -0
- mapFolding/_oeisFormulas/A001010.py +18 -0
- mapFolding/_oeisFormulas/Z0Z_oeisMeanders.py +6 -1
- mapFolding/_theTypes.py +1 -1
- mapFolding/basecamp.py +89 -9
- mapFolding/daoOfMapFolding.py +2 -1
- mapFolding/oeis.py +1 -5
- mapFolding/reference/jaxCount.py +1 -1
- mapFolding/reference/rotatedEntryPoint.py +1 -1
- mapFolding/someAssemblyRequired/A007822rawMaterials.py +46 -0
- mapFolding/someAssemblyRequired/makeAllModules.py +192 -199
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +2 -2
- mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +2 -2
- mapFolding/syntheticModules/algorithmA007822.py +166 -0
- mapFolding/syntheticModules/algorithmA007822Numba.py +95 -0
- mapFolding/syntheticModules/{countParallel.py → countParallelNumba.py} +4 -6
- mapFolding/syntheticModules/{daoOfMapFolding.py → daoOfMapFoldingNumba.py} +4 -5
- mapFolding/syntheticModules/dataPacking.py +4 -5
- mapFolding/syntheticModules/{initializeCount.py → initializeState.py} +1 -1
- mapFolding/syntheticModules/initializeStateA007822.py +69 -0
- mapFolding/syntheticModules/theorem2.py +2 -1
- mapFolding/syntheticModules/theorem2A007822.py +70 -0
- mapFolding/syntheticModules/theorem2A007822Numba.py +67 -0
- mapFolding/syntheticModules/theorem2A007822Trimmed.py +64 -0
- mapFolding/syntheticModules/theorem2Numba.py +2 -1
- mapFolding/syntheticModules/theorem2Trimmed.py +2 -1
- mapFolding/tests/test_computations.py +29 -4
- {mapfolding-0.15.0.dist-info → mapfolding-0.15.1.dist-info}/METADATA +1 -1
- {mapfolding-0.15.0.dist-info → mapfolding-0.15.1.dist-info}/RECORD +33 -26
- mapFolding/_A007822.py +0 -181
- {mapfolding-0.15.0.dist-info → mapfolding-0.15.1.dist-info}/WHEEL +0 -0
- {mapfolding-0.15.0.dist-info → mapfolding-0.15.1.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.15.0.dist-info → mapfolding-0.15.1.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.15.0.dist-info → mapfolding-0.15.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
+
|
|
3
|
+
def filterAsymmetricFolds(state: MapFoldingState) -> MapFoldingState:
|
|
4
|
+
state.indexLeaf = 0
|
|
5
|
+
leafConnectee = 0
|
|
6
|
+
while leafConnectee < state.leavesTotal + 1:
|
|
7
|
+
leafNumber = int(state.leafBelow[state.indexLeaf])
|
|
8
|
+
state.leafComparison[leafConnectee] = (leafNumber - state.indexLeaf + state.leavesTotal) % state.leavesTotal
|
|
9
|
+
state.indexLeaf = leafNumber
|
|
10
|
+
leafConnectee += 1
|
|
11
|
+
indexInMiddle = state.leavesTotal // 2
|
|
12
|
+
state.indexMiniGap = 0
|
|
13
|
+
while state.indexMiniGap < state.leavesTotal + 1:
|
|
14
|
+
ImaSymmetricFold = True
|
|
15
|
+
leafConnectee = 0
|
|
16
|
+
while leafConnectee < indexInMiddle:
|
|
17
|
+
if state.leafComparison[(state.indexMiniGap + leafConnectee) % (state.leavesTotal + 1)] != state.leafComparison[(state.indexMiniGap + state.leavesTotal + 1 - 2 - leafConnectee) % (state.leavesTotal + 1)]:
|
|
18
|
+
ImaSymmetricFold = False
|
|
19
|
+
break
|
|
20
|
+
leafConnectee += 1
|
|
21
|
+
if ImaSymmetricFold:
|
|
22
|
+
state.groupsOfFolds += 1
|
|
23
|
+
state.indexMiniGap += 1
|
|
24
|
+
return state
|
|
25
|
+
|
|
26
|
+
def activeLeafGreaterThan0(state: MapFoldingState) -> bool:
|
|
27
|
+
return state.leaf1ndex > 0
|
|
28
|
+
|
|
29
|
+
def activeLeafGreaterThanLeavesTotal(state: MapFoldingState) -> bool:
|
|
30
|
+
return state.leaf1ndex > state.leavesTotal
|
|
31
|
+
|
|
32
|
+
def activeLeafIsTheFirstLeaf(state: MapFoldingState) -> bool:
|
|
33
|
+
return state.leaf1ndex <= 1
|
|
34
|
+
|
|
35
|
+
def activeLeafIsUnconstrainedInAllDimensions(state: MapFoldingState) -> bool:
|
|
36
|
+
return not state.dimensionsUnconstrained
|
|
37
|
+
|
|
38
|
+
def activeLeafUnconstrainedInThisDimension(state: MapFoldingState) -> MapFoldingState:
|
|
39
|
+
state.dimensionsUnconstrained -= 1
|
|
40
|
+
return state
|
|
41
|
+
|
|
42
|
+
def filterCommonGaps(state: MapFoldingState) -> MapFoldingState:
|
|
43
|
+
state.gapsWhere[state.gap1ndex] = state.gapsWhere[state.indexMiniGap]
|
|
44
|
+
if state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] == state.dimensionsUnconstrained:
|
|
45
|
+
state = incrementActiveGap(state)
|
|
46
|
+
state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] = 0
|
|
47
|
+
return state
|
|
48
|
+
|
|
49
|
+
def gapAvailable(state: MapFoldingState) -> bool:
|
|
50
|
+
return state.leaf1ndex > 0
|
|
51
|
+
|
|
52
|
+
def incrementActiveGap(state: MapFoldingState) -> MapFoldingState:
|
|
53
|
+
state.gap1ndex += 1
|
|
54
|
+
return state
|
|
55
|
+
|
|
56
|
+
def incrementGap1ndexCeiling(state: MapFoldingState) -> MapFoldingState:
|
|
57
|
+
state.gap1ndexCeiling += 1
|
|
58
|
+
return state
|
|
59
|
+
|
|
60
|
+
def incrementIndexMiniGap(state: MapFoldingState) -> MapFoldingState:
|
|
61
|
+
state.indexMiniGap += 1
|
|
62
|
+
return state
|
|
63
|
+
|
|
64
|
+
def initializeIndexMiniGap(state: MapFoldingState) -> MapFoldingState:
|
|
65
|
+
state.indexMiniGap = state.gap1ndex
|
|
66
|
+
return state
|
|
67
|
+
|
|
68
|
+
def initializeVariablesToFindGaps(state: MapFoldingState) -> MapFoldingState:
|
|
69
|
+
state.dimensionsUnconstrained = state.dimensionsTotal
|
|
70
|
+
state.gap1ndexCeiling = state.gapRangeStart[state.leaf1ndex - 1]
|
|
71
|
+
state.indexDimension = 0
|
|
72
|
+
return state
|
|
73
|
+
|
|
74
|
+
def insertActiveLeaf(state: MapFoldingState) -> MapFoldingState:
|
|
75
|
+
state.indexLeaf = 0
|
|
76
|
+
while state.indexLeaf < state.leaf1ndex:
|
|
77
|
+
state.gapsWhere[state.gap1ndexCeiling] = state.indexLeaf
|
|
78
|
+
state.gap1ndexCeiling += 1
|
|
79
|
+
state.indexLeaf += 1
|
|
80
|
+
return state
|
|
81
|
+
|
|
82
|
+
def insertActiveLeafAtGap(state: MapFoldingState) -> MapFoldingState:
|
|
83
|
+
state.gap1ndex -= 1
|
|
84
|
+
state.leafAbove[state.leaf1ndex] = state.gapsWhere[state.gap1ndex]
|
|
85
|
+
state.leafBelow[state.leaf1ndex] = state.leafBelow[state.leafAbove[state.leaf1ndex]]
|
|
86
|
+
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leaf1ndex
|
|
87
|
+
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leaf1ndex
|
|
88
|
+
state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
|
|
89
|
+
state.leaf1ndex += 1
|
|
90
|
+
return state
|
|
91
|
+
|
|
92
|
+
def leafBelowSentinelIs1(state: MapFoldingState) -> bool:
|
|
93
|
+
return state.leafBelow[0] == 1
|
|
94
|
+
|
|
95
|
+
def leafConnecteeIsActiveLeaf(state: MapFoldingState) -> bool:
|
|
96
|
+
return state.leafConnectee == state.leaf1ndex
|
|
97
|
+
|
|
98
|
+
def lookForGaps(state: MapFoldingState) -> MapFoldingState:
|
|
99
|
+
state.gapsWhere[state.gap1ndexCeiling] = state.leafConnectee
|
|
100
|
+
if state.countDimensionsGapped[state.leafConnectee] == 0:
|
|
101
|
+
state = incrementGap1ndexCeiling(state)
|
|
102
|
+
state.countDimensionsGapped[state.leafConnectee] += 1
|
|
103
|
+
return state
|
|
104
|
+
|
|
105
|
+
def lookupLeafConnecteeInConnectionGraph(state: MapFoldingState) -> MapFoldingState:
|
|
106
|
+
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leaf1ndex]
|
|
107
|
+
return state
|
|
108
|
+
|
|
109
|
+
def loopingLeavesConnectedToActiveLeaf(state: MapFoldingState) -> bool:
|
|
110
|
+
return state.leafConnectee != state.leaf1ndex
|
|
111
|
+
|
|
112
|
+
def loopingThroughTheDimensions(state: MapFoldingState) -> bool:
|
|
113
|
+
return state.indexDimension < state.dimensionsTotal
|
|
114
|
+
|
|
115
|
+
def loopingToActiveGapCeiling(state: MapFoldingState) -> bool:
|
|
116
|
+
return state.indexMiniGap < state.gap1ndexCeiling
|
|
117
|
+
|
|
118
|
+
def noGapsHere(state: MapFoldingState) -> bool:
|
|
119
|
+
return state.leaf1ndex > 0 and state.gap1ndex == state.gapRangeStart[state.leaf1ndex - 1]
|
|
120
|
+
|
|
121
|
+
def tryAnotherLeafConnectee(state: MapFoldingState) -> MapFoldingState:
|
|
122
|
+
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leafBelow[state.leafConnectee]]
|
|
123
|
+
return state
|
|
124
|
+
|
|
125
|
+
def tryNextDimension(state: MapFoldingState) -> MapFoldingState:
|
|
126
|
+
state.indexDimension += 1
|
|
127
|
+
return state
|
|
128
|
+
|
|
129
|
+
def undoLastLeafPlacement(state: MapFoldingState) -> MapFoldingState:
|
|
130
|
+
state.leaf1ndex -= 1
|
|
131
|
+
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leafBelow[state.leaf1ndex]
|
|
132
|
+
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leafAbove[state.leaf1ndex]
|
|
133
|
+
return state
|
|
134
|
+
|
|
135
|
+
def count(state: MapFoldingState) -> MapFoldingState:
|
|
136
|
+
while activeLeafGreaterThan0(state):
|
|
137
|
+
if activeLeafIsTheFirstLeaf(state) or leafBelowSentinelIs1(state):
|
|
138
|
+
if activeLeafGreaterThanLeavesTotal(state):
|
|
139
|
+
state = filterAsymmetricFolds(state)
|
|
140
|
+
else:
|
|
141
|
+
state = initializeVariablesToFindGaps(state)
|
|
142
|
+
while loopingThroughTheDimensions(state):
|
|
143
|
+
state = lookupLeafConnecteeInConnectionGraph(state)
|
|
144
|
+
if leafConnecteeIsActiveLeaf(state):
|
|
145
|
+
state = activeLeafUnconstrainedInThisDimension(state)
|
|
146
|
+
else:
|
|
147
|
+
while loopingLeavesConnectedToActiveLeaf(state):
|
|
148
|
+
state = lookForGaps(state)
|
|
149
|
+
state = tryAnotherLeafConnectee(state)
|
|
150
|
+
state = tryNextDimension(state)
|
|
151
|
+
if activeLeafIsUnconstrainedInAllDimensions(state):
|
|
152
|
+
state = insertActiveLeaf(state)
|
|
153
|
+
state = initializeIndexMiniGap(state)
|
|
154
|
+
while loopingToActiveGapCeiling(state):
|
|
155
|
+
state = filterCommonGaps(state)
|
|
156
|
+
state = incrementIndexMiniGap(state)
|
|
157
|
+
while noGapsHere(state):
|
|
158
|
+
state = undoLastLeafPlacement(state)
|
|
159
|
+
if gapAvailable(state):
|
|
160
|
+
state = insertActiveLeafAtGap(state)
|
|
161
|
+
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
162
|
+
return state
|
|
163
|
+
|
|
164
|
+
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
165
|
+
state = count(state)
|
|
166
|
+
return state
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
from mapFolding.dataBaskets import Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal, MapFoldingState
|
|
2
|
+
from numba import jit
|
|
3
|
+
|
|
4
|
+
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
5
|
+
def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1ndexCeiling: DatatypeElephino, indexDimension: DatatypeLeavesTotal, indexLeaf: DatatypeLeavesTotal, indexMiniGap: DatatypeElephino, leaf1ndex: DatatypeLeavesTotal, leafConnectee: DatatypeLeavesTotal, dimensionsUnconstrained: DatatypeLeavesTotal, countDimensionsGapped: Array1DLeavesTotal, gapRangeStart: Array1DElephino, gapsWhere: Array1DLeavesTotal, leafAbove: Array1DLeavesTotal, leafBelow: Array1DLeavesTotal, leafComparison: Array1DLeavesTotal, connectionGraph: Array3DLeavesTotal, dimensionsTotal: DatatypeLeavesTotal, leavesTotal: DatatypeLeavesTotal) -> tuple[DatatypeFoldsTotal, DatatypeElephino, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal, Array1DLeavesTotal, Array1DElephino, Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal]:
|
|
6
|
+
while leaf1ndex > 0:
|
|
7
|
+
if leaf1ndex <= 1 or leafBelow[0] == 1:
|
|
8
|
+
if leaf1ndex > leavesTotal:
|
|
9
|
+
indexLeaf = 0
|
|
10
|
+
leafConnectee = 0
|
|
11
|
+
while leafConnectee < leavesTotal + 1:
|
|
12
|
+
leafNumber = int(leafBelow[indexLeaf])
|
|
13
|
+
leafComparison[leafConnectee] = (leafNumber - indexLeaf + leavesTotal) % leavesTotal
|
|
14
|
+
indexLeaf = leafNumber
|
|
15
|
+
leafConnectee += 1
|
|
16
|
+
indexInMiddle = leavesTotal // 2
|
|
17
|
+
indexMiniGap = 0
|
|
18
|
+
while indexMiniGap < leavesTotal + 1:
|
|
19
|
+
ImaSymmetricFold = True
|
|
20
|
+
leafConnectee = 0
|
|
21
|
+
while leafConnectee < indexInMiddle:
|
|
22
|
+
if leafComparison[(indexMiniGap + leafConnectee) % (leavesTotal + 1)] != leafComparison[(indexMiniGap + leavesTotal + 1 - 2 - leafConnectee) % (leavesTotal + 1)]:
|
|
23
|
+
ImaSymmetricFold = False
|
|
24
|
+
break
|
|
25
|
+
leafConnectee += 1
|
|
26
|
+
if ImaSymmetricFold:
|
|
27
|
+
groupsOfFolds += 1
|
|
28
|
+
indexMiniGap += 1
|
|
29
|
+
else:
|
|
30
|
+
dimensionsUnconstrained = dimensionsTotal
|
|
31
|
+
gap1ndexCeiling = gapRangeStart[leaf1ndex - 1]
|
|
32
|
+
indexDimension = 0
|
|
33
|
+
while indexDimension < dimensionsTotal:
|
|
34
|
+
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leaf1ndex]
|
|
35
|
+
if leafConnectee == leaf1ndex:
|
|
36
|
+
dimensionsUnconstrained -= 1
|
|
37
|
+
else:
|
|
38
|
+
while leafConnectee != leaf1ndex:
|
|
39
|
+
gapsWhere[gap1ndexCeiling] = leafConnectee
|
|
40
|
+
if countDimensionsGapped[leafConnectee] == 0:
|
|
41
|
+
gap1ndexCeiling += 1
|
|
42
|
+
countDimensionsGapped[leafConnectee] += 1
|
|
43
|
+
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leafBelow[leafConnectee]]
|
|
44
|
+
indexDimension += 1
|
|
45
|
+
if not dimensionsUnconstrained:
|
|
46
|
+
indexLeaf = 0
|
|
47
|
+
while indexLeaf < leaf1ndex:
|
|
48
|
+
gapsWhere[gap1ndexCeiling] = indexLeaf
|
|
49
|
+
gap1ndexCeiling += 1
|
|
50
|
+
indexLeaf += 1
|
|
51
|
+
indexMiniGap = gap1ndex
|
|
52
|
+
while indexMiniGap < gap1ndexCeiling:
|
|
53
|
+
gapsWhere[gap1ndex] = gapsWhere[indexMiniGap]
|
|
54
|
+
if countDimensionsGapped[gapsWhere[indexMiniGap]] == dimensionsUnconstrained:
|
|
55
|
+
gap1ndex += 1
|
|
56
|
+
countDimensionsGapped[gapsWhere[indexMiniGap]] = 0
|
|
57
|
+
indexMiniGap += 1
|
|
58
|
+
while leaf1ndex > 0 and gap1ndex == gapRangeStart[leaf1ndex - 1]:
|
|
59
|
+
leaf1ndex -= 1
|
|
60
|
+
leafBelow[leafAbove[leaf1ndex]] = leafBelow[leaf1ndex]
|
|
61
|
+
leafAbove[leafBelow[leaf1ndex]] = leafAbove[leaf1ndex]
|
|
62
|
+
if leaf1ndex > 0:
|
|
63
|
+
gap1ndex -= 1
|
|
64
|
+
leafAbove[leaf1ndex] = gapsWhere[gap1ndex]
|
|
65
|
+
leafBelow[leaf1ndex] = leafBelow[leafAbove[leaf1ndex]]
|
|
66
|
+
leafBelow[leafAbove[leaf1ndex]] = leaf1ndex
|
|
67
|
+
leafAbove[leafBelow[leaf1ndex]] = leaf1ndex
|
|
68
|
+
gapRangeStart[leaf1ndex] = gap1ndex
|
|
69
|
+
leaf1ndex += 1
|
|
70
|
+
groupsOfFolds = (groupsOfFolds + 1) // 2
|
|
71
|
+
return (groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal)
|
|
72
|
+
|
|
73
|
+
def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
74
|
+
mapShape: tuple[DatatypeLeavesTotal, ...] = state.mapShape
|
|
75
|
+
groupsOfFolds: DatatypeFoldsTotal = state.groupsOfFolds
|
|
76
|
+
gap1ndex: DatatypeElephino = state.gap1ndex
|
|
77
|
+
gap1ndexCeiling: DatatypeElephino = state.gap1ndexCeiling
|
|
78
|
+
indexDimension: DatatypeLeavesTotal = state.indexDimension
|
|
79
|
+
indexLeaf: DatatypeLeavesTotal = state.indexLeaf
|
|
80
|
+
indexMiniGap: DatatypeElephino = state.indexMiniGap
|
|
81
|
+
leaf1ndex: DatatypeLeavesTotal = state.leaf1ndex
|
|
82
|
+
leafConnectee: DatatypeLeavesTotal = state.leafConnectee
|
|
83
|
+
dimensionsUnconstrained: DatatypeLeavesTotal = state.dimensionsUnconstrained
|
|
84
|
+
countDimensionsGapped: Array1DLeavesTotal = state.countDimensionsGapped
|
|
85
|
+
gapRangeStart: Array1DElephino = state.gapRangeStart
|
|
86
|
+
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
87
|
+
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
88
|
+
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
89
|
+
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
90
|
+
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
91
|
+
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
92
|
+
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
93
|
+
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal = count(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal)
|
|
94
|
+
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, leafComparison=leafComparison)
|
|
95
|
+
return state
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
from concurrent.futures import Future as ConcurrentFuture, ProcessPoolExecutor
|
|
2
2
|
from copy import deepcopy
|
|
3
|
-
from mapFolding.dataBaskets import
|
|
4
|
-
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
5
|
-
ParallelMapFoldingState)
|
|
3
|
+
from mapFolding.dataBaskets import Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal, ParallelMapFoldingState
|
|
6
4
|
from multiprocessing import set_start_method as multiprocessing_set_start_method
|
|
7
5
|
from numba import jit
|
|
8
|
-
|
|
9
6
|
if __name__ == '__main__':
|
|
10
7
|
multiprocessing_set_start_method('spawn')
|
|
11
8
|
|
|
@@ -75,13 +72,14 @@ def unRepackParallelMapFoldingState(state: ParallelMapFoldingState) -> ParallelM
|
|
|
75
72
|
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
76
73
|
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
77
74
|
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
75
|
+
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
78
76
|
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
79
77
|
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
80
78
|
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
81
79
|
taskDivisions: DatatypeLeavesTotal = state.taskDivisions
|
|
82
80
|
taskIndex: DatatypeLeavesTotal = state.taskIndex
|
|
83
81
|
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal, taskDivisions, taskIndex = count(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal, taskDivisions, taskIndex)
|
|
84
|
-
state = ParallelMapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, taskDivisions=taskDivisions, taskIndex=taskIndex)
|
|
82
|
+
state = ParallelMapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, leafComparison=leafComparison, taskDivisions=taskDivisions, taskIndex=taskIndex)
|
|
85
83
|
return state
|
|
86
84
|
|
|
87
85
|
def doTheNeedful(state: ParallelMapFoldingState, concurrencyLimit: int) -> tuple[int, list[ParallelMapFoldingState]]:
|
|
@@ -98,4 +96,4 @@ def doTheNeedful(state: ParallelMapFoldingState, concurrencyLimit: int) -> tuple
|
|
|
98
96
|
listStatesParallel[indexSherpa] = dictionaryConcurrency[indexSherpa].result()
|
|
99
97
|
groupsOfFoldsTotal += listStatesParallel[indexSherpa].groupsOfFolds
|
|
100
98
|
foldsTotal: int = groupsOfFoldsTotal * stateParallel.leavesTotal
|
|
101
|
-
return (foldsTotal, listStatesParallel)
|
|
99
|
+
return (foldsTotal, listStatesParallel)
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import
|
|
2
|
-
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
3
|
-
MapFoldingState)
|
|
1
|
+
from mapFolding.dataBaskets import Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal, MapFoldingState
|
|
4
2
|
from numba import jit
|
|
5
3
|
|
|
6
4
|
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
@@ -68,9 +66,10 @@ def doTheNeedful(state: MapFoldingState) -> MapFoldingState:
|
|
|
68
66
|
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
69
67
|
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
70
68
|
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
69
|
+
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
71
70
|
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
72
71
|
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
73
72
|
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
74
73
|
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal = count(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|
|
75
|
-
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow)
|
|
76
|
-
return state
|
|
74
|
+
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, leafComparison=leafComparison)
|
|
75
|
+
return state
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
from mapFolding.dataBaskets import
|
|
2
|
-
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal,
|
|
3
|
-
MapFoldingState)
|
|
1
|
+
from mapFolding.dataBaskets import Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal, MapFoldingState
|
|
4
2
|
from mapFolding.syntheticModules.theorem2Numba import count
|
|
5
3
|
|
|
6
4
|
def sequential(state: MapFoldingState) -> MapFoldingState:
|
|
@@ -19,9 +17,10 @@ def sequential(state: MapFoldingState) -> MapFoldingState:
|
|
|
19
17
|
gapsWhere: Array1DLeavesTotal = state.gapsWhere
|
|
20
18
|
leafAbove: Array1DLeavesTotal = state.leafAbove
|
|
21
19
|
leafBelow: Array1DLeavesTotal = state.leafBelow
|
|
20
|
+
leafComparison: Array1DLeavesTotal = state.leafComparison
|
|
22
21
|
connectionGraph: Array3DLeavesTotal = state.connectionGraph
|
|
23
22
|
dimensionsTotal: DatatypeLeavesTotal = state.dimensionsTotal
|
|
24
23
|
leavesTotal: DatatypeLeavesTotal = state.leavesTotal
|
|
25
24
|
groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal = count(groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|
|
26
|
-
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow)
|
|
27
|
-
return state
|
|
25
|
+
state = MapFoldingState(mapShape=mapShape, groupsOfFolds=groupsOfFolds, gap1ndex=gap1ndex, gap1ndexCeiling=gap1ndexCeiling, indexDimension=indexDimension, indexLeaf=indexLeaf, indexMiniGap=indexMiniGap, leaf1ndex=leaf1ndex, leafConnectee=leafConnectee, dimensionsUnconstrained=dimensionsUnconstrained, countDimensionsGapped=countDimensionsGapped, gapRangeStart=gapRangeStart, gapsWhere=gapsWhere, leafAbove=leafAbove, leafBelow=leafBelow, leafComparison=leafComparison)
|
|
26
|
+
return state
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from mapFolding.dataBaskets import MapFoldingState
|
|
2
2
|
|
|
3
|
-
def
|
|
3
|
+
def transitionOnGroupsOfFolds(state: MapFoldingState) -> MapFoldingState:
|
|
4
4
|
while state.groupsOfFolds == 0:
|
|
5
5
|
if state.leaf1ndex <= 1 or state.leafBelow[0] == 1:
|
|
6
6
|
if state.leaf1ndex > state.leavesTotal:
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
+
|
|
3
|
+
def transitionOnGroupsOfFolds(state: MapFoldingState) -> MapFoldingState:
|
|
4
|
+
while state.groupsOfFolds == 0:
|
|
5
|
+
if state.leaf1ndex <= 1 or state.leafBelow[0] == 1:
|
|
6
|
+
if state.leaf1ndex > state.leavesTotal:
|
|
7
|
+
state.indexLeaf = 0
|
|
8
|
+
leafConnectee = 0
|
|
9
|
+
while leafConnectee < state.leavesTotal + 1:
|
|
10
|
+
leafNumber = int(state.leafBelow[state.indexLeaf])
|
|
11
|
+
state.leafComparison[leafConnectee] = (leafNumber - state.indexLeaf + state.leavesTotal) % state.leavesTotal
|
|
12
|
+
state.indexLeaf = leafNumber
|
|
13
|
+
leafConnectee += 1
|
|
14
|
+
indexInMiddle = state.leavesTotal // 2
|
|
15
|
+
state.indexMiniGap = 0
|
|
16
|
+
while state.indexMiniGap < state.leavesTotal + 1:
|
|
17
|
+
ImaSymmetricFold = True
|
|
18
|
+
leafConnectee = 0
|
|
19
|
+
while leafConnectee < indexInMiddle:
|
|
20
|
+
if state.leafComparison[(state.indexMiniGap + leafConnectee) % (state.leavesTotal + 1)] != state.leafComparison[(state.indexMiniGap + state.leavesTotal + 1 - 2 - leafConnectee) % (state.leavesTotal + 1)]:
|
|
21
|
+
ImaSymmetricFold = False
|
|
22
|
+
break
|
|
23
|
+
leafConnectee += 1
|
|
24
|
+
if ImaSymmetricFold:
|
|
25
|
+
state.groupsOfFolds += 1
|
|
26
|
+
state.indexMiniGap += 1
|
|
27
|
+
else:
|
|
28
|
+
state.dimensionsUnconstrained = state.dimensionsTotal
|
|
29
|
+
state.gap1ndexCeiling = state.gapRangeStart[state.leaf1ndex - 1]
|
|
30
|
+
state.indexDimension = 0
|
|
31
|
+
while state.indexDimension < state.dimensionsTotal:
|
|
32
|
+
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leaf1ndex]
|
|
33
|
+
if state.leafConnectee == state.leaf1ndex:
|
|
34
|
+
state.dimensionsUnconstrained -= 1
|
|
35
|
+
else:
|
|
36
|
+
while state.leafConnectee != state.leaf1ndex:
|
|
37
|
+
state.gapsWhere[state.gap1ndexCeiling] = state.leafConnectee
|
|
38
|
+
if state.countDimensionsGapped[state.leafConnectee] == 0:
|
|
39
|
+
state.gap1ndexCeiling += 1
|
|
40
|
+
state.countDimensionsGapped[state.leafConnectee] += 1
|
|
41
|
+
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leafBelow[state.leafConnectee]]
|
|
42
|
+
state.indexDimension += 1
|
|
43
|
+
if not state.dimensionsUnconstrained:
|
|
44
|
+
state.indexLeaf = 0
|
|
45
|
+
while state.indexLeaf < state.leaf1ndex:
|
|
46
|
+
state.gapsWhere[state.gap1ndexCeiling] = state.indexLeaf
|
|
47
|
+
state.gap1ndexCeiling += 1
|
|
48
|
+
state.indexLeaf += 1
|
|
49
|
+
state.indexMiniGap = state.gap1ndex
|
|
50
|
+
while state.indexMiniGap < state.gap1ndexCeiling:
|
|
51
|
+
state.gapsWhere[state.gap1ndex] = state.gapsWhere[state.indexMiniGap]
|
|
52
|
+
if state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] == state.dimensionsUnconstrained:
|
|
53
|
+
state.gap1ndex += 1
|
|
54
|
+
state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] = 0
|
|
55
|
+
state.indexMiniGap += 1
|
|
56
|
+
while state.leaf1ndex > 0 and state.gap1ndex == state.gapRangeStart[state.leaf1ndex - 1]:
|
|
57
|
+
state.leaf1ndex -= 1
|
|
58
|
+
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leafBelow[state.leaf1ndex]
|
|
59
|
+
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leafAbove[state.leaf1ndex]
|
|
60
|
+
if state.leaf1ndex > 0:
|
|
61
|
+
state.gap1ndex -= 1
|
|
62
|
+
state.leafAbove[state.leaf1ndex] = state.gapsWhere[state.gap1ndex]
|
|
63
|
+
state.leafBelow[state.leaf1ndex] = state.leafBelow[state.leafAbove[state.leaf1ndex]]
|
|
64
|
+
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leaf1ndex
|
|
65
|
+
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leaf1ndex
|
|
66
|
+
state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
|
|
67
|
+
state.leaf1ndex += 1
|
|
68
|
+
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
69
|
+
return state
|
|
@@ -45,5 +45,6 @@ def count(state: MapFoldingState) -> MapFoldingState:
|
|
|
45
45
|
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leaf1ndex
|
|
46
46
|
state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
|
|
47
47
|
state.leaf1ndex += 1
|
|
48
|
-
|
|
48
|
+
else:
|
|
49
|
+
state.groupsOfFolds *= 2
|
|
49
50
|
return state
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
+
|
|
3
|
+
def count(state: MapFoldingState) -> MapFoldingState:
|
|
4
|
+
while state.leaf1ndex > 4:
|
|
5
|
+
if state.leafBelow[0] == 1:
|
|
6
|
+
if state.leaf1ndex > state.leavesTotal:
|
|
7
|
+
state.indexLeaf = 0
|
|
8
|
+
leafConnectee = 0
|
|
9
|
+
while leafConnectee < state.leavesTotal + 1:
|
|
10
|
+
leafNumber = int(state.leafBelow[state.indexLeaf])
|
|
11
|
+
state.leafComparison[leafConnectee] = (leafNumber - state.indexLeaf + state.leavesTotal) % state.leavesTotal
|
|
12
|
+
state.indexLeaf = leafNumber
|
|
13
|
+
leafConnectee += 1
|
|
14
|
+
indexInMiddle = state.leavesTotal // 2
|
|
15
|
+
state.indexMiniGap = 0
|
|
16
|
+
while state.indexMiniGap < state.leavesTotal + 1:
|
|
17
|
+
ImaSymmetricFold = True
|
|
18
|
+
leafConnectee = 0
|
|
19
|
+
while leafConnectee < indexInMiddle:
|
|
20
|
+
if state.leafComparison[(state.indexMiniGap + leafConnectee) % (state.leavesTotal + 1)] != state.leafComparison[(state.indexMiniGap + state.leavesTotal + 1 - 2 - leafConnectee) % (state.leavesTotal + 1)]:
|
|
21
|
+
ImaSymmetricFold = False
|
|
22
|
+
break
|
|
23
|
+
leafConnectee += 1
|
|
24
|
+
if ImaSymmetricFold:
|
|
25
|
+
state.groupsOfFolds += 1
|
|
26
|
+
state.indexMiniGap += 1
|
|
27
|
+
else:
|
|
28
|
+
state.dimensionsUnconstrained = state.dimensionsTotal
|
|
29
|
+
state.gap1ndexCeiling = state.gapRangeStart[state.leaf1ndex - 1]
|
|
30
|
+
state.indexDimension = 0
|
|
31
|
+
while state.indexDimension < state.dimensionsTotal:
|
|
32
|
+
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leaf1ndex]
|
|
33
|
+
if state.leafConnectee == state.leaf1ndex:
|
|
34
|
+
state.dimensionsUnconstrained -= 1
|
|
35
|
+
else:
|
|
36
|
+
while state.leafConnectee != state.leaf1ndex:
|
|
37
|
+
state.gapsWhere[state.gap1ndexCeiling] = state.leafConnectee
|
|
38
|
+
if state.countDimensionsGapped[state.leafConnectee] == 0:
|
|
39
|
+
state.gap1ndexCeiling += 1
|
|
40
|
+
state.countDimensionsGapped[state.leafConnectee] += 1
|
|
41
|
+
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leafBelow[state.leafConnectee]]
|
|
42
|
+
state.indexDimension += 1
|
|
43
|
+
if not state.dimensionsUnconstrained:
|
|
44
|
+
state.indexLeaf = 0
|
|
45
|
+
while state.indexLeaf < state.leaf1ndex:
|
|
46
|
+
state.gapsWhere[state.gap1ndexCeiling] = state.indexLeaf
|
|
47
|
+
state.gap1ndexCeiling += 1
|
|
48
|
+
state.indexLeaf += 1
|
|
49
|
+
state.indexMiniGap = state.gap1ndex
|
|
50
|
+
while state.indexMiniGap < state.gap1ndexCeiling:
|
|
51
|
+
state.gapsWhere[state.gap1ndex] = state.gapsWhere[state.indexMiniGap]
|
|
52
|
+
if state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] == state.dimensionsUnconstrained:
|
|
53
|
+
state.gap1ndex += 1
|
|
54
|
+
state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] = 0
|
|
55
|
+
state.indexMiniGap += 1
|
|
56
|
+
while state.gap1ndex == state.gapRangeStart[state.leaf1ndex - 1]:
|
|
57
|
+
state.leaf1ndex -= 1
|
|
58
|
+
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leafBelow[state.leaf1ndex]
|
|
59
|
+
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leafAbove[state.leaf1ndex]
|
|
60
|
+
state.gap1ndex -= 1
|
|
61
|
+
state.leafAbove[state.leaf1ndex] = state.gapsWhere[state.gap1ndex]
|
|
62
|
+
state.leafBelow[state.leaf1ndex] = state.leafBelow[state.leafAbove[state.leaf1ndex]]
|
|
63
|
+
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leaf1ndex
|
|
64
|
+
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leaf1ndex
|
|
65
|
+
state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
|
|
66
|
+
state.leaf1ndex += 1
|
|
67
|
+
else:
|
|
68
|
+
state.groupsOfFolds *= 2
|
|
69
|
+
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
70
|
+
return state
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
from mapFolding.dataBaskets import (
|
|
2
|
+
Array1DElephino, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeElephino, DatatypeFoldsTotal, DatatypeLeavesTotal)
|
|
3
|
+
from numba import jit
|
|
4
|
+
|
|
5
|
+
@jit(cache=True, error_model='numpy', fastmath=True, forceinline=True)
|
|
6
|
+
def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1ndexCeiling: DatatypeElephino, indexDimension: DatatypeLeavesTotal, indexLeaf: DatatypeLeavesTotal, indexMiniGap: DatatypeElephino, leaf1ndex: DatatypeLeavesTotal, leafConnectee: DatatypeLeavesTotal, dimensionsUnconstrained: DatatypeLeavesTotal, countDimensionsGapped: Array1DLeavesTotal, gapRangeStart: Array1DElephino, gapsWhere: Array1DLeavesTotal, leafAbove: Array1DLeavesTotal, leafBelow: Array1DLeavesTotal, leafComparison: Array1DLeavesTotal, connectionGraph: Array3DLeavesTotal, dimensionsTotal: DatatypeLeavesTotal, leavesTotal: DatatypeLeavesTotal) -> tuple[DatatypeFoldsTotal, DatatypeElephino, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeElephino, DatatypeLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal, Array1DLeavesTotal, Array1DElephino, Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array1DLeavesTotal, Array3DLeavesTotal, DatatypeLeavesTotal, DatatypeLeavesTotal]:
|
|
7
|
+
while leaf1ndex > 4:
|
|
8
|
+
if leafBelow[0] == 1:
|
|
9
|
+
if leaf1ndex > leavesTotal:
|
|
10
|
+
indexLeaf = 0
|
|
11
|
+
leafConnectee = 0
|
|
12
|
+
while leafConnectee < leavesTotal + 1:
|
|
13
|
+
leafNumber = int(leafBelow[indexLeaf])
|
|
14
|
+
leafComparison[leafConnectee] = (leafNumber - indexLeaf + leavesTotal) % leavesTotal
|
|
15
|
+
indexLeaf = leafNumber
|
|
16
|
+
leafConnectee += 1
|
|
17
|
+
indexInMiddle = leavesTotal // 2
|
|
18
|
+
indexMiniGap = 0
|
|
19
|
+
while indexMiniGap < leavesTotal + 1:
|
|
20
|
+
ImaSymmetricFold = True
|
|
21
|
+
leafConnectee = 0
|
|
22
|
+
while leafConnectee < indexInMiddle:
|
|
23
|
+
if leafComparison[(indexMiniGap + leafConnectee) % (leavesTotal + 1)] != leafComparison[(indexMiniGap + leavesTotal + 1 - 2 - leafConnectee) % (leavesTotal + 1)]:
|
|
24
|
+
ImaSymmetricFold = False
|
|
25
|
+
break
|
|
26
|
+
leafConnectee += 1
|
|
27
|
+
if ImaSymmetricFold:
|
|
28
|
+
groupsOfFolds += 1
|
|
29
|
+
indexMiniGap += 1
|
|
30
|
+
else:
|
|
31
|
+
dimensionsUnconstrained = dimensionsTotal
|
|
32
|
+
gap1ndexCeiling = gapRangeStart[leaf1ndex - 1]
|
|
33
|
+
indexDimension = 0
|
|
34
|
+
while indexDimension < dimensionsTotal:
|
|
35
|
+
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leaf1ndex]
|
|
36
|
+
if leafConnectee == leaf1ndex:
|
|
37
|
+
dimensionsUnconstrained -= 1
|
|
38
|
+
else:
|
|
39
|
+
while leafConnectee != leaf1ndex:
|
|
40
|
+
gapsWhere[gap1ndexCeiling] = leafConnectee
|
|
41
|
+
if countDimensionsGapped[leafConnectee] == 0:
|
|
42
|
+
gap1ndexCeiling += 1
|
|
43
|
+
countDimensionsGapped[leafConnectee] += 1
|
|
44
|
+
leafConnectee = connectionGraph[indexDimension, leaf1ndex, leafBelow[leafConnectee]]
|
|
45
|
+
indexDimension += 1
|
|
46
|
+
indexMiniGap = gap1ndex
|
|
47
|
+
while indexMiniGap < gap1ndexCeiling:
|
|
48
|
+
gapsWhere[gap1ndex] = gapsWhere[indexMiniGap]
|
|
49
|
+
if countDimensionsGapped[gapsWhere[indexMiniGap]] == dimensionsUnconstrained:
|
|
50
|
+
gap1ndex += 1
|
|
51
|
+
countDimensionsGapped[gapsWhere[indexMiniGap]] = 0
|
|
52
|
+
indexMiniGap += 1
|
|
53
|
+
while gap1ndex == gapRangeStart[leaf1ndex - 1]:
|
|
54
|
+
leaf1ndex -= 1
|
|
55
|
+
leafBelow[leafAbove[leaf1ndex]] = leafBelow[leaf1ndex]
|
|
56
|
+
leafAbove[leafBelow[leaf1ndex]] = leafAbove[leaf1ndex]
|
|
57
|
+
gap1ndex -= 1
|
|
58
|
+
leafAbove[leaf1ndex] = gapsWhere[gap1ndex]
|
|
59
|
+
leafBelow[leaf1ndex] = leafBelow[leafAbove[leaf1ndex]]
|
|
60
|
+
leafBelow[leafAbove[leaf1ndex]] = leaf1ndex
|
|
61
|
+
leafAbove[leafBelow[leaf1ndex]] = leaf1ndex
|
|
62
|
+
gapRangeStart[leaf1ndex] = gap1ndex
|
|
63
|
+
leaf1ndex += 1
|
|
64
|
+
else:
|
|
65
|
+
groupsOfFolds *= 2
|
|
66
|
+
groupsOfFolds = (groupsOfFolds + 1) // 2
|
|
67
|
+
return (groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexLeaf, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, leafComparison, connectionGraph, dimensionsTotal, leavesTotal)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from mapFolding.dataBaskets import MapFoldingState
|
|
2
|
+
|
|
3
|
+
def count(state: MapFoldingState) -> MapFoldingState:
|
|
4
|
+
while state.leaf1ndex > 4:
|
|
5
|
+
if state.leafBelow[0] == 1:
|
|
6
|
+
if state.leaf1ndex > state.leavesTotal:
|
|
7
|
+
state.indexLeaf = 0
|
|
8
|
+
leafConnectee = 0
|
|
9
|
+
while leafConnectee < state.leavesTotal + 1:
|
|
10
|
+
leafNumber = int(state.leafBelow[state.indexLeaf])
|
|
11
|
+
state.leafComparison[leafConnectee] = (leafNumber - state.indexLeaf + state.leavesTotal) % state.leavesTotal
|
|
12
|
+
state.indexLeaf = leafNumber
|
|
13
|
+
leafConnectee += 1
|
|
14
|
+
indexInMiddle = state.leavesTotal // 2
|
|
15
|
+
state.indexMiniGap = 0
|
|
16
|
+
while state.indexMiniGap < state.leavesTotal + 1:
|
|
17
|
+
ImaSymmetricFold = True
|
|
18
|
+
leafConnectee = 0
|
|
19
|
+
while leafConnectee < indexInMiddle:
|
|
20
|
+
if state.leafComparison[(state.indexMiniGap + leafConnectee) % (state.leavesTotal + 1)] != state.leafComparison[(state.indexMiniGap + state.leavesTotal + 1 - 2 - leafConnectee) % (state.leavesTotal + 1)]:
|
|
21
|
+
ImaSymmetricFold = False
|
|
22
|
+
break
|
|
23
|
+
leafConnectee += 1
|
|
24
|
+
if ImaSymmetricFold:
|
|
25
|
+
state.groupsOfFolds += 1
|
|
26
|
+
state.indexMiniGap += 1
|
|
27
|
+
else:
|
|
28
|
+
state.dimensionsUnconstrained = state.dimensionsTotal
|
|
29
|
+
state.gap1ndexCeiling = state.gapRangeStart[state.leaf1ndex - 1]
|
|
30
|
+
state.indexDimension = 0
|
|
31
|
+
while state.indexDimension < state.dimensionsTotal:
|
|
32
|
+
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leaf1ndex]
|
|
33
|
+
if state.leafConnectee == state.leaf1ndex:
|
|
34
|
+
state.dimensionsUnconstrained -= 1
|
|
35
|
+
else:
|
|
36
|
+
while state.leafConnectee != state.leaf1ndex:
|
|
37
|
+
state.gapsWhere[state.gap1ndexCeiling] = state.leafConnectee
|
|
38
|
+
if state.countDimensionsGapped[state.leafConnectee] == 0:
|
|
39
|
+
state.gap1ndexCeiling += 1
|
|
40
|
+
state.countDimensionsGapped[state.leafConnectee] += 1
|
|
41
|
+
state.leafConnectee = state.connectionGraph[state.indexDimension, state.leaf1ndex, state.leafBelow[state.leafConnectee]]
|
|
42
|
+
state.indexDimension += 1
|
|
43
|
+
state.indexMiniGap = state.gap1ndex
|
|
44
|
+
while state.indexMiniGap < state.gap1ndexCeiling:
|
|
45
|
+
state.gapsWhere[state.gap1ndex] = state.gapsWhere[state.indexMiniGap]
|
|
46
|
+
if state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] == state.dimensionsUnconstrained:
|
|
47
|
+
state.gap1ndex += 1
|
|
48
|
+
state.countDimensionsGapped[state.gapsWhere[state.indexMiniGap]] = 0
|
|
49
|
+
state.indexMiniGap += 1
|
|
50
|
+
while state.gap1ndex == state.gapRangeStart[state.leaf1ndex - 1]:
|
|
51
|
+
state.leaf1ndex -= 1
|
|
52
|
+
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leafBelow[state.leaf1ndex]
|
|
53
|
+
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leafAbove[state.leaf1ndex]
|
|
54
|
+
state.gap1ndex -= 1
|
|
55
|
+
state.leafAbove[state.leaf1ndex] = state.gapsWhere[state.gap1ndex]
|
|
56
|
+
state.leafBelow[state.leaf1ndex] = state.leafBelow[state.leafAbove[state.leaf1ndex]]
|
|
57
|
+
state.leafBelow[state.leafAbove[state.leaf1ndex]] = state.leaf1ndex
|
|
58
|
+
state.leafAbove[state.leafBelow[state.leaf1ndex]] = state.leaf1ndex
|
|
59
|
+
state.gapRangeStart[state.leaf1ndex] = state.gap1ndex
|
|
60
|
+
state.leaf1ndex += 1
|
|
61
|
+
else:
|
|
62
|
+
state.groupsOfFolds *= 2
|
|
63
|
+
state.groupsOfFolds = (state.groupsOfFolds + 1) // 2
|
|
64
|
+
return state
|
|
@@ -42,5 +42,6 @@ def count(groupsOfFolds: DatatypeFoldsTotal, gap1ndex: DatatypeElephino, gap1nde
|
|
|
42
42
|
leafAbove[leafBelow[leaf1ndex]] = leaf1ndex
|
|
43
43
|
gapRangeStart[leaf1ndex] = gap1ndex
|
|
44
44
|
leaf1ndex += 1
|
|
45
|
-
|
|
45
|
+
else:
|
|
46
|
+
groupsOfFolds *= 2
|
|
46
47
|
return (groupsOfFolds, gap1ndex, gap1ndexCeiling, indexDimension, indexMiniGap, leaf1ndex, leafConnectee, dimensionsUnconstrained, countDimensionsGapped, gapRangeStart, gapsWhere, leafAbove, leafBelow, connectionGraph, dimensionsTotal, leavesTotal)
|