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,6 +1,44 @@
|
|
|
1
|
-
from
|
|
1
|
+
from functools import cache
|
|
2
2
|
from mapFolding.dataBaskets import MatrixMeandersState
|
|
3
3
|
|
|
4
|
+
@cache
|
|
5
|
+
def walkDyckPath(intWithExtra_0b1: int) -> int:
|
|
6
|
+
"""Find the bit position for flipping paired curve endpoints in meander transfer matrices.
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
----------
|
|
10
|
+
intWithExtra_0b1 : int
|
|
11
|
+
Binary representation of curve locations with an extra bit encoding parity information.
|
|
12
|
+
|
|
13
|
+
Returns
|
|
14
|
+
-------
|
|
15
|
+
flipExtra_0b1_Here : int
|
|
16
|
+
Bit mask indicating the position where the balance condition fails, formatted as 2^(2k).
|
|
17
|
+
|
|
18
|
+
3L33T H@X0R
|
|
19
|
+
------------
|
|
20
|
+
Binary search for first negative balance in shifted bit pairs. Returns 2^(2k) mask for
|
|
21
|
+
bit position k where cumulative balance counter transitions from non-negative to negative.
|
|
22
|
+
|
|
23
|
+
Mathematics
|
|
24
|
+
-----------
|
|
25
|
+
Implements the Dyck path balance verification algorithm from Jensen's transfer matrix
|
|
26
|
+
enumeration. Computes the position where ∑(i=0 to k) (-1)^b_i < 0 for the first time,
|
|
27
|
+
where b_i are the bits of the input at positions 2i.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
findTheExtra_0b1: int = 0
|
|
31
|
+
flipExtra_0b1_Here: int = 1
|
|
32
|
+
while True:
|
|
33
|
+
flipExtra_0b1_Here <<= 2
|
|
34
|
+
if intWithExtra_0b1 & flipExtra_0b1_Here == 0:
|
|
35
|
+
findTheExtra_0b1 += 1
|
|
36
|
+
else:
|
|
37
|
+
findTheExtra_0b1 -= 1
|
|
38
|
+
if findTheExtra_0b1 < 0:
|
|
39
|
+
break
|
|
40
|
+
return flipExtra_0b1_Here
|
|
41
|
+
|
|
4
42
|
def count(state: MatrixMeandersState) -> MatrixMeandersState:
|
|
5
43
|
"""Count meanders with matrix transfer algorithm using Python `int` (*int*eger) contained in a Python `dict` (*dict*ionary).
|
|
6
44
|
|
|
@@ -11,52 +49,53 @@ def count(state: MatrixMeandersState) -> MatrixMeandersState:
|
|
|
11
49
|
|
|
12
50
|
Notes
|
|
13
51
|
-----
|
|
14
|
-
The matrix transfer algorithm is sophisticated, but this implementation is straightforward: compute each
|
|
15
|
-
compute each `arcCode` one at a time, and compute each type of analysis one at a time.
|
|
52
|
+
The matrix transfer algorithm is sophisticated, but this implementation is straightforward: compute each `boundary` one at a
|
|
53
|
+
time, compute each `arcCode` one at a time, and compute each type of analysis one at a time.
|
|
16
54
|
"""
|
|
17
55
|
dictionaryArcCodeToCrossings: dict[int, int] = {}
|
|
18
56
|
|
|
19
57
|
while state.boundary > 0:
|
|
20
|
-
state.
|
|
21
|
-
state.bitWidth = max(state.dictionaryMeanders.keys()).bit_length()
|
|
58
|
+
state.reduceBoundary()
|
|
22
59
|
|
|
23
60
|
dictionaryArcCodeToCrossings = state.dictionaryMeanders.copy()
|
|
24
61
|
state.dictionaryMeanders = {}
|
|
25
62
|
|
|
26
|
-
|
|
27
|
-
bitsAlpha: int = arcCode & state.
|
|
28
|
-
bitsZulu: int = (arcCode >> 1) & state.locatorBits
|
|
63
|
+
def analyzeArcCode(arcCode: int, crossings: int) -> None:
|
|
64
|
+
bitsAlpha: int = arcCode & state.bitsLocator
|
|
29
65
|
bitsAlphaHasArcs: bool = bitsAlpha > 1
|
|
30
|
-
bitsZuluHasArcs: bool = bitsZulu > 1
|
|
31
66
|
bitsAlphaIsEven: int = bitsAlpha & 1 ^ 1
|
|
67
|
+
|
|
68
|
+
bitsZulu: int = arcCode >> 1 & state.bitsLocator
|
|
69
|
+
bitsZuluHasArcs: bool = bitsZulu > 1
|
|
32
70
|
bitsZuluIsEven: int = bitsZulu & 1 ^ 1
|
|
33
71
|
|
|
34
|
-
arcCodeAnalysis = (
|
|
35
|
-
# simple
|
|
72
|
+
arcCodeAnalysis: int = (bitsZulu << 1 | bitsAlpha) << 2 | 3 # Evaluate formula step-wise left to right: (parentheses) override precedence.
|
|
36
73
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
37
74
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
38
75
|
|
|
39
76
|
if bitsAlphaHasArcs:
|
|
40
|
-
arcCodeAnalysis =
|
|
77
|
+
arcCodeAnalysis = bitsAlphaIsEven << 1 | bitsAlpha >> 2 | bitsZulu << 3
|
|
41
78
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
42
79
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
43
80
|
|
|
44
81
|
if bitsZuluHasArcs:
|
|
45
|
-
arcCodeAnalysis =
|
|
82
|
+
arcCodeAnalysis = bitsZuluIsEven | bitsAlpha << 2 | bitsZulu >> 1
|
|
46
83
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
47
84
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
48
85
|
|
|
49
86
|
if bitsAlphaHasArcs and bitsZuluHasArcs and (bitsAlphaIsEven or bitsZuluIsEven):
|
|
50
|
-
#
|
|
87
|
+
# NOTE This analysis might modify `bitsAlpha` or `bitsZulu`, so it should be last.
|
|
51
88
|
if bitsAlphaIsEven and not bitsZuluIsEven:
|
|
52
89
|
bitsAlpha ^= walkDyckPath(bitsAlpha)
|
|
53
90
|
elif bitsZuluIsEven and not bitsAlphaIsEven:
|
|
54
91
|
bitsZulu ^= walkDyckPath(bitsZulu)
|
|
55
92
|
|
|
56
|
-
arcCodeAnalysis
|
|
93
|
+
arcCodeAnalysis = (bitsZulu >> 2 << 3 | bitsAlpha) >> 2 # Evaluate formula step-wise left to right: (parentheses) override precedence.
|
|
57
94
|
if arcCodeAnalysis < state.MAXIMUMarcCode:
|
|
58
95
|
state.dictionaryMeanders[arcCodeAnalysis] = state.dictionaryMeanders.get(arcCodeAnalysis, 0) + crossings
|
|
59
96
|
|
|
97
|
+
set(map(analyzeArcCode, dictionaryArcCodeToCrossings.keys(), dictionaryArcCodeToCrossings.values()))
|
|
98
|
+
|
|
60
99
|
dictionaryArcCodeToCrossings = {}
|
|
61
100
|
|
|
62
101
|
return state
|
|
@@ -74,14 +113,16 @@ def doTheNeedful(state: MatrixMeandersState) -> int:
|
|
|
74
113
|
crossings : int
|
|
75
114
|
The computed value of `crossings`.
|
|
76
115
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
116
|
+
Citations
|
|
117
|
+
---------
|
|
118
|
+
- https://github.com/hunterhogan/mapFolding/blob/main/citations/Jensen.bib
|
|
119
|
+
- https://github.com/hunterhogan/mapFolding/blob/main/citations/Howroyd.bib
|
|
80
120
|
|
|
81
121
|
See Also
|
|
82
122
|
--------
|
|
83
123
|
https://oeis.org/A000682
|
|
84
124
|
https://oeis.org/A005316
|
|
125
|
+
https://github.com/archmageirvine/joeis/blob/5dc2148344bff42182e2128a6c99df78044558c5/src/irvine/oeis/a005/A005316.java
|
|
85
126
|
"""
|
|
86
127
|
state = count(state)
|
|
87
128
|
|