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