1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
/*
* SPDX-License-Identifier: MIT
* Copyright (c) 2023 - 2026. The DeepCausality Authors and Contributors. All Rights Reserved.
*/
//! The Cayley-Menger regression, which is why elimination must search for its pivot.
//!
//! # What this guards
//!
//! `deep_causality_topology` computes simplex volumes from Cayley-Menger determinants at
//! `regge_geometry/curvature.rs:254` and `manifold/geometry/mod.rs:72`. A Cayley-Menger matrix has
//! **`m[0][0] = 0` by construction** — `manifold/geometry/mod.rs:41` allocates zeros and writes
//! `one` only into indices `1..matrix_dim`.
//!
//! The determinant this replaced, `gaussian_determinant` in `deep_causality_topology`'s
//! `simplicial_complex/lazy_hodge_star.rs`, took `mat[i][i]`
//! as its pivot and returns zero when it is small. Consolidating the two Laplace determinants onto
//! it unpivoted returns **zero for every simplex volume**. Measured on the regular unit tetrahedron
//! below:
//!
//! | method | det | vol² | vol |
//! |---|---|---|---|
//! | Laplace, what topology does today | 4.0 | 0.013888888889 | 0.117851130198 |
//! | elimination as `gaussian_determinant` was written | **0.0** | 0.0 | **NaN** |
//! | elimination with partial pivoting | 4.0 | 0.013888888889 | 0.117851130198 |
//!
//! That helper is correct today only because its own caller feeds it a Gram matrix, whose diagonal
//! is strictly positive.
use vec;
use Vec;
/// The 5×5 Cayley-Menger matrix of a regular tetrahedron with unit edge length.
///
/// Row-major. The border is `0` then four `1`s; the interior is the squared edge lengths, all `1`,
/// with a zero diagonal.
/// The determinant of [`regular_unit_tetrahedron`].
pub const TETRAHEDRON_CM_DETERMINANT: f64 = 4.0;
/// The volume of a regular unit tetrahedron, `√2 ⁄ 12`.
///
/// The exact value, not a measured one. `vol² = det / 288`, so `vol² = 4/288 = 1/72` and
/// `vol = 1/√72 = √2/12`.
pub const TETRAHEDRON_VOLUME: f64 = 0.117_851_130_197_757_92;
/// The 4×4 Cayley-Menger matrix of a right triangle with legs of length 1.
///
/// The lower-order case, which behaves the same way: determinant `-4`, and `0` unpivoted.
/// The determinant of [`right_triangle`].
pub const RIGHT_TRIANGLE_CM_DETERMINANT: f64 = -4.0;
/// Converts a Cayley-Menger determinant of order `n` into the squared content of the simplex.
///
/// For a `k`-simplex the matrix has order `k + 2` and the divisor is `(-1)^(k+1) · 2^k · (k!)²`.
/// For the tetrahedron, `k = 3`, so the divisor is `288`.