Core¶
The mathematical kernel of Versor.
Algebra¶
CliffordAlgebra
¶
Bases: Module
Differentiable Clifford algebra kernel with memory-optimized blocked accumulation.
Extends nn.Module so that all Cayley tables are registered as
non-persistent buffers. This means model.to(device) automatically
moves tables
Supports degenerate (null) dimensions via the r parameter:
Cl(p, q, r) has p positive, q negative, and r null
basis vectors (e_i^2 = 0).
Attributes:
| Name | Type | Description |
|---|---|---|
p |
int
|
Positive signature dimensions. |
q |
int
|
Negative signature dimensions. |
r |
int
|
Degenerate (null) dimensions. |
n |
int
|
Total dimensions (p + q + r). |
dim |
int
|
Total basis elements (2^n). |
Source code in core/algebra.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 | |
device
property
¶
Return the device of the algebra tables.
dtype
property
¶
Return the floating-point dtype of the algebra tables.
Reflects the current state — updated automatically when the algebra
is moved via .to(dtype=...).
grade_masks
property
¶
Grade masks indexed by grade: grade_masks[k] -> [dim] bool.
grade_masks_float
property
¶
Float grade masks indexed by grade: grade_masks_float[k] -> [dim] float.
exp_policy
property
writable
¶
Active :class:ExpPolicy controlling exp() dispatch.
num_grades
property
¶
Counts the number of grades (n + 1).
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Number of grades. |
__init__(p, q=0, r=0, device='cuda', dtype=torch.float32, exp_policy='auto')
¶
Initialize the algebra and cache the Cayley table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
int
|
Positive dimensions (+1). |
required |
q
|
int
|
Negative dimensions (-1). Defaults to 0. |
0
|
r
|
int
|
Degenerate dimensions (0). Defaults to 0. |
0
|
device
|
str
|
The device on which computations are performed. Defaults to 'cuda'. |
'cuda'
|
dtype
|
dtype
|
Floating-point dtype for algebra tables.
Defaults to |
float32
|
exp_policy
|
str or ExpPolicy
|
Bivector exp policy.
|
'auto'
|
Source code in core/algebra.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
embed_vector(vectors)
¶
Injects vectors into the Grade-1 subspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vectors
|
Tensor
|
Raw vectors [..., n]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Multivector coefficients [..., dim]. |
Source code in core/algebra.py
get_grade_norms(mv)
¶
Calculates norms per grade. Useful for invariant features.
Vectorized via scatter_add.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Input multivector [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Grade norms [..., num_grades]. |
Source code in core/algebra.py
geometric_product(A, B)
¶
Computes the Geometric Product.
Uses vectorized gather + broadcast multiply + sum.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Tensor
|
Left operand [..., Dim]. |
required |
B
|
Tensor
|
Right operand [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: The product AB [..., Dim]. |
Source code in core/algebra.py
grade_projection(mv, grade)
¶
Isolates a specific grade.
Uses multiplicative masking (mv * float_mask) instead of boolean
indexing to avoid nonzero calls that break torch.compile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Multivector [..., Dim]. |
required |
grade
|
int
|
Target grade. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Projected multivector [..., Dim]. |
Source code in core/algebra.py
reverse(mv)
¶
Computes the reversion. The Clifford conjugate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Input multivector [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Reversed multivector [..., Dim]. |
Source code in core/algebra.py
wedge(A, B)
¶
Computes the wedge (outer) product: A ^ B = (AB - BA)/2.
Single-pass implementation using precomputed antisymmetric signs.
Reference
Pence, T., Yamada, D., & Singh, V. (2025). "Composing Linear Layers from Irreducibles." arXiv:2507.11688v1 [cs.LG]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Tensor
|
Left operand [..., dim]. |
required |
B
|
Tensor
|
Right operand [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Wedge product A ^ B [..., dim]. |
Source code in core/algebra.py
right_contraction(A, B)
¶
Computes the right contraction: A _| B.
Fast path for bivector-vector case using precomputed skew-symmetric action matrices (avoids full geometric product + grade projection).
Reference
Pence, T., Yamada, D., & Singh, V. (2025). "Composing Linear Layers from Irreducibles." arXiv:2507.11688v1 [cs.LG], Algorithm 2
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Tensor
|
Left operand (bivector) [..., dim]. |
required |
B
|
Tensor
|
Right operand (vector) [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Right contraction A _| B [..., dim]. |
Source code in core/algebra.py
inner_product(A, B)
¶
Computes the inner product: A . B = (AB + BA)/2.
Single-pass implementation using precomputed symmetric signs.
Reference
Pence, T., Yamada, D., & Singh, V. (2025). "Composing Linear Layers from Irreducibles." arXiv:2507.11688v1 [cs.LG]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Tensor
|
Left operand [..., dim]. |
required |
B
|
Tensor
|
Right operand [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Inner product A . B [..., dim]. |
Source code in core/algebra.py
commutator(A, B)
¶
Computes the commutator (Lie bracket): [A, B] = AB - BA.
Single-pass implementation using precomputed antisymmetric signs
(same structure as :meth:wedge but without the 1/2 factor).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Tensor
|
Left operand [..., dim]. |
required |
B
|
Tensor
|
Right operand [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Commutator [A, B][..., dim]. |
Source code in core/algebra.py
anti_commutator(A, B)
¶
Computes the anti-commutator: {A, B} = AB + BA.
Single-pass implementation using precomputed symmetric signs
(same structure as :meth:inner_product but without the 1/2 factor).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Tensor
|
Left operand [..., dim]. |
required |
B
|
Tensor
|
Right operand [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Anti-commutator {A, B} [..., dim]. |
Source code in core/algebra.py
blade_inverse(blade)
¶
Compute the inverse of a blade: B^{-1} = B_rev / _0.
Works for any simple blade (non-degenerate). For null blades the scalar denominator is clamped to avoid division by zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blade
|
Tensor
|
Blade multivector [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Inverse blade [..., dim]. |
Source code in core/algebra.py
sandwich_product(R, x, R_rev=None)
¶
Optimized sandwich product R x R~ via action matrix.
Builds a [N, D, D] sandwich action matrix from the rotor, then applies
it to all C channels via a single batched matmul. This is much faster
than two separate geometric_product calls when x has extra channel
dimensions that R does not.
Memory: O(NDD) where N = batch (without channels). Compare to naive: O(NCD*D) - a factor of C improvement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
R
|
Tensor
|
Rotors [N, D] (2-D, batch-flattened). |
required |
x
|
Tensor
|
Multivectors [N, C, D] (3-D, C channels per rotor). |
required |
R_rev
|
Tensor
|
Optional precomputed reverse of R [N, D]. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Sandwiched result [N, C, D]. |
Source code in core/algebra.py
per_channel_sandwich(R, x, R_rev=None)
¶
Sandwich product with per-channel rotors via action matrices.
Each channel c has its own rotor R[c]. Builds a [C, D, D] action matrix (one per channel), then applies to all batch elements in one matmul.
Memory: O(CDD + BCD) vs naive two-GP: O(2BCDD).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
R
|
Tensor
|
Per-channel rotors [C, D]. |
required |
x
|
Tensor
|
Batched multivectors [B, C, D]. |
required |
R_rev
|
Tensor
|
Optional precomputed reverse of R [C, D]. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Sandwiched result [B, C, D]. |
Source code in core/algebra.py
multi_rotor_sandwich(R, x, R_rev=None)
¶
Sandwich product with K rotors applied to C-channel input.
Builds K action matrices [K, D, D] once, then applies all K rotors to x in a single einsum. This replaces the naive two-sequential-geometric-product approach used by MultiRotorLayer.
Memory: O(KDD) setup + O(BCKD) apply. Compare to naive two-GP: O(2BCKDD).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
R
|
Tensor
|
Per-rotor versors [K, D]. |
required |
x
|
Tensor
|
Batched multivectors [B, C, D]. |
required |
R_rev
|
Tensor
|
Optional precomputed reverse/inverse of R [K, D]. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Per-rotor sandwiched result [B, C, K, D]. |
Source code in core/algebra.py
pseudoscalar_product(x)
¶
Multiply by the unit pseudoscalar: x * I.
Maps grade-k to grade-(n-k) (Hodge dual). Computed as a simple permutation with sign flips - no geometric product needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Multivector [..., D]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Result [..., D]. |
Source code in core/algebra.py
blade_project(mv, blade)
¶
Project multivector onto blade subspace: (mv . B) B^{-1}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Multivector to project [..., dim]. |
required |
blade
|
Tensor
|
Blade defining the subspace [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Projected multivector [..., dim]. |
Source code in core/algebra.py
blade_reject(mv, blade)
¶
Reject multivector from blade subspace: mv - proj_B(mv).
The orthogonal complement of the projection onto blade.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Multivector to reject [..., dim]. |
required |
blade
|
Tensor
|
Blade defining the subspace [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Rejected multivector [..., dim]. |
Source code in core/algebra.py
grade_involution(mv)
¶
Grade involution (main involution): x_hat = sum (-1)^k
Flips sign of all odd-grade components, preserves even-grade. This is an algebra automorphism: (AB)^ = A_hat B_hat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Input multivector [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Involuted multivector [..., dim]. |
Source code in core/algebra.py
clifford_conjugation(mv)
¶
Clifford conjugation: bar{x} = grade_involution(reverse(x)).
Combines reversion and grade involution. For a k-blade: bar{e_I} = (-1)^k * (-1)^{k(k-1)/2} * e_I
This is an anti-automorphism: bar{AB} = bar{B} bar{A}.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Input multivector [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Conjugated multivector [..., dim]. |
Source code in core/algebra.py
norm_sq(mv)
¶
Squared norm:
Returns the scalar (grade-0) part of the product of a multivector with its reverse. For blades, this equals the square of the magnitude with the appropriate sign from the metric.
Optimized: the scalar component of A*~A is sum_i a_i^2 * rev_signs[i]
* cayley_signs[i, i]. No full geometric product needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Input multivector [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Scalar norm squared [..., 1]. |
Source code in core/algebra.py
left_contraction(A, B)
¶
Left contraction: A _| B.
Selects components where grade(A) <= grade(B) and grade(result) = grade(B) - grade(A). This is the standard contraction used in GA for projection-like operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
Tensor
|
Left operand [..., dim]. |
required |
B
|
Tensor
|
Right operand [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Left contraction A _| B [..., dim]. |
Source code in core/algebra.py
dual(mv)
¶
Hodge dual: x* = x I^{-1}, maps grade-k to grade-(n-k).
Equivalent to pseudoscalar_product but with conventional name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Input multivector [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Dual multivector [..., dim]. |
Source code in core/algebra.py
reflect(x, n)
¶
Reflect x through the hyperplane orthogonal to vector n.
Implements the versor reflection: x' = -n x n^{-1}.
Uses the sandwich product action-matrix when x has a channel dimension (3-D input), falling back to two sequential geometric products for general shapes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Multivector to reflect [..., dim]. |
required |
n
|
Tensor
|
Normal vector (grade-1) [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Reflected multivector [..., dim]. |
Source code in core/algebra.py
versor_product(V, x)
¶
General versor transformation: V x V^{-1} or hat{V} x V^{-1}.
For even versors (rotors), this is the sandwich product. For odd versors (reflections), the grade involution is applied. The parity is determined from the grade structure of V.
In practice, this computes: grade_involution(V) * x * V^{-1}, which correctly handles both even and odd versors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
V
|
Tensor
|
Versor [..., dim]. |
required |
x
|
Tensor
|
Multivector to transform [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Transformed multivector [..., dim]. |
Source code in core/algebra.py
exp(mv)
¶
Exponentiates a bivector to produce a rotor.
Dispatches by :attr:exp_policy:
FAST-- closed-form only (fastest, approximate for non-simple bivectors in n >= 4).AUTO(default) -- closed-form for n <= 3 (exact), compiled-safe decomposition for n >= 4.EXACT-- always compiled-safe decomposition (exact for all bivectors,torch.compile-safe).
Three signature regimes handled in the closed-form path
- Elliptic (B^2 < 0): exp(B) = cos(th) + sin(th)/th * B
- Hyperbolic (B^2 > 0): exp(B) = cosh(th) + sinh(th)/th * B
- Parabolic (B^2 ~ 0): exp(B) ~ 1 + B
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Pure bivector [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Rotor exp(mv) [..., dim]. |
Source code in core/algebra.py
exp_decomposed(mv, **kwargs)
¶
Exponentiates a bivector via decomposition into simple components.
.. deprecated::
Set :attr:exp_policy and call :meth:exp instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
Pure bivector [..., dim]. |
required |
**kwargs
|
Legacy kwargs ( |
{}
|
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Rotor exp(mv) [..., dim]. |
Source code in core/algebra.py
Multivector¶
Multivector
¶
Object-oriented multivector wrapper with operator overloading.
Wraps a raw coefficient tensor and its parent CliffordAlgebra,
exposing every core algebra operation as a method or Python operator.
Attributes:
| Name | Type | Description |
|---|---|---|
algebra |
CliffordAlgebra
|
The backend. |
tensor |
Tensor
|
The raw data [..., Dim]. |
Source code in core/multivector.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
from_vectors(algebra, vectors)
classmethod
¶
scalar(algebra, value, batch_shape=())
classmethod
¶
Creates a scalar multivector (grade 0 only).
Source code in core/multivector.py
grade(k)
¶
reverse()
¶
grade_involution()
¶
clifford_conjugation()
¶
dual()
¶
inverse()
¶
geometric_product(other)
¶
Explicit geometric product (same as self * other).
wedge(other)
¶
inner(other)
¶
left_contraction(other)
¶
right_contraction(other)
¶
commutator(other)
¶
Commutator (Lie bracket): [self, other] = self*other - other*self.
anti_commutator(other)
¶
Anti-commutator: {self, other} = self*other + other*self.
norm()
¶
norm_sq()
¶
get_grade_norms()
¶
exp()
¶
sandwich(x)
¶
Sandwich product: self * x * ~self.
Falls back to two geometric products when the tensor shapes don't match the optimized [N, D] + [N, C, D] layout.
Source code in core/multivector.py
reflect(n)
¶
Reflect self through hyperplane orthogonal to vector n.
versor_product(x)
¶
General versor action: hat(self) * x * self^{-1}.
blade_project(blade)
¶
Project onto blade subspace: (self · B) B^{-1}.
blade_reject(blade)
¶
Reject from blade subspace: self - proj_B(self).
to(*args, **kwargs)
¶
detach()
¶
clone()
¶
Metric¶
metric
¶
Metric definitions for Clifford algebras.
Provides distances, norms, and inner products that respect the metric signature.
inner_product(algebra, A, B)
¶
Compute the scalar product via projection onto grade 0.
Computes _0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
First multivector [Batch, Dim]. |
required |
B
|
Tensor
|
Second multivector [Batch, Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Scalar part [Batch, 1]. |
Source code in core/metric.py
induced_norm(algebra, A)
¶
Compute the induced norm respecting the metric signature.
Computes ||A|| = sqrt(|_0|).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
Multivector [Batch, Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Norm [Batch, 1]. |
Source code in core/metric.py
geometric_distance(algebra, A, B)
¶
Computes geometric distance.
dist(A, B) = ||A - B||.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
First multivector. |
required |
B
|
Tensor
|
Second multivector. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Distance. |
Source code in core/metric.py
grade_purity(algebra, A, grade)
¶
Checks the purity of the grade by examining coefficient energy.
Purity = ||_k||^2 / ||A||^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
Multivector [..., Dim]. |
required |
grade
|
int
|
Target grade. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Purity score [0, 1]. |
Source code in core/metric.py
mean_active_grade(algebra, A)
¶
Average grade. Identifies the grade where the majority of the energy resides.
Mean Grade = Sum(k * ||_k||^2) / ||A||^2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
Multivector. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: Average grade index. |
Source code in core/metric.py
clifford_conjugate(algebra, mv)
¶
Clifford conjugation (bar involution).
Combines reversion with grade involution
A_bar_k = (-1)^k * (-1)^{k(k-1)/2} * A_k
This is the natural *-involution on Cl(p,q). Useful for algebraic computations (e.g., spinor norms, Lipschitz groups).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
mv
|
Tensor
|
Multivector [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Conjugated multivector [..., Dim]. |
Source code in core/metric.py
hermitian_inner_product(algebra, A, B)
¶
Hermitian inner product on Cl(p,q):
_H = Sum_I (conj_sign_I * metric_sign_I) * a_I * b_I
Uses precomputed sign arrays so that the result equals the scalar part of the geometric product of the Clifford conjugate of A with B. For Euclidean algebras (q=0), all signs are +1 and this reduces to the simple coefficient inner product Sum a_I b_I.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
First multivector [..., Dim]. |
required |
B
|
Tensor
|
Second multivector [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Scalar inner product [..., 1]. |
Source code in core/metric.py
hermitian_norm(algebra, A)
¶
Hermitian norm: ||A||_H = sqrt(|_H|).
Always real and non-negative for any signature. Uses abs() since the signed inner product can produce negative self-products in mixed-signature algebras.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
Multivector [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Norm [..., 1]. Always >= 0. |
Source code in core/metric.py
hermitian_distance(algebra, A, B)
¶
Hermitian distance: d_H(A, B) = ||A - B||_H.
Positive-definite metric distance for any signature. Satisfies: non-negativity, symmetry, triangle inequality, identity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
First multivector [..., Dim]. |
required |
B
|
Tensor
|
Second multivector [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Distance [..., 1]. Always >= 0. |
Source code in core/metric.py
hermitian_angle(algebra, A, B)
¶
Hermitian angle between multivectors.
cos(theta) = _H / (||A||_H * ||B||_H)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
First multivector [..., Dim]. |
required |
B
|
Tensor
|
Second multivector [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Angle in radians [..., 1]. |
Source code in core/metric.py
grade_hermitian_norm(algebra, A, grade)
¶
Hermitian norm restricted to a single grade.
||k||_H = sqrt(Sum{I: |I|=k} a_I**2)
Measures the energy contribution of a specific grade in a signature-independent way.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
Multivector [..., Dim]. |
required |
grade
|
int
|
Target grade. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Grade-specific norm [..., 1]. |
Source code in core/metric.py
hermitian_grade_spectrum(algebra, A)
¶
Full Hermitian grade spectrum.
Returns |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
Multivector [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Grade energies [..., n+1]. Each entry >= 0. |
Source code in core/metric.py
signature_trace_form(algebra, A, B)
¶
Signature-aware trace form: <~A B>_0.
The standard Clifford algebra scalar product. NOT positive-definite in mixed signatures. Use hermitian_inner_product for optimization.
This form is signature-aware and useful for: - Rotor normalization (R~R = 1) - Versor validation - Spinor norm computation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
First multivector [..., Dim]. |
required |
B
|
Tensor
|
Second multivector [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Scalar trace form [..., 1]. Can be negative in mixed signatures. |
Source code in core/metric.py
signature_norm_squared(algebra, A)
¶
Signature-aware squared norm: _0.
Can be negative in mixed-signature algebras. Returns the raw value without absolute value, preserving causal structure information.
For Cl(n,0): always non-negative. For Cl(p,q) with q>0: sign encodes causal character.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
A
|
Tensor
|
Multivector [..., Dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Signed squared norm [..., 1]. |
Source code in core/metric.py
Decomposition¶
decomposition
¶
Bivector decomposition via GA power iteration.
Decomposes a general bivector into simple (blade) components that can each be exponentiated with the closed-form formula.
Reference
Pence, T., Yamada, D., & Singh, V. (2025). "Composing Linear Layers from Irreducibles." arXiv:2507.11688v1 [cs.LG]
ExpPolicy
¶
Bases: Enum
Policy controlling how CliffordAlgebra.exp() handles bivectors.
AUTO-- closed-form for n <= 3 (all bivectors simple), compiled-safe decomposition for n >= 4.FAST-- closed-form only (_exp_bivector_closed). Ignores residual error for non-simple bivectors. Fastest path.EXACT-- always use compiled-safe decomposition. Exact for all bivectors,torch.compile-safe (no CPU sync).
Source code in core/decomposition.py
ga_power_iteration(algebra, b, v_init=None, threshold=1e-06, max_iterations=100)
¶
Find the dominant simple bivector component via power iteration.
Implements Algorithm 2 from Pence et al. (2025). Iterates
v <- (b _| v) / ||b _| v|| until convergence, then recovers
the simple projection b_s = sigma * (u ^ v).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
CliffordAlgebra instance. |
required |
b
|
Tensor
|
Bivector to decompose [..., dim]. |
required |
v_init
|
Optional[Tensor]
|
Initial grade-1 vector (random if None). |
None
|
threshold
|
float
|
Convergence tolerance on |
1e-06
|
max_iterations
|
int
|
Iteration cap. |
100
|
Returns:
| Type | Description |
|---|---|
Tensor
|
(b_s, v) where b_s is the simple projection and v the converged |
Tensor
|
vector, both shaped [..., dim]. |
Source code in core/decomposition.py
differentiable_invariant_decomposition(algebra, b, k=None, threshold=1e-06, max_iterations=100)
¶
Decompose a bivector into simple components via greedy projection.
Implements Algorithm 1 from Pence et al. (2025). Iteratively extracts the dominant simple component and subtracts it from the residual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
CliffordAlgebra instance. |
required |
b
|
Tensor
|
Bivector [..., dim]. |
required |
k
|
Optional[int]
|
Number of components (auto = n(n-1)/2 if None). |
None
|
threshold
|
float
|
Stop when residual norm falls below this. |
1e-06
|
max_iterations
|
int
|
Per-component power iteration cap. |
100
|
Returns:
| Type | Description |
|---|---|
(decomp, vectors)
|
lists of simple bivectors and their |
List[Tensor]
|
associated vectors. |
Source code in core/decomposition.py
exp_simple_bivector(algebra, b)
¶
Closed-form exponential of a simple bivector.
Delegates to algebra._exp_bivector_closed which handles all
three signature regimes (elliptic, hyperbolic, parabolic).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
CliffordAlgebra instance. |
required |
b
|
Tensor
|
Simple bivector [..., dim]. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Rotor exp(b) [..., dim]. |
Source code in core/decomposition.py
exp_decomposed(algebra, b, use_decomposition=True, k=None, threshold=1e-06, max_iterations=100)
¶
Exponentiate a bivector via decomposition into simple components.
.. deprecated::
Use algebra.exp(b) with algebra.exp_policy set instead.
This function is kept for backward compatibility.
When use_decomposition is True the bivector is decomposed into
simple blades (via differentiable_invariant_decomposition), each
is exponentiated in closed form, and the rotors are composed via
geometric product.
During training the power iteration loop is detached (run in forward-only mode) so that gradients do not flow through the normalization divisions. Gradients instead flow through the closed-form exp of each component and the final GP composition. This is stable for all bivector magnitudes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
CliffordAlgebra instance. |
required |
b
|
Tensor
|
Bivector [..., dim]. |
required |
use_decomposition
|
bool
|
Enable decomposition (False -> |
True
|
k
|
Optional[int]
|
Number of simple components (auto if None). |
None
|
threshold
|
float
|
Convergence threshold. |
1e-06
|
max_iterations
|
int
|
Power iteration cap. |
100
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Rotor exp(b) [..., dim]. |
Source code in core/decomposition.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
compiled_safe_decomposed_exp(algebra, b, k=None, fixed_iterations=20)
¶
Compile-safe decomposed exponential -- no CPU sync.
Decomposes b into simple blades under torch.no_grad(),
re-projects the live (gradient-carrying) bivector onto each
discovered plane, exponentiates each in closed form, and composes
via geometric product.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra instance. |
required | |
b
|
Tensor
|
Bivector [..., dim]. |
required |
k
|
Optional[int]
|
Number of simple components (default |
None
|
fixed_iterations
|
int
|
Power iteration steps per component. |
20
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Rotor exp(b) [..., dim]. |
Source code in core/decomposition.py
Analysis¶
MetricSearch
¶
Learns optimal (p, q, r) signature via GBN probe training and bivector energy analysis.
Trains small single-rotor GBN probes on conformally-lifted data using coherence + curvature as the loss. After training, reads the learned bivector energy distribution to infer the optimal signature.
Multiple probes with biased initialization combat local minima.
Source code in core/analysis/signature.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
search(data)
¶
Returns optimal (p, q, r) signature for the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
Input data [N, D]. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[int, int, int]
|
Tuple[int, int, int]: Optimal signature (p, q, r). |
Source code in core/analysis/signature.py
search_detailed(data)
¶
Returns signature and full diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
Input data [N, D]. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
Diagnostics with 'signature', 'coherence', 'curvature', 'energy_breakdown', 'per_probe_results'. |
Source code in core/analysis/signature.py
GeodesicFlow
¶
Geodesic flow analysis in Clifford algebra.
Interprets data points as grade-1 multivectors and computes the flow field -- a bivector at each point that encodes the direction of shortest algebraic paths to its k-nearest neighbours.
The flow is computed as the mean of connection bivectors:
B_ij = <x_i . ~x_j>_2 (grade-2 part of the geometric product)
This bivector encodes the rotational "turn" needed to map x_i toward x_j, analogous to the parallel transport connection on a Lie group.
The coherence and curvature of this field reveal whether the data has causal (directional) structure:
- High coherence, low curvature -> the flow is smooth and aligned in one direction. Causality is visible.
- Low coherence, high curvature -> the flow is fragmented and collides with itself. The signal is dominated by noise.
Source code in core/analysis/geodesic.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
__init__(algebra, k=8)
¶
Initialize Geodesic Flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
The algebra instance. |
required |
k
|
int
|
Number of nearest neighbours for the flow field. |
8
|
Source code in core/analysis/geodesic.py
flow_bivectors(mv)
¶
Computes the mean flow bivector at each data point.
For each point x_i, aggregates the unit connection bivectors to its k-nearest neighbours:
B_i = mean_j { unit( <x_i . ~x_j>_2 ) }
.. note::
For perfectly symmetric data (e.g. a closed circle) the mean
cancels to zero -- which is geometrically correct since there is
no preferred flow direction. Use :meth:coherence to measure
structure without this cancellation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: |
Source code in core/analysis/geodesic.py
coherence(mv)
¶
Measures concentration of connection bivectors within each neighbourhood.
For each point, computes the mean absolute cosine similarity between all pairs of its k connection bivectors. This captures how consistently the neighbourhood connections lie on the same rotation plane.
- 1.0: all connections at every point are parallel or anti-parallel (maximally structured).
- 1/num_bivectors (~= baseline): connections point in random directions.
.. note:: In Cl(2,0) the grade-2 space is 1-dimensional (only e_12), so coherence is trivially 1.0 for any data -- use at least Cl(3,0) for meaningful discrimination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Coherence score in [0, 1]. |
Source code in core/analysis/geodesic.py
curvature(mv)
¶
Measures how much connection structure changes across the manifold.
Computes the mean dissimilarity of connection bivectors between neighbouring pairs of points:
dissimilarity(i, j) = 1 - mean_abs_cos( {B_ia}, {B_jb} )
where {B_ia} is the set of k unit connection bivectors at point i and {B_jb} at point j, and mean_abs_cos is the cross-set absolute cosine similarity.
- 0.0: all neighbouring points have the same connection structure (flat geodesics, smooth manifold).
- High: the connection direction changes rapidly between neighbours (high curvature, fragmented flow).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
Curvature score in [0, 1]. |
Source code in core/analysis/geodesic.py
interpolate(a, b, steps=10)
¶
Interpolates along the geodesic from a to b.
Uses the Lie group exponential map on the transition element:
T = a_inv . b
log(T) ~= <T - 1>_2 (grade-2 approximation for small angles)
gamma(t) = a . exp(t . log(T))
Exact when a and b are close; a first-order approximation otherwise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
Tensor
|
Start multivector |
required |
b
|
Tensor
|
End multivector |
required |
steps
|
int
|
Number of interpolation steps (including endpoints). |
10
|
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: |
Source code in core/analysis/geodesic.py
causal_report(data)
¶
Full geodesic flow analysis with a causal interpretation.
Embeds data, computes coherence and curvature, and returns a human-readable verdict.
The causal threshold is adaptive: coherence must exceed the midpoint between random baseline and 1.0 (i.e. the measured coherence must be at least halfway between chance and perfect alignment). Curvature must be below 0.5.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
report with keys |
Dict
|
|
Source code in core/analysis/geodesic.py
per_point_coherence(mv)
¶
Per-point coherence scores for stratified sampling.
Returns a scalar coherence value per data point, measuring how well-aligned that point's neighbourhood connections are.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
torch.Tensor: |
Source code in core/analysis/geodesic.py
DimensionLifter
¶
Tests whether lifting data to a higher-dimensional algebra reveals structure.
The hypothesis: data living on an n-dimensional manifold may possess latent structure that only becomes visible in Cl(n+1, q) or Cl(n, q+1).
Lifting appends extra coordinates to the grade-1 embedding:
- Positive lift
Cl(p, q) -> Cl(p+1, q): adds a spacelike dimension. The extra coordinate is set to 1 (projective / homogeneous lift). - Null lift
Cl(p, q) -> Cl(p, q+1): adds a timelike dimension. The extra coordinate is set to 0 (null vector lift for conformal-like embeddings).
After lifting, geodesic flow coherence is re-measured. An improvement indicates that the extra dimension captures hidden geometric structure.
Source code in core/analysis/dimension.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
lift(data, target_algebra, fill=1.0)
¶
Lifts data into the grade-1 subspace of a higher-dimensional algebra.
Pads each data vector with fill values in the new dimensions,
then embeds as a grade-1 multivector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
|
required |
target_algebra
|
CliffordAlgebra
|
Target algebra with n >= d. |
required |
fill
|
float
|
Coordinate value for the new dimensions. Use 1.0 for a projective (homogeneous) lift, 0.0 for a null-vector (conformal) lift. |
1.0
|
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Source code in core/analysis/dimension.py
test(data, p, q, k=8)
¶
Compares geodesic flow coherence before and after dimension lifting.
Tests three algebras:
- Original Cl(p, q): baseline coherence and curvature.
- Positive lift Cl(p+1, q): spacelike extra dimension, fill=1.
- Null lift Cl(p, q+1): timelike extra dimension, fill=0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
|
required |
p
|
int
|
Original positive signature. |
required |
q
|
int
|
Original negative signature. |
required |
k
|
int
|
Nearest neighbours for geodesic flow. |
8
|
Returns:
| Type | Description |
|---|---|
Dict
|
Dict with keys |
Dict
|
and |
Source code in core/analysis/dimension.py
format_report(results)
¶
Renders a lifting test result as a human-readable string.
Source code in core/analysis/dimension.py
GeometricAnalyzer
¶
Top-level orchestrator for the geometric analysis toolkit.
Runs a configurable subset of analyzers in the correct dependency
order and returns an :class:AnalysisReport.
Input modes:
data.ndim == 2andalgebra is None-- raw mode: full pipeline from sampling through signature search to GA analyses.data.ndim == 3andalgebra is not None-- pre-embedded mode: skip sampling / dimension / signature; run spectral, symmetry, and commutator analyses directly.data.ndim == 2andalgebra is not None-- raw + known algebra: embed data, then run GA analyses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
Optional[AnalysisConfig]
|
Master analysis configuration. |
None
|
Source code in core/analysis/pipeline.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
analyze(data, algebra=None)
¶
Run the full geometric analysis pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
Raw |
required |
algebra
|
Optional[CliffordAlgebra]
|
Required when data is pre-embedded. Optional when raw -- will be created from the signature search. |
None
|
Returns:
| Type | Description |
|---|---|
AnalysisReport
|
class: |
Source code in core/analysis/pipeline.py
SpectralAnalyzer
¶
Spectral analysis of multivector data.
Three independent analyses are combined:
- Grade energy spectrum -- population-level distribution of Hermitian grade energy across all grades.
- Bivector field spectrum -- singular values from decomposing the mean bivector into simple components (rotation planes).
- GP operator spectrum -- eigenvalues of the left-multiplication
operator :math:
L_x(y) = x \cdot y(only for small algebras).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
:class: |
required |
max_simple_components
|
int
|
Maximum number of simple components to extract from the mean bivector. |
5
|
Source code in core/analysis/spectral.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
analyze(mv_data)
¶
Full spectral analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
Multivector data. Accepted shapes:
|
required |
Returns:
| Type | Description |
|---|---|
SpectralResult
|
class: |
Source code in core/analysis/spectral.py
grade_energy_spectrum(mv_data)
¶
Mean Hermitian grade energy across the batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Source code in core/analysis/spectral.py
bivector_field_spectrum(mv_data)
¶
Decompose the mean bivector into simple components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
tuple
|
|
tuple
|
singular_values is a 1-D tensor of component norms and |
tuple
|
simple_components is a list of |
Source code in core/analysis/spectral.py
gp_operator_spectrum(mv_data, n_samples=None)
¶
Eigenvalue magnitudes of the left-multiplication operator.
For a subsample of data points, constructs the explicit matrix
representation of :math:L_x(y) = x \cdot y and computes
eigenvalues.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
|
required |
n_samples
|
Optional[int]
|
Number of data points to sample. |
None
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Sorted (descending) eigenvalue magnitudes. |
Source code in core/analysis/spectral.py
SymmetryDetector
¶
Detect symmetries, null directions, and invariances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
:class: |
required |
null_threshold
|
float
|
Energy threshold below which a direction is considered effectively null. |
0.01
|
Source code in core/analysis/symmetry.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
analyze(mv_data, commutator_result=None)
¶
Full symmetry analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
Multivector data. Accepted shapes:
|
required |
commutator_result
|
Optional[CommutatorResult]
|
Pre-computed commutator results for continuous-symmetry refinement. |
None
|
Returns:
| Type | Description |
|---|---|
SymmetryResult
|
class: |
Source code in core/analysis/symmetry.py
detect_null_directions(mv_data)
¶
Detect effectively null basis-vector directions.
For each basis vector e_i, computes the mean squared
projection energy of the data onto that direction. Directions
below :attr:null_threshold are flagged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
|
Tensor
|
null_indices lists those with score < threshold. |
Source code in core/analysis/symmetry.py
detect_involution_symmetry(mv_data)
¶
Measure grade-involution symmetry of the data distribution.
Computes the fraction of total energy in odd-grade components:
score = E[ ||x_odd||^2 / ||x||^2 ]
where x_odd = (x - alpha(x)) / 2 and alpha is the grade
involution (flips odd-grade components).
Returns:
| Type | Description |
|---|---|
float
|
Score in |
float
|
the even sub-algebra; 1 means entirely odd grades. |
Source code in core/analysis/symmetry.py
detect_reflection_symmetries(mv_data)
¶
Test reflection symmetry along each basis-vector direction.
For each basis vector e_i, reflects the data
x' = -e_i x e_i^{-1} and compares the reflected
distribution to the original.
Returns:
| Type | Description |
|---|---|
List[Dict]
|
List of dicts |
List[Dict]
|
by score ascending (lower = more symmetric). |
Source code in core/analysis/symmetry.py
detect_continuous_symmetries(mv_data, commutator_result=None, threshold=None)
¶
Estimate the dimension of the continuous symmetry group.
A bivector B_j generates a continuous symmetry if
E[||[B_j, x_i]||] is near zero for all data points.
If a :class:CommutatorResult is provided, its exchange
spectrum is used directly (eigenvalues near zero -> symmetry
generators). Otherwise the computation is done from scratch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
|
required |
commutator_result
|
Optional[CommutatorResult]
|
Pre-computed commutator analysis. |
None
|
threshold
|
Optional[float]
|
Normalised commutator norm below which a bivector is considered a symmetry generator. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Estimated dimension of the continuous symmetry group. |
Source code in core/analysis/symmetry.py
CommutatorAnalyzer
¶
Analyze algebraic exchange properties via commutators.
The commutator [A, B] = AB - BA measures non-commutativity.
In Clifford algebras, commutators of grade-1 elements yield grade-2
elements (bivectors), directly related to rotation planes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
algebra
|
CliffordAlgebra
|
:class: |
required |
max_bivectors
|
int
|
Maximum number of bivectors for Lie-bracket closure analysis (guards combinatorial cost). |
15
|
Source code in core/analysis/commutator.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
analyze(mv_data)
¶
Full commutator analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
Multivector data. Accepted shapes:
|
required |
Returns:
| Type | Description |
|---|---|
CommutatorResult
|
class: |
Source code in core/analysis/commutator.py
commutativity_matrix(mv_data)
¶
Pairwise commutativity index for input dimensions.
For each pair (i, j) of the n basis-vector directions,
computes E[||[x_i, x_j]||] where x_i is the data
projected onto e_i.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
|
Source code in core/analysis/commutator.py
exchange_spectrum(mv_data)
¶
Eigenvalue magnitudes of the adjoint operator ad_mu.
Constructs the explicit matrix for ad_mu(x) = [mu, x]
where mu = E[x] and diagonalises it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Eigenvalue magnitudes sorted descending. Returns an |
Tensor
|
empty tensor if the algebra is too large. |
Source code in core/analysis/commutator.py
mean_commutator_norm(mv_data)
¶
E[||[x_i, mu]||_2] -- scalar non-commutativity summary.
Generalises the Geometric Uncertainty Index from
:func:core.analysis.compute_uncertainty_and_alignment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
float
|
Mean commutator norm (float). |
Source code in core/analysis/commutator.py
lie_bracket_closure(mv_data)
¶
Test whether the data bivectors close under the Lie bracket.
Selects the top-k energetic bivectors from the batch,
computes all pairwise brackets [B_i, B_j], and measures
how well the results lie in the span of the original set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mv_data
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
Dict
|
Dict with |
Dict
|
|
Dict
|
of multivector-coefficient indices of the chosen bivectors). |
Source code in core/analysis/commutator.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
EffectiveDimensionAnalyzer
¶
Estimate effective intrinsic dimensionality of data.
Uses the covariance eigenvalue spectrum together with the participation ratio (random matrix theory) and the broken-stick model (MacArthur 1957) for significance testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
str
|
Torch device string. |
'cpu'
|
dtype
|
dtype
|
Floating-point dtype used for covariance computations.
Defaults to |
float32
|
k_local
|
int
|
Number of neighbours for local-dimension estimation. |
20
|
energy_threshold
|
float
|
Minimum normalised eigenvalue to count as active. |
0.05
|
Source code in core/analysis/dimension.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
analyze(data)
¶
Full effective-dimension analysis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
|
required |
Returns:
| Type | Description |
|---|---|
DimensionResult
|
class: |
DimensionResult
|
ratio, broken-stick threshold, and optional local dims. |
Source code in core/analysis/dimension.py
reduce(data, target_dim)
¶
PCA projection to target_dim dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Tensor
|
|
required |
target_dim
|
int
|
Target dimensionality. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
|