hypercomplex-engine 1.0.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.
@@ -0,0 +1,1059 @@
1
+ Metadata-Version: 2.4
2
+ Name: hypercomplex-engine
3
+ Version: 1.0.1
4
+ Summary: Fast O(1)/O(n) multiplication engine and table generator for ordinary, split, and dual Cayley-Dickson algebras.
5
+ Author-email: Maher Ben Abdessalem <ba.maher94@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 maher1719
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/maher1719/hypercomplex-engine
29
+ Project-URL: Repository, https://github.com/maher1719/hypercomplex-engine
30
+ Project-URL: Preprint: Sign Structure, https://doi.org/10.6084/m9.figshare.33705022
31
+ Keywords: hypercomplex,cayley-dickson,quaternions,octonions,split-algebra,math,physics,geometry
32
+ Classifier: Development Status :: 5 - Production/Stable
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
35
+ Classifier: Topic :: Scientific/Engineering :: Physics
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3.8
39
+ Classifier: Programming Language :: Python :: 3.9
40
+ Classifier: Programming Language :: Python :: 3.10
41
+ Classifier: Programming Language :: Python :: 3.11
42
+ Classifier: Programming Language :: Python :: 3.12
43
+ Classifier: Programming Language :: Python :: 3.13
44
+ Classifier: Operating System :: OS Independent
45
+ Requires-Python: >=3.8
46
+ Description-Content-Type: text/markdown
47
+ License-File: LICENSE
48
+ Requires-Dist: numpy>=1.20.0
49
+ Dynamic: license-file
50
+
51
+ # hypercomplex-engine
52
+
53
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
54
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
55
+ [![Tests](https://img.shields.io/badge/tests-62%20passed-success)](#)
56
+
57
+
58
+ Fast, validated multiplication and table generation for Cayley–Dickson algebras.
59
+
60
+ This library provides the computational substrate for high-dimensional hypercomplex algebra, featuring:
61
+
62
+ - **Full multiplication table generation** for standard, split, and dual algebras.
63
+ - **O(n) holographic** table-free recursive descent multiplication.
64
+ - **O(1) fast bitwise** closed-form multiplication.
65
+ - **Integer, graded, and LaTeX** notation formatting.
66
+ - **CSV export** for tables (matrix and long formats).
67
+ - A **simple facade API** for everyday use, and direct low-level classes for advanced physics/math engines.
68
+
69
+ ---
70
+
71
+ ## πŸ“„ Publications & Preprints
72
+
73
+ This library serves as the formal verification substrate and computational engine for the following mathematical preprints:
74
+
75
+ **1. The Sign Structure of Cayley–Dickson and Split Algebras By Blocks**
76
+ *Proves the OPMT (Ordered-Pair Multiplication Table) sign laws, block decomposition, and the O(1) closed-form sign evaluator implemented in the `fast` engine of this library.*
77
+ * πŸ“Š **Figshare:** [10.6084/m9.figshare.33705022](https://doi.org/10.6084/m9.figshare.33705022)
78
+ * πŸ“¦ **Zenodo:** [10.5281/zenodo.22051873](https://doi.org/10.5281/zenodo.22051873)
79
+
80
+ ---
81
+
82
+ ## Supported algebras
83
+
84
+ | Kind | Description |
85
+ |---|---|
86
+ | `standard` | Ordinary Cayley–Dickson algebras: real, complex, quaternions, octonions, sedenions, ... |
87
+ | `split` | Split Cayley–Dickson algebras: standard parent plus one split doubling at the top |
88
+ | `dual` | Dual extension of a standard algebra, with Ρ² = 0 |
89
+ | `dual_split` | Dual extension of a split algebra, with Ρ² = 0 |
90
+
91
+ ---
92
+
93
+ ## Installation
94
+
95
+ Clone the repository:
96
+
97
+ ```bash
98
+ git clone https://github.com/maher1719/hypercomplex-engine.git
99
+ cd hypercomplex-engine
100
+ ```
101
+
102
+ Install in editable mode:
103
+
104
+ ```bash
105
+ pip install -e .
106
+ ```
107
+
108
+ Run the tests:
109
+
110
+ ```bash
111
+ pytest -v
112
+ ```
113
+
114
+ ---
115
+
116
+ # Basic Use
117
+
118
+ The simplest way to use the library is through the top-level facade API.
119
+
120
+ ```python
121
+ from hypercomplex import (
122
+ build_table,
123
+ multiply,
124
+ format_element,
125
+ print_table,
126
+ export_csv,
127
+ )
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Build a table
133
+
134
+ ```python
135
+ table = build_table("standard", 3)
136
+ ```
137
+
138
+ This builds the octonion multiplication table.
139
+
140
+ Dimensions:
141
+
142
+ ```text
143
+ n = 0 -> real numbers, dimension 1
144
+ n = 1 -> complex numbers, dimension 2
145
+ n = 2 -> quaternions, dimension 4
146
+ n = 3 -> octonions, dimension 8
147
+ n = 4 -> sedenions, dimension 16
148
+ ```
149
+
150
+ ---
151
+
152
+ ## Print a table
153
+
154
+ ```python
155
+ print_table(table, title="Octonions", mode="integer")
156
+ ```
157
+
158
+ Example output style:
159
+
160
+ ```text
161
+ e0 e1 e2 e3 e4 e5 e6 e7
162
+ e0 | +e0 +e1 +e2 +e3 +e4 +e5 +e6 +e7
163
+ e1 | +e1 -e0 +e3 -e2 +e5 -e4 -e7 +e6
164
+ ...
165
+ ```
166
+
167
+ You can also use graded notation:
168
+
169
+ ```python
170
+ print_table(table, title="Octonions", mode="graded")
171
+ ```
172
+
173
+ Example:
174
+
175
+ ```text
176
+ 1 o1 o2 o3 o4 o5 o6 o7
177
+ 1 | +1 +o1 +o2 +o3 +o4 +o5 +o6 +o7
178
+ o1 | +o1 -1 ...
179
+ ...
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Export a table to CSV
185
+
186
+ Matrix-style CSV:
187
+
188
+ ```python
189
+ export_csv(
190
+ "octonions_graded.csv",
191
+ table,
192
+ mode="graded",
193
+ csv_mode="matrix",
194
+ )
195
+ ```
196
+
197
+ Long-format CSV for data analysis:
198
+
199
+ ```python
200
+ export_csv(
201
+ "octonions_long.csv",
202
+ table,
203
+ mode="integer",
204
+ csv_mode="long",
205
+ )
206
+ ```
207
+
208
+ The long format produces rows like:
209
+
210
+ ```csv
211
+ i,j,sign,index
212
+ 0,0,1,0
213
+ 0,1,1,1
214
+ 1,0,1,1
215
+ 1,1,-1,0
216
+ ...
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Multiply two basis elements
222
+
223
+ ```python
224
+ result = multiply("standard", (1, 1), (1, 2))
225
+
226
+ print(result)
227
+ # (1, 3)
228
+ ```
229
+
230
+ This means:
231
+
232
+ ```text
233
+ e1 * e2 = +e3
234
+ ```
235
+
236
+ Format the result:
237
+
238
+ ```python
239
+ print(format_element(result, mode="integer"))
240
+ # +e3
241
+
242
+ print(format_element(result, mode="graded"))
243
+ # +o12
244
+
245
+ print(format_element(result, mode="latex"))
246
+ # +e_{12}
247
+ ```
248
+
249
+ Note:
250
+
251
+ ```text
252
+ integer mode uses the basis index:
253
+ e3
254
+
255
+ graded mode uses the generator decomposition:
256
+ index 3 = binary 011 = generators 1 and 2 = o12
257
+ ```
258
+
259
+ ---
260
+
261
+ ## Split multiplication
262
+
263
+ ```python
264
+ result = multiply("split", (1, 1), (1, 1), dim=1)
265
+
266
+ print(result)
267
+ # (1, 0)
268
+ ```
269
+
270
+ In split-complex numbers:
271
+
272
+ ```text
273
+ e1Β² = +e0
274
+ ```
275
+
276
+ ---
277
+
278
+ ## Dual multiplication
279
+
280
+ ```python
281
+ # eps*e0 represented as local tuple: (sign, local_index, eps_flag)
282
+ eps_e0 = (1, 0, 1)
283
+
284
+ result = multiply("dual", (1, 0), eps_e0, dim=1)
285
+
286
+ print(result)
287
+ # (1, 0, 1)
288
+
289
+ print(format_element(result, mode="integer"))
290
+ # +eps
291
+ ```
292
+
293
+ Nilpotency:
294
+
295
+ ```python
296
+ result = multiply("dual", eps_e0, eps_e0, dim=1)
297
+
298
+ print(result)
299
+ # (0, 0, 0)
300
+ ```
301
+
302
+ This means:
303
+
304
+ ```text
305
+ Ρ² = 0
306
+ ```
307
+
308
+ ---
309
+
310
+ # Intermediate Use
311
+
312
+ The facade API is enough for most users.
313
+
314
+ For more control, you can choose the computation engine and work directly with tables or multipliers.
315
+
316
+ ---
317
+
318
+ ## Engines
319
+
320
+ The `multiply` function supports two engines:
321
+
322
+ ```python
323
+ multiply(kind, a, b, dim=None, engine="fast")
324
+ ```
325
+
326
+ | Engine | Complexity | Description |
327
+ |---|---:|---|
328
+ | `"fast"` | O(1) | Bitwise closed-form sign evaluator |
329
+ | `"holographic"` | O(n) | Recursive block descent |
330
+
331
+ Example:
332
+
333
+ ```python
334
+ from hypercomplex import multiply
335
+
336
+ a = (1, 3)
337
+ b = (1, 5)
338
+
339
+ fast_result = multiply("standard", a, b, engine="fast")
340
+ holo_result = multiply("standard", a, b, engine="holographic")
341
+
342
+ assert fast_result == holo_result
343
+ ```
344
+
345
+ ---
346
+
347
+ ## Algebra kinds
348
+
349
+ ```python
350
+ multiply("standard", a, b)
351
+ multiply("split", a, b, dim=3)
352
+ multiply("dual", a, b, dim=3)
353
+ multiply("dual_split", a, b, dim=3)
354
+ ```
355
+
356
+ For `standard`, `dim` is not needed.
357
+
358
+ For `split`, `dim` is optional and can often be inferred from the indices.
359
+
360
+ For `dual` and `dual_split`, `dim` is required.
361
+
362
+ ---
363
+
364
+ ## Table builders directly
365
+
366
+ ```python
367
+ from hypercomplex import (
368
+ StandardTableBuilder,
369
+ SplitTableBuilder,
370
+ DualTableBuilder,
371
+ )
372
+
373
+ standard_builder = StandardTableBuilder()
374
+ split_builder = SplitTableBuilder()
375
+ dual_builder = DualTableBuilder()
376
+
377
+ signs, indices = standard_builder.build(3)
378
+ signs, indices = split_builder.build(3)
379
+ signs, indices, eps = dual_builder.build(2, split=False)
380
+ ```
381
+
382
+ Return conventions:
383
+
384
+ ```text
385
+ standard:
386
+ signs, indices
387
+
388
+ split:
389
+ signs, indices
390
+
391
+ dual:
392
+ signs, indices, eps
393
+ ```
394
+
395
+ For dual tables:
396
+
397
+ - `signs[i, j]` is the sign.
398
+ - `indices[i, j]` is the local base index.
399
+ - `eps[i, j]` is the epsilon flag.
400
+
401
+ ---
402
+
403
+ ## Multipliers directly
404
+
405
+ ```python
406
+ from hypercomplex import (
407
+ StandardHolographic,
408
+ SplitHolographic,
409
+ DualHolographic,
410
+ )
411
+
412
+ holo = StandardHolographic()
413
+ result = holo.multiply((1, 1), (1, 2))
414
+
415
+ print(result)
416
+ # (1, 3)
417
+ ```
418
+
419
+ Split:
420
+
421
+ ```python
422
+ split_holo = SplitHolographic()
423
+ result = split_holo.multiply((1, 2), (1, 2), dim=2)
424
+
425
+ print(result)
426
+ # (1, 0)
427
+ ```
428
+
429
+ Dual:
430
+
431
+ ```python
432
+ dual_holo = DualHolographic(split=False)
433
+
434
+ result = dual_holo.multiply((1, 0), (1, 2), dim=1)
435
+
436
+ print(result)
437
+ # (1, 0, 1)
438
+ ```
439
+
440
+ ---
441
+
442
+ ## Fast O(1) multipliers directly
443
+
444
+ ```python
445
+ from hypercomplex import (
446
+ FastStandard,
447
+ FastSplit,
448
+ FastDual,
449
+ )
450
+
451
+ fast = FastStandard()
452
+
453
+ result = fast.multiply((1, 1), (1, 2))
454
+
455
+ print(result)
456
+ # (1, 3)
457
+ ```
458
+
459
+ Split:
460
+
461
+ ```python
462
+ fast_split = FastSplit()
463
+
464
+ result = fast_split.multiply((1, 2), (1, 2), dim=2)
465
+
466
+ print(result)
467
+ # (1, 0)
468
+ ```
469
+
470
+ Dual:
471
+
472
+ ```python
473
+ fast_dual = FastDual(split=False)
474
+
475
+ result = fast_dual.multiply((1, 0), (1, 0, 1), dim=1)
476
+
477
+ print(result)
478
+ # (1, 0, 1)
479
+ ```
480
+
481
+ ---
482
+
483
+ ## Formatting modes
484
+
485
+ | Mode | Example |
486
+ |---|---|
487
+ | `"integer"` | `+e5` |
488
+ | `"graded"` | `+o13` |
489
+ | `"latex"` | `+o_{13}` |
490
+ | `"latex_integer"` | `+e_{5}` |
491
+ | `"latex_graded"` | `+o_{13}` |
492
+
493
+ Example:
494
+
495
+ ```python
496
+ from hypercomplex import format_element
497
+
498
+ element = (-1, 5)
499
+
500
+ print(format_element(element, mode="integer"))
501
+ # -e5
502
+
503
+ print(format_element(element, mode="graded"))
504
+ # -o13
505
+
506
+ print(format_element(element, mode="latex_integer"))
507
+ # -e_{5}
508
+
509
+ print(format_element(element, mode="latex_graded"))
510
+ # -o_{13}
511
+ ```
512
+
513
+ ---
514
+
515
+ # Advanced Use
516
+
517
+ This section is for contributors, benchmarking, physics engines, and symbolic pipelines.
518
+
519
+ ---
520
+
521
+ ## Direct low-level imports
522
+
523
+ If you prefer explicit imports:
524
+
525
+ ```python
526
+ from hypercomplex.core.table_builder import (
527
+ StandardTableBuilder,
528
+ SplitTableBuilder,
529
+ DualTableBuilder,
530
+ )
531
+
532
+ from hypercomplex.core.holographic import (
533
+ StandardHolographic,
534
+ SplitHolographic,
535
+ DualHolographic,
536
+ )
537
+
538
+ from hypercomplex.core.fast import (
539
+ FastStandard,
540
+ FastSplit,
541
+ FastDual,
542
+ )
543
+
544
+ from hypercomplex.printer import (
545
+ CDFormat,
546
+ CDTablePrinter,
547
+ )
548
+ ```
549
+
550
+ ---
551
+
552
+ ## Cross-validating O(1) against the full table
553
+
554
+ ```python
555
+ from hypercomplex import StandardTableBuilder, FastStandard
556
+
557
+ builder = StandardTableBuilder()
558
+ fast = FastStandard()
559
+
560
+ n = 4
561
+ signs, indices = builder.build(n)
562
+
563
+ dim = 1 << n
564
+
565
+ for i in range(dim):
566
+ for j in range(dim):
567
+ fast_sign, fast_idx = fast.multiply_indices(i, j)
568
+
569
+ assert int(signs[i, j]) == fast_sign
570
+ assert int(indices[i, j]) == fast_idx
571
+ ```
572
+
573
+ This proves that the O(1) evaluator agrees with the O(4^n) table builder.
574
+
575
+ ---
576
+
577
+ ## Cross-validating split O(1) against the split table
578
+
579
+ ```python
580
+ from hypercomplex import SplitTableBuilder, FastSplit
581
+
582
+ builder = SplitTableBuilder()
583
+ fast = FastSplit()
584
+
585
+ n = 4
586
+ signs, indices = builder.build(n)
587
+
588
+ dim = 1 << n
589
+
590
+ for i in range(dim):
591
+ for j in range(dim):
592
+ fast_sign, fast_idx = fast.multiply_indices(i, j, dim=n)
593
+
594
+ assert int(signs[i, j]) == fast_sign
595
+ assert int(indices[i, j]) == fast_idx
596
+ ```
597
+
598
+ ---
599
+
600
+ ## Dual local and global indices
601
+
602
+ For dual multiplication, the total dimension is:
603
+
604
+ ```text
605
+ 2^(dim + 1)
606
+ ```
607
+
608
+ The epsilon bit is bit `dim`.
609
+
610
+ Example for `dim=1`:
611
+
612
+ ```text
613
+ lower half: 0, 1 base elements
614
+ upper half: 2, 3 epsilon elements
615
+ ```
616
+
617
+ The dual multipliers accept both:
618
+
619
+ ```python
620
+ # global index tuple
621
+ (1, 2)
622
+
623
+ # local tuple with epsilon flag
624
+ (1, 0, 1)
625
+ ```
626
+
627
+ Both represent Ρ·eβ‚€ when `dim=1`.
628
+
629
+ The output convention is:
630
+
631
+ ```python
632
+ (sign, local_index, eps_flag)
633
+ ```
634
+
635
+ This makes formatting easy:
636
+
637
+ ```python
638
+ from hypercomplex import format_element
639
+
640
+ result = (1, 0, 1)
641
+
642
+ print(format_element(result, mode="integer"))
643
+ # +eps
644
+
645
+ print(format_element(result, mode="latex"))
646
+ # +\epsilon
647
+ ```
648
+
649
+ ---
650
+
651
+ ## Using the fast engine in a physics loop
652
+
653
+ For simulations, avoid building large tables. Use the fast engine directly.
654
+
655
+ ```python
656
+ from hypercomplex import FastStandard
657
+
658
+ fast = FastStandard()
659
+
660
+ def basis_product(i: int, j: int):
661
+ sign, index = fast.multiply((1, i), (1, j))
662
+ return sign, index
663
+
664
+ sign, index = basis_product(1, 2)
665
+
666
+ print(sign, index)
667
+ # 1 3
668
+ ```
669
+
670
+ For octonionic or higher-dimensional simulations, this avoids O(4^n) memory.
671
+
672
+ ---
673
+
674
+ ## Table size warning
675
+
676
+ Full table generation grows as:
677
+
678
+ ```text
679
+ entries = 4^n
680
+ ```
681
+
682
+ where `n` is the dimension exponent.
683
+
684
+ | n | Dimension | Entries |
685
+ |---:|---:|---:|
686
+ | 0 | 1 | 1 |
687
+ | 1 | 2 | 4 |
688
+ | 2 | 4 | 16 |
689
+ | 3 | 8 | 64 |
690
+ | 4 | 16 | 256 |
691
+ | 5 | 32 | 1,024 |
692
+ | 6 | 64 | 4,096 |
693
+ | 8 | 256 | 65,536 |
694
+ | 10 | 1,024 | 1,048,576 |
695
+ | 12 | 4,096 | 16,777,216 |
696
+
697
+ For large dimensions, prefer:
698
+
699
+ ```python
700
+ engine="fast"
701
+ ```
702
+
703
+ or:
704
+
705
+ ```python
706
+ engine="holographic"
707
+ ```
708
+
709
+ ---
710
+
711
+ # API Reference
712
+
713
+ ## Top-level functions
714
+
715
+ ### `build_table(kind, n)`
716
+
717
+ Builds a multiplication table.
718
+
719
+ ```python
720
+ table = build_table("standard", 3)
721
+ ```
722
+
723
+ Returns:
724
+
725
+ ```text
726
+ standard:
727
+ (signs, indices)
728
+
729
+ split:
730
+ (signs, indices)
731
+
732
+ dual:
733
+ (signs, indices, eps)
734
+
735
+ dual_split:
736
+ (signs, indices, eps)
737
+ ```
738
+
739
+ ---
740
+
741
+ ### `multiply(kind, a, b, dim=None, engine="fast")`
742
+
743
+ Multiplies two basis elements.
744
+
745
+ ```python
746
+ result = multiply("standard", (1, 1), (1, 2))
747
+ ```
748
+
749
+ Returns:
750
+
751
+ ```text
752
+ standard:
753
+ (sign, index)
754
+
755
+ split:
756
+ (sign, index)
757
+
758
+ dual:
759
+ (sign, local_index, eps_flag)
760
+
761
+ dual_split:
762
+ (sign, local_index, eps_flag)
763
+ ```
764
+
765
+ ---
766
+
767
+ ### `format_element(element, mode="integer")`
768
+
769
+ Formats a basis element tuple.
770
+
771
+ ```python
772
+ format_element((1, 3), mode="integer")
773
+ # "+e3"
774
+
775
+ format_element((1, 3), mode="graded")
776
+ # "+o12"
777
+ ```
778
+
779
+ ---
780
+
781
+ ### `print_table(table, title=None, limit=None, mode="integer")`
782
+
783
+ Prints a table.
784
+
785
+ ```python
786
+ table = build_table("standard", 2)
787
+ print_table(table, mode="graded")
788
+ ```
789
+
790
+ ---
791
+
792
+ ### `export_csv(path, table, mode="integer", csv_mode="matrix")`
793
+
794
+ Exports a table to CSV.
795
+
796
+ ```python
797
+ table = build_table("standard", 3)
798
+
799
+ export_csv(
800
+ "octonions.csv",
801
+ table,
802
+ mode="graded",
803
+ csv_mode="matrix",
804
+ )
805
+ ```
806
+
807
+ CSV modes:
808
+
809
+ | `csv_mode` | Output |
810
+ |---|---|
811
+ | `"matrix"` | Spreadsheet-style grid |
812
+ | `"long"` | One row per product |
813
+
814
+ ---
815
+
816
+ ## Algebra kinds
817
+
818
+ | Kind | Meaning |
819
+ |---|---|
820
+ | `"standard"` | Ordinary Cayley–Dickson |
821
+ | `"split"` | Split Cayley–Dickson |
822
+ | `"dual"` | Dual extension of standard algebra |
823
+ | `"dual_split"` | Dual extension of split algebra |
824
+
825
+ Aliases:
826
+
827
+ ```text
828
+ standard: "std", "ordinary", "o"
829
+ split: "s"
830
+ dual: "d", "dual_standard"
831
+ dual_split: "split_dual", "ds"
832
+ ```
833
+
834
+ ---
835
+
836
+ ## Engines
837
+
838
+ | Engine | Aliases | Complexity |
839
+ |---|---|---:|
840
+ | `"fast"` | `"o1"`, `"bitwise"`, `"constant"` | O(1) Word-RAM |
841
+ | `"holographic"` | `"on"`, `"descent"` | O(n) |
842
+
843
+ ---
844
+
845
+ # Mathematical Background
846
+
847
+ ## Basis product rule
848
+
849
+ For standard and split Cayley–Dickson algebras:
850
+
851
+ ```text
852
+ e_i * e_j = sign(i, j) * e_{i XOR j}
853
+ ```
854
+
855
+ The index is always:
856
+
857
+ ```text
858
+ i XOR j
859
+ ```
860
+
861
+ The sign is determined by the OPMT block laws.
862
+
863
+ ---
864
+
865
+ ## Standard doubling formula
866
+
867
+ ```text
868
+ (a, b)(c, d) = (ac - d* b, da + b c*)
869
+ ```
870
+
871
+ with conjugation:
872
+
873
+ ```text
874
+ e0* = e0
875
+ ek* = -ek for k > 0
876
+ ```
877
+
878
+ ---
879
+
880
+ ## Split doubling formula
881
+
882
+ ```text
883
+ (a, b)(c, d) = (ac + d* b, da + b c*)
884
+ ```
885
+
886
+ The only difference from the standard construction is the sign of the `d* b` term.
887
+
888
+ This causes Block d signs to invert relative to the standard algebra.
889
+
890
+ ---
891
+
892
+ ## Block decomposition
893
+
894
+ Each multiplication table splits into four blocks:
895
+
896
+ ```text
897
+ [ a b ]
898
+ [ c d ]
899
+ ```
900
+
901
+ where:
902
+
903
+ ```text
904
+ Block a: e_i * e_j
905
+ Block b: e_i * (e_j β„“)
906
+ Block c: (e_i β„“) * e_j
907
+ Block d: (e_i β„“) * (e_j β„“)
908
+ ```
909
+
910
+ For standard algebras:
911
+
912
+ ```text
913
+ Block d interior sign = -Οƒ_a
914
+ ```
915
+
916
+ For split algebras:
917
+
918
+ ```text
919
+ Block d interior sign = +Οƒ_a
920
+ ```
921
+
922
+ ---
923
+
924
+ ## Dual numbers
925
+
926
+ Dual algebras adjoin Ξ΅ such that:
927
+
928
+ ```text
929
+ Ρ² = 0
930
+ ```
931
+
932
+ Multiplication rules:
933
+
934
+ ```text
935
+ e_i * e_j = parent product
936
+ e_i * (Ξ΅ e_j) = Ξ΅ (e_i e_j)
937
+ (Ξ΅ e_i) * e_j = Ξ΅ (e_i e_j)
938
+ (Ξ΅ e_i) * (Ξ΅ e_j) = 0
939
+ ```
940
+
941
+ ---
942
+
943
+ # Complexity
944
+
945
+ | Operation | Complexity | Memory |
946
+ |---|---:|---:|
947
+ | Full table generation | O(4^n) | O(4^n) |
948
+ | Holographic multiplication | O(n) | O(1) |
949
+ | Fast bitwise multiplication | O(1) Word-RAM | O(1) |
950
+
951
+ For arbitrary-precision integers, the fast evaluator uses O(n) bit operations, where:
952
+
953
+ ```text
954
+ n = ceil(log2(max(i, j) + 1))
955
+ ```
956
+
957
+ ---
958
+
959
+ # Testing
960
+
961
+ Run all tests:
962
+
963
+ ```bash
964
+ pytest -v
965
+ ```
966
+
967
+ Run specific test files:
968
+
969
+ ```bash
970
+ pytest tests/test_mega_mother.py -v
971
+ pytest tests/test_fast_mode.py -v
972
+ ```
973
+
974
+ The test suite validates:
975
+
976
+ - Basis notation conversion.
977
+ - Input validation.
978
+ - Standard table generation.
979
+ - Split table generation.
980
+ - Dual table generation.
981
+ - Holographic O(n) multiplication.
982
+ - Fast O(1) multiplication.
983
+ - Cross-validation between tables and multipliers.
984
+ - Facade API behavior.
985
+ - CSV export.
986
+
987
+ ---
988
+
989
+ # Repository Structure
990
+
991
+ ```text
992
+ hypercomplex-engine/
993
+ β”œβ”€β”€ examples/
994
+ β”‚ β”œβ”€β”€ direct_implementation/
995
+ β”‚ β”‚ └── full_table_builder_simple.py
996
+ β”‚ └── uses/
997
+ β”‚ β”œβ”€β”€ outputs/
998
+ β”‚ └── use.ipynb
999
+ β”œβ”€β”€ hypercomplex/
1000
+ β”‚ β”œβ”€β”€ core/
1001
+ β”‚ β”‚ β”œβ”€β”€ basis_element.py
1002
+ β”‚ β”‚ β”œβ”€β”€ basis_notation.py
1003
+ β”‚ β”‚ β”œβ”€β”€ validation.py
1004
+ β”‚ β”‚ β”œβ”€β”€ table_builder/
1005
+ β”‚ β”‚ β”‚ β”œβ”€β”€ common.py
1006
+ β”‚ β”‚ β”‚ β”œβ”€β”€ standard.py
1007
+ β”‚ β”‚ β”‚ β”œβ”€β”€ split.py
1008
+ β”‚ β”‚ β”‚ └── dual.py
1009
+ β”‚ β”‚ β”œβ”€β”€ holographic/
1010
+ β”‚ β”‚ β”‚ β”œβ”€β”€ standard.py
1011
+ β”‚ β”‚ β”‚ β”œβ”€β”€ split.py
1012
+ β”‚ β”‚ β”‚ └── dual.py
1013
+ β”‚ β”‚ └── fast/
1014
+ β”‚ β”‚ β”œβ”€β”€ bit_utils.py
1015
+ β”‚ β”‚ β”œβ”€β”€ fast_standard.py
1016
+ β”‚ β”‚ β”œβ”€β”€ fast_split.py
1017
+ β”‚ β”‚ └── fast_dual.py
1018
+ β”‚ β”œβ”€β”€ printer/
1019
+ β”‚ β”‚ β”œβ”€β”€ cd_format.py
1020
+ β”‚ β”‚ └── cd_table_printer.py
1021
+ β”‚ β”œβ”€β”€ facade.py
1022
+ β”‚ └── __init__.py
1023
+ β”œβ”€β”€ tests/
1024
+ β”‚ β”œβ”€β”€ test_algebra.py
1025
+ β”‚ β”œβ”€β”€ test_fast_mode.py
1026
+ β”‚ β”œβ”€β”€ test_holographic_vs_table.py
1027
+ β”‚ └── test_mega_mother.py
1028
+ β”œβ”€β”€ LICENSE
1029
+ β”œβ”€β”€ README.md
1030
+ └── pyproject.toml
1031
+ ```
1032
+
1033
+ ---
1034
+
1035
+ # Citation
1036
+
1037
+ If you use this engine in your research, physics simulations, or geometric deep learning models, please cite the underlying theoretical preprints:
1038
+
1039
+ ```bibtex
1040
+ @article{ben abdessalem2026,
1041
+ author = "maher ben abdessalem",
1042
+ title = "{A Proven Sign Law for Cayley-Dickson Algebras: Ordinary, Split, dual Constructions and their computational proofs and implementations}",
1043
+ year = "2026",
1044
+ month = "9",
1045
+ url = "https://figshare.com/articles/preprint/A_Proven_Sign_Law_for_Cayley-Dickson_Algebras_Ordinary_and_Split_Constructions/33705022",
1046
+ doi = "10.6084/m9.figshare.33705022.v5"
1047
+ }
1048
+
1049
+ ```
1050
+
1051
+ ---
1052
+
1053
+ # License
1054
+
1055
+ MIT License.
1056
+
1057
+ See [`LICENSE`](LICENSE) for details.
1058
+
1059
+ Copyright (c) 2026 Maher Ben Abdessalem