Repository navigation
Expand file tree
/
Copy pathsimple.rs
More file actions
137 lines (129 loc) · 4.17 KB
/
Copy pathsimple.rs
File metadata and controls
137 lines (129 loc) · 4.17 KB
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
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
//! Compact exact sectors, sharing all Laurent work in one native call.
//!
//! These are algebraic simplifications of `triangle_massless` and
//! `box_massless_low_case` (including `with_box_normalization`). Selection uses
//! exact zero tests only, after the public input-domain checks. No approximate
//! degeneracy test, finite-width regulator or precision fallback is used.
use super::primitives::{C, NativeFloat, mul};
#[derive(Clone)]
pub(super) struct Constants<T> {
one: T,
two: T,
four: T,
half: T,
pi: T,
pi_squared: T,
}
impl<T: NativeFloat> Constants<T> {
pub(super) fn new(prototype: &T) -> Self {
let one = prototype.one();
let two = prototype.from_i64(2);
let pi = prototype.pi();
let pi_squared = pi.clone() * π
Self {
half: one.clone() / &two,
one,
two,
four: prototype.from_i64(4),
pi,
pi_squared,
}
}
}
fn zero<T: NativeFloat>(prototype: &T) -> C<T> {
C::new(prototype.zero(), prototype.zero())
}
pub(super) fn zeros<T: NativeFloat>(prototype: &T) -> [C<T>; 3] {
std::array::from_fn(|_| zero(prototype))
}
#[inline]
fn scale<T: NativeFloat>(value: &C<T>, factor: &T) -> C<T> {
C::new(value.re.clone() * factor, value.im.clone() * factor)
}
// For a nonzero real invariant s, log((-s-i0)/mu²). Separate real
// logarithms avoid overflowing/underflowing the ratio. The sheet is explicit,
// independent of an accidental signed zero from intermediate arithmetic.
#[inline]
fn momentum_log<T: NativeFloat>(s: &T, log_mu: &T, c: &Constants<T>) -> C<T> {
C::new(
s.norm().log() - log_mu,
if *s > s.zero() {
-c.pi.clone()
} else {
s.zero()
},
)
}
pub(super) fn massless_triangle<T: NativeFloat>(a: &[C<T>], c: &Constants<T>) -> Option<[C<T>; 3]> {
if a[3..6]
.iter()
.any(|z| !z.re.is_fully_zero() || !z.im.is_fully_zero())
{
return None;
}
let mut nonzero = a[..3].iter().filter(|z| !z.re.is_fully_zero());
let Some(s) = nonzero.next().map(|z| &z.re) else {
return Some(zeros(&c.one));
};
let t = nonzero.next().map(|z| &z.re);
if nonzero.next().is_some() {
return None;
}
let log_mu = a[6].re.log();
let ls = momentum_log(s, &log_mu, c);
Some(if let Some(t) = t {
let lt = momentum_log(t, &log_mu, c);
let difference = s.clone() - t;
let pole = if difference.is_fully_zero() {
C::new(-s.inv(), s.zero())
} else {
scale(
&C::new(lt.re.clone() - &ls.re, lt.im.clone() - &ls.im),
&difference.inv(),
)
};
let sum = C::new(ls.re + lt.re, ls.im + lt.im);
let finite = scale(&mul(&pole, &sum), &(-c.half.clone()));
[finite, pole, zero(&c.one)]
} else {
let reciprocal = s.inv();
// The raw triangle sector's -pi²/(12s) cancels against the
// +pi²/12 times double-pole normalization of the public master.
let finite = scale(&mul(&ls, &ls), &c.half);
[
scale(&finite, &reciprocal),
scale(&ls, &(-reciprocal.clone())),
C::new(reciprocal, s.zero()),
]
})
}
pub(super) fn massless_onshell_box<T: NativeFloat>(
a: &[C<T>],
c: &Constants<T>,
) -> Option<[C<T>; 3]> {
if a[..4].iter().any(|z| !z.re.is_fully_zero())
|| a[6..10]
.iter()
.any(|z| !z.re.is_fully_zero() || !z.im.is_fully_zero())
|| a[4].re.is_fully_zero()
|| a[5].re.is_fully_zero()
{
return None;
}
let log_mu = a[10].re.log();
let ls = momentum_log(&a[4].re, &log_mu, c);
let lt = momentum_log(&a[5].re, &log_mu, c);
let factor = (a[4].re.clone() * &a[5].re).inv();
// Ls²+Lt²−(Ls−Lt)²−4π²/3 + (4π²/12) = 2 Ls Lt−π².
let mut finite = scale(&mul(&ls, <), &c.two);
finite.re -= &c.pi_squared;
let pole = scale(
&C::new(ls.re + lt.re, ls.im + lt.im),
&(-c.two.clone() * &factor),
);
Some([
scale(&finite, &factor),
pole,
C::new(c.four.clone() * factor, c.one.zero()),
])
}