mapFolding 0.16.1__py3-none-any.whl → 0.16.2__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 +1 -1
- easyRun/A005316.py +2 -3
- easyRun/NOTcountingFolds.py +3 -3
- easyRun/meanders.py +17 -19
- mapFolding/algorithms/matrixMeanders.py +15 -28
- mapFolding/algorithms/matrixMeandersBeDry.py +34 -116
- mapFolding/algorithms/matrixMeandersNumPy.py +117 -70
- mapFolding/algorithms/matrixMeandersPandas.py +113 -130
- mapFolding/algorithms/oeisIDbyFormula.py +23 -12
- mapFolding/algorithms/zCuzDocStoopidoeisIDbyFormula.py +26 -12
- mapFolding/basecamp.py +140 -242
- mapFolding/dataBaskets.py +14 -30
- mapFolding/reference/A000682facts.py +785 -1264
- mapFolding/reference/A005316facts.py +958 -923
- mapFolding/reference/matrixMeandersAnalysis/signatures.py +2030 -0
- mapFolding/someAssemblyRequired/A007822/A007822rawMaterials.py +2 -2
- mapFolding/someAssemblyRequired/A007822/makeA007822AsynchronousModules.py +83 -21
- mapFolding/someAssemblyRequired/A007822/makeA007822Modules.py +13 -12
- mapFolding/someAssemblyRequired/makeJobTheorem2Numba.py +2 -2
- mapFolding/someAssemblyRequired/makingModules_count.py +88 -80
- mapFolding/someAssemblyRequired/makingModules_doTheNeedful.py +11 -7
- mapFolding/someAssemblyRequired/mapFolding/makeMapFoldingModules.py +3 -3
- mapFolding/someAssemblyRequired/meanders/makeMeandersModules.py +7 -8
- mapFolding/someAssemblyRequired/toolkitMakeModules.py +9 -9
- mapFolding/someAssemblyRequired/transformationTools.py +8 -8
- mapFolding/syntheticModules/A007822/algorithm.py +1 -0
- mapFolding/syntheticModules/A007822/asynchronous.py +6 -4
- mapFolding/syntheticModules/A007822/asynchronousAnnex.py +1 -1
- mapFolding/syntheticModules/A007822/asynchronousAnnexNumba.py +2 -17
- mapFolding/syntheticModules/A007822/asynchronousNumba.py +35 -8
- mapFolding/syntheticModules/A007822/asynchronousTheorem2.py +15 -3
- mapFolding/syntheticModules/A007822/asynchronousTrimmed.py +12 -3
- mapFolding/syntheticModules/A007822/theorem2.py +6 -0
- mapFolding/syntheticModules/A007822/theorem2Numba.py +28 -3
- mapFolding/syntheticModules/A007822/theorem2Trimmed.py +7 -1
- mapFolding/syntheticModules/daoOfMapFoldingNumba.py +2 -4
- mapFolding/syntheticModules/dataPacking.py +3 -5
- mapFolding/syntheticModules/meanders/bigInt.py +24 -34
- mapFolding/syntheticModules/theorem2.py +6 -0
- mapFolding/syntheticModules/theorem2Numba.py +9 -4
- mapFolding/syntheticModules/theorem2Trimmed.py +6 -0
- mapFolding/tests/test_computations.py +1 -1
- mapFolding/zCuzDocStoopid/makeDocstrings.py +2 -0
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/METADATA +1 -1
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/RECORD +49 -48
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/WHEEL +0 -0
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/entry_points.txt +0 -0
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/licenses/LICENSE +0 -0
- {mapfolding-0.16.1.dist-info → mapfolding-0.16.2.dist-info}/top_level.txt +0 -0
|
@@ -12,6 +12,24 @@ import numpy
|
|
|
12
12
|
if TYPE_CHECKING:
|
|
13
13
|
from numpy.lib._arraysetops_impl import UniqueInverseResult
|
|
14
14
|
|
|
15
|
+
"""More ideas for memory efficiency:
|
|
16
|
+
- In `recordAnalysis`, use `numpy.unique_inverse` on the newly added `arcCode`.
|
|
17
|
+
- In `recordAnalysis`, use `numpy.unique_inverse` on `arrayAnalyzed` after adding new `arcCode`.
|
|
18
|
+
- By deduplicating more often, I can decrease the allocated size of `arrayAnalyzed`. However, that may reduce the usefulness of `makeStorage`.
|
|
19
|
+
- I suspect that `makeStorage(numpy.flatnonzero(prepArea)...` contains a latent array.
|
|
20
|
+
- In every case (or almost every case) I use a selector, I _feel_ like there is more memory efficient way I don't know about.
|
|
21
|
+
- It's not clear to me whether or not I am instructing numpy to release _all_ memory I no longer need.
|
|
22
|
+
- Hypothetically, `arcCode` might be compressible, but IDK no nothing.
|
|
23
|
+
- `numpy.unique_inverse` uses a ton of memory, but I've failed to find a better way. BUT I might be able to improve
|
|
24
|
+
`aggregateAnalyzed` now that `arrayArcCodes` is a single axis.
|
|
25
|
+
- For analyzeBitsAlpha and analyzeBitsZulu, find an equivalent formula that does not require a secondary stack.
|
|
26
|
+
- analyzeAligned requires a ton of memory. By analyzing it before the other three analyses (therefore `arrayAnalyzed` is empty)
|
|
27
|
+
and using `makeStorage`, I've offset much of the usage, but I don't have confidence it's a good flow.
|
|
28
|
+
|
|
29
|
+
To mitigate memory problems:
|
|
30
|
+
- Put `arrayAnalyzed` in a `numpy.memmap`.
|
|
31
|
+
"""
|
|
32
|
+
|
|
15
33
|
indicesPrepArea: int = 1
|
|
16
34
|
indexAnalysis = 0
|
|
17
35
|
slicerAnalysis: ShapeSlicer = ShapeSlicer(length=..., indices=indexAnalysis)
|
|
@@ -32,30 +50,20 @@ def countNumPy(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
|
32
50
|
Returns
|
|
33
51
|
-------
|
|
34
52
|
state : MatrixMeandersState
|
|
35
|
-
Updated state including `
|
|
53
|
+
Updated state including `boundary` and `arrayMeanders`.
|
|
36
54
|
"""
|
|
37
|
-
while state.
|
|
55
|
+
while state.boundary > 0 and not areIntegersWide(state):
|
|
38
56
|
def aggregateAnalyzed(arrayAnalyzed: NDArray[numpy.uint64], state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
39
57
|
"""Create new `arrayMeanders` by deduplicating `arcCode` and summing `crossings`."""
|
|
40
58
|
unique: UniqueInverseResult[numpy.uint64] = numpy.unique_inverse(arrayAnalyzed[slicerArcCode])
|
|
41
59
|
|
|
42
|
-
|
|
43
|
-
state.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
state.arrayMeanders[state.slicerArcCode] = unique.values
|
|
47
|
-
numpy.add.at(state.arrayMeanders[state.slicerCrossings], unique.inverse_indices, arrayAnalyzed[slicerCrossings])
|
|
60
|
+
state.arrayArcCodes = unique.values
|
|
61
|
+
state.arrayCrossings = numpy.zeros_like(state.arrayArcCodes, dtype=state.datatypeCrossings)
|
|
62
|
+
numpy.add.at(state.arrayCrossings, unique.inverse_indices, arrayAnalyzed[slicerCrossings])
|
|
48
63
|
del unique
|
|
49
64
|
|
|
50
65
|
return state
|
|
51
66
|
|
|
52
|
-
def bitsAlpha(state: MatrixMeandersNumPyState) -> NDArray[numpy.uint64]:
|
|
53
|
-
return bitwise_and(state.arrayMeanders[state.slicerArcCode], state.locatorBits)
|
|
54
|
-
|
|
55
|
-
def bitsZulu(state: MatrixMeandersNumPyState) -> NDArray[numpy.uint64]:
|
|
56
|
-
IsThisMemoryEfficient: NDArray[numpy.uint64] = bitwise_right_shift(state.arrayMeanders[state.slicerArcCode], 1)
|
|
57
|
-
return bitwise_and(IsThisMemoryEfficient, state.locatorBits)
|
|
58
|
-
|
|
59
67
|
def makeStorage[个: numpy.integer[Any]](dataTarget: NDArray[个], state: MatrixMeandersNumPyState, storageTarget: NDArray[numpy.uint64], indexAssignment: int = indexArcCode) -> NDArray[个]:
|
|
60
68
|
"""Store `dataTarget` in `storageTarget` on `indexAssignment` if there is enough space, otherwise allocate a new array."""
|
|
61
69
|
lengthStorageTarget: int = len(storageTarget)
|
|
@@ -87,24 +95,23 @@ def countNumPy(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
|
87
95
|
selectorAnalysis: NDArray[numpy.intp] = numpy.flatnonzero(arcCode)
|
|
88
96
|
|
|
89
97
|
indexStop: int = state.indexTarget + len(selectorAnalysis)
|
|
90
|
-
|
|
98
|
+
sliceAnalysis: slice = slice(state.indexTarget, indexStop)
|
|
91
99
|
state.indexTarget = indexStop
|
|
92
100
|
del indexStop
|
|
93
101
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
del
|
|
97
|
-
|
|
98
|
-
arrayAnalyzed[slicerArcCodeNonzero] = arcCode[selectorAnalysis]
|
|
99
|
-
del slicerArcCodeNonzero
|
|
102
|
+
slicerArcCodeAnalysis = ShapeSlicer(length=sliceAnalysis, indices=indexArcCode)
|
|
103
|
+
slicerCrossingsAnalysis = ShapeSlicer(length=sliceAnalysis, indices=indexCrossings)
|
|
104
|
+
del sliceAnalysis
|
|
100
105
|
|
|
101
|
-
arrayAnalyzed[
|
|
102
|
-
del
|
|
106
|
+
arrayAnalyzed[slicerArcCodeAnalysis] = arcCode[selectorAnalysis]
|
|
107
|
+
del slicerArcCodeAnalysis
|
|
103
108
|
|
|
109
|
+
arrayAnalyzed[slicerCrossingsAnalysis] = state.arrayCrossings[selectorAnalysis]
|
|
110
|
+
del slicerCrossingsAnalysis, selectorAnalysis
|
|
111
|
+
goByeBye()
|
|
104
112
|
return state
|
|
105
113
|
|
|
106
|
-
|
|
107
|
-
state.bitWidth = int(state.arrayMeanders[state.slicerArcCode].max()).bit_length()
|
|
114
|
+
state.bitWidth = int(state.arrayArcCodes.max()).bit_length()
|
|
108
115
|
|
|
109
116
|
lengthArrayAnalyzed: int = getBucketsTotal(state, 1.2)
|
|
110
117
|
shape = ShapeArray(length=lengthArrayAnalyzed, indices=indicesAnalyzed)
|
|
@@ -114,7 +121,7 @@ def countNumPy(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
|
114
121
|
arrayAnalyzed: NDArray[numpy.uint64] = numpy.zeros(shape, dtype=state.datatypeArcCode)
|
|
115
122
|
del shape
|
|
116
123
|
|
|
117
|
-
shape = ShapeArray(length=len(state.
|
|
124
|
+
shape = ShapeArray(length=len(state.arrayArcCodes), indices=indicesPrepArea)
|
|
118
125
|
arrayPrepArea: NDArray[numpy.uint64] = numpy.zeros(shape, dtype=state.datatypeArcCode)
|
|
119
126
|
del shape
|
|
120
127
|
|
|
@@ -122,122 +129,158 @@ def countNumPy(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
|
122
129
|
|
|
123
130
|
state.indexTarget = 0
|
|
124
131
|
|
|
125
|
-
state.
|
|
132
|
+
state.boundary -= 1
|
|
126
133
|
|
|
127
134
|
# =============== analyze aligned ===== if bitsAlpha > 1 and bitsZulu > 1 =============================================
|
|
135
|
+
arrayBitsAlpha: NDArray[numpy.uint64] = bitwise_and(state.arrayArcCodes, state.locatorBits) # NOTE extra array
|
|
128
136
|
# ======= > * > bitsAlpha 1 bitsZulu 1 ====================
|
|
129
|
-
greater(
|
|
130
|
-
|
|
137
|
+
greater(arrayBitsAlpha, 1, out=prepArea)
|
|
138
|
+
bitsZuluStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexCrossings)
|
|
139
|
+
bitwise_right_shift(bitsZuluStack, 1, out=bitsZuluStack) # O indexArcCode X indexCrossings
|
|
140
|
+
bitwise_and(bitsZuluStack, state.locatorBits, out=bitsZuluStack)
|
|
141
|
+
multiply(bitsZuluStack, prepArea, out=prepArea)
|
|
131
142
|
greater(prepArea, 1, out=prepArea)
|
|
132
143
|
selectorGreaterThan1: NDArray[numpy.uint64] = makeStorage(prepArea, state, arrayAnalyzed, indexArcCode)
|
|
133
|
-
|
|
144
|
+
# X indexArcCode X indexCrossings
|
|
134
145
|
# ======= if bitsAlphaAtEven and not bitsZuluAtEven =======
|
|
135
146
|
# ======= ^ & | ^ & bitsZulu 1 1 bitsAlpha 1 1 ============
|
|
136
|
-
bitwise_and(
|
|
147
|
+
bitwise_and(bitsZuluStack, 1, out=prepArea)
|
|
148
|
+
del bitsZuluStack # X indexArcCode O indexCrossings
|
|
137
149
|
bitwise_xor(prepArea, 1, out=prepArea)
|
|
138
|
-
bitwise_or(
|
|
150
|
+
bitwise_or(arrayBitsAlpha, prepArea, out=prepArea)
|
|
139
151
|
bitwise_and(prepArea, 1, out=prepArea)
|
|
140
152
|
bitwise_xor(prepArea, 1, out=prepArea)
|
|
141
153
|
|
|
142
154
|
bitwise_and(selectorGreaterThan1, prepArea, out=prepArea)
|
|
143
155
|
selectorAlignAlpha: NDArray[numpy.intp] = makeStorage(numpy.flatnonzero(prepArea), state, arrayAnalyzed, indexCrossings)
|
|
144
|
-
|
|
145
|
-
arrayBitsAlpha: NDArray[numpy.uint64] = bitsAlpha(state)
|
|
146
|
-
|
|
156
|
+
# X indexArcCode X indexCrossings
|
|
147
157
|
arrayBitsAlpha[selectorAlignAlpha] = flipTheExtra_0b1AsUfunc(arrayBitsAlpha[selectorAlignAlpha])
|
|
148
|
-
del selectorAlignAlpha
|
|
158
|
+
del selectorAlignAlpha # X indexArcCode O indexCrossings
|
|
149
159
|
|
|
150
160
|
# ======= if bitsZuluAtEven and not bitsAlphaAtEven =======
|
|
151
161
|
# ======= ^ & | ^ & bitsAlpha 1 1 bitsZulu 1 1 ============
|
|
152
|
-
|
|
162
|
+
bitsAlphaStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexCrossings)
|
|
163
|
+
bitwise_and(bitsAlphaStack, state.locatorBits, out=bitsAlphaStack)
|
|
164
|
+
bitwise_and(bitsAlphaStack, 1, out=prepArea)
|
|
165
|
+
del bitsAlphaStack # X indexArcCode O indexCrossings
|
|
153
166
|
bitwise_xor(prepArea, 1, out=prepArea)
|
|
154
|
-
|
|
167
|
+
bitsZuluStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexCrossings)
|
|
168
|
+
bitwise_right_shift(bitsZuluStack, 1, out=bitsZuluStack)
|
|
169
|
+
bitwise_and(bitsZuluStack, state.locatorBits, out=bitsZuluStack)
|
|
170
|
+
bitwise_or(bitsZuluStack, prepArea, out=prepArea)
|
|
171
|
+
del bitsZuluStack # X indexArcCode O indexCrossings
|
|
155
172
|
bitwise_and(prepArea, 1, out=prepArea)
|
|
156
173
|
bitwise_xor(prepArea, 1, out=prepArea)
|
|
157
174
|
|
|
158
175
|
bitwise_and(selectorGreaterThan1, prepArea, out=prepArea)
|
|
159
176
|
selectorAlignZulu: NDArray[numpy.intp] = makeStorage(numpy.flatnonzero(prepArea), state, arrayAnalyzed, indexCrossings)
|
|
160
|
-
|
|
177
|
+
# X indexArcCode X indexCrossings
|
|
161
178
|
# ======= bitsAlphaAtEven or bitsZuluAtEven ===============
|
|
179
|
+
bitwise_and(state.arrayArcCodes, state.locatorBits, out=prepArea)
|
|
162
180
|
# ======= ^ & & bitsAlpha 1 bitsZulu 1 ====================
|
|
163
|
-
bitwise_and(
|
|
164
|
-
|
|
181
|
+
bitwise_and(prepArea, 1, out=prepArea)
|
|
182
|
+
sherpaBitsZulu: NDArray[numpy.uint64] = bitwise_right_shift(state.arrayArcCodes, 1) # NOTE 2° extra array
|
|
183
|
+
bitwise_and(sherpaBitsZulu, state.locatorBits, out=sherpaBitsZulu)
|
|
184
|
+
bitwise_and(sherpaBitsZulu, prepArea, out=prepArea)
|
|
185
|
+
del sherpaBitsZulu # NOTE del 2° extra array
|
|
165
186
|
bitwise_xor(prepArea, 1, out=prepArea)
|
|
166
187
|
|
|
167
188
|
bitwise_and(selectorGreaterThan1, prepArea, out=prepArea) # selectorBitsAtEven
|
|
168
|
-
del selectorGreaterThan1
|
|
189
|
+
del selectorGreaterThan1 # O indexArcCode X indexCrossings
|
|
169
190
|
bitwise_xor(prepArea, 1, out=prepArea)
|
|
170
191
|
selectorDisqualified: NDArray[numpy.intp] = makeStorage(numpy.flatnonzero(prepArea), state, arrayAnalyzed, indexArcCode)
|
|
171
|
-
|
|
172
|
-
|
|
192
|
+
# X indexArcCode X indexCrossings
|
|
193
|
+
bitwise_right_shift(state.arrayArcCodes, 1, out=prepArea)
|
|
194
|
+
bitwise_and(prepArea, state.locatorBits, out=prepArea)
|
|
173
195
|
|
|
174
196
|
prepArea[selectorAlignZulu] = flipTheExtra_0b1AsUfunc(prepArea[selectorAlignZulu])
|
|
175
|
-
del selectorAlignZulu
|
|
197
|
+
del selectorAlignZulu # X indexArcCode O indexCrossings
|
|
176
198
|
|
|
177
|
-
|
|
199
|
+
bitsZuluStack: NDArray[numpy.uint64] = makeStorage(prepArea, state, arrayAnalyzed, indexCrossings)
|
|
178
200
|
|
|
179
201
|
# ======= (((bitsZulu >> 2) << 3) | bitsAlpha) >> 2 =======
|
|
180
202
|
# ======= >> | << >> bitsZulu 2 3 bitsAlpha 2 =============
|
|
181
|
-
bitwise_right_shift(
|
|
182
|
-
del
|
|
203
|
+
bitwise_right_shift(bitsZuluStack, 2, out=prepArea)
|
|
204
|
+
del bitsZuluStack # X indexArcCode O indexCrossings
|
|
183
205
|
bitwise_left_shift(prepArea, 3, out=prepArea)
|
|
184
206
|
bitwise_or(arrayBitsAlpha, prepArea, out=prepArea)
|
|
185
|
-
del arrayBitsAlpha
|
|
207
|
+
del arrayBitsAlpha # NOTE del extra array
|
|
186
208
|
bitwise_right_shift(prepArea, 2, out=prepArea)
|
|
187
209
|
|
|
188
210
|
prepArea[selectorDisqualified] = 0
|
|
189
|
-
del selectorDisqualified
|
|
211
|
+
del selectorDisqualified # O indexArcCode O indexCrossings
|
|
190
212
|
|
|
191
213
|
state = recordAnalysis(arrayAnalyzed, state, prepArea)
|
|
192
214
|
|
|
193
215
|
# ----------------- analyze bitsAlpha ------- (bitsAlpha >> 2) | (bitsZulu << 3) | ((1 - (bitsAlpha & 1)) << 1) ---------
|
|
216
|
+
bitsAlphaStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexArcCode)
|
|
217
|
+
bitwise_and(bitsAlphaStack, state.locatorBits, out=bitsAlphaStack) # X indexArcCode O indexCrossings
|
|
194
218
|
# ------- >> | << | (<< - 1 & bitsAlpha 1 1) << bitsZulu 3 2 bitsAlpha 2 ----------
|
|
195
|
-
bitsAlphaStack: NDArray[numpy.uint64] = makeStorage(bitsAlpha(state), state, arrayAnalyzed, indexCrossings)
|
|
196
219
|
bitwise_and(bitsAlphaStack, 1, out=bitsAlphaStack)
|
|
197
220
|
subtract(1, bitsAlphaStack, out=bitsAlphaStack)
|
|
198
221
|
bitwise_left_shift(bitsAlphaStack, 1, out=bitsAlphaStack)
|
|
199
|
-
|
|
222
|
+
bitsZuluStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexCrossings)
|
|
223
|
+
bitwise_right_shift(bitsZuluStack, 1, out=bitsZuluStack)
|
|
224
|
+
bitwise_and(bitsZuluStack, state.locatorBits, out=bitsZuluStack)
|
|
225
|
+
bitwise_left_shift(bitsZuluStack, 3, out=prepArea)
|
|
226
|
+
del bitsZuluStack # X indexArcCode O indexCrossings
|
|
200
227
|
bitwise_or(bitsAlphaStack, prepArea, out=prepArea)
|
|
201
|
-
del bitsAlphaStack
|
|
228
|
+
del bitsAlphaStack # O indexArcCode O indexCrossings
|
|
202
229
|
bitwise_left_shift(prepArea, 2, out=prepArea)
|
|
203
|
-
|
|
230
|
+
bitsAlphaStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexCrossings)
|
|
231
|
+
bitwise_and(bitsAlphaStack, state.locatorBits, out=bitsAlphaStack) # O indexArcCode X indexCrossings
|
|
232
|
+
bitwise_or(bitsAlphaStack, prepArea, out=prepArea)
|
|
204
233
|
bitwise_right_shift(prepArea, 2, out=prepArea)
|
|
205
234
|
|
|
206
235
|
# ------- if bitsAlpha > 1 ------------ > bitsAlpha 1 -----
|
|
207
|
-
bitsAlphaStack: NDArray[numpy.uint64] = makeStorage(bitsAlpha(state), state, arrayAnalyzed, indexCrossings)
|
|
208
236
|
less_equal(bitsAlphaStack, 1, out=bitsAlphaStack)
|
|
209
237
|
selectorUnderLimit: NDArray[numpy.intp] = makeStorage(numpy.flatnonzero(bitsAlphaStack), state, arrayAnalyzed, indexArcCode)
|
|
238
|
+
del bitsAlphaStack # X indexArcCode O indexCrossings
|
|
210
239
|
prepArea[selectorUnderLimit] = 0
|
|
211
|
-
del selectorUnderLimit
|
|
240
|
+
del selectorUnderLimit # O indexArcCode O indexCrossings
|
|
212
241
|
|
|
213
242
|
state = recordAnalysis(arrayAnalyzed, state, prepArea)
|
|
214
243
|
|
|
215
244
|
# ----------------- analyze bitsZulu ---------- (bitsZulu >> 1) | (bitsAlpha << 2) | (1 - (bitsZulu & 1)) -------------
|
|
245
|
+
arrayBitsZulu: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexCrossings)
|
|
246
|
+
arrayBitsZulu = bitwise_right_shift(arrayBitsZulu, 1) # O indexArcCode X indexCrossings
|
|
247
|
+
arrayBitsZulu = bitwise_and(arrayBitsZulu, state.locatorBits)
|
|
216
248
|
# ------- >> | << | (- 1 & bitsZulu 1) << bitsAlpha 2 1 bitsZulu 1 ----------
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
del
|
|
249
|
+
bitwise_and(arrayBitsZulu, 1, out=arrayBitsZulu)
|
|
250
|
+
subtract(1, arrayBitsZulu, out=arrayBitsZulu)
|
|
251
|
+
bitsAlphaStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexArcCode)
|
|
252
|
+
bitwise_and(bitsAlphaStack, state.locatorBits, out=bitsAlphaStack) # X indexArcCode X indexCrossings
|
|
253
|
+
bitwise_left_shift(bitsAlphaStack, 2, out=prepArea)
|
|
254
|
+
del bitsAlphaStack # O indexArcCode X indexCrossings
|
|
255
|
+
bitwise_or(arrayBitsZulu, prepArea, out=prepArea)
|
|
256
|
+
del arrayBitsZulu # O indexArcCode O indexCrossings
|
|
223
257
|
bitwise_left_shift(prepArea, 1, out=prepArea)
|
|
224
|
-
|
|
258
|
+
bitsZuluStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexCrossings)
|
|
259
|
+
bitwise_right_shift(bitsZuluStack, 1, out=bitsZuluStack) # O indexArcCode X indexCrossings
|
|
260
|
+
bitwise_and(bitsZuluStack, state.locatorBits, out=bitsZuluStack)
|
|
261
|
+
bitwise_or(bitsZuluStack, prepArea, out=prepArea)
|
|
225
262
|
bitwise_right_shift(prepArea, 1, out=prepArea)
|
|
226
263
|
|
|
227
264
|
# ------- if bitsZulu > 1 ------------- > bitsZulu 1 ------
|
|
228
|
-
bitsZuluStack: NDArray[numpy.uint64] = makeStorage(bitsZulu(state), state, arrayAnalyzed, indexCrossings)
|
|
229
265
|
less_equal(bitsZuluStack, 1, out=bitsZuluStack)
|
|
230
266
|
selectorUnderLimit = makeStorage(numpy.flatnonzero(bitsZuluStack), state, arrayAnalyzed, indexArcCode)
|
|
231
|
-
del bitsZuluStack
|
|
267
|
+
del bitsZuluStack # X indexArcCode O indexCrossings
|
|
232
268
|
prepArea[selectorUnderLimit] = 0
|
|
233
|
-
del selectorUnderLimit
|
|
269
|
+
del selectorUnderLimit # O indexArcCode O indexCrossings
|
|
234
270
|
|
|
235
271
|
state = recordAnalysis(arrayAnalyzed, state, prepArea)
|
|
236
272
|
|
|
237
273
|
# ----------------- analyze simple ------------------------ ((bitsAlpha | (bitsZulu << 1)) << 2) | 3 ------------------
|
|
274
|
+
bitsZuluStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexCrossings)
|
|
275
|
+
bitwise_right_shift(bitsZuluStack, 1, out=bitsZuluStack) # O indexArcCode X indexCrossings
|
|
276
|
+
bitwise_and(bitsZuluStack, state.locatorBits, out=bitsZuluStack)
|
|
238
277
|
# ------- | << | bitsAlpha << bitsZulu 1 2 3 --------------
|
|
239
|
-
bitwise_left_shift(
|
|
240
|
-
|
|
278
|
+
bitwise_left_shift(bitsZuluStack, 1, out=prepArea)
|
|
279
|
+
del bitsZuluStack # O indexArcCode O indexCrossings
|
|
280
|
+
bitsAlphaStack: NDArray[numpy.uint64] = makeStorage(state.arrayArcCodes, state, arrayAnalyzed, indexArcCode)
|
|
281
|
+
bitwise_and(bitsAlphaStack, state.locatorBits, out=bitsAlphaStack) # X indexArcCode O indexCrossings
|
|
282
|
+
bitwise_or(bitsAlphaStack, prepArea, out=prepArea)
|
|
283
|
+
del bitsAlphaStack # O indexArcCode O indexCrossings
|
|
241
284
|
bitwise_left_shift(prepArea, 2, out=prepArea)
|
|
242
285
|
bitwise_or(prepArea, 3, out=prepArea)
|
|
243
286
|
|
|
@@ -245,6 +288,7 @@ def countNumPy(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
|
245
288
|
|
|
246
289
|
del prepArea, arrayPrepArea
|
|
247
290
|
# ----------------------------------------------- aggregation ---------------------------------------------------------
|
|
291
|
+
state.arrayArcCodes = numpy.zeros((0,), dtype=state.datatypeArcCode)
|
|
248
292
|
arrayAnalyzed.resize((state.indexTarget, indicesAnalyzed))
|
|
249
293
|
|
|
250
294
|
goByeBye()
|
|
@@ -252,6 +296,9 @@ def countNumPy(state: MatrixMeandersNumPyState) -> MatrixMeandersNumPyState:
|
|
|
252
296
|
|
|
253
297
|
del arrayAnalyzed
|
|
254
298
|
|
|
299
|
+
if state.n >= 45:
|
|
300
|
+
# oeisID,n,boundary,buckets,arcCodes,arcCodeBitWidth,crossingsBitWidth
|
|
301
|
+
print(state.oeisID, state.n, state.boundary+1, state.indexTarget, len(state.arrayArcCodes), int(state.arrayArcCodes.max()).bit_length(), int(state.arrayCrossings.max()).bit_length(), sep=',') # noqa: T201
|
|
255
302
|
return state
|
|
256
303
|
|
|
257
304
|
def doTheNeedful(state: MatrixMeandersNumPyState) -> int:
|
|
@@ -276,7 +323,7 @@ def doTheNeedful(state: MatrixMeandersNumPyState) -> int:
|
|
|
276
323
|
https://oeis.org/A000682
|
|
277
324
|
https://oeis.org/A005316
|
|
278
325
|
"""
|
|
279
|
-
while state.
|
|
326
|
+
while state.boundary > 0:
|
|
280
327
|
if areIntegersWide(state):
|
|
281
328
|
state = countBigInt(state)
|
|
282
329
|
else:
|