hypercomplex-engine 0.5.0__tar.gz → 0.6.0.1__tar.gz

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 (46) hide show
  1. hypercomplex_engine-0.6.0.1/PKG-INFO +28 -0
  2. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/__init__.py +5 -0
  3. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/__init__.py +6 -0
  4. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/fast/bit_utils.py +3 -1
  5. hypercomplex_engine-0.6.0.1/hypercomplex_engine/core/vectorized/__init__.py +6 -0
  6. hypercomplex_engine-0.6.0.1/hypercomplex_engine/core/vectorized/vectorized_standard.py +118 -0
  7. hypercomplex_engine-0.6.0.1/hypercomplex_engine.egg-info/PKG-INFO +28 -0
  8. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine.egg-info/SOURCES.txt +5 -2
  9. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/pyproject.toml +2 -1
  10. hypercomplex_engine-0.6.0.1/tests/test_vectorized_extended.py +420 -0
  11. hypercomplex_engine-0.6.0.1/tests/test_vectorized_standard.py +156 -0
  12. hypercomplex_engine-0.5.0/PKG-INFO +0 -1147
  13. hypercomplex_engine-0.5.0/README.md +0 -1119
  14. hypercomplex_engine-0.5.0/hypercomplex_engine.egg-info/PKG-INFO +0 -1147
  15. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/LICENSE +0 -0
  16. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/NOTICE +0 -0
  17. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/basis_element.py +0 -0
  18. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/basis_notation.py +0 -0
  19. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/fast/__init__.py +0 -0
  20. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/fast/fast_dual.py +0 -0
  21. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/fast/fast_split.py +0 -0
  22. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/fast/fast_standard.py +0 -0
  23. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/holographic/__init__.py +0 -0
  24. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/holographic/dual.py +0 -0
  25. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/holographic/split.py +0 -0
  26. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/holographic/standard.py +0 -0
  27. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/table_builder/__init__.py +0 -0
  28. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/table_builder/common.py +0 -0
  29. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/table_builder/dual.py +0 -0
  30. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/table_builder/split.py +0 -0
  31. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/table_builder/standard.py +0 -0
  32. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/core/validation.py +0 -0
  33. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/facade.py +0 -0
  34. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/printer/__init__.py +0 -0
  35. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/printer/cd_format.py +0 -0
  36. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine/printer/cd_table_printer.py +0 -0
  37. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine.egg-info/dependency_links.txt +0 -0
  38. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine.egg-info/requires.txt +0 -0
  39. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/hypercomplex_engine.egg-info/top_level.txt +0 -0
  40. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/setup.cfg +0 -0
  41. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/tests/test_dual_tuple_regression.py +0 -0
  42. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/tests/test_fast_mode.py +0 -0
  43. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/tests/test_fixes_0_4.py +0 -0
  44. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/tests/test_mega_mother.py +0 -0
  45. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/tests/test_split_dim.py +0 -0
  46. {hypercomplex_engine-0.5.0 → hypercomplex_engine-0.6.0.1}/tests/test_strict_dual_3tuple.py +0 -0
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: hypercomplex-engine
3
+ Version: 0.6.0.1
4
+ Summary: Fast O(1)/O(n) multiplication engine for arbitrary dimensions and table generator for ordinary, split, and dual Cayley-Dickson algebras.
5
+ Author-email: Maher Ben Abdessalem <ba.maher94@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/maher1719/hypercomplex-engine
8
+ Project-URL: Repository, https://github.com/maher1719/hypercomplex-engine
9
+ Project-URL: Preprint: Sign Structure, https://doi.org/10.6084/m9.figshare.33705022
10
+ Keywords: hypercomplex,cayley-dickson,quaternions,octonions,split-algebra,math,physics,geometry,sedenions
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
15
+ Classifier: Topic :: Scientific/Engineering :: Physics
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
22
+ Classifier: Operating System :: OS Independent
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ License-File: NOTICE
27
+ Requires-Dist: numpy>=1.22.0
28
+ Dynamic: license-file
@@ -29,6 +29,8 @@ from .core import (
29
29
  FastStandard,
30
30
  FastSplit,
31
31
  FastDual,
32
+
33
+ VectorizedStandard
32
34
  )
33
35
 
