hypercomplex-engine 0.4.1__tar.gz → 0.4.2.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.
- {hypercomplex_engine-0.4.1/hypercomplex_engine.egg-info → hypercomplex_engine-0.4.2.1}/PKG-INFO +93 -5
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/README.md +91 -3
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/fast/fast_standard.py +0 -3
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/facade.py +7 -3
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/printer/cd_table_printer.py +3 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1/hypercomplex_engine.egg-info}/PKG-INFO +93 -5
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/pyproject.toml +2 -2
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/tests/test_dual_tuple_regression.py +4 -2
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/LICENSE +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/__init__.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/__init__.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/basis_element.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/basis_notation.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/fast/__init__.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/fast/bit_utils.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/fast/fast_dual.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/fast/fast_split.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/holographic/__init__.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/holographic/dual.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/holographic/split.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/holographic/standard.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/table_builder/__init__.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/table_builder/common.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/table_builder/dual.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/table_builder/split.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/table_builder/standard.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/validation.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/printer/__init__.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/printer/cd_format.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex_engine.egg-info/SOURCES.txt +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex_engine.egg-info/dependency_links.txt +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex_engine.egg-info/requires.txt +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex_engine.egg-info/top_level.txt +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/setup.cfg +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/tests/test_fast_mode.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/tests/test_fixes_0_4.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/tests/test_mega_mother.py +0 -0
- {hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/tests/test_split_dim.py +0 -0
{hypercomplex_engine-0.4.1/hypercomplex_engine.egg-info → hypercomplex_engine-0.4.2.1}/PKG-INFO
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hypercomplex-engine
|
|
3
|
-
Version: 0.4.1
|
|
4
|
-
Summary: Fast O(1)/O(n) multiplication engine and table generator for ordinary, split, and dual Cayley-Dickson algebras.
|
|
3
|
+
Version: 0.4.2.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
5
|
Author-email: Maher Ben Abdessalem <ba.maher94@gmail.com>
|
|
6
6
|
License: MIT License
|
|
7
7
|
|
|
@@ -50,13 +50,15 @@ Dynamic: license-file
|
|
|
50
50
|
|
|
51
51
|
[](https://opensource.org/licenses/MIT)
|
|
52
52
|
[](https://www.python.org/downloads/)
|
|
53
|
-
[](#)
|
|
54
53
|
[](https://github.com/maher1719/hypercomplex-engine)
|
|
55
|
-
[](https://pypi.org/project/hypercomplex-engine/)
|
|
56
55
|
[](https://pepy.tech/project/hypercomplex-engine)
|
|
57
56
|
|
|
58
57
|
|
|
59
|
-
Fast, validated multiplication and table generation for Cayley–Dickson algebras.
|
|
58
|
+
Fast, cross validated multiplication and table generation for Cayley–Dickson algebras multiplication up to **one million digit** two elements index tested for O(1)/O(n) and depend on RAM allocation up to 2^13 or more for table builder.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
For more info please visit All benchamrks in [BENCHMARKS.md](https://github.com/maher1719/hypercomplex-engine/blob/main/BENCHMARKS.md) and Jupyter Notebook used in [examples/benchmark/benchmark.ipynb](https://github.com/maher1719/hypercomplex-engine/blob/main/examples/benchmark/benchmark.ipynb) (note speed time may vary depend on your hardware).
|
|
60
62
|
|
|
61
63
|
This library provides the computational substrate for high-dimensional hypercomplex algebra, featuring:
|
|
62
64
|
|
|
@@ -69,6 +71,11 @@ This library provides the computational substrate for high-dimensional hypercomp
|
|
|
69
71
|
|
|
70
72
|
---
|
|
71
73
|
|
|
74
|
+
## Scope and limitations
|
|
75
|
+
|
|
76
|
+
If you build upon this package, please read fully [Go to Scope, Strengths, and Limitations](#scope-strengths-and-limitations) below for more information or check [Scope, Strengths, and Limitations file](https://github.com/maher1719/hypercomplex-engine/blob/main/README_scope_and_limitations.md#scope-strengths-and-limitations)
|
|
77
|
+
|
|
78
|
+
|
|
72
79
|
## 📄 Publications & Preprints
|
|
73
80
|
|
|
74
81
|
This library serves as the formal verification substrate and computational engine for the following mathematical preprints:
|
|
@@ -1037,6 +1044,87 @@ hypercomplex-engine/
|
|
|
1037
1044
|
└── pyproject.toml
|
|
1038
1045
|
```
|
|
1039
1046
|
|
|
1047
|
+
# Scope, strengths and limitations
|
|
1048
|
+
|
|
1049
|
+
> **Status: 0.4.x, pre-1.0.** The API can still change. Read this section before building on the package.
|
|
1050
|
+
|
|
1051
|
+
## What this package is
|
|
1052
|
+
|
|
1053
|
+
It computes the product of two **signed basis elements** of a Cayley–Dickson algebra: `±e_i × ±e_j → ±e_k` (or zero in dual algebras). It is a low-level component, a sign and index calculator, not a number type. There are no coefficients, no sums, and no vectors.
|
|
1054
|
+
|
|
1055
|
+
## Advantages
|
|
1056
|
+
|
|
1057
|
+
- **One job, small surface.** About 2,000 lines, one dependency (NumPy), and multipliers that keep no per-call state.
|
|
1058
|
+
- **Two interchangeable engines.**
|
|
1059
|
+
- `fast` is a closed-form bitwise evaluator. It does constant work per call for word-sized indices, and cost grows only with bit length for arbitrary-precision indices.
|
|
1060
|
+
- `holographic` is an O(n) recursive descent, useful as a cross-check.
|
|
1061
|
+
- **Works where tables cannot.** Only the two indices are needed, so indices hundreds of bits long are fine. Full tables need 4^n entries.
|
|
1062
|
+
- **Cross-validated.** The test suite checks the table builders, the `fast` engine and the `holographic` engine against each other.
|
|
1063
|
+
- **Strict about types.** `bool`, `float`, `str` and `list` inputs are rejected. Results are plain Python `int`s.
|
|
1064
|
+
- **Tested on Python 3.10–3.14** and with NumPy 1.22 and newer.
|
|
1065
|
+
|
|
1066
|
+
## Input rules (0.4.x behavior)
|
|
1067
|
+
|
|
1068
|
+
| Kind | Element form | `dim` | Index range |
|
|
1069
|
+
|---|---|---|---|
|
|
1070
|
+
| `standard` | `(sign, index)` | not used | any integer ≥ 0 (no upper bound, since there is no `dim` to check against) |
|
|
1071
|
+
| `split` | `(sign, index)` | **required** | `0 ≤ index < 2**dim` |
|
|
1072
|
+
| `dual`, `dual_split` | `(sign, global_index)` or `(sign, local_index, eps)` | **required** | global: `0 ≤ i < 2**(dim+1)`; local: `0 ≤ i < 2**dim` |
|
|
1073
|
+
|
|
1074
|
+
- Elements must be **tuples**. Integers only, and NumPy integers are accepted.
|
|
1075
|
+
- `sign` should be `-1` or `+1`. Note: `multiply` currently also accepts `0` as a formal zero and returns zero. **Do not rely on this**; it may be removed.
|
|
1076
|
+
- Dual elements have two spellings of the same thing. At `dim=3`, `(1, 9)` and `(1, 1, 1)` both mean `+ε·e1` (global index `8 + 1`).
|
|
1077
|
+
- **Known looseness:** at `dim=3`, `(1, 9, 1)` and even `(1, 9, 0)` are also accepted and read as `+ε·e1`. The second one contradicts itself, so don't rely on it.
|
|
1078
|
+
- The dual result is always `(sign, local_index, eps)`, and `ε·ε` gives `(0, 0, 0)`.
|
|
1079
|
+
|
|
1080
|
+
## What the package cannot detect (your responsibility)
|
|
1081
|
+
|
|
1082
|
+
Elements are plain tuples, so they do not remember which algebra produced them.
|
|
1083
|
+
|
|
1084
|
+
- Feeding a result from one `dim` into an algebra of a different `dim` is not detected if the index happens to be in range.
|
|
1085
|
+
- Mixing `standard` and `split` elements is not detected. The same tuple means different things: `e2·e2` is `-1` in the standard algebra, `+1` in `split` with `dim=2`, and `-1` in `split` with `dim>=3`.
|
|
1086
|
+
- For `standard`, nothing tells you an index is "too big for the octonions".
|
|
1087
|
+
|
|
1088
|
+
## Not supported
|
|
1089
|
+
|
|
1090
|
+
- **No chain multiplication and no expressions.** `multiply` is strictly binary. You can pass a result into the next call yourself, but you choose the bracketing. From `n=3` (octonions) upward multiplication is **not associative**, so `(ab)c` and `a(bc)` can differ in sign.
|
|
1091
|
+
- **No coefficients, sums, vectors, arrays, or parsing** of expressions like `e1+e2+e12`. This is planned for a separate package built on top of this one.
|
|
1092
|
+
- **No addition, conjugation, norm, inverse, or division.**
|
|
1093
|
+
- **`split` means one split doubling on top of a standard parent.** Other sign patterns are not offered.
|
|
1094
|
+
- **`dual` and `dual_split`** extend a standard or split parent with a central `ε`, where `ε² = 0`.
|
|
1095
|
+
|
|
1096
|
+
## Algebra facts to keep in mind
|
|
1097
|
+
|
|
1098
|
+
| n | Standard | Split |
|
|
1099
|
+
|---|---|---|
|
|
1100
|
+
| 1 | complex, commutative | split-complex, commutative, has zero divisors |
|
|
1101
|
+
| 2 | quaternions, associative, **not commutative** | split-quaternions, associative, not commutative |
|
|
1102
|
+
| 3 | octonions, alternative, **not associative** | split-octonions, alternative, not associative, has zero divisors |
|
|
1103
|
+
| ≥ 4 | sedenions and beyond: **zero divisors**, no longer alternative | no longer alternative |
|
|
1104
|
+
|
|
1105
|
+
## Convention
|
|
1106
|
+
|
|
1107
|
+
Products follow the standard doubling `(a, b)(c, d) = (ac − d*b, da + bc*)` (split algebras flip the sign of the `d*b` term at the top level). Other conventions give isomorphic algebras with **different tables**, so comparing against another source may show sign differences after relabeling. For example, here `e1·e2 = e3` and `e1·e6 = −e7`.
|
|
1108
|
+
|
|
1109
|
+
## Direct low-level classes
|
|
1110
|
+
|
|
1111
|
+
`FastStandard`, `FastSplit`, `FastDual`, `StandardHolographic`, `SplitHolographic` and `DualHolographic` are exported, but they validate **differently** from each other and from `multiply`. For example, `FastSplit` accepts a zero element while the other three reject it. Their `multiply_indices` methods do only minimal checks. **Prefer `multiply`.** These classes are not a stable API and are expected to become internal.
|
|
1112
|
+
|
|
1113
|
+
## Tables and memory
|
|
1114
|
+
|
|
1115
|
+
Full tables have `4**n` entries. `build_table` refuses requests above a default memory budget (`max_bytes`, 256 MiB):
|
|
1116
|
+
|
|
1117
|
+
- `standard` and `split` are allowed up to `n = 13`.
|
|
1118
|
+
- `dual` and `dual_split` are allowed up to `n = 12`, since they are one doubling larger.
|
|
1119
|
+
|
|
1120
|
+
Use `estimate_table_bytes(kind, n)` to check a size, and pass a larger `max_bytes` (or `None`) if you really mean it. In dual tables, `sign == 0` marks `ε·ε`.
|
|
1121
|
+
|
|
1122
|
+
## Stability and planned changes
|
|
1123
|
+
|
|
1124
|
+
- Pin your dependency, for example `hypercomplex-engine>=0.4.1,<0.5`.
|
|
1125
|
+
- *Planned for 0.5.0, subject to change:* stricter inputs (no zero elements, one dual form), and low-level classes made internal. Breaking changes will be listed in the release notes.
|
|
1126
|
+
- Do not treat the package as 1.0-stable until it has been used by futur a palnned package the vector-and-expression package.
|
|
1127
|
+
|
|
1040
1128
|
---
|
|
1041
1129
|
|
|
1042
1130
|
# Citation
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://opensource.org/licenses/MIT)
|
|
4
4
|
[](https://www.python.org/downloads/)
|
|
5
|
-
[](#)
|
|
6
5
|
[](https://github.com/maher1719/hypercomplex-engine)
|
|
7
|
-
[](https://pypi.org/project/hypercomplex-engine/)
|
|
8
7
|
[](https://pepy.tech/project/hypercomplex-engine)
|
|
9
8
|
|
|
10
9
|
|
|
11
|
-
Fast, validated multiplication and table generation for Cayley–Dickson algebras.
|
|
10
|
+
Fast, cross validated multiplication and table generation for Cayley–Dickson algebras multiplication up to **one million digit** two elements index tested for O(1)/O(n) and depend on RAM allocation up to 2^13 or more for table builder.
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
For more info please visit All benchamrks in [BENCHMARKS.md](https://github.com/maher1719/hypercomplex-engine/blob/main/BENCHMARKS.md) and Jupyter Notebook used in [examples/benchmark/benchmark.ipynb](https://github.com/maher1719/hypercomplex-engine/blob/main/examples/benchmark/benchmark.ipynb) (note speed time may vary depend on your hardware).
|
|
12
14
|
|
|
13
15
|
This library provides the computational substrate for high-dimensional hypercomplex algebra, featuring:
|
|
14
16
|
|
|
@@ -21,6 +23,11 @@ This library provides the computational substrate for high-dimensional hypercomp
|
|
|
21
23
|
|
|
22
24
|
---
|
|
23
25
|
|
|
26
|
+
## Scope and limitations
|
|
27
|
+
|
|
28
|
+
If you build upon this package, please read fully [Go to Scope, Strengths, and Limitations](#scope-strengths-and-limitations) below for more information or check [Scope, Strengths, and Limitations file](https://github.com/maher1719/hypercomplex-engine/blob/main/README_scope_and_limitations.md#scope-strengths-and-limitations)
|
|
29
|
+
|
|
30
|
+
|
|
24
31
|
## 📄 Publications & Preprints
|
|
25
32
|
|
|
26
33
|
This library serves as the formal verification substrate and computational engine for the following mathematical preprints:
|
|
@@ -989,6 +996,87 @@ hypercomplex-engine/
|
|
|
989
996
|
└── pyproject.toml
|
|
990
997
|
```
|
|
991
998
|
|
|
999
|
+
# Scope, strengths and limitations
|
|
1000
|
+
|
|
1001
|
+
> **Status: 0.4.x, pre-1.0.** The API can still change. Read this section before building on the package.
|
|
1002
|
+
|
|
1003
|
+
## What this package is
|
|
1004
|
+
|
|
1005
|
+
It computes the product of two **signed basis elements** of a Cayley–Dickson algebra: `±e_i × ±e_j → ±e_k` (or zero in dual algebras). It is a low-level component, a sign and index calculator, not a number type. There are no coefficients, no sums, and no vectors.
|
|
1006
|
+
|
|
1007
|
+
## Advantages
|
|
1008
|
+
|
|
1009
|
+
- **One job, small surface.** About 2,000 lines, one dependency (NumPy), and multipliers that keep no per-call state.
|
|
1010
|
+
- **Two interchangeable engines.**
|
|
1011
|
+
- `fast` is a closed-form bitwise evaluator. It does constant work per call for word-sized indices, and cost grows only with bit length for arbitrary-precision indices.
|
|
1012
|
+
- `holographic` is an O(n) recursive descent, useful as a cross-check.
|
|
1013
|
+
- **Works where tables cannot.** Only the two indices are needed, so indices hundreds of bits long are fine. Full tables need 4^n entries.
|
|
1014
|
+
- **Cross-validated.** The test suite checks the table builders, the `fast` engine and the `holographic` engine against each other.
|
|
1015
|
+
- **Strict about types.** `bool`, `float`, `str` and `list` inputs are rejected. Results are plain Python `int`s.
|
|
1016
|
+
- **Tested on Python 3.10–3.14** and with NumPy 1.22 and newer.
|
|
1017
|
+
|
|
1018
|
+
## Input rules (0.4.x behavior)
|
|
1019
|
+
|
|
1020
|
+
| Kind | Element form | `dim` | Index range |
|
|
1021
|
+
|---|---|---|---|
|
|
1022
|
+
| `standard` | `(sign, index)` | not used | any integer ≥ 0 (no upper bound, since there is no `dim` to check against) |
|
|
1023
|
+
| `split` | `(sign, index)` | **required** | `0 ≤ index < 2**dim` |
|
|
1024
|
+
| `dual`, `dual_split` | `(sign, global_index)` or `(sign, local_index, eps)` | **required** | global: `0 ≤ i < 2**(dim+1)`; local: `0 ≤ i < 2**dim` |
|
|
1025
|
+
|
|
1026
|
+
- Elements must be **tuples**. Integers only, and NumPy integers are accepted.
|
|
1027
|
+
- `sign` should be `-1` or `+1`. Note: `multiply` currently also accepts `0` as a formal zero and returns zero. **Do not rely on this**; it may be removed.
|
|
1028
|
+
- Dual elements have two spellings of the same thing. At `dim=3`, `(1, 9)` and `(1, 1, 1)` both mean `+ε·e1` (global index `8 + 1`).
|
|
1029
|
+
- **Known looseness:** at `dim=3`, `(1, 9, 1)` and even `(1, 9, 0)` are also accepted and read as `+ε·e1`. The second one contradicts itself, so don't rely on it.
|
|
1030
|
+
- The dual result is always `(sign, local_index, eps)`, and `ε·ε` gives `(0, 0, 0)`.
|
|
1031
|
+
|
|
1032
|
+
## What the package cannot detect (your responsibility)
|
|
1033
|
+
|
|
1034
|
+
Elements are plain tuples, so they do not remember which algebra produced them.
|
|
1035
|
+
|
|
1036
|
+
- Feeding a result from one `dim` into an algebra of a different `dim` is not detected if the index happens to be in range.
|
|
1037
|
+
- Mixing `standard` and `split` elements is not detected. The same tuple means different things: `e2·e2` is `-1` in the standard algebra, `+1` in `split` with `dim=2`, and `-1` in `split` with `dim>=3`.
|
|
1038
|
+
- For `standard`, nothing tells you an index is "too big for the octonions".
|
|
1039
|
+
|
|
1040
|
+
## Not supported
|
|
1041
|
+
|
|
1042
|
+
- **No chain multiplication and no expressions.** `multiply` is strictly binary. You can pass a result into the next call yourself, but you choose the bracketing. From `n=3` (octonions) upward multiplication is **not associative**, so `(ab)c` and `a(bc)` can differ in sign.
|
|
1043
|
+
- **No coefficients, sums, vectors, arrays, or parsing** of expressions like `e1+e2+e12`. This is planned for a separate package built on top of this one.
|
|
1044
|
+
- **No addition, conjugation, norm, inverse, or division.**
|
|
1045
|
+
- **`split` means one split doubling on top of a standard parent.** Other sign patterns are not offered.
|
|
1046
|
+
- **`dual` and `dual_split`** extend a standard or split parent with a central `ε`, where `ε² = 0`.
|
|
1047
|
+
|
|
1048
|
+
## Algebra facts to keep in mind
|
|
1049
|
+
|
|
1050
|
+
| n | Standard | Split |
|
|
1051
|
+
|---|---|---|
|
|
1052
|
+
| 1 | complex, commutative | split-complex, commutative, has zero divisors |
|
|
1053
|
+
| 2 | quaternions, associative, **not commutative** | split-quaternions, associative, not commutative |
|
|
1054
|
+
| 3 | octonions, alternative, **not associative** | split-octonions, alternative, not associative, has zero divisors |
|
|
1055
|
+
| ≥ 4 | sedenions and beyond: **zero divisors**, no longer alternative | no longer alternative |
|
|
1056
|
+
|
|
1057
|
+
## Convention
|
|
1058
|
+
|
|
1059
|
+
Products follow the standard doubling `(a, b)(c, d) = (ac − d*b, da + bc*)` (split algebras flip the sign of the `d*b` term at the top level). Other conventions give isomorphic algebras with **different tables**, so comparing against another source may show sign differences after relabeling. For example, here `e1·e2 = e3` and `e1·e6 = −e7`.
|
|
1060
|
+
|
|
1061
|
+
## Direct low-level classes
|
|
1062
|
+
|
|
1063
|
+
`FastStandard`, `FastSplit`, `FastDual`, `StandardHolographic`, `SplitHolographic` and `DualHolographic` are exported, but they validate **differently** from each other and from `multiply`. For example, `FastSplit` accepts a zero element while the other three reject it. Their `multiply_indices` methods do only minimal checks. **Prefer `multiply`.** These classes are not a stable API and are expected to become internal.
|
|
1064
|
+
|
|
1065
|
+
## Tables and memory
|
|
1066
|
+
|
|
1067
|
+
Full tables have `4**n` entries. `build_table` refuses requests above a default memory budget (`max_bytes`, 256 MiB):
|
|
1068
|
+
|
|
1069
|
+
- `standard` and `split` are allowed up to `n = 13`.
|
|
1070
|
+
- `dual` and `dual_split` are allowed up to `n = 12`, since they are one doubling larger.
|
|
1071
|
+
|
|
1072
|
+
Use `estimate_table_bytes(kind, n)` to check a size, and pass a larger `max_bytes` (or `None`) if you really mean it. In dual tables, `sign == 0` marks `ε·ε`.
|
|
1073
|
+
|
|
1074
|
+
## Stability and planned changes
|
|
1075
|
+
|
|
1076
|
+
- Pin your dependency, for example `hypercomplex-engine>=0.4.1,<0.5`.
|
|
1077
|
+
- *Planned for 0.5.0, subject to change:* stricter inputs (no zero elements, one dual form), and low-level classes made internal. Breaking changes will be listed in the release notes.
|
|
1078
|
+
- Do not treat the package as 1.0-stable until it has been used by futur a palnned package the vector-and-expression package.
|
|
1079
|
+
|
|
992
1080
|
---
|
|
993
1081
|
|
|
994
1082
|
# Citation
|
|
@@ -267,8 +267,12 @@ def multiply(
|
|
|
267
267
|
# Validate inputs before any early return, so malformed data always
|
|
268
268
|
# raises ValidationError instead of leaking TypeError/IndexError.
|
|
269
269
|
allow_eps = kind in ("dual", "dual_split")
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
if allow_eps:
|
|
271
|
+
Validation.basis_tuple(a, allow_zero=True, allow_eps=allow_eps)
|
|
272
|
+
Validation.basis_tuple(b, allow_zero=True, allow_eps=allow_eps)
|
|
273
|
+
else:
|
|
274
|
+
Validation.basis_tuple(a, allow_zero=False, allow_eps=False)
|
|
275
|
+
Validation.basis_tuple(b, allow_zero=False, allow_eps=False)
|
|
272
276
|
|
|
273
277
|
# Zero propagation
|
|
274
278
|
if int(a[0]) == 0 or int(b[0]) == 0:
|
|
@@ -354,7 +358,7 @@ def export_csv(
|
|
|
354
358
|
Export a table built by build_table().
|
|
355
359
|
"""
|
|
356
360
|
signs, indices, eps = _unpack_table(table)
|
|
357
|
-
|
|
361
|
+
|
|
358
362
|
return CDTablePrinter.export_csv(
|
|
359
363
|
path,
|
|
360
364
|
signs,
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/printer/cd_table_printer.py
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from .cd_format import CDFormat
|
|
2
|
+
import logging
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class CDTablePrinter:
|
|
@@ -200,5 +201,7 @@ class CDTablePrinter:
|
|
|
200
201
|
line += f",{int(eps[i, j])}"
|
|
201
202
|
|
|
202
203
|
f.write(line + "\n")
|
|
204
|
+
logging.basicConfig(level=logging.INFO)
|
|
203
205
|
|
|
206
|
+
logging.info(f"Table successfully built {path} ")
|
|
204
207
|
return path
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1/hypercomplex_engine.egg-info}/PKG-INFO
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hypercomplex-engine
|
|
3
|
-
Version: 0.4.1
|
|
4
|
-
Summary: Fast O(1)/O(n) multiplication engine and table generator for ordinary, split, and dual Cayley-Dickson algebras.
|
|
3
|
+
Version: 0.4.2.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
5
|
Author-email: Maher Ben Abdessalem <ba.maher94@gmail.com>
|
|
6
6
|
License: MIT License
|
|
7
7
|
|
|
@@ -50,13 +50,15 @@ Dynamic: license-file
|
|
|
50
50
|
|
|
51
51
|
[](https://opensource.org/licenses/MIT)
|
|
52
52
|
[](https://www.python.org/downloads/)
|
|
53
|
-
[](#)
|
|
54
53
|
[](https://github.com/maher1719/hypercomplex-engine)
|
|
55
|
-
[](https://pypi.org/project/hypercomplex-engine/)
|
|
56
55
|
[](https://pepy.tech/project/hypercomplex-engine)
|
|
57
56
|
|
|
58
57
|
|
|
59
|
-
Fast, validated multiplication and table generation for Cayley–Dickson algebras.
|
|
58
|
+
Fast, cross validated multiplication and table generation for Cayley–Dickson algebras multiplication up to **one million digit** two elements index tested for O(1)/O(n) and depend on RAM allocation up to 2^13 or more for table builder.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
For more info please visit All benchamrks in [BENCHMARKS.md](https://github.com/maher1719/hypercomplex-engine/blob/main/BENCHMARKS.md) and Jupyter Notebook used in [examples/benchmark/benchmark.ipynb](https://github.com/maher1719/hypercomplex-engine/blob/main/examples/benchmark/benchmark.ipynb) (note speed time may vary depend on your hardware).
|
|
60
62
|
|
|
61
63
|
This library provides the computational substrate for high-dimensional hypercomplex algebra, featuring:
|
|
62
64
|
|
|
@@ -69,6 +71,11 @@ This library provides the computational substrate for high-dimensional hypercomp
|
|
|
69
71
|
|
|
70
72
|
---
|
|
71
73
|
|
|
74
|
+
## Scope and limitations
|
|
75
|
+
|
|
76
|
+
If you build upon this package, please read fully [Go to Scope, Strengths, and Limitations](#scope-strengths-and-limitations) below for more information or check [Scope, Strengths, and Limitations file](https://github.com/maher1719/hypercomplex-engine/blob/main/README_scope_and_limitations.md#scope-strengths-and-limitations)
|
|
77
|
+
|
|
78
|
+
|
|
72
79
|
## 📄 Publications & Preprints
|
|
73
80
|
|
|
74
81
|
This library serves as the formal verification substrate and computational engine for the following mathematical preprints:
|
|
@@ -1037,6 +1044,87 @@ hypercomplex-engine/
|
|
|
1037
1044
|
└── pyproject.toml
|
|
1038
1045
|
```
|
|
1039
1046
|
|
|
1047
|
+
# Scope, strengths and limitations
|
|
1048
|
+
|
|
1049
|
+
> **Status: 0.4.x, pre-1.0.** The API can still change. Read this section before building on the package.
|
|
1050
|
+
|
|
1051
|
+
## What this package is
|
|
1052
|
+
|
|
1053
|
+
It computes the product of two **signed basis elements** of a Cayley–Dickson algebra: `±e_i × ±e_j → ±e_k` (or zero in dual algebras). It is a low-level component, a sign and index calculator, not a number type. There are no coefficients, no sums, and no vectors.
|
|
1054
|
+
|
|
1055
|
+
## Advantages
|
|
1056
|
+
|
|
1057
|
+
- **One job, small surface.** About 2,000 lines, one dependency (NumPy), and multipliers that keep no per-call state.
|
|
1058
|
+
- **Two interchangeable engines.**
|
|
1059
|
+
- `fast` is a closed-form bitwise evaluator. It does constant work per call for word-sized indices, and cost grows only with bit length for arbitrary-precision indices.
|
|
1060
|
+
- `holographic` is an O(n) recursive descent, useful as a cross-check.
|
|
1061
|
+
- **Works where tables cannot.** Only the two indices are needed, so indices hundreds of bits long are fine. Full tables need 4^n entries.
|
|
1062
|
+
- **Cross-validated.** The test suite checks the table builders, the `fast` engine and the `holographic` engine against each other.
|
|
1063
|
+
- **Strict about types.** `bool`, `float`, `str` and `list` inputs are rejected. Results are plain Python `int`s.
|
|
1064
|
+
- **Tested on Python 3.10–3.14** and with NumPy 1.22 and newer.
|
|
1065
|
+
|
|
1066
|
+
## Input rules (0.4.x behavior)
|
|
1067
|
+
|
|
1068
|
+
| Kind | Element form | `dim` | Index range |
|
|
1069
|
+
|---|---|---|---|
|
|
1070
|
+
| `standard` | `(sign, index)` | not used | any integer ≥ 0 (no upper bound, since there is no `dim` to check against) |
|
|
1071
|
+
| `split` | `(sign, index)` | **required** | `0 ≤ index < 2**dim` |
|
|
1072
|
+
| `dual`, `dual_split` | `(sign, global_index)` or `(sign, local_index, eps)` | **required** | global: `0 ≤ i < 2**(dim+1)`; local: `0 ≤ i < 2**dim` |
|
|
1073
|
+
|
|
1074
|
+
- Elements must be **tuples**. Integers only, and NumPy integers are accepted.
|
|
1075
|
+
- `sign` should be `-1` or `+1`. Note: `multiply` currently also accepts `0` as a formal zero and returns zero. **Do not rely on this**; it may be removed.
|
|
1076
|
+
- Dual elements have two spellings of the same thing. At `dim=3`, `(1, 9)` and `(1, 1, 1)` both mean `+ε·e1` (global index `8 + 1`).
|
|
1077
|
+
- **Known looseness:** at `dim=3`, `(1, 9, 1)` and even `(1, 9, 0)` are also accepted and read as `+ε·e1`. The second one contradicts itself, so don't rely on it.
|
|
1078
|
+
- The dual result is always `(sign, local_index, eps)`, and `ε·ε` gives `(0, 0, 0)`.
|
|
1079
|
+
|
|
1080
|
+
## What the package cannot detect (your responsibility)
|
|
1081
|
+
|
|
1082
|
+
Elements are plain tuples, so they do not remember which algebra produced them.
|
|
1083
|
+
|
|
1084
|
+
- Feeding a result from one `dim` into an algebra of a different `dim` is not detected if the index happens to be in range.
|
|
1085
|
+
- Mixing `standard` and `split` elements is not detected. The same tuple means different things: `e2·e2` is `-1` in the standard algebra, `+1` in `split` with `dim=2`, and `-1` in `split` with `dim>=3`.
|
|
1086
|
+
- For `standard`, nothing tells you an index is "too big for the octonions".
|
|
1087
|
+
|
|
1088
|
+
## Not supported
|
|
1089
|
+
|
|
1090
|
+
- **No chain multiplication and no expressions.** `multiply` is strictly binary. You can pass a result into the next call yourself, but you choose the bracketing. From `n=3` (octonions) upward multiplication is **not associative**, so `(ab)c` and `a(bc)` can differ in sign.
|
|
1091
|
+
- **No coefficients, sums, vectors, arrays, or parsing** of expressions like `e1+e2+e12`. This is planned for a separate package built on top of this one.
|
|
1092
|
+
- **No addition, conjugation, norm, inverse, or division.**
|
|
1093
|
+
- **`split` means one split doubling on top of a standard parent.** Other sign patterns are not offered.
|
|
1094
|
+
- **`dual` and `dual_split`** extend a standard or split parent with a central `ε`, where `ε² = 0`.
|
|
1095
|
+
|
|
1096
|
+
## Algebra facts to keep in mind
|
|
1097
|
+
|
|
1098
|
+
| n | Standard | Split |
|
|
1099
|
+
|---|---|---|
|
|
1100
|
+
| 1 | complex, commutative | split-complex, commutative, has zero divisors |
|
|
1101
|
+
| 2 | quaternions, associative, **not commutative** | split-quaternions, associative, not commutative |
|
|
1102
|
+
| 3 | octonions, alternative, **not associative** | split-octonions, alternative, not associative, has zero divisors |
|
|
1103
|
+
| ≥ 4 | sedenions and beyond: **zero divisors**, no longer alternative | no longer alternative |
|
|
1104
|
+
|
|
1105
|
+
## Convention
|
|
1106
|
+
|
|
1107
|
+
Products follow the standard doubling `(a, b)(c, d) = (ac − d*b, da + bc*)` (split algebras flip the sign of the `d*b` term at the top level). Other conventions give isomorphic algebras with **different tables**, so comparing against another source may show sign differences after relabeling. For example, here `e1·e2 = e3` and `e1·e6 = −e7`.
|
|
1108
|
+
|
|
1109
|
+
## Direct low-level classes
|
|
1110
|
+
|
|
1111
|
+
`FastStandard`, `FastSplit`, `FastDual`, `StandardHolographic`, `SplitHolographic` and `DualHolographic` are exported, but they validate **differently** from each other and from `multiply`. For example, `FastSplit` accepts a zero element while the other three reject it. Their `multiply_indices` methods do only minimal checks. **Prefer `multiply`.** These classes are not a stable API and are expected to become internal.
|
|
1112
|
+
|
|
1113
|
+
## Tables and memory
|
|
1114
|
+
|
|
1115
|
+
Full tables have `4**n` entries. `build_table` refuses requests above a default memory budget (`max_bytes`, 256 MiB):
|
|
1116
|
+
|
|
1117
|
+
- `standard` and `split` are allowed up to `n = 13`.
|
|
1118
|
+
- `dual` and `dual_split` are allowed up to `n = 12`, since they are one doubling larger.
|
|
1119
|
+
|
|
1120
|
+
Use `estimate_table_bytes(kind, n)` to check a size, and pass a larger `max_bytes` (or `None`) if you really mean it. In dual tables, `sign == 0` marks `ε·ε`.
|
|
1121
|
+
|
|
1122
|
+
## Stability and planned changes
|
|
1123
|
+
|
|
1124
|
+
- Pin your dependency, for example `hypercomplex-engine>=0.4.1,<0.5`.
|
|
1125
|
+
- *Planned for 0.5.0, subject to change:* stricter inputs (no zero elements, one dual form), and low-level classes made internal. Breaking changes will be listed in the release notes.
|
|
1126
|
+
- Do not treat the package as 1.0-stable until it has been used by futur a palnned package the vector-and-expression package.
|
|
1127
|
+
|
|
1040
1128
|
---
|
|
1041
1129
|
|
|
1042
1130
|
# Citation
|
|
@@ -4,11 +4,11 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "hypercomplex-engine"
|
|
7
|
-
version = "0.4.1"
|
|
7
|
+
version = "0.4.2.1"
|
|
8
8
|
authors = [
|
|
9
9
|
{ name="Maher Ben Abdessalem", email="ba.maher94@gmail.com" },
|
|
10
10
|
]
|
|
11
|
-
description = "Fast O(1)/O(n) multiplication engine and table generator for ordinary, split, and dual Cayley-Dickson algebras."
|
|
11
|
+
description = "Fast O(1)/O(n) multiplication engine for arbitrary dimensions and table generator for ordinary, split, and dual Cayley-Dickson algebras."
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
license = { file="LICENSE" }
|
|
14
14
|
requires-python = ">=3.10"
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/tests/test_dual_tuple_regression.py
RENAMED
|
@@ -73,8 +73,10 @@ def test_facade_dual_3tuple_promotion():
|
|
|
73
73
|
def test_facade_zero_shapes():
|
|
74
74
|
assert multiply("dual", (0, 2), (1, 3), dim=2) == (0, 0, 0)
|
|
75
75
|
assert multiply("dual_split", (1, 2), (0, 3), dim=2) == (0, 0, 0)
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
with pytest.raises((TypeError, ValueError)):
|
|
77
|
+
assert multiply("standard", (0, 2), (1, 3), dim=2) == (0, 0)
|
|
78
|
+
with pytest.raises((TypeError, ValueError)): # formal zero
|
|
79
|
+
assert multiply("split", (0, 2), (1, 3), dim=2) == (0, 0)
|
|
78
80
|
|
|
79
81
|
|
|
80
82
|
def test_facade_malformed_raises_validation_error():
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/basis_element.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/basis_notation.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/fast/__init__.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/fast/bit_utils.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/fast/fast_dual.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/fast/fast_split.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/holographic/__init__.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/holographic/dual.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/holographic/split.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/holographic/standard.py
RENAMED
|
File without changes
|
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/table_builder/common.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/table_builder/dual.py
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex/core/table_builder/split.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex_engine.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex_engine.egg-info/requires.txt
RENAMED
|
File without changes
|
{hypercomplex_engine-0.4.1 → hypercomplex_engine-0.4.2.1}/hypercomplex_engine.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|