Skip to content

Commit

Permalink
rust: Remove G3p2 from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhekhorn committed Feb 3, 2025
1 parent ffc6f70 commit 3a1bf31
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use num::complex::Complex;

use crate::constants::{ChargeCombinations, CA, CF, ED2, EU2, NC, TR, ZETA2, ZETA3};
use crate::harmonics::cache::{Cache, K};
use std::f64::consts::PI;

/// Compute the photon-quark anomalous dimension.
///
Expand Down Expand Up @@ -112,6 +113,16 @@ pub fn gamma_gg(_c: &mut Cache, _nf: u8) -> Complex<f64> {
cmplx!(4.0 * TR * (NC as f64), 0.)
}

/// Shift for $g_3(N)$ by 2.
///
/// This is $g_3(N+2) - g_3(N)$.
fn g3_shift(c: &mut Cache) -> Complex<f64> {
let n = c.n();
let S1 = c.get(K::S1);
(6. * (n + 1.) * (2. * n + 1.) * S1 + n * (-PI.powi(2) * (n + 1.).powu(2) - 6. * n))
/ (6. * n.powu(2) * (n + 1.).powu(3))
}

/// Compute the singlet-like non-singlet anomalous dimension.
///
/// Implements Eqs. (33-34) of [\[deFlorian:2015ujt\]][crate::bib::deFlorian2015ujt].
Expand All @@ -128,7 +139,7 @@ pub fn gamma_nsp(c: &mut Cache, _nf: u8) -> Complex<f64> {
let S3p1h = c.get(K::S3ph);

let g3N = c.get(K::G3);
let g3Np2 = c.get(K::G3p2);
let g3Np2 = g3N + g3_shift(c);

#[rustfmt::skip]
let result = 32.0 * ZETA2 * S1h - 32.0 * ZETA2 * S1p1h
Expand Down Expand Up @@ -159,7 +170,7 @@ pub fn gamma_nsm(c: &mut Cache, _nf: u8) -> Complex<f64> {
let S2p1h = c.get(K::S2ph);
let S3p1h = c.get(K::S3ph);
let g3N = c.get(K::G3);
let g3Np2 = c.get(K::G3p2);
let g3Np2 = g3N + g3_shift(c);

#[rustfmt::skip]
let result =
Expand Down Expand Up @@ -302,4 +313,18 @@ mod tests {
let me = gamma_nsp(&mut c, NF) + gamma_gq(&mut c, NF) + gamma_phq(&mut c, NF);
assert_approx_eq_cmplx!(f64, me, Complex::zero(), epsilon = 1e-4);
}

#[test]
fn test_g3_shift() {
for N in [cmplx!(1.23, 0.), cmplx!(5., 0.), cmplx!(2., 1.)] {
let mut c = Cache::new(N);
let mut c2 = Cache::new(N + 2.);
assert_approx_eq_cmplx!(
f64,
g3_shift(&mut c),
c2.get(K::G3) - c.get(K::G3),
epsilon = 1e-6
);
}
}
}
2 changes: 0 additions & 2 deletions crates/ekore/src/harmonics/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ pub enum K {
S2ph,
S3ph,
S1p2,
G3p2,
}

/// Hold all cached values.
Expand Down Expand Up @@ -96,7 +95,6 @@ impl Cache {
K::S2mh => w2::S2((self.n - 1.) / 2.),
K::S3mh => w3::S3((self.n - 1.) / 2.),
K::G3 => g_functions::g3(self.n, self.get(K::S1)),
K::G3p2 => g_functions::g3(self.n + 2., self.get(K::S1p2)),
K::Sm1e => w1::Sm1e(self.get(K::S1), self.get(K::S1h)),
K::Sm1o => w1::Sm1o(self.get(K::S1), self.get(K::S1mh)),
K::Sm2e => w2::Sm2e(self.get(K::S2), self.get(K::S2h)),
Expand Down

0 comments on commit 3a1bf31

Please sign in to comment.