hypercomplex-engine 0.4.0__py3-none-any.whl → 0.4.1__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.
@@ -125,18 +125,24 @@ class FastDual:
125
125
  (final_sign, local_index, eps_flag)
126
126
  """
127
127
  dim = Validation.dimension(dim)
128
+ Validation.basis_tuple(t1, allow_zero=True, allow_eps=True)
129
+ Validation.basis_tuple(t2, allow_zero=True, allow_eps=True)
128
130
 
129
- s1, i = self._extract_global(t1, dim)
130
- s2, j = self._extract_global(t2, dim)
131
+
132
+
133
+ s1, i = int(t1[0]), int(t1[1])
134
+ s2, j = int(t2[0]), int(t2[1])
135
+ i_eps_flag = int(t1[2]) if len(t1) == 3 else 0
136
+ j_eps_flag = int(t2[2]) if len(t2) == 3 else 0
131
137
 
132
138
  if s1 == 0 or s2 == 0:
133
139
  return (0, 0, 0)
134
140
 
135
- sign, idx, eps = self.multiply_indices(i, j, dim)
141
+ sign, idx, eps = self.multiply_indices(i, j,dim,i_eps_flag,j_eps_flag)
136
142
 
137
143
  return (s1 * s2 * sign, idx, eps)
138
144
 
139
- def multiply_indices(self, i: int, j: int, dim: int) -> tuple:
145
+ def multiply_indices(self, i: int, j: int,dim:int, i_eps_flag=0 ,j_eps_flag=0) -> tuple:
140
146
  """
141
147
  Core dual O(1) multiplication using global indices.
142
148
 
@@ -156,8 +162,8 @@ class FastDual:
156
162
  if j < 0 or j >= total:
157
163
  raise ValueError(f"index must be in [0, {total - 1}] for dual dim={dim}, got {j}")
158
164
 
159
- i_eps = i >= half
160
- j_eps = j >= half
165
+ i_eps = i >= half or i_eps_flag
166
+ j_eps = j >= half or j_eps_flag
161
167
 
162
168
  i_loc = i & (half - 1)
163
169
  j_loc = j & (half - 1)
@@ -28,8 +28,8 @@ class FastStandard:
28
28
  Returns:
29
29
  (final_sign, index1 XOR index2)
