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.
Files changed (80) hide show
  1. easyRun/A000682.py +2 -2
  2. easyRun/NOTcountingFolds.py +16 -8
  3. easyRun/countFolds.py +9 -2
  4. easyRun/generateAllModules.py +14 -0
  5. easyRun/meanders.py +4 -4
  6. mapFolding/__init__.py +1 -0
  7. mapFolding/_theSSOT.py +3 -2
  8. mapFolding/_theTypes.py +3 -0
  9. mapFolding/algorithms/A000136constraintPropagation.py +95 -0
  10. mapFolding/algorithms/A000136elimination.py +163 -0
  11. mapFolding/algorithms/A000136eliminationParallel.py +77 -0
  12. mapFolding/algorithms/A086345.py +75 -0
  13. mapFolding/algorithms/matrixMeanders.py +59 -18
  14. mapFolding/algorithms/matrixMeandersNumPyndas.py +841 -0
  15. mapFolding/algorithms/oeisIDbyFormula.py +2 -2
  16. mapFolding/algorithms/symmetricFolds.py +35 -0
  17. mapFolding/basecamp.py +100 -153
  18. mapFolding/dataBaskets.py +142 -65
  19. mapFolding/filesystemToolkit.py +4 -32
  20. mapFolding/oeis.py +5 -12
  21. mapFolding/reference/A086345Wu.py +25 -0
  22. mapFolding/reference/irvineJavaPort.py +3 -3
  23. mapFolding/reference/matrixMeandersAnalysis/signatures.py +3 -0
  24. mapFolding/reference/meandersDumpingGround/matrixMeandersNumPyV1finalForm.py +1 -1
  25. mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +10 -45
  26. mapFolding/someAssemblyRequired/A007822/_asynchronousAnnex.py +51 -0
  27. mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +39 -196
  28. mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +57 -43
  29. mapFolding/someAssemblyRequired/RecipeJob.py +84 -34
  30. mapFolding/someAssemblyRequired/__init__.py +4 -8
  31. mapFolding/someAssemblyRequired/_toolkitContainers.py +38 -7
  32. mapFolding/someAssemblyRequired/infoBooth.py +41 -23
  33. mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +140 -164
  34. mapFolding/someAssemblyRequired/makeJobTheorem2codon.py +63 -96
  35. mapFolding/someAssemblyRequired/makingModules_count.py +26 -30
  36. mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +10 -72
  37. mapFolding/someAssemblyRequired/{mapFolding → mapFoldingModules}/makeMapFoldingModules.py +30 -35
  38. mapFolding/someAssemblyRequired/meanders/makeMeandersModules.py +13 -11
  39. mapFolding/someAssemblyRequired/toolkitMakeModules.py +5 -31
  40. mapFolding/someAssemblyRequired/toolkitNumba.py +3 -2
  41. mapFolding/someAssemblyRequired/transformationTools.py +12 -15
  42. mapFolding/syntheticModules/A007822/algorithm.py +45 -50
  43. mapFolding/syntheticModules/A007822/asynchronous.py +92 -36
  44. mapFolding/syntheticModules/A007822/initializeState.py +19 -23
  45. mapFolding/syntheticModules/A007822/theorem2.py +20 -24
  46. mapFolding/syntheticModules/A007822/theorem2Numba.py +23 -25
  47. mapFolding/syntheticModules/A007822/theorem2Trimmed.py +19 -23
  48. mapFolding/syntheticModules/countParallelNumba.py +1 -2
  49. mapFolding/syntheticModules/daoOfMapFoldingNumba.py +5 -4
  50. mapFolding/syntheticModules/initializeState.py +1 -1
  51. mapFolding/syntheticModules/meanders/bigInt.py +59 -22
  52. mapFolding/syntheticModules/theorem2.py +1 -1
  53. mapFolding/syntheticModules/theorem2Numba.py +30 -9
  54. mapFolding/syntheticModules/theorem2Trimmed.py +2 -2
  55. mapFolding/tests/test_computations.py +29 -3
  56. {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/METADATA +11 -8
  57. mapfolding-0.17.0.dist-info/RECORD +107 -0
  58. mapFolding/_dataPacking.py +0 -68
  59. mapFolding/algorithms/matrixMeandersBeDry.py +0 -182
  60. mapFolding/algorithms/matrixMeandersNumPy.py +0 -333
  61. mapFolding/algorithms/matrixMeandersPandas.py +0 -334
  62. mapFolding/reference/meandersDumpingGround/A005316intOptimized.py +0 -122
  63. mapFolding/reference/meandersDumpingGround/A005316optimized128bit.py +0 -79
  64. mapFolding/reference/meandersDumpingGround/matrixMeandersBaseline.py +0 -65
  65. mapFolding/reference/meandersDumpingGround/matrixMeandersBaselineAnnex.py +0 -84
  66. mapFolding/reference/meandersDumpingGround/matrixMeandersSimpleQueue.py +0 -90
  67. mapFolding/syntheticModules/A007822/algorithmNumba.py +0 -94
  68. mapFolding/syntheticModules/A007822/asynchronousAnnex.py +0 -66
  69. mapFolding/syntheticModules/A007822/asynchronousAnnexNumba.py +0 -70
  70. mapFolding/syntheticModules/A007822/asynchronousNumba.py +0 -79
  71. mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +0 -65
  72. mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +0 -56
  73. mapFolding/syntheticModules/dataPacking.py +0 -26
  74. mapFolding/syntheticModules/dataPackingA007822.py +0 -92
  75. mapfolding-0.16.2.dist-info/RECORD +0 -115
  76. /mapFolding/someAssemblyRequired/{mapFolding → mapFoldingModules}/__init__.py +0 -0
  77. {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/WHEEL +0 -0
  78. {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/entry_points.txt +0 -0
  79. {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/licenses/LICENSE +0 -0
  80. {mapfolding-0.16.2.dist-info → mapfolding-0.17.0.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,44 @@
1
- from mapFolding.algorithms.matrixMeandersBeDry import walkDyckPath
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 index one at a time,
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.boundary -= 1
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
- for arcCode, crossings in dictionaryArcCodeToCrossings.items():
27
- bitsAlpha: int = arcCode & state.locatorBits
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 = ((bitsAlpha | (bitsZulu << 1)) << 2) | 3
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 = (bitsAlpha >> 2) | (bitsZulu << 3) | (bitsAlphaIsEven << 1)
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 = (bitsZulu >> 1) | (bitsAlpha << 2) | bitsZuluIsEven
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
- # aligned
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: int = ((bitsZulu >> 2) << 1) | (bitsAlpha >> 2)
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
- Notes
78
- -----
79
- Citation: https://github.com/hunterhogan/mapFolding/blob/main/citations/Jensen.bibtex
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