mapFolding 0.16.2__py3-none-any.whl → 0.17.0__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.
- easyRun/A000682.py +2 -2
- easyRun/NOTcountingFolds.py +16 -8
- easyRun/countFolds.py +9 -2
- easyRun/generateAllModules.py +14 -0
- easyRun/meanders.py +4 -4
- mapFolding/__init__.py +1 -0
- mapFolding/_theSSOT.py +3 -2
- mapFolding/_theTypes.py +3 -0
- mapFolding/algorithms/A000136constraintPropagation.py +95 -0
- mapFolding/algorithms/A000136elimination.py +163 -0
- mapFolding/algorithms/A000136eliminationParallel.py +77 -0
- mapFolding/algorithms/A086345.py +75 -0
- mapFolding/algorithms/matrixMeanders.py +59 -18
- mapFolding/algorithms/matrixMeandersNumPyndas.py +841 -0
- mapFolding/algorithms/oeisIDbyFormula.py +2 -2
- mapFolding/algorithms/symmetricFolds.py +35 -0
- mapFolding/basecamp.py +100 -153
- mapFolding/dataBaskets.py +142 -65
- mapFolding/filesystemToolkit.py +4 -32
- mapFolding/oeis.py +5 -12
- mapFolding/reference/A086345Wu.py +25 -0
- mapFolding/reference/irvineJavaPort.py +3 -3
- mapFolding/reference/matrixMeandersAnalysis/signatures.py +3 -0
- mapFolding/reference/meandersDumpingGround/matrixMeandersNumPyV1finalForm.py +1 -1
- mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +10 -45
- mapFolding/someAssemblyRequired/A007822/_asynchronousAnnex.py +51 -0
- mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +39 -196
- mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +57 -43
- mapFolding/someAssemblyRequired/RecipeJob.py +84 -34
- mapFolding/someAssemblyRequired/__init__.py +4 -8
- mapFolding/someAssemblyRequired/_toolkitContainers.py +38 -7
- mapFolding/someAssemblyRequired/infoBooth.py +41 -23
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +140 -164
- mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +63 -96
- mapFolding/someAssemblyRequired/makingModules_count.py +26 -30
- mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +10 -72
- mapFolding/someAssemblyRequired/{mapFolding → mapFoldingModules}/makeMapFoldingModules.py +30 -35
- mapFolding/someAssemblyRequired/meanders/makeMeandersModules.py +13 -11
- mapFolding/someAssemblyRequired/toolkitMakeModules.py +5 -31
- mapFolding/someAssemblyRequired/toolkitNumba.py +3 -2
- mapFolding/someAssemblyRequired/transformationTools.py +12 -15
- mapFolding/syntheticModules/A007822/algorithm.py +45 -50
- mapFolding/syntheticModules/A007822/asynchronous.py +92 -36
- mapFolding/syntheticModules/A007822/initializeState.py +19 -23
- mapFolding/syntheticModules/A007822/theorem2.py +20 -24
- mapFolding/syntheticModules/A007822/theorem2Numba.py +23 -25
- mapFolding/syntheticModules/A007822/theorem2Trimmed.py +19 -23
- mapFolding/syntheticModules/countParallelNumba.py +1 -2
- mapFolding/syntheticModules/daoOfMapFoldingNumba.py +5 -4
- mapFolding/syntheticModules/initializeState.py +1 -1
- mapFolding/syntheticModules/meanders/bigInt.py +59 -22
- mapFolding/syntheticModules/theorem2.py +1 -1
- mapFolding/syntheticModules/theorem2Numba.py +30 -9
- mapFolding/syntheticModules/theorem2Trimmed.py +2 -2
- mapFolding/tests/test_computations.py +29 -3
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/METADATA +11 -8
- mapfolding-0.17.0.dist-info/RECORD +107 -0
- mapFolding/_dataPacking.py +0 -68
- mapFolding/algorithms/matrixMeandersBeDry.py +0 -182
- mapFolding/algorithms/matrixMeandersNumPy.py +0 -333
- mapFolding/algorithms/matrixMeandersPandas.py +0 -334
- mapFolding/reference/meandersDumpingGround/A005316intOptimized.py +0 -122
- mapFolding/reference/meandersDumpingGround/A005316optimized128bit.py +0 -79
- mapFolding/reference/meandersDumpingGround/matrixMeandersBaseline.py +0 -65
- mapFolding/reference/meandersDumpingGround/matrixMeandersBaselineAnnex.py +0 -84
- mapFolding/reference/meandersDumpingGround/matrixMeandersSimpleQueue.py +0 -90
- mapFolding/syntheticModules/A007822/algorithmNumba.py +0 -94
- mapFolding/syntheticModules/A007822/asynchronousAnnex.py +0 -66
- mapFolding/syntheticModules/A007822/asynchronousAnnexNumba.py +0 -70
- mapFolding/syntheticModules/A007822/asynchronousNumba.py +0 -79
- mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +0 -65
- mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +0 -56
- mapFolding/syntheticModules/dataPacking.py +0 -26
- mapFolding/syntheticModules/dataPackingA007822.py +0 -92
- mapfolding-0.16.2.dist-info/RECORD +0 -115
- /mapFolding/someAssemblyRequired/{mapFolding → mapFoldingModules}/__init__.py +0 -0
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/WHEEL +0 -0
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/top_level.txt +0 -0
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
from gc import collect as goByeBye
|
|
2
|
-
from mapFolding.algorithms.matrixMeandersBeDry import areIntegersWide, flipTheExtra_0b1AsUfunc, getBucketsTotal
|
|
3
|
-
from mapFolding.dataBaskets import MatrixMeandersNumPyState
|
|
4
|
-
from mapFolding.syntheticModules.meanders.bigInt import countBigInt
|
|
5
|
-
from warnings import warn
|
|
6
|
-
import pandas
|
|
7
|
-
|
|
8
|
-
def countPandas(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
9
|
-
"""Count meanders with matrix transfer algorithm using pandas DataFrame.
|
|
10
|
-
|
|
11
|
-
Parameters
|
|
12
|
-
----------
|
|
13
|
-
state : MatrixMeandersState
|
|
14
|
-
The algorithm state containing current `boundary`, `dictionaryMeanders`, and thresholds.
|
|
15
|
-
|
|
16
|
-
Returns
|
|
17
|
-
-------
|
|
18
|
-
state : MatrixMeandersState
|
|
19
|
-
Updated state with new `boundary` and `dictionaryMeanders`.
|
|
20
|
-
"""
|
|
21
|
-
dataframeAnalyzed = pandas.DataFrame({
|
|
22
|
-
'analyzed': pandas.Series(name='analyzed', data=state.dictionaryMeanders.keys(), copy=False, dtype=state.datatypeArcCode)
|
|
23
|
-
, 'crossings': pandas.Series(name='crossings', data=state.dictionaryMeanders.values(), copy=False, dtype=state.datatypeCrossings)
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
state.dictionaryMeanders.clear()
|
|
27
|
-
|
|
28
|
-
while (state.boundary > 0 and not areIntegersWide(state, dataframe=dataframeAnalyzed)):
|
|
29
|
-
|
|
30
|
-
def aggregateArcCodes() -> None:
|
|
31
|
-
nonlocal dataframeAnalyzed
|
|
32
|
-
dataframeAnalyzed = dataframeAnalyzed.iloc[0:state.indexTarget].groupby('analyzed', sort=False)['crossings'].aggregate('sum').reset_index()
|
|
33
|
-
|
|
34
|
-
def analyzeArcCodesAligned(dataframeMeanders: pandas.DataFrame) -> pandas.DataFrame:
|
|
35
|
-
"""Compute `arcCode` from `bitsAlpha` and `bitsZulu` if at least one is an even number.
|
|
36
|
-
|
|
37
|
-
Before computing `arcCode`, some values of `bitsAlpha` and `bitsZulu` are modified.
|
|
38
|
-
|
|
39
|
-
Warning
|
|
40
|
-
-------
|
|
41
|
-
This function deletes rows from `dataframeMeanders`. Always run this analysis last.
|
|
42
|
-
|
|
43
|
-
Formula
|
|
44
|
-
-------
|
|
45
|
-
```python
|
|
46
|
-
if bitsAlpha > 1 and bitsZulu > 1 and (bitsAlphaIsEven or bitsZuluIsEven):
|
|
47
|
-
arcCode = (bitsAlpha >> 2) | ((bitsZulu >> 2) << 1)
|
|
48
|
-
```
|
|
49
|
-
"""
|
|
50
|
-
# NOTE Step 1 drop unqualified rows
|
|
51
|
-
# ======= > * > bitsAlpha 1 bitsZulu 1 ====================
|
|
52
|
-
dataframeMeanders['analyzed'] = dataframeMeanders['arcCode'].copy() # `bitsAlpha`
|
|
53
|
-
dataframeMeanders['analyzed'] &= state.locatorBits # `bitsAlpha`
|
|
54
|
-
|
|
55
|
-
dataframeMeanders['analyzed'] = dataframeMeanders['analyzed'].gt(1) # if bitsAlphaHasArcs
|
|
56
|
-
|
|
57
|
-
bitsTarget: pandas.Series = dataframeMeanders['arcCode'].copy() # `bitsZulu`
|
|
58
|
-
bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
|
|
59
|
-
bitsTarget &= state.locatorBits # `bitsZulu`
|
|
60
|
-
|
|
61
|
-
dataframeMeanders['analyzed'] *= bitsTarget
|
|
62
|
-
del bitsTarget
|
|
63
|
-
dataframeMeanders = dataframeMeanders.loc[(dataframeMeanders['analyzed'] > 1)] # if (bitsAlphaHasArcs and bitsZuluHasArcs)
|
|
64
|
-
|
|
65
|
-
# ======= ^ & & bitsAlpha 1 bitsZulu 1 ====================
|
|
66
|
-
dataframeMeanders.loc[:, 'analyzed'] = dataframeMeanders['arcCode'].copy() # `bitsAlpha`
|
|
67
|
-
dataframeMeanders.loc[:, 'analyzed'] &= state.locatorBits # `bitsAlpha`
|
|
68
|
-
|
|
69
|
-
dataframeMeanders.loc[:, 'analyzed'] &= 1 # `bitsAlpha`
|
|
70
|
-
|
|
71
|
-
bitsTarget: pandas.Series = dataframeMeanders['arcCode'].copy() # `bitsZulu`
|
|
72
|
-
bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
|
|
73
|
-
bitsTarget &= state.locatorBits # `bitsZulu`
|
|
74
|
-
|
|
75
|
-
dataframeMeanders.loc[:, 'analyzed'] &= bitsTarget
|
|
76
|
-
del bitsTarget
|
|
77
|
-
dataframeMeanders.loc[:, 'analyzed'] ^= 1
|
|
78
|
-
|
|
79
|
-
dataframeMeanders = dataframeMeanders.loc[(dataframeMeanders['analyzed'] > 0)] # if (bitsAlphaIsEven or bitsZuluIsEven)
|
|
80
|
-
|
|
81
|
-
# NOTE Step 2 modify rows
|
|
82
|
-
# Make a selector for bitsZuluAtOdd, so you can modify bitsAlpha
|
|
83
|
-
dataframeMeanders.loc[:, 'analyzed'] = dataframeMeanders['arcCode'].copy() # `bitsZulu`
|
|
84
|
-
dataframeMeanders.loc[:, 'analyzed'] //= 2**1 # `bitsZulu` (bitsZulu >> 1)
|
|
85
|
-
dataframeMeanders.loc[:, 'analyzed'] &= 1 # selectorBitsZuluAtOdd
|
|
86
|
-
|
|
87
|
-
bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsAlpha`
|
|
88
|
-
bitsTarget &= state.locatorBits # `bitsAlpha`
|
|
89
|
-
|
|
90
|
-
# if bitsAlphaAtEven and not bitsZuluAtEven, modify bitsAlphaPairedToOdd
|
|
91
|
-
bitsTarget.loc[(dataframeMeanders['analyzed'] > 0)] = state.datatypeArcCode(
|
|
92
|
-
flipTheExtra_0b1AsUfunc(bitsTarget.loc[(dataframeMeanders['analyzed'] > 0)]))
|
|
93
|
-
|
|
94
|
-
dataframeMeanders.loc[:, 'analyzed'] = dataframeMeanders['arcCode'].copy() # `bitsZulu`
|
|
95
|
-
dataframeMeanders.loc[:, 'analyzed'] //= 2**1 # `bitsZulu` (bitsZulu >> 1)
|
|
96
|
-
dataframeMeanders.loc[:, 'analyzed'] &= state.locatorBits # `bitsZulu`
|
|
97
|
-
|
|
98
|
-
# if bitsZuluAtEven and not bitsAlphaAtEven, modify bitsZuluPairedToOdd
|
|
99
|
-
dataframeMeanders.loc[((dataframeMeanders.loc[:, 'arcCode'] & 1) > 0), 'analyzed'] = state.datatypeArcCode(
|
|
100
|
-
flipTheExtra_0b1AsUfunc(dataframeMeanders.loc[((dataframeMeanders.loc[:, 'arcCode'] & 1) > 0), 'analyzed']))
|
|
101
|
-
|
|
102
|
-
# NOTE Step 3 compute arcCode
|
|
103
|
-
# ======= >> | << >> bitsZulu 2 3 bitsAlpha 2 =============
|
|
104
|
-
dataframeMeanders.loc[:, 'analyzed'] //= 2**2 # (bitsZulu >> 2)
|
|
105
|
-
dataframeMeanders.loc[:, 'analyzed'] *= 2**3 # (bitsZulu << 3)
|
|
106
|
-
dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget
|
|
107
|
-
del bitsTarget
|
|
108
|
-
dataframeMeanders.loc[:, 'analyzed'] //= 2**2 # (... >> 2)
|
|
109
|
-
|
|
110
|
-
dataframeMeanders.loc[dataframeMeanders['analyzed'] >= state.MAXIMUMarcCode, 'analyzed'] = 0
|
|
111
|
-
|
|
112
|
-
return dataframeMeanders
|
|
113
|
-
|
|
114
|
-
def analyzeArcCodesSimple(dataframeMeanders: pandas.DataFrame) -> pandas.DataFrame:
|
|
115
|
-
"""Compute arcCode with the 'simple' formula.
|
|
116
|
-
|
|
117
|
-
Formula
|
|
118
|
-
-------
|
|
119
|
-
```python
|
|
120
|
-
arcCode = ((bitsAlpha | (bitsZulu << 1)) << 2) | 3
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Notes
|
|
124
|
-
-----
|
|
125
|
-
Using `+= 3` instead of `|= 3` is valid in this specific case. Left shift by two means the last bits are '0b00'. '0 + 3'
|
|
126
|
-
is '0b11', and '0b00 | 0b11' is also '0b11'.
|
|
127
|
-
|
|
128
|
-
"""
|
|
129
|
-
dataframeMeanders['analyzed'] = dataframeMeanders['arcCode']
|
|
130
|
-
dataframeMeanders.loc[:, 'analyzed'] &= state.locatorBits
|
|
131
|
-
|
|
132
|
-
bitsZulu: pandas.Series = dataframeMeanders['arcCode'].copy()
|
|
133
|
-
bitsZulu //= 2**1 # (bitsZulu >> 1)
|
|
134
|
-
bitsZulu &= state.locatorBits # `bitsZulu`
|
|
135
|
-
|
|
136
|
-
bitsZulu *= 2**1 # (bitsZulu << 1)
|
|
137
|
-
|
|
138
|
-
dataframeMeanders.loc[:, 'analyzed'] |= bitsZulu # ((bitsAlpha | (bitsZulu ...))
|
|
139
|
-
|
|
140
|
-
del bitsZulu
|
|
141
|
-
|
|
142
|
-
dataframeMeanders.loc[:, 'analyzed'] *= 2**2 # (... << 2)
|
|
143
|
-
dataframeMeanders.loc[:, 'analyzed'] += 3 # (...) | 3
|
|
144
|
-
dataframeMeanders.loc[dataframeMeanders['analyzed'] >= state.MAXIMUMarcCode, 'analyzed'] = 0
|
|
145
|
-
|
|
146
|
-
return dataframeMeanders
|
|
147
|
-
|
|
148
|
-
def analyzeBitsAlpha(dataframeMeanders: pandas.DataFrame) -> pandas.DataFrame:
|
|
149
|
-
"""Compute `arcCode` from `bitsAlpha`.
|
|
150
|
-
|
|
151
|
-
Formula
|
|
152
|
-
-------
|
|
153
|
-
```python
|
|
154
|
-
if bitsAlpha > 1:
|
|
155
|
-
arcCode = ((1 - (bitsAlpha & 1)) << 1) | (bitsZulu << 3) | (bitsAlpha >> 2)
|
|
156
|
-
# `(1 - (bitsAlpha & 1)` is an evenness test.
|
|
157
|
-
```
|
|
158
|
-
"""
|
|
159
|
-
dataframeMeanders['analyzed'] = dataframeMeanders['arcCode']
|
|
160
|
-
dataframeMeanders.loc[:, 'analyzed'] &= 1 # (bitsAlpha & 1)
|
|
161
|
-
dataframeMeanders.loc[:, 'analyzed'] ^= 1 # (1 - (bitsAlpha ...))
|
|
162
|
-
|
|
163
|
-
dataframeMeanders.loc[:, 'analyzed'] *= 2**1 # ((bitsAlpha ...) << 1)
|
|
164
|
-
|
|
165
|
-
bitsTarget: pandas.Series = dataframeMeanders['arcCode'].copy() # `bitsZulu`
|
|
166
|
-
bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
|
|
167
|
-
bitsTarget &= state.locatorBits # `bitsZulu`
|
|
168
|
-
|
|
169
|
-
bitsTarget *= 2**3 # (bitsZulu << 3)
|
|
170
|
-
dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget # ... | (bitsZulu ...)
|
|
171
|
-
|
|
172
|
-
del bitsTarget
|
|
173
|
-
|
|
174
|
-
"""NOTE In this code block, I rearranged the "formula" to use `bitsTarget` for two goals. 1. `(bitsAlpha >> 2)`.
|
|
175
|
-
2. `if bitsAlpha > 1`. The trick is in the equivalence of v1 and v2.
|
|
176
|
-
v1: BITScow | (BITSwalk >> 2)
|
|
177
|
-
v2: ((BITScow << 2) | BITSwalk) >> 2
|
|
178
|
-
|
|
179
|
-
The "formula" calls for v1, but by using v2, `bitsTarget` is not changed. Therefore, because `bitsTarget` is
|
|
180
|
-
`bitsAlpha`, I can use `bitsTarget` for goal 2, `if bitsAlpha > 1`.
|
|
181
|
-
"""
|
|
182
|
-
dataframeMeanders.loc[:, 'analyzed'] *= 2**2 # ... | (bitsAlpha >> 2)
|
|
183
|
-
|
|
184
|
-
bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsAlpha`
|
|
185
|
-
bitsTarget &= state.locatorBits # `bitsAlpha`
|
|
186
|
-
|
|
187
|
-
dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget # ... | (bitsAlpha)
|
|
188
|
-
dataframeMeanders.loc[:, 'analyzed'] //= 2**2 # (... >> 2)
|
|
189
|
-
|
|
190
|
-
dataframeMeanders.loc[(bitsTarget <= 1), 'analyzed'] = 0 # if bitsAlpha > 1
|
|
191
|
-
|
|
192
|
-
del bitsTarget
|
|
193
|
-
|
|
194
|
-
dataframeMeanders.loc[dataframeMeanders['analyzed'] >= state.MAXIMUMarcCode, 'analyzed'] = 0
|
|
195
|
-
|
|
196
|
-
return dataframeMeanders
|
|
197
|
-
|
|
198
|
-
def analyzeBitsZulu(dataframeMeanders: pandas.DataFrame) -> pandas.DataFrame:
|
|
199
|
-
"""Compute `arcCode` from `bitsZulu`.
|
|
200
|
-
|
|
201
|
-
Formula
|
|
202
|
-
-------
|
|
203
|
-
```python
|
|
204
|
-
if bitsZulu > 1:
|
|
205
|
-
arcCode = (1 - (bitsZulu & 1)) | (bitsAlpha << 2) | (bitsZulu >> 1)
|
|
206
|
-
```
|
|
207
|
-
"""
|
|
208
|
-
# NOTE `(1 - (bitsZulu & 1))` is an evenness test: we want a single bit as the answer.
|
|
209
|
-
dataframeMeanders.loc[:, 'analyzed'] = dataframeMeanders['arcCode'] # `bitsZulu`
|
|
210
|
-
dataframeMeanders.loc[:, 'analyzed'] //= 2**1 # `bitsZulu` (bitsZulu >> 1)
|
|
211
|
-
dataframeMeanders.loc[:, 'analyzed'] &= 1 # `bitsZulu`
|
|
212
|
-
dataframeMeanders.loc[:, 'analyzed'] &= 1 # (bitsZulu & 1)
|
|
213
|
-
dataframeMeanders.loc[:, 'analyzed'] ^= 1 # (1 - (bitsZulu ...))
|
|
214
|
-
|
|
215
|
-
bitsTarget: pandas.Series = dataframeMeanders['arcCode'].copy() # `bitsAlpha`
|
|
216
|
-
bitsTarget &= state.locatorBits # `bitsAlpha`
|
|
217
|
-
|
|
218
|
-
bitsTarget *= 2**2 # (bitsAlpha << 2)
|
|
219
|
-
dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget # ... | (bitsAlpha ...)
|
|
220
|
-
del bitsTarget
|
|
221
|
-
|
|
222
|
-
# NOTE Same trick as in `analyzeBitsAlpha`.
|
|
223
|
-
dataframeMeanders.loc[:, 'analyzed'] *= 2**1 # (... << 1)
|
|
224
|
-
|
|
225
|
-
bitsTarget = dataframeMeanders['arcCode'].copy() # `bitsZulu`
|
|
226
|
-
bitsTarget //= 2**1 # `bitsZulu` (bitsZulu >> 1)
|
|
227
|
-
bitsTarget &= state.locatorBits # `bitsZulu`
|
|
228
|
-
|
|
229
|
-
dataframeMeanders.loc[:, 'analyzed'] |= bitsTarget # ... | (bitsZulu)
|
|
230
|
-
dataframeMeanders.loc[:, 'analyzed'] //= 2**1 # (... >> 1)
|
|
231
|
-
|
|
232
|
-
dataframeMeanders.loc[bitsTarget <= 1, 'analyzed'] = 0 # if bitsZulu > 1
|
|
233
|
-
del bitsTarget
|
|
234
|
-
|
|
235
|
-
dataframeMeanders.loc[dataframeMeanders['analyzed'] >= state.MAXIMUMarcCode, 'analyzed'] = 0
|
|
236
|
-
|
|
237
|
-
return dataframeMeanders
|
|
238
|
-
|
|
239
|
-
def recordArcCodes(dataframeMeanders: pandas.DataFrame) -> pandas.DataFrame:
|
|
240
|
-
nonlocal dataframeAnalyzed
|
|
241
|
-
|
|
242
|
-
indexStopAnalyzed: int = state.indexTarget + int((dataframeMeanders['analyzed'] > 0).sum())
|
|
243
|
-
|
|
244
|
-
if indexStopAnalyzed > state.indexTarget:
|
|
245
|
-
if len(dataframeAnalyzed.index) < indexStopAnalyzed:
|
|
246
|
-
warn(f"Lengthened `dataframeAnalyzed` from {len(dataframeAnalyzed.index)} to {indexStopAnalyzed=}; n={state.n}, {state.boundary=}.", stacklevel=2)
|
|
247
|
-
dataframeAnalyzed = dataframeAnalyzed.reindex(index=pandas.RangeIndex(indexStopAnalyzed), fill_value=0)
|
|
248
|
-
|
|
249
|
-
dataframeAnalyzed.loc[state.indexTarget:indexStopAnalyzed - 1, ['analyzed']] = (
|
|
250
|
-
dataframeMeanders.loc[(dataframeMeanders['analyzed'] > 0), ['analyzed']
|
|
251
|
-
].to_numpy(dtype=state.datatypeArcCode, copy=False)
|
|
252
|
-
)
|
|
253
|
-
|
|
254
|
-
dataframeAnalyzed.loc[state.indexTarget:indexStopAnalyzed - 1, ['crossings']] = (
|
|
255
|
-
dataframeMeanders.loc[(dataframeMeanders['analyzed'] > 0), ['crossings']
|
|
256
|
-
].to_numpy(dtype=state.datatypeCrossings, copy=False)
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
state.indexTarget = indexStopAnalyzed
|
|
260
|
-
|
|
261
|
-
del indexStopAnalyzed
|
|
262
|
-
|
|
263
|
-
return dataframeMeanders
|
|
264
|
-
|
|
265
|
-
dataframeMeanders = pandas.DataFrame({
|
|
266
|
-
'arcCode': pandas.Series(name='arcCode', data=dataframeAnalyzed['analyzed'], copy=False, dtype=state.datatypeArcCode)
|
|
267
|
-
, 'analyzed': pandas.Series(name='analyzed', data=0, dtype=state.datatypeArcCode)
|
|
268
|
-
, 'crossings': pandas.Series(name='crossings', data=dataframeAnalyzed['crossings'], copy=False, dtype=state.datatypeCrossings)
|
|
269
|
-
}
|
|
270
|
-
)
|
|
271
|
-
|
|
272
|
-
del dataframeAnalyzed
|
|
273
|
-
goByeBye()
|
|
274
|
-
|
|
275
|
-
state.bitWidth = int(dataframeMeanders['arcCode'].max()).bit_length()
|
|
276
|
-
length: int = getBucketsTotal(state)
|
|
277
|
-
dataframeAnalyzed = pandas.DataFrame({
|
|
278
|
-
'analyzed': pandas.Series(name='analyzed', data=0, index=pandas.RangeIndex(length), dtype=state.datatypeArcCode)
|
|
279
|
-
, 'crossings': pandas.Series(name='crossings', data=0, index=pandas.RangeIndex(length), dtype=state.datatypeCrossings)
|
|
280
|
-
}, index=pandas.RangeIndex(length)
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
state.boundary -= 1
|
|
284
|
-
|
|
285
|
-
state.indexTarget = 0
|
|
286
|
-
|
|
287
|
-
dataframeMeanders: pandas.DataFrame = analyzeArcCodesSimple(dataframeMeanders)
|
|
288
|
-
dataframeMeanders = recordArcCodes(dataframeMeanders)
|
|
289
|
-
|
|
290
|
-
dataframeMeanders = analyzeBitsAlpha(dataframeMeanders)
|
|
291
|
-
dataframeMeanders = recordArcCodes(dataframeMeanders)
|
|
292
|
-
|
|
293
|
-
dataframeMeanders = analyzeBitsZulu(dataframeMeanders)
|
|
294
|
-
dataframeMeanders = recordArcCodes(dataframeMeanders)
|
|
295
|
-
|
|
296
|
-
dataframeMeanders = analyzeArcCodesAligned(dataframeMeanders)
|
|
297
|
-
dataframeMeanders = recordArcCodes(dataframeMeanders)
|
|
298
|
-
del dataframeMeanders
|
|
299
|
-
goByeBye()
|
|
300
|
-
|
|
301
|
-
aggregateArcCodes()
|
|
302
|
-
|
|
303
|
-
state.dictionaryMeanders = dataframeAnalyzed.set_index('analyzed')['crossings'].to_dict()
|
|
304
|
-
del dataframeAnalyzed
|
|
305
|
-
return state
|
|
306
|
-
|
|
307
|
-
def doTheNeedful(state: MatrixMeandersNumPyState) -> int:
|
|
308
|
-
"""Compute `crossings` with a transfer matrix algorithm implemented in pandas.
|
|
309
|
-
|
|
310
|
-
Parameters
|
|
311
|
-
----------
|
|
312
|
-
state : MatrixMeandersState
|
|
313
|
-
The algorithm state.
|
|
314
|
-
|
|
315
|
-
Returns
|
|
316
|
-
-------
|
|
317
|
-
crossings : int
|
|
318
|
-
The computed value of `crossings`.
|
|
319
|
-
|
|
320
|
-
Notes
|
|
321
|
-
-----
|
|
322
|
-
Citation: https://github.com/hunterhogan/mapFolding/blob/main/citations/Jensen.bibtex
|
|
323
|
-
|
|
324
|
-
See Also
|
|
325
|
-
--------
|
|
326
|
-
https://oeis.org/A000682
|
|
327
|
-
https://oeis.org/A005316
|
|
328
|
-
"""
|
|
329
|
-
while state.boundary > 0:
|
|
330
|
-
if areIntegersWide(state):
|
|
331
|
-
state = countBigInt(state)
|
|
332
|
-
else:
|
|
333
|
-
state = countPandas(state)
|
|
334
|
-
return sum(state.dictionaryMeanders.values())
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
from collections.abc import Iterable
|
|
2
|
-
from hunterMakesPy import raiseIfNone
|
|
3
|
-
|
|
4
|
-
class BasicMeanderProblem:
|
|
5
|
-
|
|
6
|
-
def __init__(self, remainingBridges: int) -> None:
|
|
7
|
-
self.remainingBridges = remainingBridges
|
|
8
|
-
self.archStateLimit = 1 << (2 + (2 * (remainingBridges + 1)))
|
|
9
|
-
self.bridgesTotalIsOdd = (remainingBridges & 1) == 1
|
|
10
|
-
|
|
11
|
-
def initializeA005316(self) -> list[int]:
|
|
12
|
-
if self.bridgesTotalIsOdd:
|
|
13
|
-
bitPattern = (1 << 2) | 1
|
|
14
|
-
bitPattern <<= 2
|
|
15
|
-
return [bitPattern | 1 << 1]
|
|
16
|
-
else:
|
|
17
|
-
bitPattern = (1 << 2) | 1
|
|
18
|
-
return [bitPattern | bitPattern << 1]
|
|
19
|
-
|
|
20
|
-
def initializeA000682(self) -> list[int]:
|
|
21
|
-
initialStatesList: list[int] = []
|
|
22
|
-
bitPattern = 1 if self.bridgesTotalIsOdd else ((1 << 2) | 1)
|
|
23
|
-
|
|
24
|
-
packedState = bitPattern | bitPattern << 1
|
|
25
|
-
while packedState < self.archStateLimit:
|
|
26
|
-
initialStatesList.append(packedState)
|
|
27
|
-
bitPattern = ((bitPattern << 2) | 1) << 2 | 1
|
|
28
|
-
packedState = bitPattern | bitPattern << 1
|
|
29
|
-
|
|
30
|
-
return initialStatesList
|
|
31
|
-
|
|
32
|
-
def enumerate(self, packedState: int) -> list[int]: # noqa: C901
|
|
33
|
-
bitMask = 0x5555555555555555
|
|
34
|
-
bitWidth = 64
|
|
35
|
-
while bitMask < packedState:
|
|
36
|
-
bitMask |= bitMask << bitWidth
|
|
37
|
-
bitWidth += bitWidth
|
|
38
|
-
lower: int = packedState & bitMask
|
|
39
|
-
upper: int = (packedState - lower) >> 1
|
|
40
|
-
nextStatesList: list[int] = []
|
|
41
|
-
|
|
42
|
-
if lower != 1:
|
|
43
|
-
nextState: int = (lower >> 2 | (((upper << 2) ^ (1 if (lower & 1) == 0 else 0)) << 1))
|
|
44
|
-
if nextState < self.archStateLimit:
|
|
45
|
-
nextStatesList.append(nextState)
|
|
46
|
-
|
|
47
|
-
if upper != 1:
|
|
48
|
-
nextState = (((lower << 2) ^ (1 if (upper & 1) == 0 else 0)) | (upper >> 2) << 1)
|
|
49
|
-
if nextState < self.archStateLimit:
|
|
50
|
-
nextStatesList.append(nextState)
|
|
51
|
-
|
|
52
|
-
nextState = ((lower << 2) | 1 | ((upper << 2) | 1) << 1)
|
|
53
|
-
if nextState < self.archStateLimit:
|
|
54
|
-
nextStatesList.append(nextState)
|
|
55
|
-
|
|
56
|
-
if lower != 1 and upper != 1 and ((lower & 1) == 0 or (upper & 1) == 0):
|
|
57
|
-
if (lower & 1) == 0 and (upper & 1) == 1:
|
|
58
|
-
archBalance = 0
|
|
59
|
-
bitPosition = 1
|
|
60
|
-
while archBalance >= 0:
|
|
61
|
-
bitPosition <<= 2
|
|
62
|
-
archBalance += 1 if (lower & bitPosition) == 0 else -1
|
|
63
|
-
lower ^= bitPosition
|
|
64
|
-
if (upper & 1) == 0 and (lower & 1) == 1:
|
|
65
|
-
archBalance = 0
|
|
66
|
-
bitPosition = 1
|
|
67
|
-
while archBalance >= 0:
|
|
68
|
-
bitPosition <<= 2
|
|
69
|
-
archBalance += 1 if (upper & bitPosition) == 0 else -1
|
|
70
|
-
upper ^= bitPosition
|
|
71
|
-
nextState = (lower >> 2 | (upper >> 2) << 1)
|
|
72
|
-
if nextState < self.archStateLimit:
|
|
73
|
-
nextStatesList.append(nextState)
|
|
74
|
-
|
|
75
|
-
return nextStatesList
|
|
76
|
-
|
|
77
|
-
class SimpleProcessor:
|
|
78
|
-
|
|
79
|
-
def __init__(self) -> None:
|
|
80
|
-
self.createStateMachine: type | None = None
|
|
81
|
-
self.totalTransitions = 0
|
|
82
|
-
|
|
83
|
-
def setCreateStateMachine(self, stateMachineCreator: type) -> None:
|
|
84
|
-
self.createStateMachine = stateMachineCreator
|
|
85
|
-
|
|
86
|
-
def process(self, bridgesCount: int, initialStates: Iterable[int]) -> int:
|
|
87
|
-
stateCounts: list[tuple[int, int]] = [(state, 1) for state in initialStates]
|
|
88
|
-
|
|
89
|
-
self.createStateMachine = raiseIfNone(self.createStateMachine, "State machine creator must be set before processing.")
|
|
90
|
-
bridgesRemaining: int = bridgesCount
|
|
91
|
-
while bridgesRemaining > 0:
|
|
92
|
-
bridgesRemaining -= 1
|
|
93
|
-
stateCounts = self._accumulate(self.createStateMachine(bridgesRemaining), stateCounts)
|
|
94
|
-
|
|
95
|
-
return sum(count for state, count in stateCounts)
|
|
96
|
-
|
|
97
|
-
def _accumulate(self, layer: BasicMeanderProblem, previousCounts: list[tuple[int, int]]) -> list[tuple[int, int]]:
|
|
98
|
-
stateCountsDict: dict[int, int] = {}
|
|
99
|
-
transitions: int = 0
|
|
100
|
-
|
|
101
|
-
for state, count in previousCounts:
|
|
102
|
-
for nextState in layer.enumerate(state):
|
|
103
|
-
if nextState in stateCountsDict:
|
|
104
|
-
stateCountsDict[nextState] += count
|
|
105
|
-
else:
|
|
106
|
-
stateCountsDict[nextState] = count
|
|
107
|
-
transitions += 1
|
|
108
|
-
|
|
109
|
-
self.totalTransitions += transitions
|
|
110
|
-
return list(stateCountsDict.items())
|
|
111
|
-
|
|
112
|
-
def A005316(n: int) -> int:
|
|
113
|
-
processor = SimpleProcessor()
|
|
114
|
-
processor.setCreateStateMachine(BasicMeanderProblem)
|
|
115
|
-
meanderProblem = BasicMeanderProblem(n)
|
|
116
|
-
return processor.process(n, meanderProblem.initializeA005316())
|
|
117
|
-
|
|
118
|
-
def A000682(n: int) -> int:
|
|
119
|
-
processor = SimpleProcessor()
|
|
120
|
-
processor.setCreateStateMachine(BasicMeanderProblem)
|
|
121
|
-
meanderProblem = BasicMeanderProblem(n-1)
|
|
122
|
-
return processor.process(n-1, meanderProblem.initializeA000682())
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
def count(bridges: int, dictionaryCurveLocationsKnown: dict[int, int]) -> int:
|
|
2
|
-
while bridges > 0:
|
|
3
|
-
bridges -= 1
|
|
4
|
-
curveLocationsMAXIMUM = 1 << (2 * bridges + 4)
|
|
5
|
-
dictionaryCurveLocationsDiscovered: dict[int, int] = {}
|
|
6
|
-
|
|
7
|
-
for curveLocations, distinctCrossings in dictionaryCurveLocationsKnown.items():
|
|
8
|
-
bifurcationAlpha = curveLocations & 0x5555555555555555555555555555555555555555555555555555555555555555
|
|
9
|
-
bifurcationZulu = (curveLocations ^ bifurcationAlpha) >> 1
|
|
10
|
-
|
|
11
|
-
bifurcationAlphaHasCurves = bifurcationAlpha != 1
|
|
12
|
-
bifurcationZuluHasCurves = bifurcationZulu != 1
|
|
13
|
-
bifurcationAlphaFinalZero = not bifurcationAlpha & 1
|
|
14
|
-
bifurcationZuluFinalZero = not bifurcationZulu & 1
|
|
15
|
-
|
|
16
|
-
if bifurcationAlphaHasCurves:
|
|
17
|
-
curveLocationAnalysis = (bifurcationAlpha >> 2) | (bifurcationZulu << 3) | (bifurcationAlphaFinalZero << 1)
|
|
18
|
-
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
19
|
-
dictionaryCurveLocationsDiscovered[curveLocationAnalysis] = dictionaryCurveLocationsDiscovered.get(curveLocationAnalysis, 0) + distinctCrossings
|
|
20
|
-
|
|
21
|
-
if bifurcationZuluHasCurves:
|
|
22
|
-
curveLocationAnalysis = (bifurcationZulu >> 1) | (bifurcationAlpha << 2) | bifurcationZuluFinalZero
|
|
23
|
-
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
24
|
-
dictionaryCurveLocationsDiscovered[curveLocationAnalysis] = dictionaryCurveLocationsDiscovered.get(curveLocationAnalysis, 0) + distinctCrossings
|
|
25
|
-
|
|
26
|
-
curveLocationAnalysis = ((bifurcationAlpha | (bifurcationZulu << 1)) << 2) | 3
|
|
27
|
-
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
28
|
-
dictionaryCurveLocationsDiscovered[curveLocationAnalysis] = dictionaryCurveLocationsDiscovered.get(curveLocationAnalysis, 0) + distinctCrossings
|
|
29
|
-
|
|
30
|
-
if bifurcationAlphaHasCurves and bifurcationZuluHasCurves and (bifurcationAlphaFinalZero or bifurcationZuluFinalZero):
|
|
31
|
-
XOrHere2makePair = 0b1
|
|
32
|
-
findUnpairedBinary1 = 0
|
|
33
|
-
if bifurcationAlphaFinalZero and not bifurcationZuluFinalZero:
|
|
34
|
-
while findUnpairedBinary1 >= 0:
|
|
35
|
-
XOrHere2makePair <<= 2
|
|
36
|
-
findUnpairedBinary1 += 1 if (bifurcationAlpha & XOrHere2makePair) == 0 else -1
|
|
37
|
-
bifurcationAlpha ^= XOrHere2makePair
|
|
38
|
-
|
|
39
|
-
elif bifurcationZuluFinalZero and not bifurcationAlphaFinalZero:
|
|
40
|
-
while findUnpairedBinary1 >= 0:
|
|
41
|
-
XOrHere2makePair <<= 2
|
|
42
|
-
findUnpairedBinary1 += 1 if (bifurcationZulu & XOrHere2makePair) == 0 else -1
|
|
43
|
-
bifurcationZulu ^= XOrHere2makePair
|
|
44
|
-
|
|
45
|
-
curveLocationAnalysis = (bifurcationAlpha >> 2) | ((bifurcationZulu >> 2) << 1)
|
|
46
|
-
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
47
|
-
dictionaryCurveLocationsDiscovered[curveLocationAnalysis] = dictionaryCurveLocationsDiscovered.get(curveLocationAnalysis, 0) + distinctCrossings
|
|
48
|
-
|
|
49
|
-
dictionaryCurveLocationsKnown = dictionaryCurveLocationsDiscovered
|
|
50
|
-
|
|
51
|
-
return sum(dictionaryCurveLocationsKnown.values())
|
|
52
|
-
|
|
53
|
-
def initializeA005316(n: int) -> dict[int, int]:
|
|
54
|
-
if n & 1:
|
|
55
|
-
return {22: 1}
|
|
56
|
-
else:
|
|
57
|
-
return {15: 1}
|
|
58
|
-
|
|
59
|
-
def initializeA000682(n: int) -> dict[int, int]:
|
|
60
|
-
stateToCount: dict[int, int] = {}
|
|
61
|
-
|
|
62
|
-
curveLocationsMAXIMUM = 1 << (2 * n + 4)
|
|
63
|
-
|
|
64
|
-
bitPattern = 5 - (n & 1) * 4
|
|
65
|
-
|
|
66
|
-
packedState = bitPattern | (bitPattern << 1)
|
|
67
|
-
while packedState < curveLocationsMAXIMUM:
|
|
68
|
-
stateToCount[packedState] = 1
|
|
69
|
-
bitPattern = ((bitPattern << 4) | 0b0101)
|
|
70
|
-
packedState = bitPattern | (bitPattern << 1)
|
|
71
|
-
|
|
72
|
-
return stateToCount
|
|
73
|
-
|
|
74
|
-
def A005316(n: int) -> int:
|
|
75
|
-
return count(n, initializeA005316(n))
|
|
76
|
-
|
|
77
|
-
def A000682(n: int) -> int:
|
|
78
|
-
return count(n - 1, initializeA000682(n - 1))
|
|
79
|
-
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
from mapFolding._oeisFormulas.matrixMeandersAnnex import curveMaximum as curveMaximum
|
|
2
|
-
|
|
3
|
-
dictionaryCurveLocations: dict[int, int] = {}
|
|
4
|
-
|
|
5
|
-
def getCurveLocations() -> dict[int, int]:
|
|
6
|
-
global dictionaryCurveLocations # noqa: PLW0603
|
|
7
|
-
sherpa = dictionaryCurveLocations.copy()
|
|
8
|
-
dictionaryCurveLocations = {}
|
|
9
|
-
return sherpa
|
|
10
|
-
|
|
11
|
-
def recordAnalysis(curveLocationAnalysis: int, curveLocationsMAXIMUM: int, distinctCrossings: int) -> None:
|
|
12
|
-
if curveLocationAnalysis < curveLocationsMAXIMUM:
|
|
13
|
-
dictionaryCurveLocations[curveLocationAnalysis] = dictionaryCurveLocations.get(curveLocationAnalysis, 0) + distinctCrossings
|
|
14
|
-
|
|
15
|
-
def initializeCurveLocations(startingCurveLocations: dict[int, int]) -> None:
|
|
16
|
-
global dictionaryCurveLocations # noqa: PLW0603
|
|
17
|
-
dictionaryCurveLocations = startingCurveLocations.copy()
|
|
18
|
-
|
|
19
|
-
def count(bridges: int, startingCurveLocations: dict[int, int]) -> int:
|
|
20
|
-
initializeCurveLocations(startingCurveLocations)
|
|
21
|
-
|
|
22
|
-
while bridges > 0:
|
|
23
|
-
bridges -= 1
|
|
24
|
-
curveLocationsMAXIMUM, bifurcationZuluLocator, bifurcationAlphaLocator = curveMaximum[bridges]
|
|
25
|
-
|
|
26
|
-
for curveLocations, distinctCrossings in getCurveLocations().items():
|
|
27
|
-
bifurcationZulu = (curveLocations & bifurcationZuluLocator) >> 1
|
|
28
|
-
bifurcationAlpha = curveLocations & bifurcationAlphaLocator
|
|
29
|
-
|
|
30
|
-
bifurcationZuluFinalZero = (bifurcationZulu & 0b1) == 0
|
|
31
|
-
bifurcationZuluHasCurves = bifurcationZulu != 1
|
|
32
|
-
bifurcationAlphaFinalZero = (bifurcationAlpha & 0b1) == 0
|
|
33
|
-
bifurcationAlphaHasCurves = bifurcationAlpha != 1
|
|
34
|
-
|
|
35
|
-
if bifurcationZuluHasCurves:
|
|
36
|
-
curveLocationAnalysis = (bifurcationZulu >> 1) | (bifurcationAlpha << 2) | bifurcationZuluFinalZero
|
|
37
|
-
recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
|
|
38
|
-
|
|
39
|
-
if bifurcationAlphaHasCurves:
|
|
40
|
-
curveLocationAnalysis = (bifurcationAlpha >> 2) | (bifurcationZulu << 3) | (bifurcationAlphaFinalZero << 1)
|
|
41
|
-
recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
|
|
42
|
-
|
|
43
|
-
curveLocationAnalysis = ((bifurcationAlpha | (bifurcationZulu << 1)) << 2) | 3
|
|
44
|
-
recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
|
|
45
|
-
|
|
46
|
-
if bifurcationZuluHasCurves and bifurcationAlphaHasCurves and (bifurcationZuluFinalZero or bifurcationAlphaFinalZero):
|
|
47
|
-
XOrHere2makePair = 0b1
|
|
48
|
-
findUnpairedBinary1 = 0
|
|
49
|
-
|
|
50
|
-
if bifurcationZuluFinalZero and not bifurcationAlphaFinalZero:
|
|
51
|
-
while findUnpairedBinary1 >= 0:
|
|
52
|
-
XOrHere2makePair <<= 2
|
|
53
|
-
findUnpairedBinary1 += 1 if (bifurcationZulu & XOrHere2makePair) == 0 else -1
|
|
54
|
-
bifurcationZulu ^= XOrHere2makePair
|
|
55
|
-
|
|
56
|
-
elif bifurcationAlphaFinalZero and not bifurcationZuluFinalZero:
|
|
57
|
-
while findUnpairedBinary1 >= 0:
|
|
58
|
-
XOrHere2makePair <<= 2
|
|
59
|
-
findUnpairedBinary1 += 1 if (bifurcationAlpha & XOrHere2makePair) == 0 else -1
|
|
60
|
-
bifurcationAlpha ^= XOrHere2makePair
|
|
61
|
-
|
|
62
|
-
curveLocationAnalysis = ((bifurcationZulu >> 2) << 1) | (bifurcationAlpha >> 2)
|
|
63
|
-
recordAnalysis(curveLocationAnalysis, curveLocationsMAXIMUM, distinctCrossings)
|
|
64
|
-
|
|
65
|
-
return sum(getCurveLocations().values())
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
from typing import NamedTuple
|
|
2
|
-
import sys
|
|
3
|
-
|
|
4
|
-
class limitLocators(NamedTuple):
|
|
5
|
-
curveLocationsMAXIMUM: int
|
|
6
|
-
bifurcationZuluLocator: int
|
|
7
|
-
bifurcationAlphaLocator: int
|
|
8
|
-
|
|
9
|
-
curveMaximum: dict[int, limitLocators] = {
|
|
10
|
-
0: limitLocators(16, 0x2a, 0x15),
|
|
11
|
-
1: limitLocators(64, 0xaa, 0x55),
|
|
12
|
-
2: limitLocators(256, 0x2aa, 0x155),
|
|
13
|
-
3: limitLocators(1024, 0xaaa, 0x555),
|
|
14
|
-
4: limitLocators(4096, 0x2aaa, 0x1555),
|
|
15
|
-
5: limitLocators(16384, 0xaaaa, 0x5555),
|
|
16
|
-
6: limitLocators(65536, 0x2aaaa, 0x15555),
|
|
17
|
-
7: limitLocators(262144, 0xaaaaa, 0x55555),
|
|
18
|
-
8: limitLocators(1048576, 0x2aaaaa, 0x155555),
|
|
19
|
-
9: limitLocators(4194304, 0xaaaaaa, 0x555555),
|
|
20
|
-
10: limitLocators(16777216, 0x2aaaaaa, 0x1555555),
|
|
21
|
-
11: limitLocators(67108864, 0xaaaaaaa, 0x5555555),
|
|
22
|
-
12: limitLocators(268435456, 0x2aaaaaaa, 0x15555555),
|
|
23
|
-
13: limitLocators(1073741824, 0xaaaaaaaa, 0x55555555),
|
|
24
|
-
14: limitLocators(4294967296, 0x2aaaaaaaa, 0x155555555),
|
|
25
|
-
15: limitLocators(17179869184, 0xaaaaaaaaa, 0x555555555),
|
|
26
|
-
16: limitLocators(68719476736, 0x2aaaaaaaaa, 0x1555555555),
|
|
27
|
-
17: limitLocators(274877906944, 0xaaaaaaaaaa, 0x5555555555),
|
|
28
|
-
18: limitLocators(1099511627776, 0x2aaaaaaaaaa, 0x15555555555),
|
|
29
|
-
19: limitLocators(4398046511104, 0xaaaaaaaaaaa, 0x55555555555),
|
|
30
|
-
20: limitLocators(17592186044416, 0x2aaaaaaaaaaa, 0x155555555555),
|
|
31
|
-
21: limitLocators(70368744177664, 0xaaaaaaaaaaaa, 0x555555555555),
|
|
32
|
-
22: limitLocators(281474976710656, 0x2aaaaaaaaaaaa, 0x1555555555555),
|
|
33
|
-
23: limitLocators(1125899906842624, 0xaaaaaaaaaaaaa, 0x5555555555555),
|
|
34
|
-
24: limitLocators(4503599627370496, 0x2aaaaaaaaaaaaa, 0x15555555555555),
|
|
35
|
-
25: limitLocators(18014398509481984, 0xaaaaaaaaaaaaaa, 0x55555555555555),
|
|
36
|
-
26: limitLocators(72057594037927936, 0x2aaaaaaaaaaaaaa, 0x155555555555555),
|
|
37
|
-
27: limitLocators(288230376151711744, 0xaaaaaaaaaaaaaaa, 0x555555555555555),
|
|
38
|
-
28: limitLocators(1152921504606846976, 0x2aaaaaaaaaaaaaaa, 0x1555555555555555),
|
|
39
|
-
29: limitLocators(4611686018427387904, 0xaaaaaaaaaaaaaaaa, 0x5555555555555555),
|
|
40
|
-
30: limitLocators(18446744073709551616, 0x2aaaaaaaaaaaaaaaa, 0x15555555555555555),
|
|
41
|
-
31: limitLocators(73786976294838206464, 0xaaaaaaaaaaaaaaaaa, 0x55555555555555555),
|
|
42
|
-
32: limitLocators(295147905179352825856, 0x2aaaaaaaaaaaaaaaaa, 0x155555555555555555),
|
|
43
|
-
33: limitLocators(1180591620717411303424, 0xaaaaaaaaaaaaaaaaaa, 0x555555555555555555),
|
|
44
|
-
34: limitLocators(4722366482869645213696, 0x2aaaaaaaaaaaaaaaaaa, 0x1555555555555555555),
|
|
45
|
-
35: limitLocators(18889465931478580854784, 0xaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555),
|
|
46
|
-
36: limitLocators(75557863725914323419136, 0x2aaaaaaaaaaaaaaaaaaa, 0x15555555555555555555),
|
|
47
|
-
37: limitLocators(302231454903657293676544, 0xaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555),
|
|
48
|
-
38: limitLocators(1208925819614629174706176, 0x2aaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555),
|
|
49
|
-
39: limitLocators(4835703278458516698824704, 0xaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555),
|
|
50
|
-
40: limitLocators(19342813113834066795298816, 0x2aaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555),
|
|
51
|
-
41: limitLocators(77371252455336267181195264, 0xaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555),
|
|
52
|
-
42: limitLocators(309485009821345068724781056, 0x2aaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555),
|
|
53
|
-
43: limitLocators(1237940039285380274899124224, 0xaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555),
|
|
54
|
-
44: limitLocators(4951760157141521099596496896, 0x2aaaaaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555555),
|
|
55
|
-
45: limitLocators(19807040628566084398385987584, 0xaaaaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555555),
|
|
56
|
-
46: limitLocators(79228162514264337593543950336, 0x2aaaaaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555555),
|
|
57
|
-
47: limitLocators(316912650057057350374175801344, 0xaaaaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555555),
|
|
58
|
-
48: limitLocators(1267650600228229401496703205376, 0x2aaaaaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555555),
|
|
59
|
-
49: limitLocators(5070602400912917605986812821504, 0xaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555555),
|
|
60
|
-
50: limitLocators(20282409603651670423947251286016, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555555555),
|
|
61
|
-
51: limitLocators(81129638414606681695789005144064, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555555555),
|
|
62
|
-
52: limitLocators(324518553658426726783156020576256, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555555555),
|
|
63
|
-
53: limitLocators(1298074214633706907132624082305024, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555555555),
|
|
64
|
-
54: limitLocators(5192296858534827628530496329220096, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555555555),
|
|
65
|
-
55: limitLocators(20769187434139310514121985316880384, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555555555),
|
|
66
|
-
56: limitLocators(83076749736557242056487941267521536, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x155555555555555555555555555555),
|
|
67
|
-
57: limitLocators(332306998946228968225951765070086144, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x555555555555555555555555555555),
|
|
68
|
-
58: limitLocators(1329227995784915872903807060280344576, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x1555555555555555555555555555555),
|
|
69
|
-
59: limitLocators(5316911983139663491615228241121378304, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x5555555555555555555555555555555),
|
|
70
|
-
60: limitLocators(21267647932558653966460912964485513216, 0x2aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x15555555555555555555555555555555),
|
|
71
|
-
61: limitLocators(85070591730234615865843651857942052864, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, 0x55555555555555555555555555555555),
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
def makeCurveMaximum() -> None:
|
|
75
|
-
sys.stdout.write("curveMaximum: dict[int, limitLocators] = {\n")
|
|
76
|
-
for n in range(62):
|
|
77
|
-
curveLocationsMAXIMUM = 1 << (2 * n + 4)
|
|
78
|
-
bifurcationAlphaLocator = int('01' * ((curveLocationsMAXIMUM.bit_length() + 1) // 2), 2)
|
|
79
|
-
sys.stdout.write(f"{n}: limitLocators({curveLocationsMAXIMUM}, {hex(bifurcationAlphaLocator << 1)}, {hex(bifurcationAlphaLocator)}),\n")
|
|
80
|
-
sys.stdout.write("}\n")
|
|
81
|
-
|
|
82
|
-
if __name__ == '__main__':
|
|
83
|
-
makeCurveMaximum()
|
|
84
|
-
|