34
36
  from .printer import (
@@ -65,6 +67,9 @@ __all__ = [
65
67
  "FastSplit",
66
68
  "FastDual",
67
69
 
70
+ #VectorizedStandard
71
+ "VectorizedStandard"
72
+
68
73
  # Printer / formatter
69
74
  "CDFormat",
70
75
  "CDTablePrinter",
@@ -20,6 +20,10 @@ from .fast import (
20
20
  FastDual,
21
21
  )
22
22
 
23
+ from .vectorized import (
24
+ VectorizedStandard
25
+ )
26
+
23
27
  __all__ = [
24
28
  "BasisElement",
25
29
  "BasisNotation",
@@ -36,4 +40,6 @@ __all__ = [
36
40
  "FastStandard",
37
41
  "FastSplit",
38
42
  "FastDual",
43
+
44
+ "VectorizedStandard",
39
45
  ]
@@ -17,4 +17,6 @@ def popcount(x: int) -> int:
17
17
  """
18
18
  Number of set bits.
19
19
  """
20
- return int(x).bit_count()
20
+ x=int(x)
21
+ return x.bit_count() if hasattr(x, "bit_count") else bin(x).count("1")
22
+
@@ -0,0 +1,6 @@
1
+ from .vectorized_standard import VectorizedStandard
2
+
3
+
4
+ __all__ = [
5
+ "VectorizedStandard"
6
+ ]
@@ -0,0 +1,118 @@
1
+ import numpy as np
2
+ from ..validation import Validation
3
+
4
+ class VectorizedStandard:
5
+ """
6
+ SIMD-Accelerated O(1) Vectorized Multiplier for Standard Cayley-Dickson Algebras.
7
+ Replaces nested Python loops with C-Level Twisted Convolution via Scatter-Add.
8
+ """
9
+
10
+ @staticmethod
11
+ def _get_np_popcount():
12
+ """Hardware-accelerated popcount for NumPy arrays."""
13
+ try:
14
+ return np.bitwise_count
15
+ except AttributeError:
16
+ def popcount_vec(x):
17
+ x = np.asarray(x, dtype=np.uint64)
18
+ x = x - ((x >> 1) & np.uint64(0x5555555555555555))
19
+ x = (x & np.uint64(0x3333333333333333)) + ((x >> 2) & np.uint64(0x3333333333333333))
20
+ x = (x + (x >> 4)) & np.uint64(0x0F0F0F0F0F0F0F0F)
21
+ return ((x * np.uint64(0x0101010101010101)) >> np.uint64(56)).astype(np.uint8)
22
+ return popcount_vec
23
+
24
+ def multiply_indices_vec(self, i_arr: np.ndarray, j_arr: np.ndarray) -> tuple:
25
+ """
26
+ Vectorized Core O(1) multiplication for arrays of indices.
27
+ Returns: (signs_array, indices_array)
28
+ """
29
+ _popcount = self._get_np_popcount()
30
+ i = np.asarray(i_arr, dtype=np.uint64)
31
+ j = np.asarray(j_arr, dtype=np.uint64)
32
+
33
+ # Target index is always XOR
34
+ idx = i ^ j
35
+
36
+ # Masks for structural cases
37
+ mask_zero = (i == 0) | (j == 0)
38
+ mask_diag = (i == j) & ~mask_zero
39
+
40
+ # Safe guards for nu2 (avoid log2(0) or popcount(-1) issues)
41
+ i_safe = np.where(i == 0, 1, i)
42
+ j_safe = np.where(j == 0, 1, j)
43
+ ij_safe = np.where((i ^ j) == 0, 1, i ^ j)
44
+
45
+ # Vectorized nu2: popcount((x & -x) - 1)
46
+ t = _popcount((ij_safe & -ij_safe) - np.uint64(1)).astype(np.uint64)
47
+ ti = _popcount((i_safe & -i_safe) - np.uint64(1)).astype(np.uint64)
48
+ tj = _popcount((j_safe & -j_safe) - np.uint64(1)).astype(np.uint64)
49
+
50
+ # Branch 1: Diagonal break (t >= ti and t >= tj)
51
+ cond1 = (t >= ti) & (t >= tj)
52
+ s1 = 2 * ((i >> t) & np.uint64(1)).astype(np.int8) - 1
53
+
54
+ # Branch 2: i-axis break (ti > t and ti >= tj)
55
+ cond2 = (~cond1) & (ti >= tj)
56
+ b = (j >> ti) & np.uint64(1)
57
+ j_loc = j & ((np.uint64(1) << ti) - np.uint64(1))
58
+ delta = np.where(j_loc == 0, 1, -1).astype(np.int8)
59
+ s2 = np.where(b == 0, delta, -delta)
60
+
61
+ # Branch 3: j-axis break (tj > t and tj > ti)
62
+ cond3 = ~cond1 & ~cond2
63
+ s3 = 1 - 2 * ((i >> tj) & np.uint64(1)).astype(np.int8)
64
+
65
+ # Combine branches
66
+ s = np.where(cond1, s1, np.where(cond2, s2, s3))
67
+
68
+ # Higher-bit parity correction
69
+ k = np.maximum(np.maximum(t, ti), tj) + np.uint64(1)
70
+ parity = _popcount((i | j) >> k) & np.uint8(1)
71
+ s = np.where(parity == 1, -s, s)
72
+
73
+ # Apply structural overrides
74
+ s = np.where(mask_zero, 1, s)
75
+ s = np.where(mask_diag, -1, s)
76
+
77
+ return s.astype(np.int8), idx
78
+
79
+ def multiply_arrays(self, arr1: np.ndarray, arr2: np.ndarray) -> np.ndarray:
80
+ """
81
+ Full polynomial multiplication using Twisted Convolution via C-Level Scatter-Add.
82
+ Automatically handles sparsity to prevent RAM explosion on high dimensions.
83
+ """
84
+ size1 = len(arr1)
85
+ size2 = len(arr2)
86
+ max_size = max(size1, size2)
87
+
88
+ if max_size <= 1:
89
+ return np.array([arr1[0] * arr2[0]], dtype=np.float64) if size1 > 0 and size2 > 0 else np.zeros(1, dtype=np.float64)
90
+
91
+ # Calculate required power-of-two dimension
92
+ # Equivalent to 1 << math.ceil(math.log2(max_size))
93
+ dim = 1 << (max_size - 1).bit_length()
94
+
95
+ # 1. SPARSE OPTIMIZATION: Isolate non-zero elements
96
+ nz_A = np.nonzero(arr1)[0]
97
+ nz_B = np.nonzero(arr2)[0]
98
+
99
+ if len(nz_A) == 0 or len(nz_B) == 0:
100
+ return np.zeros(dim, dtype=np.float64)
101
+
102
+ # 2. Create the 2D Grid of ONLY the active indices
103
+ I, J = np.meshgrid(nz_A, nz_B, indexing='ij')
104
+
105
+ # 3. Calculate the entire Sign and Index Matrix in one C-level SIMD sweep
106
+ S, V = self.multiply_indices_vec(I, J)
107
+
108
+ # 4. Calculate the Outer Product of ONLY the active coefficients
109
+ M = np.outer(arr1[nz_A], arr2[nz_B])
110
+
111
+ # 5. Apply Signs to the Coefficients
112
+ weighted_M = S.astype(np.float64) * M
113
+
114
+ # 6. C-Level Scatter-Add into the Result Array
115
+ result = np.zeros(dim, dtype=np.float64)
116
+ np.add.at(result, V.ravel(), weighted_M.ravel())
117
+
118
+ return result
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: hypercomplex-engine
3
+ Version: 0.6.0.1
4
+ Summary: Fast O(1)/O(n) multiplication engine for arbitrary dimensions and table generator for ordinary, split, and dual Cayley-Dickson algebras.
5
+ Author-email: Maher Ben Abdessalem <ba.maher94@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/maher1719/hypercomplex-engine
8
+ Project-URL: Repository, https://github.com/maher1719/hypercomplex-engine
9
+ Project-URL: Preprint: Sign Structure, https://doi.org/10.6084/m9.figshare.33705022
10
+ Keywords: hypercomplex,cayley-dickson,quaternions,octonions,split-algebra,math,physics,geometry,sedenions
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
15
+ Classifier: Topic :: Scientific/Engineering :: Physics
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Programming Language :: Python :: 3.15
22
+ Classifier: Operating System :: OS Independent
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ License-File: NOTICE
27
+ Requires-Dist: numpy>=1.22.0
28
+ Dynamic: license-file
@@ -1,6 +1,5 @@
1
1
  LICENSE
2
2
  NOTICE
3
- README.md
4
3
  pyproject.toml
5
4
  hypercomplex_engine/__init__.py
6
5
  hypercomplex_engine/facade.py
@@ -27,6 +26,8 @@ hypercomplex_engine/core/table_builder/common.py
27
26
  hypercomplex_engine/core/table_builder/dual.py
28
27
  hypercomplex_engine/core/table_builder/split.py
29
28
  hypercomplex_engine/core/table_builder/standard.py
29
+ hypercomplex_engine/core/vectorized/__init__.py
30
+ hypercomplex_engine/core/vectorized/vectorized_standard.py
30
31
  hypercomplex_engine/printer/__init__.py
31
32
  hypercomplex_engine/printer/cd_format.py
32
33
  hypercomplex_engine/printer/cd_table_printer.py
@@ -35,4 +36,6 @@ tests/test_fast_mode.py
35
36
  tests/test_fixes_0_4.py
36
37
  tests/test_mega_mother.py
37
38
  tests/test_split_dim.py
38
- tests/test_strict_dual_3tuple.py
39
+ tests/test_strict_dual_3tuple.py
40
+ tests/test_vectorized_extended.py
41
+ tests/test_vectorized_standard.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hypercomplex-engine"
7
- version = "0.5.0"
7
+ version = "0.6.0.1"
8
8
  authors = [
9
9
  { name="Maher Ben Abdessalem", email="ba.maher94@gmail.com" },
10
10
  ]
@@ -31,6 +31,7 @@ classifiers = [
31
31
  "Programming Language :: Python :: 3.12",
32
32
  "Programming Language :: Python :: 3.13",
33
33
  "Programming Language :: Python :: 3.14",
34
+ "Programming Language :: Python :: 3.15",
34
35
  "Operating System :: OS Independent",
35
36
  ]
36
37