30
30
  """
31
- Validation.basis_tuple(t1, allow_zero=True, allow_eps=False)
32
- Validation.basis_tuple(t2, allow_zero=True, allow_eps=False)
31
+ Validation.basis_tuple(t1, allow_zero=False, allow_eps=False)
32
+ Validation.basis_tuple(t2, allow_zero=False, allow_eps=False)
33
33
 
34
34
  s1, i = int(t1[0]), int(t1[1])
35
35
  s2, j = int(t2[0]), int(t2[1])
@@ -48,7 +48,8 @@ class DualHolographic:
48
48
 
49
49
  s1, i = int(t1[0]), int(t1[1])
50
50
  s2, j = int(t2[0]), int(t2[1])
51
-
51
+ i_eps_flag = int(t1[2]) if len(t1) == 3 else 0
52
+ j_eps_flag = int(t2[2]) if len(t2) == 3 else 0
52
53
  # Zero propagates.
53
54
  if s1 == 0 or s2 == 0:
54
55
  return (0, 0, 0)
@@ -63,8 +64,8 @@ class DualHolographic:
63
64
 
64
65
  half = 1 << dim
65
66
 
66
- i_eps = i >= half
67
- j_eps = j >= half
67
+ i_eps = i >= half or i_eps_flag
68
+ j_eps = j >= half or j_eps_flag
68
69
 
69
70
  i_loc = i & (half - 1)
70
71
  j_loc = j & (half - 1)
@@ -59,6 +59,7 @@ class Validation:
59
59
 
60
60
  if len(data) == 3 and not allow_eps:
61
61
  raise ValueError("3-tuple epsilon form is not allowed here")
62
+
62
63
 
63
64
  sign = data[0]
64
65
  index = data[1]
hypercomplex/facade.py CHANGED
@@ -264,6 +264,11 @@ def multiply(
264
264
  # required, never inferred. Validate before anything else.
265
265
  if kind in ("split", "dual", "dual_split") and dim is None:
266
266
  raise ValueError(f"dim is required for {kind} multiplication")
267
+ # Validate inputs before any early return, so malformed data always
268
+ # raises ValidationError instead of leaking TypeError/IndexError.
269
+ allow_eps = kind in ("dual", "dual_split")
270
+ Validation.basis_tuple(a, allow_zero=True, allow_eps=allow_eps)
271
+ Validation.basis_tuple(b, allow_zero=True, allow_eps=allow_eps)
267
272
 
268
273
  # Zero propagation
269
274
  if int(a[0]) == 0 or int(b[0]) == 0:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hypercomplex-engine
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: Fast O(1)/O(n) multiplication engine and table generator for ordinary, split, and dual Cayley-Dickson algebras.
5
5
  Author-email: Maher Ben Abdessalem <ba.maher94@gmail.com>
6
6
  License: MIT License
@@ -1,16 +1,16 @@
1
1
  hypercomplex/__init__.py,sha256=DM_jeWSzhDkdz8KboGrVQVqVaj6xkr8k22C_uNRRxr8,1010
2
- hypercomplex/facade.py,sha256=qneXgwLehlvec4f18jFQ_VnsTYmSiUoyswLqlE0nOes,9195
2
+ hypercomplex/facade.py,sha256=zuG5HnbDxBCn6V7OroaAhYYb4HzL-6QVaUQprhdDNwg,9528
3
3
  hypercomplex/core/__init__.py,sha256=7cD5SJFbAewuVMIvKnQ6tb7JwcmpGQktSvGbN5n8dIM,668
4
4
  hypercomplex/core/basis_element.py,sha256=TnPb1xLICv0TK0AfTW_I8_8T2TavktKTq4MEPLWnyU8,1402
5
5
  hypercomplex/core/basis_notation.py,sha256=K17IUXEio7KmY3pvpFdDFI2MsLs11-E5Z5Cp10CS84Y,4887
6
- hypercomplex/core/validation.py,sha256=_W23VmbWZh0OB7pIG4Pbm--N75Vdomh3hbHCRVXTTek,3165
6
+ hypercomplex/core/validation.py,sha256=1ehTiV2fuV9ahGaGcDswWqUJMBzmGcYQ-3wY8lbrd7k,3174
7
7
  hypercomplex/core/fast/__init__.py,sha256=6KsWo1dhNlT69jT_Bi8-khOrNFX9cDs98987TGTXo4w,173
8
8
  hypercomplex/core/fast/bit_utils.py,sha256=aqBjPX2srWym6AjxZqTzt998-in_-5VAxNUiQXUFAVw,385
9
- hypercomplex/core/fast/fast_dual.py,sha256=8y7U5pV2JIhMYtsiuLAaei977VUPo6DVx48kGH6DPoE,5223
9
+ hypercomplex/core/fast/fast_dual.py,sha256=Y5JFtGunb9p9qezogqPBWJfjNdiijtXV1LsKJXEENqY,5540
10
10
  hypercomplex/core/fast/fast_split.py,sha256=Wdr9pd9zXA_mFzlMxVv8LpPwDZJFP-XPVa0uQIEs3jA,3037
11
- hypercomplex/core/fast/fast_standard.py,sha256=S4ujHlp0Q_Z07jFKbpmFzrqYvf-zZTrIGm_LLwTwQUE,3306
11
+ hypercomplex/core/fast/fast_standard.py,sha256=KRZk7HPfV2J364p5x22kgveJa7ztucbsTla7emix_Kk,3308
12
12
  hypercomplex/core/holographic/__init__.py,sha256=TGMyPs6dyeaQ9I--rFooBOrKzkex73IbwzQtL7Q0i04,200
13
- hypercomplex/core/holographic/dual.py,sha256=6ntw2Uwz6hI18ogHrsC3e2XmZrkTb2qQy8hbMWqoV4E,2761
13
+ hypercomplex/core/holographic/dual.py,sha256=1JdYDPpFk7u0yMswDOxRhhEUcg4CDxCu3Rk-a1rDImA,2898
14
14
  hypercomplex/core/holographic/split.py,sha256=kJXPXvw3rT8YieENor0hNTko4qBoXaKKb9n07UWhfQY,2864
15
15
  hypercomplex/core/holographic/standard.py,sha256=nNgM0QxvWXVMlTenHdxKd63RvLOkF_xu1cB0f00EumA,3935
16
16
  hypercomplex/core/table_builder/__init__.py,sha256=qkKJQ1S44hlSeNdW-Cc9REvbCeU2K646pkCalV9Sft4,206
@@ -21,8 +21,8 @@ hypercomplex/core/table_builder/standard.py,sha256=3kyg4TLCG_LKhC8lT95hZBFmOee0W
21
21
  hypercomplex/printer/__init__.py,sha256=6EZOUBYb9TDgfqrFpnIfPS1bbPFZ0dMX6RCPDZepL6M,129
22
22
  hypercomplex/printer/cd_format.py,sha256=X_cotGumJlRMuJO5cbsnI8FA9Py12TGYftPlUdx-9xg,5731
23
23
  hypercomplex/printer/cd_table_printer.py,sha256=uQlSmiTYiJkLZ4wC0ezXm7RSCYlldva0YCF2reNfKq4,4882
24
- hypercomplex_engine-0.4.0.dist-info/licenses/LICENSE,sha256=guj-B90dY9uDtG1POm34JUQQ0HU3YE47dq8RmVY4znI,1066
25
- hypercomplex_engine-0.4.0.dist-info/METADATA,sha256=D1LIPbrrZ5azxrhQVngsB3Rhx0W6MCLzzMpkqosMx5A,19938
26
- hypercomplex_engine-0.4.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
27
- hypercomplex_engine-0.4.0.dist-info/top_level.txt,sha256=WTtGtCnGtWsHvFBLdcsO6VRbm4wa1kU3yV-HrypIdwE,13
28
- hypercomplex_engine-0.4.0.dist-info/RECORD,,
24
+ hypercomplex_engine-0.4.1.dist-info/licenses/LICENSE,sha256=guj-B90dY9uDtG1POm34JUQQ0HU3YE47dq8RmVY4znI,1066
25
+ hypercomplex_engine-0.4.1.dist-info/METADATA,sha256=TSQ9T9KsNnD4Ej_f8Fea43J_a2nfWgYyBegjbWylsbM,19938
26
+ hypercomplex_engine-0.4.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
27
+ hypercomplex_engine-0.4.1.dist-info/top_level.txt,sha256=WTtGtCnGtWsHvFBLdcsO6VRbm4wa1kU3yV-HrypIdwE,13
28
+ hypercomplex_engine-0.4.1.dist-info/RECORD,,